当前位置: 首页>>代码示例>>Java>>正文


Java UserProfile类代码示例

本文整理汇总了Java中org.springframework.social.connect.UserProfile的典型用法代码示例。如果您正苦于以下问题:Java UserProfile类的具体用法?Java UserProfile怎么用?Java UserProfile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UserProfile类属于org.springframework.social.connect包,在下文中一共展示了UserProfile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: viewModel

import org.springframework.social.connect.UserProfile; //导入依赖的package包/类
private DiscordConnectionVM viewModel(Connection<Discord> connection, boolean user, boolean guilds, boolean connections) {
    DiscordConnectionVM vm = new DiscordConnectionVM();
    vm.setUserId(connection.getKey().getProviderUserId());
    vm.setUsername(connection.getDisplayName());
    vm.setAvatarUrl(connection.getImageUrl());
    if (user) {
        UserProfile userProfile = connection.fetchUserProfile();
        vm.setNickname(userProfile.getFirstName() + "#" + userProfile.getLastName());
    }
    if (guilds) {
        vm.setGuilds(connection.getApi().userOperations().getGuilds());
    }
    if (connections) {
        vm.setConnections(connection.getApi().userOperations().getConnections());
    }
    return vm;
}
 
开发者ID:quanticc,项目名称:sentry,代码行数:18,代码来源:DiscordResource.java

示例2: createRegistrationDTO

import org.springframework.social.connect.UserProfile; //导入依赖的package包/类
/**
 * Creates the form object used in the registration form.
 * @param connection
 * @return  If a user is signing in by using a social provider, this method returns a form
 *          object populated by the values given by the provider. Otherwise this method returns
 *          an empty form object (normal form registration).
 */
private RegistrationForm createRegistrationDTO(Connection<?> connection) {
    RegistrationForm dto = new RegistrationForm();

    if (connection != null) {
        UserProfile socialMediaProfile = connection.fetchUserProfile();
        dto.setEmail(socialMediaProfile.getEmail());
        dto.setFirstName(socialMediaProfile.getFirstName());
        dto.setLastName(socialMediaProfile.getLastName());

        ConnectionKey providerKey = connection.getKey();
        dto.setSignInProvider(SocialMediaService.valueOf(providerKey.getProviderId().toUpperCase()));
    }

    return dto;
}
 
开发者ID:eduyayo,项目名称:gamesboard,代码行数:23,代码来源:RegistrationController.java

示例3: createCalendarUserFromProvider

import org.springframework.social.connect.UserProfile; //导入依赖的package包/类
public static CalendarUser createCalendarUserFromProvider(Connection<?> connection){
    // TODO: FIXME: Need to put this into a Utility:
    UserProfile profile = connection.fetchUserProfile();

    CalendarUser user = new CalendarUser();

    if(profile.getEmail() != null){
        user.setEmail(profile.getEmail());
    }
    else if(profile.getUsername() != null){
        user.setEmail(profile.getUsername());
    }
    else {
        user.setEmail(connection.getDisplayName());
    }

    user.setFirstName(profile.getFirstName());
    user.setLastName(profile.getLastName());

    user.setPassword(randomAlphabetic(32));

    return user;

}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:25,代码来源:SocialAuthenticationUtils.java

示例4: getUser

import org.springframework.social.connect.UserProfile; //导入依赖的package包/类
private User getUser(final UserProfile userProfile, final String providerId) {
    final String username = Optional.ofNullable(userProfile.getUsername())
            .orElse(userProfile.getEmail());

    return Optional.ofNullable(username)
            .map(usrname -> {
                final User user = userRepository.findByUsername(usrname);
                final SocialProvider provider = SocialProvider.valueOf(providerId.toUpperCase());

                if (Objects.nonNull(user) && socialLoginEnabledForUser(user, provider)) {
                    return user;
                } else {
                    throw new SocialLoginException(String
                            .format("Social login through:%s not enabled for user:%s", provider.toString(),
                                    username));
                }
            }).orElseThrow(() -> new IllegalArgumentException("Username cannot be null"));
}
 
开发者ID:vlsidlyarevich,项目名称:unity,代码行数:19,代码来源:DefaultSocialUserService.java

示例5: createUserAccount

import org.springframework.social.connect.UserProfile; //导入依赖的package包/类
public User createUserAccount(Connection<?> connection) {

        UserProfile userProfile = connection.fetchUserProfile();

        String sql = "Insert into USERS "
                + " (id, email,user_name,first_name,last_name,role) "
                + " values (?,?,?,?,?,?) ";

        // Random string with 36 characters.
        String id = UUID.randomUUID().toString();

        String userName = userProfile.getFirstName().trim()
                + " " + userProfile.getLastName().trim();

        this.getJdbcTemplate().update(sql, id, userProfile.getEmail(), userName,
                userProfile.getFirstName(), userProfile.getLastName(), User.ROLE_USER);
        return findById(id);
    }
 
开发者ID:DmitriyLy,项目名称:travel_portal,代码行数:19,代码来源:UserDAO.java

示例6: execute

import org.springframework.social.connect.UserProfile; //导入依赖的package包/类
public String execute(Connection<?> connection) {
      UserProfile profile = connection.fetchUserProfile();

      // If the user already exists we return the user id (email)
      Optional<User> user = userService.findByEmail(profile.getEmail());
      if (user.isPresent()) {
          log.info("Connecting existing account to " + connection.getKey().getProviderId());
          return user.get().getEmail();
      }

      // The user doesn't exist so we need to create them
      User newUser = userService.create(profile.getEmail(), profile.getFirstName(), profile.getLastName());

log.info("Creating new user {} from {}", newUser.getEmail(), connection.getKey().getProviderId());

      return newUser.getEmail();
  }
 
开发者ID:leon,项目名称:spring-oauth-social-microservice-starter,代码行数:18,代码来源:SocialConnectionSignUp.java

示例7: execute

import org.springframework.social.connect.UserProfile; //导入依赖的package包/类
@Override
public String execute(Connection<?> connection) {
    final UserProfile profile = connection.fetchUserProfile();
    final User user = new User();
    user.setEmail(profile.getEmail());
    if ((profile.getUsername() == null) ||
            (profile.getUsername().length() < 2) ||
            (profile.getUsername().length() > MAX_NAME_LENGTH)) {
        user.setUserData(new UserData(user, profile.getFirstName(), profile.getFirstName(),
                profile.getLastName(), connection.getImageUrl(), "", false));
    } else {
        user.setUserData(new UserData(user, profile.getUsername(), profile.getFirstName(),
                profile.getLastName(), connection.getImageUrl(), "", false));
    }
    user.setPassword(KeyGenerators.string().generateKey());
    if (userService.getByEmail(user.getEmail()) == null) {
        userService.save(user);
        publisher.publishEvent(mails.welcomeMail(user));
    }
    return user.getEmail();
}
 
开发者ID:music-for-all,项目名称:music-for-all-application,代码行数:22,代码来源:AccountConnectionSignUpService.java

示例8: register

import org.springframework.social.connect.UserProfile; //导入依赖的package包/类
public String register(RegisterCustomerForm registerCustomerForm, HttpServletRequest request,
                       HttpServletResponse response, Model model) {
    Connection<?> connection = ProviderSignInUtils.getConnection(new ServletWebRequest(request));
    if (connection != null) {
        UserProfile userProfile = connection.fetchUserProfile();
        Customer customer = registerCustomerForm.getCustomer();
        customer.setFirstName(userProfile.getFirstName());
        customer.setLastName(userProfile.getLastName());
        customer.setEmailAddress(userProfile.getEmail());
        if (isUseEmailForLogin()){
            customer.setUsername(userProfile.getEmail());
        } else {
            customer.setUsername(userProfile.getUsername());
        }
    }

    return super.register(registerCustomerForm, request, response, model);
}
 
开发者ID:passion1014,项目名称:metaworks_framework,代码行数:19,代码来源:BroadleafSocialRegisterController.java

示例9: getForm

import org.springframework.social.connect.UserProfile; //导入依赖的package包/类
@RequestMapping(value="/signup", method = RequestMethod.GET)
public String getForm(NativeWebRequest request,  @ModelAttribute User user) {
	String view = successView;

	// check if this is a new user signing in via Spring Social
    Connection<?> connection = providerSignInUtils.getConnectionFromSession(request);
    if (connection != null) {
        // populate new User from social connection user profile
        UserProfile userProfile = connection.fetchUserProfile();
        user.setId(userProfile.getUsername());

        // finish social signup/login
        providerSignInUtils.doPostSignUp(user.getUsername(), request);

        // sign the user in and send them to the user home page
        signInAdapter.signIn(user.getUsername(), connection, request);
		view += "?spi="+ user.getUsername();
    }
    
    return view;
}
 
开发者ID:alex-bretet,项目名称:cloudstreetmarket.com,代码行数:22,代码来源:OAuth2CloudstreetController.java

示例10: retreiveSocialAsUser

import org.springframework.social.connect.UserProfile; //导入依赖的package包/类
private User retreiveSocialAsUser(Connection<?> con) {
    if (con == null) throw new IllegalStateException("No connection to social api");

    // build a new User from the external provider's version of the User
    UserProfile profile = con.fetchUserProfile();
    String firstName = profile.getFirstName();
    String lastName = profile.getLastName();
    String email = profile.getEmail();

    // build the UserAccountExternal from the ConnectionKey
    String externalAccountProviderName = con.getKey().getProviderId();
    ExternalProvider externalProvider = ExternalProvider.caseInsensitiveValueOf(externalAccountProviderName);
    String externalUserId = con.getKey().getProviderUserId();

    // check that we got the information we needed
    if (StringUtils.isBlank(email))
        throw new ApiException(externalAccountProviderName, "provider failed to return email");

    User socialUser = new User(firstName, lastName, email, externalProvider, externalUserId);

    log.debug("Retrieved details from {} for user '{}'", externalAccountProviderName, externalUserId);
    return socialUser;
}
 
开发者ID:esutoniagodesu,项目名称:egd-web,代码行数:24,代码来源:SocialConnectionSignUp.java

示例11: createConnection

import org.springframework.social.connect.UserProfile; //导入依赖的package包/类
private Connection<?> createConnection(String login,
                                       String email,
                                       String firstName,
                                       String lastName,
                                       String providerId) {
  UserProfile userProfile = mock(UserProfile.class);
  when(userProfile.getEmail()).thenReturn(email);
  when(userProfile.getUsername()).thenReturn(login);
  when(userProfile.getFirstName()).thenReturn(firstName);
  when(userProfile.getLastName()).thenReturn(lastName);

  Connection<?> connection = mock(Connection.class);
  ConnectionKey key = new ConnectionKey(providerId, "PROVIDER_USER_ID");
  when(connection.fetchUserProfile()).thenReturn(userProfile);
  when(connection.getKey()).thenReturn(key);

  return connection;
}
 
开发者ID:priitl,项目名称:p2p-webtv,代码行数:19,代码来源:SocialServiceTest.java

示例12: addProviderProfileInfo

import org.springframework.social.connect.UserProfile; //导入依赖的package包/类
/**
 * Adds the info from the provider profile to the specified profile.
 *
 * @param profile           the target profile
 * @param providerProfile   the provider profile where to get the info
 */
public static void addProviderProfileInfo(Profile profile, UserProfile providerProfile) {
    String email = providerProfile.getEmail();
    if (StringUtils.isEmpty(email)) {
        throw new IllegalStateException("No email included in provider profile");
    }

    String username = providerProfile.getUsername();
    if (StringUtils.isEmpty(username)) {
        username = email;
    }

    String firstName = providerProfile.getFirstName();
    String lastName = providerProfile.getLastName();

    profile.setUsername(username);
    profile.setEmail(email);
    profile.setAttribute(FIRST_NAME_ATTRIBUTE_NAME, firstName);
    profile.setAttribute(LAST_NAME_ATTRIBUTE_NAME, lastName);
}
 
开发者ID:craftercms,项目名称:profile,代码行数:26,代码来源:ConnectionUtils.java

示例13: testFetchUserProfile

import org.springframework.social.connect.UserProfile; //导入依赖的package包/类
@Test
public void testFetchUserProfile() {
	Evernote evernote = mock(Evernote.class);
	UserStoreOperations userStoreOperations = mock(UserStoreOperations.class);
	User user = new User();
	user.setName("foo");
	user.setUsername("FOO");
	user.setEmail("[email protected]");

	when(evernote.userStoreOperations()).thenReturn(userStoreOperations);
	when(userStoreOperations.getUser()).thenReturn(user);

	EvernoteAdapter adapter = new EvernoteAdapter();
	UserProfile userProfile = adapter.fetchUserProfile(evernote);

	assertThat(userProfile.getName(), is("foo"));
	assertThat(userProfile.getUsername(), is("FOO"));
	assertThat(userProfile.getEmail(), is("[email protected]"));
}
 
开发者ID:ttddyy,项目名称:spring-social-evernote,代码行数:20,代码来源:EvernoteAdapterTest.java

示例14: postService

import org.springframework.social.connect.UserProfile; //导入依赖的package包/类
/**
 * Hook for registerFederated()
 * Set the "email to SalesForce" on the connection after a user registered
 */
@Override
public void postService(CrudController controller, CrudService service, 
        HttpServletRequest request, String namespace, int operation, 
        Object json, Serializable id, Object serviceResponse) {
    
    switch (operation) {
        case OAuth2Service.OPERATION_REGISTER_FEDERATED:
            DConnection conn = (DConnection)json;
            UserProfile profile = (UserProfile) serviceResponse;
            String userId = (String)id;

            if (null != conn && OAuth2Service.PROVIDER_ID_SALESFORCE.equals(conn.getProviderId())) {
                String address = getEmailServiceAddress(conn.getAppArg0(), conn.getAccessToken());
                conn.setSecret(address);
            }
            break;
    }
}
 
开发者ID:goldengekko,项目名称:Meetr-Backend,代码行数:23,代码来源:MeetrService.java

示例15: userForm

import org.springframework.social.connect.UserProfile; //导入依赖的package包/类
@ModelAttribute("userForm")
public UserForm userForm(final WebRequest webRequest) {

    final Connection<?> connection = ProviderSignInUtils.getConnection(webRequest);

    if (connection == null) {
        return new UserForm();
    }

    final UserProfile userProfile = connection.fetchUserProfile();

    return userProfile == null
           ? new UserForm()
           : new UserForm(userProfile.getEmail(),
                          userProfile.getFirstName(),
                          userProfile.getLastName());
}
 
开发者ID:martinlau,项目名称:unidle-old,代码行数:18,代码来源:SignupController.java


注:本文中的org.springframework.social.connect.UserProfile类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。