本文整理汇总了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;
}