use of com.evolveum.midpoint.authentication.api.AuthenticationChannel in project midpoint by Evolveum.
the class AuthSequenceUtil method buildAuthChannel.
public static AuthenticationChannel buildAuthChannel(AuthChannelRegistryImpl registry, AuthenticationSequenceType sequence) {
Validate.notNull(sequence, "Couldn't build authentication channel object, because sequence is null");
String channelId = null;
AuthenticationSequenceChannelType channelSequence = sequence.getChannel();
if (channelSequence != null) {
channelId = channelSequence.getChannelId();
}
AbstractChannelFactory factory = registry.findModelFactory(channelId);
if (factory == null) {
LOGGER.error("Couldn't find factory for {}", channelId);
return null;
}
AuthenticationChannel channel = null;
try {
channel = factory.createAuthChannel(channelSequence);
} catch (Exception e) {
LOGGER.error("Couldn't create channel for {}", channelId);
}
return channel;
}
use of com.evolveum.midpoint.authentication.api.AuthenticationChannel in project midpoint by Evolveum.
the class MidpointAnonymousAuthenticationFilter method createAuthentication.
protected Authentication createAuthentication(HttpServletRequest request) {
Authentication auth = createBasicAuthentication(request);
MidpointAuthentication authentication = new MidpointAuthentication(SecurityPolicyUtil.createDefaultSequence());
AuthenticationsPolicyType authenticationsPolicy;
try {
authenticationsPolicy = SecurityPolicyUtil.createDefaultAuthenticationPolicy(NO_CUSTOM_IGNORED_LOCAL_PATH, prismContext.getSchemaRegistry());
} catch (SchemaException e) {
LOGGER.error("Couldn't get default authentication policy");
throw new IllegalArgumentException("Couldn't get default authentication policy", e);
}
AuthenticationSequenceType sequence = SecurityPolicyUtil.createDefaultSequence();
AuthenticationChannel authenticationChannel = AuthSequenceUtil.buildAuthChannel(authChannelRegistry, sequence);
List<AuthModule> authModules = AuthSequenceUtil.buildModuleFilters(authRegistry, sequence, request, authenticationsPolicy.getModules(), null, new HashMap<>(), authenticationChannel);
authentication.setAuthModules(authModules);
if (authModules != null) {
ModuleAuthenticationImpl module = (ModuleAuthenticationImpl) authModules.get(0).getBaseModuleAuthentication();
module.setAuthentication(auth);
authentication.addAuthentications(module);
}
authentication.setPrincipal(auth.getPrincipal());
return authentication;
}
use of com.evolveum.midpoint.authentication.api.AuthenticationChannel in project midpoint by Evolveum.
the class HttpHeaderModuleWebSecurityConfigurer method requestHeaderAuthenticationFilter.
private RequestHeaderAuthenticationFilter requestHeaderAuthenticationFilter() {
MidpointRequestHeaderAuthenticationFilter filter = new MidpointRequestHeaderAuthenticationFilter();
filter.setPrincipalRequestHeader(getConfiguration().getPrincipalRequestHeader());
filter.setExceptionIfHeaderMissing(false);
filter.setAuthenticationManager(authenticationManager);
filter.setAuthenticationFailureHandler(new MidpointAuthenticationFailureHandler() {
@Override
protected String getPathAfterUnsuccessfulAuthentication(AuthenticationChannel authenticationChannel) {
return "/error/401";
}
});
MidPointAuthenticationSuccessHandler successHandler = new MidPointAuthenticationSuccessHandler() {
@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws ServletException, IOException {
if (getRequestCache().getRequest(request, response) == null) {
getRequestCache().saveRequest(request, response);
}
super.onAuthenticationSuccess(request, response, authentication);
}
};
filter.setAuthenticationSuccessHandler(getObjectPostProcessor().postProcess(successHandler));
filter.setSessionRegistry(getSessionRegistry());
return filter;
}
Aggregations