/** * <p>Checks if an authenticated user is setted with an attribute with the given name.</p> * * <p>This method requires that valid {@link ELEvaluationContext} associated with the current * invation thread.</p> * * @param attributeName The attribute's name. * * @return True if the user is setted with the attribute. Otherwise, returns false. */ public static boolean hasAttribute(String attributeName) { ELEvaluationContext evaluationContext = ELEvaluationContext.get(); Identity identity = evaluationContext.getIdentity(); Account account = identity.getAccount(); if (account != null && account.getAttribute(attributeName) != null) { return true; } return false; }
/** * <p>Checks if an authenticated user is setted with an attribute with the given name.</p> * * <p>This method requires that valid {@link ELEvaluationContext} associated with the current * invation thread.</p> * * @param attributeName The attribute's name. * * @return True if the user is setted with the attribute. Otherwise, returns false. */ public static boolean hasAttribute(String attributeName) { ELEvaluationContext evaluationContext = ELEvaluationContext.get(); Identity identity = evaluationContext.getIdentity(); Account account = identity.getAccount(); if (account != null && account.getAttribute(attributeName) != null) { return true; } return false; }
/** * <p>Checks if an authenticated user is setted with an attribute with the given name.</p> * * <p>This method requires that valid {@link ELEvaluationContext} associated with the current * invation thread.</p> * * @param attributeName The attribute's name. * * @return True if the user is setted with the attribute. Otherwise, returns false. */ public static boolean hasAttribute(String attributeName) { ELEvaluationContext evaluationContext = ELEvaluationContext.get(); Identity identity = evaluationContext.getIdentity(); Account account = identity.getAccount(); if (account != null && account.getAttribute(attributeName) != null) { return true; } return false; }
@Override protected boolean validateCredential(IdentityContext context, CredentialStorage credentialStorage, UsernamePasswordCredentials credentials, LDAPIdentityStore ldapIdentityStore) { Account account = getAccount(context, credentials.getUsername()); char[] password = credentials.getPassword().getValue(); String userDN = (String) account.getAttribute(LDAPIdentityStore.ENTRY_DN_ATTRIBUTE_NAME).getValue(); if (CREDENTIAL_LOGGER.isDebugEnabled()) { CREDENTIAL_LOGGER.debugf("Using DN [%s] for authentication of user [%s]", userDN, credentials.getUsername()); } if (ldapIdentityStore.getOperationManager().authenticate(userDN, new String(password))) { return true; } return false; } }