Search in sources :

Example 1 with RemoteModuleAuthentication

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

the class AbstractPageRemoteAuthenticationSelect method getProviders.

private List<IdentityProvider> getProviders() {
    List<IdentityProvider> providers = new ArrayList<>();
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    if (authentication instanceof MidpointAuthentication) {
        MidpointAuthentication mpAuthentication = (MidpointAuthentication) authentication;
        ModuleAuthentication moduleAuthentication = mpAuthentication.getProcessingModuleAuthentication();
        if (moduleAuthentication instanceof RemoteModuleAuthentication) {
            providers = ((RemoteModuleAuthentication) moduleAuthentication).getProviders();
            if (providers.isEmpty()) {
                String key = getErrorKeyEmptyProviders();
                error(getString(key));
            }
            return providers;
        }
        String key = getErrorKeyUnsupportedType();
        error(getString(key));
        return providers;
    }
    String key = "web.security.flexAuth.unsupported.auth.type";
    error(getString(key));
    return providers;
}
Also used : ModuleAuthentication(com.evolveum.midpoint.authentication.api.config.ModuleAuthentication) RemoteModuleAuthentication(com.evolveum.midpoint.authentication.api.config.RemoteModuleAuthentication) ModuleAuthentication(com.evolveum.midpoint.authentication.api.config.ModuleAuthentication) MidpointAuthentication(com.evolveum.midpoint.authentication.api.config.MidpointAuthentication) RemoteModuleAuthentication(com.evolveum.midpoint.authentication.api.config.RemoteModuleAuthentication) Authentication(org.springframework.security.core.Authentication) RemoteModuleAuthentication(com.evolveum.midpoint.authentication.api.config.RemoteModuleAuthentication) ArrayList(java.util.ArrayList) IdentityProvider(com.evolveum.midpoint.authentication.api.IdentityProvider) MidpointAuthentication(com.evolveum.midpoint.authentication.api.config.MidpointAuthentication)

Example 2 with RemoteModuleAuthentication

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

the class RemoteAuthenticationEntryPoint method commence.

@Override
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException {
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    if (authentication instanceof MidpointAuthentication) {
        MidpointAuthentication mpAuthentication = (MidpointAuthentication) authentication;
        ModuleAuthentication moduleAuthentication = mpAuthentication.getProcessingModuleAuthentication();
        if (moduleAuthentication instanceof RemoteModuleAuthentication) {
            List<IdentityProvider> providers = ((RemoteModuleAuthentication) moduleAuthentication).getProviders();
            if (request.getSession().getAttribute("SPRING_SECURITY_LAST_EXCEPTION") == null) {
                if (providers.size() == 1) {
                    response.sendRedirect(providers.get(0).getRedirectLink());
                    return;
                }
            } else if (getLoginFormUrl().equals(request.getServletPath()) && AuthenticationModuleState.LOGIN_PROCESSING.equals(moduleAuthentication.getState())) {
                return;
            }
        }
    }
    super.commence(request, response, authException);
}
Also used : ModuleAuthentication(com.evolveum.midpoint.authentication.api.config.ModuleAuthentication) RemoteModuleAuthentication(com.evolveum.midpoint.authentication.api.config.RemoteModuleAuthentication) ModuleAuthentication(com.evolveum.midpoint.authentication.api.config.ModuleAuthentication) MidpointAuthentication(com.evolveum.midpoint.authentication.api.config.MidpointAuthentication) RemoteModuleAuthentication(com.evolveum.midpoint.authentication.api.config.RemoteModuleAuthentication) Authentication(org.springframework.security.core.Authentication) RemoteModuleAuthentication(com.evolveum.midpoint.authentication.api.config.RemoteModuleAuthentication) IdentityProvider(com.evolveum.midpoint.authentication.api.IdentityProvider) MidpointAuthentication(com.evolveum.midpoint.authentication.api.config.MidpointAuthentication)

Aggregations

IdentityProvider (com.evolveum.midpoint.authentication.api.IdentityProvider)2 MidpointAuthentication (com.evolveum.midpoint.authentication.api.config.MidpointAuthentication)2 ModuleAuthentication (com.evolveum.midpoint.authentication.api.config.ModuleAuthentication)2 RemoteModuleAuthentication (com.evolveum.midpoint.authentication.api.config.RemoteModuleAuthentication)2 Authentication (org.springframework.security.core.Authentication)2 ArrayList (java.util.ArrayList)1