當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。