本文整理汇总了Java中org.springframework.social.security.SocialAuthenticationToken类的典型用法代码示例。如果您正苦于以下问题:Java SocialAuthenticationToken类的具体用法?Java SocialAuthenticationToken怎么用?Java SocialAuthenticationToken使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SocialAuthenticationToken类属于org.springframework.social.security包,在下文中一共展示了SocialAuthenticationToken类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: enter
import org.springframework.social.security.SocialAuthenticationToken; //导入依赖的package包/类
@Override
public void enter(ViewChangeEvent event) {
/*
* UsernamePasswordAuthenticationToken OR
* SocialAuthenticationToken
*/
Authentication a = security.getAuthentication(); //SocialAuthenticationToken //UsernamePassword
String userName = a.getName();
/*
* SocialUser or User
*/
// Object principial = a.getPrincipal(); //SocialUser //User
String loginType = "";
if (a instanceof UsernamePasswordAuthenticationToken) {
loginType = "username and password";
} else if (a instanceof SocialAuthenticationToken) {
SocialAuthenticationToken token = (SocialAuthenticationToken) a;
loginType = StringUtils.capitalize(token.getProviderId()) + " account";
}
getView().initView(userName, loginType);
}
开发者ID:markoradinovic,项目名称:Vaadin4Spring-MVP-Sample-SpringSecuritySocial,代码行数:27,代码来源:HomePresenter.java
示例2: signIn
import org.springframework.social.security.SocialAuthenticationToken; //导入依赖的package包/类
@Override
public String signIn(String localUserId, Connection<?> connection, NativeWebRequest request) {
log.debug("signin {}", localUserId);
SocialUserDetails userDetails = socialUserDetailsService.loadUserByUserId(localUserId);
Authentication token = new SocialAuthenticationToken(connection, userDetails, null, userDetails.getAuthorities());
SecurityContextHolder.getContext().setAuthentication(token);
return null;
}