Package org.rest.sec.model.dto

Examples of org.rest.sec.model.dto.User


            if (authenticationResponse.getStatusCode().value() == 401) {
                // temporary - the idea here is to generate the not authorized exception - not by hand, but by returning wrong credentials which in turn will be refused later
                return new org.springframework.security.core.userdetails.User("wrongUsername", "wrongPass", Lists.<GrantedAuthority> newArrayList());
            }

            final User principalFromRest = authenticationResponse.getBody();

            final Set<String> privilegesFromRest = Sets.newHashSet();
            final Set<Role> roles = principalFromRest.getRoles();
            for (final Role role : roles) {
                privilegesFromRest.addAll(Collections2.transform(role.getPrivileges(), Functions.toStringFunction()));
            }
            final String[] authorityStringsAsArray = privilegesFromRest.toArray(new String[privilegesFromRest.size()]);
            final List<GrantedAuthority> authorities = AuthorityUtils.createAuthorityList(authorityStringsAsArray);
View Full Code Here


    @Override
    @Transactional(readOnly = true)
    public User searchOne(final Triple<String, ClientOperation, String>... constraints) {
        final Principal principalResultedFromSearch = principalService.searchOne(constraints);
        final User userResultedFromSearch = new PrincipalToUserFunction().apply(principalResultedFromSearch);

        return userResultedFromSearch;
    }
View Full Code Here

    @Override
    @Transactional(readOnly = true)
    public User findByName(final String name) {
        final Principal principal = principalService.findByName(name);
        return new User(principal);
    }
View Full Code Here

    public User findOne(final long id) {
        final Principal principal = principalService.findOne(id);
        if (principal == null) {
            return null;
        }
        return new User(principal);
    }
View Full Code Here

    // other

    @Override
    public User getCurrentUser() {
        final Principal principal = principalService.getCurrentPrincipal();
        return new User(principal);
    }
View Full Code Here

            }
        };
        final Collection<Privilege> privileges = Collections2.transform(authenticationInSpring.getAuthorities(), springAuthorityToPrivilegeFunction);
        final Role defaultRole = new Role("defaultRole", Sets.<Privilege> newHashSet(privileges));

        final User authenticationResource = new User(authenticationInSpring.getName(), (String) authenticationInSpring.getCredentials(), Sets.<Role> newHashSet(defaultRole));
        return authenticationResource;
    }
View Full Code Here

    public final void whenAuthenticationIsPerformed_thenPrincipalResponseIsCorrect() {
        // When
        final Response response = givenAuthenticated().contentType(APPLICATION_JSON.toString()).get(paths.getAuthenticationUri());

        // Then
        assertEquals(new User(SecurityConstants.EMAIL, SecurityConstants.PASS, null), response.as(User.class));
    }
View Full Code Here

    // find - one

    @Test
    @Ignore("in progress - create association first")
    public final void whenResourceIsRetrieved_thenAssociationsAreAlsoRetrieved() {
        final User existingResource = getApi().create(getEntityOps().createNewEntity());
        assertThat(existingResource.getRoles(), not(Matchers.<Role> empty()));
    }
View Full Code Here

     * - note: this test ensures that a new User cannot automatically create new Privileges <br>
     * - note: the standard way to do this is: first create the Privilege resource(s), then associate them with the new User resource and then create the User resource
     */
    @Test
    public final void whenResourceIsCreatedWithNewAssociation_then409IsReceived() {
        final User newResource = getEntityOps().createNewEntity();
        newResource.getRoles().add(getAssociationEntityOps().createNewEntity());

        // When
        final Response response = getApi().createAsResponse(newResource);

        // Then
View Full Code Here

    @Test
    @Ignore("intermitent failures - temporarily ignored")
    public final void whenResourceIsCreatedWithInvalidAssociation_then409IsReceived() {
        final Role invalidAssociation = getAssociationEntityOps().createNewEntity();
        invalidAssociation.setId(1001l);
        final User newResource = getEntityOps().createNewEntity();
        newResource.getRoles().add(invalidAssociation);

        // When
        final Response response = getApi().createAsResponse(newResource);

        // Then
View Full Code Here

TOP

Related Classes of org.rest.sec.model.dto.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.