@Override protected void assertCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) throws AuthenticationException { CredentialsMatcher cm = getCredentialsMatcher(); if (cm != null) { if (!cm.doCredentialsMatch(token, info)) { //not successful - throw an exception to indicate this: String msg = "Submitted credentials for token [" + token + "] did not match the expected credentials."; throw new IncorrectCredentialsException(msg); }else { //记录登陆日志 /* ShiroUser shiroUser = (ShiroUser)(info.getPrincipals().getPrimaryPrincipal()); Log log = LogBuilder.OP_LOG.buildCommonLog("登陆", shiroUser.getClientIp(), shiroUser.getLoginName()); logService.log(log);*/ } } else { throw new AuthenticationException("A CredentialsMatcher must be configured in order to verify " + "credentials during authentication. If you do not wish for credentials to be examined, you " + "can configure an " + AllowAllCredentialsMatcher.class.getName() + " instance."); } }
public AccountRealm() { super(new AllowAllCredentialsMatcher()); setAuthenticationTokenClass(UsernamePasswordToken.class); //FIXME: 暂时禁用Cache setCachingEnabled(false); }
@Override public void afterPropertiesSet() throws Exception { setCachingEnabled(true); setCacheManager(cacheManager); setAuthenticationCachingEnabled(true); setAuthenticationCacheName(CACHE_AUTHENTICATION); setAuthorizationCachingEnabled(true); setAuthorizationCacheName(CACHE_AUTHORIZATION); setAuthenticationTokenClass(OauthUserToken.class); setCredentialsMatcher(new AllowAllCredentialsMatcher()); }
/** * Default no-argument constructor that defaults the internal {@link LdapContextFactory} instance to a * {@link JndiLdapContextFactory}. */ public DefaultLdapRealm() { //Credentials Matching is not necessary - the LDAP directory will do it automatically: setCredentialsMatcher(new AllowAllCredentialsMatcher()); //Any Object principal and Object credentials may be passed to the LDAP provider, so accept any token: setAuthenticationTokenClass(AuthenticationToken.class); this.contextFactory = new JndiLdapContextFactory(); }
/** * Asserts that the submitted {@code AuthenticationToken}'s credentials match the stored account * {@code AuthenticationInfo}'s credentials, and if not, throws an {@link AuthenticationException}. * * @param token the submitted authentication token * @param info the AuthenticationInfo corresponding to the given {@code token} * @throws AuthenticationException if the token's credentials do not match the stored account credentials. */ protected void assertCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) throws AuthenticationException { CredentialsMatcher cm = getCredentialsMatcher(); if (cm != null) { if (!cm.doCredentialsMatch(token, info)) { //not successful - throw an exception to indicate this: String msg = "Submitted credentials for token [" + token + "] did not match the expected credentials."; throw new IncorrectCredentialsException(msg); } } else { throw new AuthenticationException("A CredentialsMatcher must be configured in order to verify " + "credentials during authentication. If you do not wish for credentials to be examined, you " + "can configure an " + AllowAllCredentialsMatcher.class.getName() + " instance."); } }
public Realm( CacheManager cacheManager ) { super( cacheManager ); setCredentialsMatcher( new AllowAllCredentialsMatcher() ); setPermissionResolver(new CustomPermissionResolver()); setCachingEnabled(true); setAuthenticationCachingEnabled(true); }
public BearerTokenAuthenticatingRealm() { super(new AllowAllCredentialsMatcher()); setAuthenticationTokenClass(BearerToken.class); }
@PostConstruct public void postConstruct() { setCacheManager(new MemoryConstrainedCacheManager()); setCredentialsMatcher(new AllowAllCredentialsMatcher()); }
public Realm() { setCredentialsMatcher(new AllowAllCredentialsMatcher()); setPermissionResolver(new CustomPermissionResolver()); }
public Realm( CredentialsMatcher matcher ) { super(new AllowAllCredentialsMatcher()); setPermissionResolver(new CustomPermissionResolver()); }
public Realm( CacheManager cacheManager, CredentialsMatcher matcher ) { super(cacheManager, new AllowAllCredentialsMatcher()); setPermissionResolver( new CustomPermissionResolver() ); setCachingEnabled(true); setAuthenticationCachingEnabled(true); }
/** * Constructor with token URI and client id / secret, set authentication token * class to {@link OAuthClientToken} * * @param tokenURI * token URI * @param clientId * client id * @param clientSecret * client secret */ public OAuthAuthorizeRealm(String tokenURI, String clientId, String clientSecret) { super(); this.tokenURI = tokenURI; this.clientId = clientId; this.clientSecret = clientSecret; setAuthenticationTokenClass(OAuthClientToken.class); setCredentialsMatcher(new AllowAllCredentialsMatcher()); }