Package org.springframework.social.connect

Examples of org.springframework.social.connect.UserProfileBuilder


    values.setImageUrl(profile.getImageUrl());
  }

  public UserProfile fetchUserProfile(Google google) {
    Person profile = google.plusOperations().getGoogleProfile();
    return new UserProfileBuilder().setUsername(profile.getId())
        .setEmail(profile.getAccountEmail())
        .setName(profile.getDisplayName())
        .setFirstName(profile.getGivenName())
        .setLastName(profile.getFamilyName()).build();
  }
View Full Code Here


    @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

     @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);
        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"));
View Full Code Here

        ((UserServiceImpl) userService).setUserRepository(userRepository);
        //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

    }

    @Override
    public UserProfile fetchUserProfile(Dropbox dropboxApi) {
        DropboxUserProfile profile = dropboxApi.getUserProfile();
        return new UserProfileBuilder().setName(profile.getDisplayName()).setUsername(profile.getEmail()).setEmail(profile.getEmail()).build();
    }
View Full Code Here

    values.setProviderUserId(api.getVerifiedOpenId());
  }

  @Override
  public UserProfile fetchUserProfile(OpenId api) {
    return new UserProfileBuilder().setUsername(api.getVerifiedOpenId()).build();
  }
View Full Code Here

    public UserProfile fetchUserProfile(Foursquare instagram) {
        FoursquareUser user = instagram.userOperations().getUser();
        String name = user.getFirstName() + " " + user.getLastName();
        String email = user.getContactInfo().getEmail();
        return new UserProfileBuilder().setName(name).setUsername(email).setEmail(email).build();
    }
View Full Code Here

  public void refresh() {
  }

  public UserProfile fetchUserProfile() {
    return new UserProfileBuilder().setEmail(_key.getProviderUserId() + "@example.com").build();
  }
View Full Code Here

  public void refresh() {
  }

  public UserProfile fetchUserProfile() {
    return new UserProfileBuilder().setEmail(_key.getProviderUserId() + "@example.com").build();
  }
View Full Code Here

      values.setProfileUrl(profileUrl);
      values.setImageUrl(profilePictureUrl);
    }

    public UserProfile fetchUserProfile(TestFacebookApi api) {
      return new UserProfileBuilder().setName(name).setEmail("keith@interface21.com").setUsername("Keith.Donald").build();
    }
View Full Code Here

TOP

Related Classes of org.springframework.social.connect.UserProfileBuilder

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.