本文整理匯總了Java中org.apache.shiro.authc.AuthenticationToken.getClass方法的典型用法代碼示例。如果您正苦於以下問題:Java AuthenticationToken.getClass方法的具體用法?Java AuthenticationToken.getClass怎麽用?Java AuthenticationToken.getClass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.shiro.authc.AuthenticationToken
的用法示例。
在下文中一共展示了AuthenticationToken.getClass方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: afterAttempt
import org.apache.shiro.authc.AuthenticationToken; //導入方法依賴的package包/類
/**
* 在每個Realm之後調用
*/
@Override
public AuthenticationInfo afterAttempt(Realm realm, AuthenticationToken token, AuthenticationInfo singleRealmInfo, AuthenticationInfo aggregateInfo, Throwable t) throws AuthenticationException {
AuthenticationInfo authenticationInfo = null;
if(singleRealmInfo == null){//當前沒有通過驗證
authenticationInfo = aggregateInfo;//保存之前所合並的
}else{//通過驗證
if(aggregateInfo== null){//之前沒有合並過
authenticationInfo = singleRealmInfo;//初始化
}else{
authenticationInfo = merge(singleRealmInfo, aggregateInfo);//合並
if(authenticationInfo.getPrincipals().getRealmNames().size() > 1){
System.out.println(authenticationInfo.getPrincipals().getRealmNames());
throw new AuthenticationException("[" + token.getClass() + "] " +
"這個認證令牌無法通過realm的驗證,請確認您提供的令牌隻允許通過1個realm驗證");
}
}
}
return authenticationInfo;
}
示例2: afterAllAttempts
import org.apache.shiro.authc.AuthenticationToken; //導入方法依賴的package包/類
/**
* 在所有Realm之後調用
*/
@Override
public AuthenticationInfo afterAllAttempts(AuthenticationToken token, AuthenticationInfo aggregate) throws AuthenticationException {
if(aggregate == null || CollectionUtils.isEmpty(aggregate.getPrincipals()) || aggregate.getPrincipals().getRealmNames().size() < 2){
throw new AuthenticationException("["+token.getClass()+"] 這個認證令牌無法通過realm的驗證,請確認您提供的令牌至少通過2個realm驗證");
}
return aggregate;
}
示例3: afterAllAttempts
import org.apache.shiro.authc.AuthenticationToken; //導入方法依賴的package包/類
/**
* Ensures that the <code>aggregate</code> method argument is not <code>null</code> and
* <code>aggregate.{@link org.apache.shiro.authc.AuthenticationInfo#getPrincipals() getPrincipals()}</code>
* is not <code>null</code>, and if either is <code>null</code>, throws an AuthenticationException to indicate
* that none of the realms authenticated successfully.
*/
public AuthenticationInfo afterAllAttempts(AuthenticationToken token, AuthenticationInfo aggregate) throws AuthenticationException {
//we know if one or more were able to succesfully authenticate if the aggregated account object does not
//contain null or empty data:
if (aggregate == null || CollectionUtils.isEmpty(aggregate.getPrincipals())) {
throw new AuthenticationException("Authentication token of type [" + token.getClass() + "] " +
"could not be authenticated by any configured realms. Please ensure that at least one realm can " +
"authenticate these tokens.");
}
return aggregate;
}