当前位置: 首页>>代码示例>>Java>>正文


Java AuthenticationToken.getClass方法代码示例

本文整理汇总了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;
}
 
开发者ID:l81893521,项目名称:shiro-demo,代码行数:23,代码来源:OnlyOneAuthenticatorStrategy.java

示例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;
}
 
开发者ID:l81893521,项目名称:shiro-demo,代码行数:11,代码来源:AtLeastTwoAuthenticatorStrategy.java

示例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;
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:18,代码来源:AtLeastOneSuccessfulStrategy.java


注:本文中的org.apache.shiro.authc.AuthenticationToken.getClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。