use of org.springframework.security.authentication.AnonymousAuthenticationToken in project midpoint by Evolveum.
the class MidPointAbstractAuthenticationProvider method supports.
public boolean supports(Class<?> authenticationClass, Authentication authentication) {
if (!(authentication instanceof MidpointAuthentication)) {
return supports(authenticationClass);
}
MidpointAuthentication mpAuthentication = (MidpointAuthentication) authentication;
ModuleAuthentication moduleAuthentication = getProcessingModule(mpAuthentication);
if (moduleAuthentication == null || moduleAuthentication.getAuthentication() == null) {
return false;
}
if (moduleAuthentication.getAuthentication() instanceof AnonymousAuthenticationToken) {
// hack for specific situation when user is anonymous, but accessDecisionManager resolve it
return true;
}
return supports(moduleAuthentication.getAuthentication().getClass());
}
use of org.springframework.security.authentication.AnonymousAuthenticationToken in project midpoint by Evolveum.
the class MidpointAnonymousAuthenticationFilter method createBasicAuthentication.
protected Authentication createBasicAuthentication(HttpServletRequest request) {
AnonymousAuthenticationToken auth = new AnonymousAuthenticationToken(key, getPrincipal(), getAuthorities());
auth.setDetails(authenticationDetailsSource.buildDetails(request));
return auth;
}
use of org.springframework.security.authentication.AnonymousAuthenticationToken in project midpoint by Evolveum.
the class MidpointExceptionTranslationFilter method sendStartAuthentication.
@Override
protected void sendStartAuthentication(HttpServletRequest request, HttpServletResponse response, FilterChain chain, AuthenticationException reason) throws ServletException, IOException {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (!AuthSequenceUtil.isRecordSessionLessAccessChannel(request)) {
requestCache.saveRequest(request, response);
}
LOGGER.debug("Calling Authentication entry point.");
getAuthenticationEntryPoint().commence(request, response, reason);
if (authentication instanceof MidpointAuthentication) {
MidpointAuthentication mpAuthentication = (MidpointAuthentication) authentication;
ModuleAuthenticationImpl moduleAuthentication = (ModuleAuthenticationImpl) mpAuthentication.getProcessingModuleAuthentication();
if (moduleAuthentication != null && moduleAuthentication.getAuthentication() instanceof AnonymousAuthenticationToken) {
moduleAuthentication.setAuthentication(createNewAuthentication((AnonymousAuthenticationToken) moduleAuthentication.getAuthentication()));
mpAuthentication.setPrincipal(null);
}
SecurityContextHolder.getContext().setAuthentication(mpAuthentication);
}
}
use of org.springframework.security.authentication.AnonymousAuthenticationToken in project cia by Hack23.
the class AbstractServiceFunctionalIntegrationTest method setAuthenticatedAdminuser.
/**
* Sets the authenticated adminuser.
*/
protected final void setAuthenticatedAdminuser() {
final Collection<SimpleGrantedAuthority> authorities = new ArrayList<>();
authorities.add(new SimpleGrantedAuthority(ROLE_ADMIN));
authorities.add(new SimpleGrantedAuthority(ROLE_ANONYMOUS));
SecurityContextHolder.getContext().setAuthentication(new AnonymousAuthenticationToken(KEY, PRINCIPAL, authorities));
}
use of org.springframework.security.authentication.AnonymousAuthenticationToken in project cia by Hack23.
the class AbstractServiceFunctionalIntegrationTest method setAuthenticatedAnonymousUser.
/**
* Sets the authenticated anonymous user.
*/
protected final void setAuthenticatedAnonymousUser() {
final Collection<SimpleGrantedAuthority> authorities = new ArrayList<>();
authorities.add(new SimpleGrantedAuthority(ROLE_ANONYMOUS));
SecurityContextHolder.getContext().setAuthentication(new AnonymousAuthenticationToken(KEY, PRINCIPAL, authorities));
}
Aggregations