Package jenkins.security
Class BasicHeaderProcessor
java.lang.Object
jenkins.security.BasicHeaderProcessor
- All Implemented Interfaces:
- jakarta.servlet.Filter,- org.kohsuke.stapler.CompatibleFilter
- Direct Known Subclasses:
- ApiTokenFilter
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
public class BasicHeaderProcessor
extends Object
implements org.kohsuke.stapler.CompatibleFilter
Takes "username:password" given in the 
Authorization HTTP header and authenticates
 the request.
 
 Implementations of BasicHeaderAuthenticator includes one that accepts the real password,
 then one that checks the user's API token. We call them all from a single Filter like this,
 as opposed to using a list of Filters, so that multiple filters don't end up trying
 to authenticate the same header differently and fail.
- Author:
- Kohsuke Kawaguchi
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected List<? extends BasicHeaderAuthenticator> all()protected booleanauthenticationIsRequired(String username) If the request is already authenticated to the same user that the Authorization header claims, for example through the HTTP session, then there's no need to re-authenticate the Authorization header, so we skip that.voiddestroy()voiddoFilter(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain) protected voidfail(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse rsp, org.springframework.security.authentication.BadCredentialsException failure) voidinit(jakarta.servlet.FilterConfig filterConfig) voidsetAuthenticationEntryPoint(org.springframework.security.web.AuthenticationEntryPoint authenticationEntryPoint) voidsetRememberMeServices(org.springframework.security.web.authentication.RememberMeServices rememberMeServices) protected voidsuccess(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse rsp, jakarta.servlet.FilterChain chain, org.springframework.security.core.Authentication auth) Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.kohsuke.stapler.CompatibleFilterdoFilter, init
- 
Constructor Details- 
BasicHeaderProcessorpublic BasicHeaderProcessor()
 
- 
- 
Method Details- 
initpublic void init(jakarta.servlet.FilterConfig filterConfig) throws jakarta.servlet.ServletException - Specified by:
- initin interface- jakarta.servlet.Filter
- Throws:
- jakarta.servlet.ServletException
 
- 
setAuthenticationEntryPointpublic void setAuthenticationEntryPoint(org.springframework.security.web.AuthenticationEntryPoint authenticationEntryPoint) 
- 
setRememberMeServicespublic void setRememberMeServices(org.springframework.security.web.authentication.RememberMeServices rememberMeServices) 
- 
doFilterpublic void doFilter(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain) throws IOException, jakarta.servlet.ServletException - Specified by:
- doFilterin interface- jakarta.servlet.Filter
- Throws:
- IOException
- jakarta.servlet.ServletException
 
- 
authenticationIsRequiredIf the request is already authenticated to the same user that the Authorization header claims, for example through the HTTP session, then there's no need to re-authenticate the Authorization header, so we skip that. This avoids stressingSecurityRealm. This method returns false if we can take this short-cut.
- 
successprotected void success(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse rsp, jakarta.servlet.FilterChain chain, org.springframework.security.core.Authentication auth) throws IOException, jakarta.servlet.ServletException - Throws:
- IOException
- jakarta.servlet.ServletException
 
- 
failprotected void fail(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse rsp, org.springframework.security.authentication.BadCredentialsException failure) throws IOException, jakarta.servlet.ServletException - Throws:
- IOException
- jakarta.servlet.ServletException
 
- 
all
- 
destroypublic void destroy()- Specified by:
- destroyin interface- jakarta.servlet.Filter
 
 
-