本文整理匯總了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;
}