Examples of UserProfile


Examples of org.springframework.social.connect.UserProfile

  }

  @Override
  protected String extractProviderUserId(AccessGrant accessGrant) {
    Google api = ((GoogleServiceProvider)getServiceProvider()).getApi(accessGrant.getAccessToken());
      UserProfile userProfile = getApiAdapter().fetchUserProfile(api);
      return userProfile.getUsername();
  }
View Full Code Here

Examples of org.springframework.social.connect.UserProfile

    Mockito.when(person.getFamilyName()).thenReturn("Axel");
    Mockito.when(person.getAccountEmail()).thenReturn("guznik@gmail.com");
    Mockito.when(person.getId()).thenReturn("114863353858610846998");

    Mockito.when(plusOperations.getGoogleProfile()).thenReturn(person);
    UserProfile profile = apiAdapter.fetchUserProfile(google);
    assertEquals("Gabriel Axel", profile.getName());
    assertEquals("Gabriel", profile.getFirstName());
    assertEquals("Axel", profile.getLastName());
    assertEquals("guznik@gmail.com", profile.getEmail());
    assertEquals("114863353858610846998", profile.getUsername());
  }
View Full Code Here

Examples of org.springframework.social.connect.UserProfile

        userToSave.setRole(role);
        return userToSave;
    }

    private void updateUserFromProfile(Connection<?> connection, User user) {
        UserProfile profile = connection.fetchUserProfile();
        user.setEmailAddress(profile.getEmail());
        user.setFirstName(profile.getFirstName());
        user.setLastName(profile.getLastName());
        //users logging in from social network are already verified
        user.setVerified(true);
        if(user.hasRole(Role.anonymous)) {
            user.setRole(Role.authenticated);
        }
View Full Code Here

Examples of org.springframework.social.connect.UserProfile

    @Test
    public void validSocialLogin() {
        UserService userService = new UserServiceImpl(usersConnectionRepository, validator, applicationConfig);
        ((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"));
View Full Code Here

Examples of org.springframework.social.connect.UserProfile

     @Test
    public void updateFromSocialLogin() {
        UserService userService = new UserServiceImpl(usersConnectionRepository, validator, applicationConfig);
        ((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);
        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);
View Full Code Here

Examples of org.springframework.social.connect.UserProfile

        //create email account
        CreateUserRequest request = getCreateUserRequest(RandomStringUtils.randomAlphabetic(8) + "@example.com");
        AuthenticatedUserToken token = userService.createUser(request, Role.authenticated);

        UserProfileBuilder builder = new UserProfileBuilder();
        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());
View Full Code Here

Examples of org.springframework.social.connect.UserProfile

        String referralLink = "referralLink";

        Mockito.when(dropboxApi.getUserProfile())
                .thenReturn(new DropboxUserProfile(uid, displayName, email, country, referralLink, sharedQuota, quota, normalQuota));

        UserProfile profile = adapter.fetchUserProfile(dropboxApi);

        assertEquals(displayName, profile.getName());
    }
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.