Package org.apache.solr.security
Class AuthenticationPlugin
- java.lang.Object
- 
- org.apache.solr.security.AuthenticationPlugin
 
- 
- All Implemented Interfaces:
- AutoCloseable,- SolrInfoBean,- SolrMetricProducer
 - Direct Known Subclasses:
- BasicAuthPlugin,- CertAuthPlugin,- MultiAuthPlugin,- PKIAuthenticationPlugin
 
 public abstract class AuthenticationPlugin extends Object implements SolrInfoBean - WARNING: This API is experimental and might change in incompatible ways in the next release.
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface org.apache.solr.core.SolrInfoBeanSolrInfoBean.Category, SolrInfoBean.Group
 
- 
 - 
Field SummaryFields Modifier and Type Field Description static StringAUTHENTICATION_PLUGIN_PROPstatic StringHTTP_HEADER_X_SOLR_AUTHDATAprotected com.codahale.metrics.CounternumAuthenticatedprotected com.codahale.metrics.MeternumErrorsprotected com.codahale.metrics.CounternumMissingCredentialsprotected com.codahale.metrics.CounternumPassThroughprotected com.codahale.metrics.CounternumWrongCredentialsprotected com.codahale.metrics.Counterrequestsprotected com.codahale.metrics.TimerrequestTimesprotected SolrMetricsContextsolrMetricsContextprotected com.codahale.metrics.CountertotalTime
 - 
Constructor SummaryConstructors Constructor Description AuthenticationPlugin()
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanauthenticate(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.FilterChain filterChain)This method is called by SolrDispatchFilter in order to initiate authentication.voidcloseRequest()Cleanup any per request dataabstract booleandoAuthenticate(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.FilterChain filterChain)This method attempts to authenticate the request.SolrInfoBean.CategorygetCategory()Category of this componentStringgetDescription()Simple one or two line descriptionStringgetName()Simple common usage name, e.g.SolrMetricsContextgetSolrMetricsContext()Implementations should return the context used inSolrMetricProducer.initializeMetrics(SolrMetricsContext, String)to ensure proper cleanup of metrics at the end of the life-cycle of this component.abstract voidinit(Map<String,Object> pluginConfig)This is called upon loading up of a plugin, used for setting it up.voidinitializeMetrics(SolrMetricsContext parentContext, String scope)Initialize metrics specific to this producer.protected booleaninterceptInternodeRequest(org.apache.http.HttpRequest httpRequest, org.apache.http.protocol.HttpContext httpContext)Override this method to intercept internode requests.protected booleaninterceptInternodeRequest(org.eclipse.jetty.client.api.Request request)Override this method to intercept internode requests.protected javax.servlet.http.HttpServletRequestwrapWithPrincipal(javax.servlet.http.HttpServletRequest request, Principal principal)protected javax.servlet.http.HttpServletRequestwrapWithPrincipal(javax.servlet.http.HttpServletRequest request, Principal principal, String username)- 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.apache.solr.metrics.SolrMetricProducerclose
 
- 
 
- 
- 
- 
Field Detail- 
AUTHENTICATION_PLUGIN_PROPpublic static final String AUTHENTICATION_PLUGIN_PROP - See Also:
- Constant Field Values
 
 - 
HTTP_HEADER_X_SOLR_AUTHDATApublic static final String HTTP_HEADER_X_SOLR_AUTHDATA - See Also:
- Constant Field Values
 
 - 
solrMetricsContextprotected SolrMetricsContext solrMetricsContext 
 - 
numErrorsprotected com.codahale.metrics.Meter numErrors 
 - 
requestsprotected com.codahale.metrics.Counter requests 
 - 
requestTimesprotected com.codahale.metrics.Timer requestTimes 
 - 
totalTimeprotected com.codahale.metrics.Counter totalTime 
 - 
numAuthenticatedprotected com.codahale.metrics.Counter numAuthenticated 
 - 
numPassThroughprotected com.codahale.metrics.Counter numPassThrough 
 - 
numWrongCredentialsprotected com.codahale.metrics.Counter numWrongCredentials 
 - 
numMissingCredentialsprotected com.codahale.metrics.Counter numMissingCredentials 
 
- 
 - 
Method Detail- 
initpublic abstract void init(Map<String,Object> pluginConfig) This is called upon loading up of a plugin, used for setting it up.- Parameters:
- pluginConfig- Config parameters, possibly from a ZK source
 
 - 
doAuthenticatepublic abstract boolean doAuthenticate(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.FilterChain filterChain) throws ExceptionThis method attempts to authenticate the request. Upon a successful authentication, this must call the next filter in the filter chain and set the user principal of the request, or else, upon an error or an authentication failure, throw an exception.- Parameters:
- request- the http request
- response- the http response
- filterChain- the servlet filter chain
- Returns:
- false if the request not be processed by Solr (not continue), i.e. the response and status code have already been sent.
- Throws:
- Exception- any exception thrown during the authentication, e.g. PrivilegedActionException
 
 - 
authenticatepublic final boolean authenticate(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.FilterChain filterChain) throws ExceptionThis method is called by SolrDispatchFilter in order to initiate authentication. It does some standard metrics counting.- Throws:
- Exception
 
 - 
wrapWithPrincipalprotected javax.servlet.http.HttpServletRequest wrapWithPrincipal(javax.servlet.http.HttpServletRequest request, Principal principal)
 - 
wrapWithPrincipalprotected javax.servlet.http.HttpServletRequest wrapWithPrincipal(javax.servlet.http.HttpServletRequest request, Principal principal, String username)
 - 
interceptInternodeRequestprotected boolean interceptInternodeRequest(org.apache.http.HttpRequest httpRequest, org.apache.http.protocol.HttpContext httpContext)Override this method to intercept internode requests. This allows your authentication plugin to decide on per-request basis whether it should handle inter-node requests or delegate toPKIAuthenticationPlugin. Return true to indicate that your plugin did handle the request, or false to signal that PKI plugin should handle it. This method will be called byPKIAuthenticationPlugin's interceptor.If not overridden, this method will return true for plugins implementing HttpClientBuilderPlugin. This method can be overridden by subclasses e.g. to set HTTP headers, even if you don't use a clientBuilder.- Parameters:
- httpRequest- the httpRequest that is about to be sent to another internal Solr node
- httpContext- the context of that request.
- Returns:
- true if this plugin handled authentication for the request, else false
 
 - 
interceptInternodeRequestprotected boolean interceptInternodeRequest(org.eclipse.jetty.client.api.Request request) Override this method to intercept internode requests. This allows your authentication plugin to decide on per-request basis whether it should handle inter-node requests or delegate toPKIAuthenticationPlugin. Return true to indicate that your plugin did handle the request, or false to signal that PKI plugin should handle it. This method will be called byPKIAuthenticationPlugin's interceptor.If not overridden, this method will return true for plugins implementing HttpClientBuilderPlugin. This method can be overridden by subclasses e.g. to set HTTP headers, even if you don't use a clientBuilder.- Parameters:
- request- the httpRequest that is about to be sent to another internal Solr node
- Returns:
- true if this plugin handled authentication for the request, else false
 
 - 
closeRequestpublic void closeRequest() Cleanup any per request data
 - 
getSolrMetricsContextpublic SolrMetricsContext getSolrMetricsContext() Description copied from interface:SolrMetricProducerImplementations should return the context used inSolrMetricProducer.initializeMetrics(SolrMetricsContext, String)to ensure proper cleanup of metrics at the end of the life-cycle of this component. This should be the child context if one was created, or null if the parent context was used.- Specified by:
- getSolrMetricsContextin interface- SolrMetricProducer
 
 - 
initializeMetricspublic void initializeMetrics(SolrMetricsContext parentContext, String scope) Description copied from interface:SolrMetricProducerInitialize metrics specific to this producer.- Specified by:
- initializeMetricsin interface- SolrMetricProducer
- Parameters:
- parentContext- parent metrics context. If this component has the same life-cycle as the parent it can simply use the parent context, otherwise it should obtain a child context using- SolrMetricsContext.getChildContext(Object)passing- thisas the child object.
- scope- component scope
 
 - 
getNamepublic String getName() Description copied from interface:SolrInfoBeanSimple common usage name, e.g. BasicQueryHandler, or fully qualified class name.- Specified by:
- getNamein interface- SolrInfoBean
 
 - 
getDescriptionpublic String getDescription() Description copied from interface:SolrInfoBeanSimple one or two line description- Specified by:
- getDescriptionin interface- SolrInfoBean
 
 - 
getCategorypublic SolrInfoBean.Category getCategory() Description copied from interface:SolrInfoBeanCategory of this component- Specified by:
- getCategoryin interface- SolrInfoBean
 
 
- 
 
-