use of com.evolveum.midpoint.authentication.api.config.ModuleAuthentication in project midpoint by Evolveum.
the class HttpAuthenticationEntryPoint method commence.
@Override
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication instanceof MidpointAuthentication) {
MidpointAuthentication mpAuthentication = (MidpointAuthentication) authentication;
List<ModuleAuthentication> parallelProcessingModules = mpAuthentication.getParallelProcessingModules();
if (!parallelProcessingModules.isEmpty()) {
for (ModuleAuthentication moduleAuthentication : parallelProcessingModules) {
response.addHeader("WWW-Authenticate", getRealmForHeader(moduleAuthentication, authException));
}
}
}
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
}
use of com.evolveum.midpoint.authentication.api.config.ModuleAuthentication 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);
}
use of com.evolveum.midpoint.authentication.api.config.ModuleAuthentication in project midpoint by Evolveum.
the class AuthUtil method getProcessingModule.
private static ModuleAuthentication getProcessingModule(boolean required) {
Authentication actualAuthentication = SecurityContextHolder.getContext().getAuthentication();
if (actualAuthentication instanceof MidpointAuthentication) {
MidpointAuthentication mpAuthentication = (MidpointAuthentication) actualAuthentication;
ModuleAuthentication moduleAuthentication = mpAuthentication.getProcessingModuleAuthentication();
if (required && moduleAuthentication == null) {
LOGGER.error("Couldn't find processing module authentication {}", mpAuthentication);
throw new AuthenticationServiceException("web.security.flexAuth.module.null");
}
return moduleAuthentication;
} else if (required) {
LOGGER.error("Type of actual authentication in security context isn't MidpointAuthentication");
throw new AuthenticationServiceException("web.security.flexAuth.auth.wrong.type");
}
return null;
}
use of com.evolveum.midpoint.authentication.api.config.ModuleAuthentication in project midpoint by Evolveum.
the class MidpointAuthenticationTrustResolverImpl method isAnonymous.
public boolean isAnonymous(Authentication authentication) {
if ((anonymousClass == null) || (authentication == null)) {
return false;
}
if (authentication instanceof MidpointAuthentication) {
MidpointAuthentication mpAuthentication = (MidpointAuthentication) authentication;
ModuleAuthentication moduleAuthentication = mpAuthentication.getProcessingModuleAuthentication();
if (moduleAuthentication == null || moduleAuthentication.getAuthentication() == null) {
return false;
}
return anonymousClass.isAssignableFrom(moduleAuthentication.getAuthentication().getClass());
}
return anonymousClass.isAssignableFrom(authentication.getClass());
}
use of com.evolveum.midpoint.authentication.api.config.ModuleAuthentication 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);
}
}
Aggregations