本文整理匯總了Java中org.springframework.security.authentication.jaas.JaasAuthenticationToken類的典型用法代碼示例。如果您正苦於以下問題:Java JaasAuthenticationToken類的具體用法?Java JaasAuthenticationToken怎麽用?Java JaasAuthenticationToken使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
JaasAuthenticationToken類屬於org.springframework.security.authentication.jaas包,在下文中一共展示了JaasAuthenticationToken類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: authenticate
import org.springframework.security.authentication.jaas.JaasAuthenticationToken; //導入依賴的package包/類
@Override
public Authentication authenticate(Authentication authentication) {
JaasAuthenticationToken jaasAuthenticationToken = (JaasAuthenticationToken) delegate
.authenticate(authentication);
if (jaasAuthenticationToken.isAuthenticated()) {
String userName = jaasAuthenticationToken.getPrincipal().toString();
jaasAuthenticationToken.getLoginContext().getSubject().getPrincipals().add(new UserPrincipal(userName));
jaasAuthenticationToken.getLoginContext().getSubject().getPrincipals().add(new GroupPrincipal("group_1"));
jaasAuthenticationToken.getLoginContext().getSubject().getPrincipals().add(new GroupPrincipal("group_2"));
jaasAuthenticationToken.getLoginContext().getSubject().getPrincipals().add(new GroupPrincipal("group_3"));
return jaasAuthenticationToken;
} else {
return null;
}
}
示例2: authenticate
import org.springframework.security.authentication.jaas.JaasAuthenticationToken; //導入依賴的package包/類
public Authentication authenticate(Authentication auth) throws AuthenticationException {
JaasAuthenticationToken ret = (JaasAuthenticationToken)super.authenticate(auth);
for (GrantedAuthority role: ret.getAuthorities()) {
UniTimeUserContext user = new UniTimeUserContext(role.getAuthority(), ret.getName(), null, null);
return new JaasAuthenticationToken(user, ret.getCredentials(), new ArrayList<GrantedAuthority>(user.getAuthorities()), ret.getLoginContext());
}
return null;
}