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


Java Connection.fetchUserProfile方法代码示例

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


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

示例1: viewModel

import org.springframework.social.connect.Connection; //导入方法依赖的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.Connection; //导入方法依赖的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.Connection; //导入方法依赖的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: createUserAccount

import org.springframework.social.connect.Connection; //导入方法依赖的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

示例5: execute

import org.springframework.social.connect.Connection; //导入方法依赖的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

示例6: execute

import org.springframework.social.connect.Connection; //导入方法依赖的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

示例7: register

import org.springframework.social.connect.Connection; //导入方法依赖的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

示例8: getForm

import org.springframework.social.connect.Connection; //导入方法依赖的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

示例9: retreiveSocialAsUser

import org.springframework.social.connect.Connection; //导入方法依赖的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

示例10: createSocialUser

import org.springframework.social.connect.Connection; //导入方法依赖的package包/类
/**
 * Create new user.
 * @param connection connection
 * @param langKey lang key
 */
public void createSocialUser(Connection<?> connection, String langKey) {
    if (connection == null) {
        log.error("Cannot create social user because connection is null");
        throw new IllegalArgumentException("Connection cannot be null");
    }
    UserProfile userProfile = connection.fetchUserProfile();
    String providerId = connection.getKey().getProviderId();
    String imageUrl = connection.getImageUrl();
    User user = createUserIfNotExist(userProfile, langKey, imageUrl);
    createSocialConnection(user.getUserKey(), connection);
    mailService.sendSocialRegistrationValidationEmail(user, userProfile.getEmail(), providerId,
        TenantContext.getCurrent().getTenant(), MDCUtil.getRid());
}
 
开发者ID:xm-online,项目名称:xm-uaa,代码行数:19,代码来源:SocialService.java

示例11: loadAuthentication

import org.springframework.social.connect.Connection; //导入方法依赖的package包/类
@Override
public OAuth2Authentication loadAuthentication(String accessToken)
		throws AuthenticationException, InvalidTokenException {
	AccessGrant accessGrant = new AccessGrant(accessToken);
	Connection<?> connection = this.connectionFactory.createConnection(accessGrant);
	UserProfile user = connection.fetchUserProfile();
	return extractAuthentication(user);
}
 
开发者ID:spring-projects,项目名称:spring-security-oauth2-boot,代码行数:9,代码来源:SpringSocialTokenServices.java

示例12: createSocialUser

import org.springframework.social.connect.Connection; //导入方法依赖的package包/类
public void createSocialUser(Connection<?> connection, String langKey) {
    if (connection == null) {
        log.error("Cannot create social user because connection is null");
        throw new IllegalArgumentException("Connection cannot be null");
    }
    UserProfile userProfile = connection.fetchUserProfile();
    String providerId = connection.getKey().getProviderId();
    String imageUrl = connection.getImageUrl();
    User user = createUserIfNotExist(userProfile, langKey, providerId, imageUrl);
    createSocialConnection(user.getLogin(), connection);
    mailService.sendSocialRegistrationValidationEmail(user, providerId);
}
 
开发者ID:Microsoft,项目名称:MTC_Labrat,代码行数:13,代码来源:SocialService.java

示例13: registrationView

import org.springframework.social.connect.Connection; //导入方法依赖的package包/类
@GetMapping
public String registrationView(RegistrationForm registrationForm, WebRequest request) {
	Connection<?> connection = providerSignInUtils.getConnectionFromSession(request);
	if (connection != null) {
		UserProfile profile = connection.fetchUserProfile();
		registrationForm.setUsername(profile.getUsername());
		registrationForm.setEmail(profile.getEmail());
	}
	return REGISTRATION;
}
 
开发者ID:codenergic,项目名称:theskeleton,代码行数:11,代码来源:RegistrationController.java

示例14: createSocialUser

import org.springframework.social.connect.Connection; //导入方法依赖的package包/类
public void createSocialUser(Connection<?> connection, String langKey) {
    if (connection == null) {
        log.error("Cannot create social user because connection is null");
        throw new IllegalArgumentException("Connection cannot be null");
    }
    UserProfile userProfile = connection.fetchUserProfile();
    String providerId = connection.getKey().getProviderId();
    User user = createUserIfNotExist(userProfile, langKey, providerId);
    createSocialConnection(user.getLogin(), connection);
    mailService.sendSocialRegistrationValidationEmail(user, providerId);
}
 
开发者ID:quanticc,项目名称:sentry,代码行数:12,代码来源:SocialService.java

示例15: createCalendarUserFromProvider

import org.springframework.social.connect.Connection; //导入方法依赖的package包/类
public static CalendarUser createCalendarUserFromProvider(Connection<?> connection){

        // TODO: There is a defect with Facebook:
        // org.springframework.social.UncategorizedApiException: (#12) bio field is
        // deprecated for versions v2.8 and higher:
//
//        Connection<Facebook> connection = facebookConnectionFactory.createConnection(accessGrant);
//        Facebook facebook = connection.getApi();
//        String [] fields = { "id", "email",  "first_name", "last_name" };
//        User userProfile = facebook.fetchObject("me", User.class, fields);
//
//        Object api = connection.getApi();
//        if(api instanceof FacebookTemplate){
//            System.out.println("Facebook");
//        }


        // Does not work with spring-social-facebook:2.0.3.RELEASE
        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,代码行数:41,代码来源:SocialAuthenticationUtils.java


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