Search in sources :

Example 1 with IGatekeeperUserProfile

use of org.finra.gatekeeper.common.authfilter.parser.IGatekeeperUserProfile in project Gatekeeper by FINRAOS.

the class GatekeeperCommonConfig method userProfile.

/* Request scoped bean to create autowireable UserProfile object */
@Bean
@Scope(value = "request", proxyMode = ScopedProxyMode.TARGET_CLASS)
public IGatekeeperUserProfile userProfile() {
    HttpServletRequest req = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
    Principal p = req.getUserPrincipal();
    return (IGatekeeperUserProfile) p;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletRequestAttributes(org.springframework.web.context.request.ServletRequestAttributes) IGatekeeperUserProfile(org.finra.gatekeeper.common.authfilter.parser.IGatekeeperUserProfile) Principal(java.security.Principal) Scope(org.springframework.context.annotation.Scope) FilterRegistrationBean(org.springframework.boot.context.embedded.FilterRegistrationBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with IGatekeeperUserProfile

use of org.finra.gatekeeper.common.authfilter.parser.IGatekeeperUserProfile in project Gatekeeper by FINRAOS.

the class UserHeaderFilter method doFilter.

@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain filterChain) throws IOException, ServletException {
    HttpServletRequest httpReq = (HttpServletRequest) req;
    Optional<IGatekeeperUserProfile> userProfile = userProfileParser.parse(httpReq);
    if (userProfile.isPresent()) {
        filterChain.doFilter(new UserProfileRequestWrapper(httpReq, userProfile.get()), res);
    } else {
        filterChain.doFilter(httpReq, res);
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) IGatekeeperUserProfile(org.finra.gatekeeper.common.authfilter.parser.IGatekeeperUserProfile)

Aggregations

HttpServletRequest (javax.servlet.http.HttpServletRequest)2 IGatekeeperUserProfile (org.finra.gatekeeper.common.authfilter.parser.IGatekeeperUserProfile)2 Principal (java.security.Principal)1 FilterRegistrationBean (org.springframework.boot.context.embedded.FilterRegistrationBean)1 Bean (org.springframework.context.annotation.Bean)1 Scope (org.springframework.context.annotation.Scope)1 ServletRequestAttributes (org.springframework.web.context.request.ServletRequestAttributes)1