Package org.apache.solr.security
Class AuditEvent
- java.lang.Object
- 
- org.apache.solr.security.AuditEvent
 
- 
 public class AuditEvent extends Object Audit event that takes request and auth context as input to be able to audit log custom things. This interface may change in next release and is marked experimental- Since:
- 8.1.0
- WARNING: This API is experimental and might change in incompatible ways in the next release.
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classAuditEvent.EventTypestatic classAuditEvent.Levelstatic classAuditEvent.RequestType
 - 
Constructor SummaryConstructors Modifier Constructor Description protectedAuditEvent()AuditEvent(AuditEvent.EventType eventType)Empty event, must be filled by user using setters.AuditEvent(AuditEvent.EventType eventType, Throwable exception, javax.servlet.http.HttpServletRequest httpRequest)Event based on an HttpServletRequest, typically used during authentication.AuditEvent(AuditEvent.EventType eventType, javax.servlet.http.HttpServletRequest httpRequest)AuditEvent(AuditEvent.EventType eventType, javax.servlet.http.HttpServletRequest httpRequest, AuthorizationContext authorizationContext)Event based on request and AuthorizationContext.AuditEvent(AuditEvent.EventType eventType, javax.servlet.http.HttpServletRequest httpRequest, AuthorizationContext authorizationContext, double qTime, Throwable exception)Event to log completed requests.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description AuthorizationResponsegetAutResponse()The authorization response object from authorization plugin, or null authz has not happenedStringgetBaseUrl()First part of URL of the request, but not including request parameters, or null if not setStringgetClientIp()IP address of the client doing the requestList<String>getCollections()List of collection names involved in requestMap<String,Object>getContext()A general purpose context map with potential extra information about the eventDategetDate()Date that the event happenedAuditEvent.EventTypegetEventType()EventType tells the outcome of the event such as REJECTED, UNAUTHORIZED or ERRORThrowablegetException()In case of ERROR event, find the exception causing the errorMap<String,String>getHeaders()Map of all HTTP request headers belonging to the requestStringgetHttpMethod()The HTTP method.StringgetHttpQueryString()Query part of URL or null if query partAuditEvent.LevelgetLevel()Level of this event.StringgetMessage()The human readable message about this eventStringgetNodeName()Node name of Solr node, on the internal format host:port_context, e.g.doublegetQTime()Request time in milliseconds for completed requestsAuditEvent.RequestTypegetRequestType()Determines the type of request.StringBuffergetRequestUrl()Deprecated.Please usegetBaseUrl()insteadStringgetResource()Identifies the resource being operated on.StringgetSession()Session identifierStringgetSolrHost()Host name of the Solr node logging the eventStringgetSolrIp()IP address of the Solr node logging the eventStringgetSolrParamAsString(String key)Gets first value of a certain Solr request parameterMap<String,List<String>>getSolrParams()Map of all Solr request parameters attached to the request.intgetSolrPort()Port number of the Solr node logging the eventintgetStatus()HTTP status code of event, i.e.StringgetUrl()Full URL of the original request.StringgetUsername()Username of logged in user, or null if no authenticated userprotected StringnormalizeResourcePath(String resourcePath)AuditEventsetAutResponse(AuthorizationResponse autResponse)AuditEventsetBaseUrl(String baseUrl)AuditEventsetClientIp(String clientIp)AuditEventsetCollections(List<String> collections)AuditEventsetContext(Map<String,Object> context)AuditEventsetContextEntry(String key, Object value)AuditEventsetDate(Date date)AuditEventsetException(Throwable exception)AuditEventsetHeaders(Map<String,String> headers)AuditEventsetHttpMethod(String httpMethod)AuditEventsetHttpQueryString(String httpQueryString)AuditEventsetLevel(AuditEvent.Level level)AuditEventsetMessage(String message)AuditEventsetQTime(double qTime)AuditEventsetRequestType(AuditEvent.RequestType requestType)AuditEventsetResource(String resource)AuditEventsetSession(String session)AuditEventsetSolrHost(String solrHost)AuditEventsetSolrIp(String solrIp)AuditEventsetSolrParams(Map<String,List<String>> solrParams)AuditEventsetSolrPort(int solrPort)AuditEventsetStatus(int status)AuditEventsetUsername(String username)
 
- 
- 
- 
Constructor Detail- 
AuditEventpublic AuditEvent(AuditEvent.EventType eventType) Empty event, must be filled by user using setters. Message and Loglevel will be initialized from EventType but can be overridden with setters afterwards.- Parameters:
- eventType- a predefined or custom EventType
 
 - 
AuditEventpublic AuditEvent(AuditEvent.EventType eventType, javax.servlet.http.HttpServletRequest httpRequest) 
 - 
AuditEventprotected AuditEvent() 
 - 
AuditEventpublic AuditEvent(AuditEvent.EventType eventType, Throwable exception, javax.servlet.http.HttpServletRequest httpRequest) Event based on an HttpServletRequest, typically used during authentication. Solr will fill in details such as ip, http method etc from the request, and username if Principal exists on the request.- Parameters:
- eventType- a predefined or custom EventType
- httpRequest- the request to initialize from
 
 - 
AuditEventpublic AuditEvent(AuditEvent.EventType eventType, javax.servlet.http.HttpServletRequest httpRequest, AuthorizationContext authorizationContext) Event based on request and AuthorizationContext. Solr will fill in details such as collections, ip, http method etc from the context.- Parameters:
- eventType- a predefined or custom EventType
- httpRequest- the request to initialize from
- authorizationContext- the context to initialize from
 
 - 
AuditEventpublic AuditEvent(AuditEvent.EventType eventType, javax.servlet.http.HttpServletRequest httpRequest, AuthorizationContext authorizationContext, double qTime, Throwable exception) Event to log completed requests. Takes time and status. Solr will fill in details such as collections, ip, http method etc from the HTTP request and context.- Parameters:
- eventType- a predefined or custom EventType
- httpRequest- the request to initialize from
- authorizationContext- the context to initialize from
- qTime- query time
- exception- exception from query response, or null if OK
 
 
- 
 - 
Method Detail- 
getMessagepublic String getMessage() The human readable message about this event
 - 
getLevelpublic AuditEvent.Level getLevel() Level of this event. Can be INFO, WARN or ERROR- Returns:
- AuditEvent.Levelenum
 
 - 
getDatepublic Date getDate() Date that the event happened
 - 
getUsernamepublic String getUsername() Username of logged in user, or null if no authenticated user
 - 
getSessionpublic String getSession() Session identifier
 - 
getClientIppublic String getClientIp() IP address of the client doing the request
 - 
getContextpublic Map<String,Object> getContext() A general purpose context map with potential extra information about the event
 - 
getResourcepublic String getResource() Identifies the resource being operated on. This is not the same as URL path. For queries the resource is relative to collection name, e.g. /select or /update. For other events the resource may be /api/node/health or /admin/collection
 - 
getHttpMethodpublic String getHttpMethod() The HTTP method. E.g. GET, POST, PUT
 - 
getHttpQueryStringpublic String getHttpQueryString() Query part of URL or null if query part
 - 
getEventTypepublic AuditEvent.EventType getEventType() EventType tells the outcome of the event such as REJECTED, UNAUTHORIZED or ERROR- Returns:
- AuditEvent.EventTypeenum
 
 - 
getSolrHostpublic String getSolrHost() Host name of the Solr node logging the event
 - 
getSolrIppublic String getSolrIp() IP address of the Solr node logging the event
 - 
getSolrPortpublic int getSolrPort() Port number of the Solr node logging the event
 - 
getHeaderspublic Map<String,String> getHeaders() Map of all HTTP request headers belonging to the request
 - 
getSolrParamspublic Map<String,List<String>> getSolrParams() Map of all Solr request parameters attached to the request. Pulled from url
 - 
getSolrParamAsStringpublic String getSolrParamAsString(String key) Gets first value of a certain Solr request parameter- Parameters:
- key- name of request parameter to retrieve
- Returns:
- String value of the first value, regardless of number of valies
 
 - 
getAutResponsepublic AuthorizationResponse getAutResponse() The authorization response object from authorization plugin, or null authz has not happened
 - 
getNodeNamepublic String getNodeName() Node name of Solr node, on the internal format host:port_context, e.g. 10.0.0.1:8983_solr
 - 
getRequestTypepublic AuditEvent.RequestType getRequestType() Determines the type of request. Can be ADMIN, SEARCH, UPDATE, STREAMING, UNKNOWN- Returns:
- AuditEvent.RequestTypeenum
 
 - 
getStatuspublic int getStatus() HTTP status code of event, i.e. 200 = OK, 401 = unauthorized
 - 
getQTimepublic double getQTime() Request time in milliseconds for completed requests
 - 
getExceptionpublic Throwable getException() In case of ERROR event, find the exception causing the error
 - 
getRequestUrl@Deprecated public StringBuffer getRequestUrl() Deprecated.Please usegetBaseUrl()insteadGet baseUrl as StringBuffer for back compat with previous version- Returns:
- StringBuffer of the base url without query part
 
 - 
getUrlpublic String getUrl() Full URL of the original request. This isbaseUrl+ "?" +httpQueryString. Returns null if not set
 - 
getBaseUrlpublic String getBaseUrl() First part of URL of the request, but not including request parameters, or null if not set
 - 
setBaseUrlpublic AuditEvent setBaseUrl(String baseUrl) 
 - 
setSessionpublic AuditEvent setSession(String session) 
 - 
setClientIppublic AuditEvent setClientIp(String clientIp) 
 - 
setContextpublic AuditEvent setContext(Map<String,Object> context) 
 - 
setContextEntrypublic AuditEvent setContextEntry(String key, Object value) 
 - 
setMessagepublic AuditEvent setMessage(String message) 
 - 
setLevelpublic AuditEvent setLevel(AuditEvent.Level level) 
 - 
setDatepublic AuditEvent setDate(Date date) 
 - 
setUsernamepublic AuditEvent setUsername(String username) 
 - 
setCollectionspublic AuditEvent setCollections(List<String> collections) 
 - 
setResourcepublic AuditEvent setResource(String resource) 
 - 
setHttpMethodpublic AuditEvent setHttpMethod(String httpMethod) 
 - 
setHttpQueryStringpublic AuditEvent setHttpQueryString(String httpQueryString) 
 - 
setSolrHostpublic AuditEvent setSolrHost(String solrHost) 
 - 
setSolrPortpublic AuditEvent setSolrPort(int solrPort) 
 - 
setSolrIppublic AuditEvent setSolrIp(String solrIp) 
 - 
setHeaderspublic AuditEvent setHeaders(Map<String,String> headers) 
 - 
setSolrParamspublic AuditEvent setSolrParams(Map<String,List<String>> solrParams) 
 - 
setAutResponsepublic AuditEvent setAutResponse(AuthorizationResponse autResponse) 
 - 
setRequestTypepublic AuditEvent setRequestType(AuditEvent.RequestType requestType) 
 - 
setQTimepublic AuditEvent setQTime(double qTime) 
 - 
setStatuspublic AuditEvent setStatus(int status) 
 - 
setExceptionpublic AuditEvent setException(Throwable exception) 
 
- 
 
-