本文整理匯總了Java中org.apache.shiro.realm.Realm.supports方法的典型用法代碼示例。如果您正苦於以下問題:Java Realm.supports方法的具體用法?Java Realm.supports怎麽用?Java Realm.supports使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.shiro.realm.Realm
的用法示例。
在下文中一共展示了Realm.supports方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: beforeAttempt
import org.apache.shiro.realm.Realm; //導入方法依賴的package包/類
/**
* Because all realms in this strategy must complete successfully, this implementation ensures that the given
* <code>Realm</code> {@link org.apache.shiro.realm.Realm#supports(org.apache.shiro.authc.AuthenticationToken) supports} the given
* <code>token</code> argument. If it does not, this method throws an
* {@link UnsupportedTokenException UnsupportedTokenException} to end the authentication
* process immediately. If the realm does support the token, the <code>info</code> argument is returned immediately.
*/
public AuthenticationInfo beforeAttempt(Realm realm, AuthenticationToken token, AuthenticationInfo info) throws AuthenticationException {
if (!realm.supports(token)) {
String msg = "Realm [" + realm + "] of type [" + realm.getClass().getName() + "] does not support " +
" the submitted AuthenticationToken [" + token + "]. The [" + getClass().getName() +
"] implementation requires all configured realm(s) to support and be able to process the submitted " +
"AuthenticationToken.";
throw new UnsupportedTokenException(msg);
}
return info;
}
示例2: doMultiRealmAuthentication
import org.apache.shiro.realm.Realm; //導入方法依賴的package包/類
@Override
protected AuthenticationInfo doMultiRealmAuthentication(final Collection<Realm> realms,
final AuthenticationToken token)
{
log.trace("Iterating through [{}] realms for PAM authentication", realms.size());
for (Realm realm : realms) {
// check if the realm supports this token
if (realm.supports(token)) {
log.trace("Attempting to authenticate token [{}] using realm of type [{}]", token, realm);
try {
AuthenticationInfo info = realm.getAuthenticationInfo(token);
if (info != null) {
return info;
}
log.trace("Realm [{}] returned null when authenticating token [{}]", realm, token);
}
catch (Throwable t) {
log.trace("Realm [{}] threw an exception during a multi-realm authentication attempt", realm, t);
}
}
else {
log.trace("Realm of type [{}] does not support token [{}]; skipping realm", realm, token);
}
}
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.");
}
示例3: doMultiRealmAuthentication
import org.apache.shiro.realm.Realm; //導入方法依賴的package包/類
/**
* Performs the multi-realm authentication attempt by calling back to a {@link AuthenticationStrategy} object
* as each realm is consulted for {@code AuthenticationInfo} for the specified {@code token}.
*
* @param realms the multiple realms configured on this Authenticator instance.
* @param token the submitted AuthenticationToken representing the subject's (user's) log-in principals and credentials.
* @return an aggregated AuthenticationInfo instance representing account data across all the successfully
* consulted realms.
*/
protected AuthenticationInfo doMultiRealmAuthentication(Collection<Realm> realms, AuthenticationToken token) {
AuthenticationStrategy strategy = getAuthenticationStrategy();
AuthenticationInfo aggregate = strategy.beforeAllAttempts(realms, token);
if (log.isTraceEnabled()) {
log.trace("Iterating through {} realms for PAM authentication", realms.size());
}
for (Realm realm : realms) {
aggregate = strategy.beforeAttempt(realm, token, aggregate);
if (realm.supports(token)) {
log.trace("Attempting to authenticate token [{}] using realm [{}]", token, realm);
AuthenticationInfo info = null;
Throwable t = null;
try {
info = realm.getAuthenticationInfo(token);
} catch (Throwable throwable) {
t = throwable;
if (log.isWarnEnabled()) {
String msg = "Realm [" + realm + "] threw an exception during a multi-realm authentication attempt:";
log.warn(msg, t);
}
}
aggregate = strategy.afterAttempt(realm, token, info, aggregate, t);
} else {
log.debug("Realm [{}] does not support token {}. Skipping realm.", realm, token);
}
}
aggregate = strategy.afterAllAttempts(token, aggregate);
return aggregate;
}