use of com.evolveum.midpoint.authentication.impl.module.authentication.RemoteModuleAuthenticationImpl in project midpoint by Evolveum.
the class RemoteAuthenticationFilter method doRemoteFilter.
default void doRemoteFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
boolean sentRequest = false;
if (authentication instanceof MidpointAuthentication) {
MidpointAuthentication mpAuthentication = (MidpointAuthentication) authentication;
RemoteModuleAuthenticationImpl moduleAuthentication = (RemoteModuleAuthenticationImpl) mpAuthentication.getProcessingModuleAuthentication();
if (moduleAuthentication != null && RequestState.SENDED.equals(moduleAuthentication.getRequestState())) {
sentRequest = true;
}
boolean requiresAuthentication = requiresAuth((HttpServletRequest) req, (HttpServletResponse) res);
if (!requiresAuthentication && sentRequest) {
AuthenticationServiceException exception = new AuthenticationServiceException(getErrorMessageKeyNotResponse());
unsuccessfulAuth((HttpServletRequest) req, (HttpServletResponse) res, exception);
} else {
if (moduleAuthentication != null && requiresAuthentication && sentRequest) {
moduleAuthentication.setRequestState(RequestState.RECEIVED);
}
doAuth(req, res, chain);
}
} else {
throw new AuthenticationServiceException("Unsupported type of Authentication");
}
}
use of com.evolveum.midpoint.authentication.impl.module.authentication.RemoteModuleAuthenticationImpl in project midpoint by Evolveum.
the class AuthSequenceUtil method doRemoteFilter.
public static void doRemoteFilter(ServletRequest req, ServletResponse res, FilterChain chain, RemoteAuthenticationFilter remoteFilter) throws IOException, ServletException {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
boolean sendedRequest = false;
if (authentication instanceof MidpointAuthentication) {
MidpointAuthentication mpAuthentication = (MidpointAuthentication) authentication;
RemoteModuleAuthenticationImpl moduleAuthentication = (RemoteModuleAuthenticationImpl) mpAuthentication.getProcessingModuleAuthentication();
if (moduleAuthentication != null && RequestState.SENDED.equals(moduleAuthentication.getRequestState())) {
sendedRequest = true;
}
boolean requiresAuthentication = remoteFilter.requiresAuth((HttpServletRequest) req, (HttpServletResponse) res);
if (!requiresAuthentication && sendedRequest) {
AuthenticationServiceException exception = new AuthenticationServiceException("web.security.flexAuth.oidc.not.response");
remoteFilter.unsuccessfulAuth((HttpServletRequest) req, (HttpServletResponse) res, exception);
} else {
if (moduleAuthentication != null && requiresAuthentication && sendedRequest) {
moduleAuthentication.setRequestState(RequestState.RECEIVED);
}
remoteFilter.doAuth(req, res, chain);
}
} else {
throw new AuthenticationServiceException("Unsupported type of Authentication");
}
}
Aggregations