Search in sources :

Example 56 with MidpointAuthentication

use of com.evolveum.midpoint.authentication.api.config.MidpointAuthentication in project midpoint by Evolveum.

the class BasicMidPointAuthenticationSuccessHandler method onAuthenticationSuccess.

@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
    if (authentication instanceof MidpointAuthentication) {
        MidpointAuthentication mpAuthentication = (MidpointAuthentication) authentication;
        ModuleAuthentication moduleAuthentication = mpAuthentication.getProcessingModuleAuthentication();
        moduleAuthentication.setState(AuthenticationModuleState.SUCCESSFULLY);
    }
}
Also used : ModuleAuthentication(com.evolveum.midpoint.authentication.api.config.ModuleAuthentication) MidpointAuthentication(com.evolveum.midpoint.authentication.api.config.MidpointAuthentication)

Example 57 with MidpointAuthentication

use of com.evolveum.midpoint.authentication.api.config.MidpointAuthentication in project midpoint by Evolveum.

the class MidPointAbstractAuthenticationProvider method initAuthRequirements.

private Authentication initAuthRequirements(Authentication processingAuthentication, Authentication originalAuthentication, Authentication actualAuthentication, AuthenticationRequirements authRequirements) {
    if (originalAuthentication instanceof MidpointAuthentication) {
        MidpointAuthentication mpAuthentication = (MidpointAuthentication) originalAuthentication;
        ModuleAuthentication moduleAuthentication = getProcessingModule(mpAuthentication);
        if (moduleAuthentication.getFocusType() != null) {
            authRequirements.focusType = PrismContext.get().getSchemaRegistry().determineCompileTimeClass(moduleAuthentication.getFocusType());
        }
        authRequirements.requireAssignment = mpAuthentication.getSequence().getRequireAssignmentTarget();
        authRequirements.channel = mpAuthentication.getAuthenticationChannel();
        return moduleAuthentication.getAuthentication();
    } else if (actualAuthentication instanceof MidpointAuthentication) {
        MidpointAuthentication mpAuthentication = (MidpointAuthentication) actualAuthentication;
        ModuleAuthentication moduleAuthentication = getProcessingModule(mpAuthentication);
        if (moduleAuthentication != null && moduleAuthentication.getFocusType() != null) {
            authRequirements.focusType = PrismContext.get().getSchemaRegistry().determineCompileTimeClass(moduleAuthentication.getFocusType());
        }
        authRequirements.requireAssignment = mpAuthentication.getSequence().getRequireAssignmentTarget();
        authRequirements.channel = mpAuthentication.getAuthenticationChannel();
    }
    return processingAuthentication;
}
Also used : ModuleAuthentication(com.evolveum.midpoint.authentication.api.config.ModuleAuthentication) MidpointAuthentication(com.evolveum.midpoint.authentication.api.config.MidpointAuthentication)

Example 58 with MidpointAuthentication

use of com.evolveum.midpoint.authentication.api.config.MidpointAuthentication in project midpoint by Evolveum.

the class MidPointAbstractAuthenticationProvider method createConnectEnvironment.

protected ConnectionEnvironment createConnectEnvironment(String channel) {
    ConnectionEnvironment env = ConnectionEnvironment.create(channel);
    Authentication actualAuthentication = SecurityContextHolder.getContext().getAuthentication();
    if (actualAuthentication instanceof MidpointAuthentication && ((MidpointAuthentication) actualAuthentication).getSessionId() != null) {
        env.setSessionIdOverride(((MidpointAuthentication) actualAuthentication).getSessionId());
    }
    return env;
}
Also used : ModuleAuthentication(com.evolveum.midpoint.authentication.api.config.ModuleAuthentication) MidpointAuthentication(com.evolveum.midpoint.authentication.api.config.MidpointAuthentication) Authentication(org.springframework.security.core.Authentication) MidpointAuthentication(com.evolveum.midpoint.authentication.api.config.MidpointAuthentication) ConnectionEnvironment(com.evolveum.midpoint.security.api.ConnectionEnvironment)

Example 59 with MidpointAuthentication

use of com.evolveum.midpoint.authentication.api.config.MidpointAuthentication in project midpoint by Evolveum.

the class MidPointAbstractAuthenticationProvider method supports.

public boolean supports(Class<?> authenticationClass, Authentication authentication) {
    if (!(authentication instanceof MidpointAuthentication)) {
        return supports(authenticationClass);
    }
    MidpointAuthentication mpAuthentication = (MidpointAuthentication) authentication;
    ModuleAuthentication moduleAuthentication = 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;
    }
    return supports(moduleAuthentication.getAuthentication().getClass());
}
Also used : ModuleAuthentication(com.evolveum.midpoint.authentication.api.config.ModuleAuthentication) AnonymousAuthenticationToken(org.springframework.security.authentication.AnonymousAuthenticationToken) MidpointAuthentication(com.evolveum.midpoint.authentication.api.config.MidpointAuthentication)

Aggregations

MidpointAuthentication (com.evolveum.midpoint.authentication.api.config.MidpointAuthentication)59 Authentication (org.springframework.security.core.Authentication)41 ModuleAuthentication (com.evolveum.midpoint.authentication.api.config.ModuleAuthentication)30 ModuleAuthenticationImpl (com.evolveum.midpoint.authentication.impl.module.authentication.ModuleAuthenticationImpl)9 MidPointPrincipal (com.evolveum.midpoint.security.api.MidPointPrincipal)7 AnonymousAuthenticationToken (org.springframework.security.authentication.AnonymousAuthenticationToken)6 AuthenticationServiceException (org.springframework.security.authentication.AuthenticationServiceException)5 RemoteModuleAuthentication (com.evolveum.midpoint.authentication.api.config.RemoteModuleAuthentication)4 HttpModuleAuthentication (com.evolveum.midpoint.authentication.impl.module.authentication.HttpModuleAuthentication)4 AuditEventRecord (com.evolveum.midpoint.audit.api.AuditEventRecord)3 LdapModuleAuthentication (com.evolveum.midpoint.authentication.impl.module.authentication.LdapModuleAuthentication)3 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)3 Task (com.evolveum.midpoint.task.api.Task)3 AuthenticationException (org.springframework.security.core.AuthenticationException)3 OAuth2LoginAuthenticationToken (org.springframework.security.oauth2.client.authentication.OAuth2LoginAuthenticationToken)3 IdentityProvider (com.evolveum.midpoint.authentication.api.IdentityProvider)2 CredentialModuleAuthentication (com.evolveum.midpoint.authentication.api.config.CredentialModuleAuthentication)2 MailNonceModuleAuthenticationImpl (com.evolveum.midpoint.authentication.impl.module.authentication.MailNonceModuleAuthenticationImpl)2 OidcClientModuleAuthenticationImpl (com.evolveum.midpoint.authentication.impl.module.authentication.OidcClientModuleAuthenticationImpl)2 RemoteModuleAuthenticationImpl (com.evolveum.midpoint.authentication.impl.module.authentication.RemoteModuleAuthenticationImpl)2