Search in sources :

Example 1 with CredentialModuleAuthenticationImpl

use of com.evolveum.midpoint.authentication.impl.module.authentication.CredentialModuleAuthenticationImpl in project midpoint by Evolveum.

the class AbstractCredentialProvider method supports.

public boolean supports(Class<?> authenticationClass, Authentication authentication) {
    if (!(authentication instanceof MidpointAuthentication)) {
        return supports(authenticationClass);
    }
    MidpointAuthentication mpAuthentication = (MidpointAuthentication) authentication;
    ModuleAuthenticationImpl moduleAuthentication = (ModuleAuthenticationImpl) getProcessingModule(mpAuthentication);
    if (moduleAuthentication == null || moduleAuthentication.getAuthentication() == null) {
        return false;
    }
    if (moduleAuthentication.getAuthentication() instanceof AnonymousAuthenticationToken) {
        // hack for specific situation when user is anonymous, but accessDecisionManager resolve it
        return true;
    }
    if (moduleAuthentication instanceof CredentialModuleAuthenticationImpl) {
        Class<? extends CredentialPolicyType> moduleCredentialType = ((CredentialModuleAuthenticationImpl) moduleAuthentication).getCredentialType();
        if (moduleCredentialType == null) {
            return false;
        }
        if (!getTypeOfCredential().equals(moduleCredentialType)) {
            return false;
        }
    }
    return supports(moduleAuthentication.getAuthentication().getClass());
}
Also used : ModuleAuthenticationImpl(com.evolveum.midpoint.authentication.impl.module.authentication.ModuleAuthenticationImpl) CredentialModuleAuthenticationImpl(com.evolveum.midpoint.authentication.impl.module.authentication.CredentialModuleAuthenticationImpl) CredentialModuleAuthenticationImpl(com.evolveum.midpoint.authentication.impl.module.authentication.CredentialModuleAuthenticationImpl) AnonymousAuthenticationToken(org.springframework.security.authentication.AnonymousAuthenticationToken) MidpointAuthentication(com.evolveum.midpoint.authentication.api.config.MidpointAuthentication)

Aggregations

MidpointAuthentication (com.evolveum.midpoint.authentication.api.config.MidpointAuthentication)1 CredentialModuleAuthenticationImpl (com.evolveum.midpoint.authentication.impl.module.authentication.CredentialModuleAuthenticationImpl)1 ModuleAuthenticationImpl (com.evolveum.midpoint.authentication.impl.module.authentication.ModuleAuthenticationImpl)1 AnonymousAuthenticationToken (org.springframework.security.authentication.AnonymousAuthenticationToken)1