Examples of ExternalUser


Examples of com.porterhead.rest.user.api.ExternalUser

        authorizationService = new SessionTokenAuthorizationService(userRepository);
    }

    @Test
    public void authorizeUser() throws Exception {
        ExternalUser user = authorizationService.authorize(getAuthorizationRequest(AUTH_TOKEN, "user/123", null));
        assertThat(user.getId(), is(USER.getUuid().toString()));
    }
View Full Code Here

Examples of com.porterhead.rest.user.api.ExternalUser

        authorizationService.authorize(getAuthorizationRequest("abc", "abcdef", "123"));
    }

    @Test
    public void noSessionToken() {
        ExternalUser user = authorizationService.authorize(getAuthorizationRequest(null, "abcdef", null));
        assertThat(user, is(Matchers.<Object>nullValue()));
    }
View Full Code Here

Examples of com.porterhead.rest.user.api.ExternalUser

* Time: 09:01
*/
public abstract class SimpleSecurityFilter implements ContainerRequestFilter {

    public ContainerRequest filter(ContainerRequest request) {
        ExternalUser externalUser = new ExternalUser(getUser());
        request.setSecurityContext(new SecurityContextImpl(externalUser));
        return request;
    }
View Full Code Here

Examples of com.porterhead.rest.user.api.ExternalUser

        request.setPassword(new PasswordRequest("password"));
        return request;
    }

    protected ExternalUser getUser() {
        ExternalUser user = ExternalUserBuilder.create().withFirstName("John")
                .withLastName("Smith")
                .withEmailAddress(createRandomEmailAddress())
                .build();
        return user;
    }
View Full Code Here

Examples of com.porterhead.rest.user.api.ExternalUser

        ((UserServiceImpl)userService).setUserRepository(userRepository);
        UserProfileBuilder builder = new UserProfileBuilder();
        UserProfile profile = builder.setFirstName("Tom").setLastName("Tucker").setEmail("tt@example.com").setUsername("ttucker").build();
        when(connection.fetchUserProfile()).thenReturn(profile);
        AuthenticatedUserToken token = userService.socialLogin(connection);
        ExternalUser user = userService.getUser(new ExternalUser(token.getUserId()), token.getUserId());
        assertThat(user, is(notNullValue()));
        assertThat(user.getEmailAddress(), is("tt@example.com"));
        assertThat(user.getFirstName(), is("Tom"));
        assertThat(user.getLastName(), is("Tucker"));
        assertThat(user.isVerified(), is(true));
        assertThat(user.getRole().equalsIgnoreCase(Role.authenticated.toString()), is(true));
    }
View Full Code Here

Examples of com.porterhead.rest.user.api.ExternalUser

        userService.socialLogin(connection);
        //login again and update
        profile = builder.setFirstName("Foo").setLastName("Bar").setEmail("foobar@example.com").setUsername("foobar").build();
        when(connection.fetchUserProfile()).thenReturn(profile);
        AuthenticatedUserToken token = userService.socialLogin(connection);
        ExternalUser user = userService.getUser(new ExternalUser(token.getUserId()), token.getUserId());
        assertThat(user, is(notNullValue()));
        assertThat(user.getEmailAddress(), is("foobar@example.com"));
        assertThat(user.getFirstName(), is("Foo"));
        assertThat(user.getLastName(), is("Bar"));
        assertThat(user.isVerified(), is(true));
        assertThat(user.getRole().equalsIgnoreCase(Role.authenticated.toString()), is(true));
    }
View Full Code Here

Examples of com.porterhead.rest.user.api.ExternalUser

        UserProfile profile = builder.setFirstName(user.getFirstName()).setLastName(user.getLastName()).setEmail(user.getEmailAddress()).setUsername("jsmith.12").build();
        when(connection.fetchUserProfile()).thenReturn(profile);
        when(userRepository.findByEmailAddress(any(String.class))).thenReturn(new User(UUID.fromString(token.getUserId())));
        when(userRepository.findByUuid(any(String.class))).thenReturn(new User(UUID.fromString(token.getUserId())));
        AuthenticatedUserToken loginToken = userService.socialLogin(connection);
        ExternalUser user = userService.getUser(new ExternalUser(token.getUserId()), token.getUserId());
        assertThat(token.getUserId(), is(loginToken.getUserId()));
    }
View Full Code Here

Examples of com.porterhead.rest.user.api.ExternalUser

        assertThat(token.getUserId(), is(loginToken.getUserId()));
    }

    private CreateUserRequest getCreateUserRequest(String emailAddress) {
        CreateUserRequest request = new CreateUserRequest();
        ExternalUser user = ExternalUserBuilder.create().withFirstName("John")
                .withLastName("Smith")
                .withEmailAddress(emailAddress)
                .build();
        request.setUser(user);
        request.setPassword(new PasswordRequest("password"));
View Full Code Here

Examples of com.porterhead.rest.user.api.ExternalUser


    private final ExternalUser user;

    public ExternalUserBuilder() {
        user = new ExternalUser();
    }
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser

        if (!(credentials instanceof SimpleCredentials)) {
            log.debug("LDAP IDP can only authenticate SimpleCredentials.");
            return null;
        }
        final SimpleCredentials creds = (SimpleCredentials) credentials;
        final ExternalUser user = getUser(creds.getUserID());
        if (user != null) {
            // authenticate
            LdapConnection connection = null;
            try {
                DebugTimer timer = new DebugTimer();
                connection = userPool.getConnection();
                timer.mark("connect");
                connection.bind(user.getExternalId().getId(), new String(creds.getPassword()));
                timer.mark("bind");
                if (log.isDebugEnabled()) {
                    log.debug("authenticate({}) {}", user.getId(), timer.getString());
                }
            } catch (LdapAuthenticationException e) {
                throw new LoginException("Unable to authenticate against LDAP server: " + e.getMessage());
            } catch (Exception e) {
                throw new ExternalIdentityException("Error while binding user credentials", e);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.