Search in sources :

Example 11 with HttpSessionSecurityContextRepository

use of org.springframework.security.web.context.HttpSessionSecurityContextRepository in project spring-security by spring-projects.

the class SessionManagementConfigurerServlet31Tests method login.

private void login(Authentication auth) {
    HttpSessionSecurityContextRepository repo = new HttpSessionSecurityContextRepository();
    HttpRequestResponseHolder requestResponseHolder = new HttpRequestResponseHolder(this.request, this.response);
    repo.loadContext(requestResponseHolder);
    SecurityContextImpl securityContextImpl = new SecurityContextImpl();
    securityContextImpl.setAuthentication(auth);
    repo.saveContext(securityContextImpl, requestResponseHolder.getRequest(), requestResponseHolder.getResponse());
}
Also used : HttpRequestResponseHolder(org.springframework.security.web.context.HttpRequestResponseHolder) SecurityContextImpl(org.springframework.security.core.context.SecurityContextImpl) HttpSessionSecurityContextRepository(org.springframework.security.web.context.HttpSessionSecurityContextRepository)

Aggregations

HttpSessionSecurityContextRepository (org.springframework.security.web.context.HttpSessionSecurityContextRepository)11 HttpRequestResponseHolder (org.springframework.security.web.context.HttpRequestResponseHolder)4 SecurityContextRepository (org.springframework.security.web.context.SecurityContextRepository)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 SecurityContext (org.springframework.security.core.context.SecurityContext)3 SecurityContextPersistenceFilter (org.springframework.security.web.context.SecurityContextPersistenceFilter)3 ArrayList (java.util.ArrayList)2 Filter (javax.servlet.Filter)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 AuthenticationTrustResolver (org.springframework.security.authentication.AuthenticationTrustResolver)2 SecurityContextImpl (org.springframework.security.core.context.SecurityContextImpl)2 ExceptionTranslationFilter (org.springframework.security.web.access.ExceptionTranslationFilter)2 AnonymousAuthenticationFilter (org.springframework.security.web.authentication.AnonymousAuthenticationFilter)2 SecurityContextHolderFilter (org.springframework.security.web.context.SecurityContextHolderFilter)2 RequestCache (org.springframework.security.web.savedrequest.RequestCache)2 MidpointSecurityContext (com.evolveum.midpoint.authentication.impl.MidpointSecurityContext)1 JWKSet (com.nimbusds.jose.jwk.JWKSet)1 PluginServletFilter (hudson.util.PluginServletFilter)1 Filter (jakarta.servlet.Filter)1 ServletRequest (javax.servlet.ServletRequest)1