use of com.evolveum.midpoint.authentication.api.config.ModuleAuthentication in project midpoint by Evolveum.
the class AuthSequenceUtil method isLoginPageForActualAuthModule.
public static boolean isLoginPageForActualAuthModule(String url) {
ModuleAuthentication authModule = AuthUtil.getProcessingModule();
String moduleType = authModule.getNameOfModuleType();
return DescriptorLoaderImpl.getPageUrlsByAuthName(moduleType).contains(url);
}
use of com.evolveum.midpoint.authentication.api.config.ModuleAuthentication in project midpoint by Evolveum.
the class RemoteModuleWebSecurityConfigurer method createAnonymousFilter.
@Override
protected AnonymousAuthenticationFilter createAnonymousFilter() {
AnonymousAuthenticationFilter filter = new MidpointAnonymousAuthenticationFilter(authRegistry, authChannelRegistry, PrismContext.get(), UUID.randomUUID().toString(), "anonymousUser", AuthorityUtils.createAuthorityList("ROLE_ANONYMOUS")) {
@Override
protected void processAuthentication(ServletRequest req) {
if (SecurityContextHolder.getContext().getAuthentication() instanceof MidpointAuthentication) {
MidpointAuthentication mpAuthentication = (MidpointAuthentication) SecurityContextHolder.getContext().getAuthentication();
ModuleAuthenticationImpl moduleAuthentication = (ModuleAuthenticationImpl) mpAuthentication.getProcessingModuleAuthentication();
if (moduleAuthentication != null && (moduleAuthentication.getAuthentication() == null || getAuthTokenClass().isAssignableFrom(moduleAuthentication.getAuthentication().getClass()))) {
Authentication authentication = createBasicAuthentication((HttpServletRequest) req);
moduleAuthentication.setAuthentication(authentication);
mpAuthentication.setPrincipal(authentication.getPrincipal());
}
}
}
};
filter.setAuthenticationDetailsSource(new RemoteAuthenticationDetailsSource(getAuthTokenClass()));
return filter;
}
use of com.evolveum.midpoint.authentication.api.config.ModuleAuthentication in project midpoint by Evolveum.
the class AuthSequenceUtil method resolveProxyUserOidHeader.
public static void resolveProxyUserOidHeader(HttpServletRequest request) {
String proxyUserOid = request.getHeader(PROXY_USER_OID_HEADER);
Authentication actualAuth = SecurityContextHolder.getContext().getAuthentication();
if (proxyUserOid != null && actualAuth instanceof MidpointAuthentication) {
ModuleAuthentication moduleAuth = ((MidpointAuthentication) actualAuth).getProcessingModuleAuthentication();
if (moduleAuth instanceof HttpModuleAuthentication) {
((HttpModuleAuthentication) moduleAuth).setProxyUserOid(proxyUserOid);
}
}
}
use of com.evolveum.midpoint.authentication.api.config.ModuleAuthentication in project midpoint by Evolveum.
the class Saml2ModuleAuthenticationImpl method clone.
@Override
public ModuleAuthenticationImpl clone() {
Saml2ModuleAuthenticationImpl module = new Saml2ModuleAuthenticationImpl();
module.setAdditionalConfiguration(this.getAdditionalConfiguration());
module.setProviders(this.getProviders());
Authentication actualAuth = SecurityContextHolder.getContext().getAuthentication();
Authentication newAuthentication = this.getAuthentication();
if (actualAuth instanceof MidpointAuthentication && ((MidpointAuthentication) actualAuth).getAuthentications() != null && !((MidpointAuthentication) actualAuth).getAuthentications().isEmpty()) {
ModuleAuthentication actualModule = ((MidpointAuthentication) actualAuth).getAuthentications().get(0);
if (actualModule instanceof Saml2ModuleAuthenticationImpl && actualModule.getAuthentication() instanceof Saml2AuthenticationToken) {
newAuthentication = actualModule.getAuthentication();
}
}
module.setAuthentication(newAuthentication);
super.clone(module);
return module;
}
use of com.evolveum.midpoint.authentication.api.config.ModuleAuthentication in project midpoint by Evolveum.
the class MidpointSaml2LogoutRequestResolver method resolve.
@Override
public Saml2LogoutRequest resolve(HttpServletRequest httpServletRequest, Authentication authentication) {
Saml2AuthenticationToken token = null;
if (authentication instanceof MidpointAuthentication) {
ModuleAuthentication authModule = ((MidpointAuthentication) authentication).getProcessingModuleAuthentication();
if (authModule instanceof Saml2ModuleAuthenticationImpl) {
if (authModule.getAuthentication() instanceof Saml2AuthenticationToken) {
token = (Saml2AuthenticationToken) authModule.getAuthentication();
} else if ((authModule.getAuthentication() instanceof PreAuthenticatedAuthenticationToken || authModule.getAuthentication() instanceof AnonymousAuthenticationToken) && authModule.getAuthentication().getDetails() instanceof Saml2AuthenticationToken) {
token = (Saml2AuthenticationToken) authModule.getAuthentication().getDetails();
}
}
} else if (authentication instanceof AnonymousAuthenticationToken && authentication.getDetails() instanceof Saml2AuthenticationToken) {
token = (Saml2AuthenticationToken) authentication.getDetails();
}
if (token != null) {
AuthenticatedPrincipal principal = token.getDetails() instanceof AuthenticatedPrincipal ? (AuthenticatedPrincipal) token.getDetails() : null;
if (!(principal instanceof Saml2AuthenticatedPrincipal)) {
String name = token.getRelyingPartyRegistration().getEntityId();
String relyingPartyRegistrationId = token.getRelyingPartyRegistration().getRegistrationId();
principal = new Saml2AuthenticatedPrincipal() {
@Override
public String getName() {
return name;
}
@Override
public String getRelyingPartyRegistrationId() {
return relyingPartyRegistrationId;
}
};
}
return resolver.resolve(httpServletRequest, new Saml2Authentication(principal, token.getSaml2Response(), null));
}
return resolver.resolve(httpServletRequest, authentication);
}
Aggregations