Package org.apache.solr.security
Class AuditEvent
java.lang.Object
org.apache.solr.security.AuditEvent
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 Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic enumstatic enum -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAuditEvent(AuditEvent.EventType eventType) Empty event, must be filled by user using setters.AuditEvent(AuditEvent.EventType eventType, jakarta.servlet.http.HttpServletRequest httpRequest) AuditEvent(AuditEvent.EventType eventType, jakarta.servlet.http.HttpServletRequest httpRequest, AuthorizationContext authorizationContext) Event based on request and AuthorizationContext.AuditEvent(AuditEvent.EventType eventType, jakarta.servlet.http.HttpServletRequest httpRequest, AuthorizationContext authorizationContext, double qTime, Throwable exception) Event to log completed requests.AuditEvent(AuditEvent.EventType eventType, Throwable exception, jakarta.servlet.http.HttpServletRequest httpRequest) Event based on an HttpServletRequest, typically used during authentication. -
Method Summary
Modifier and TypeMethodDescriptionThe authorization response object from authorization plugin, or null authz has not happenedFirst part of URL of the request, but not including request parameters, or null if not setIP address of the client doing the requestList of collection names involved in requestA general purpose context map with potential extra information about the eventgetDate()Date that the event happenedEventType tells the outcome of the event such as REJECTED, UNAUTHORIZED or ERRORIn case of ERROR event, find the exception causing the errorMap of all HTTP request headers belonging to the requestThe HTTP method.Query part of URL or null if query partgetLevel()Level of this event.The human readable message about this eventNode name of Solr node, on the internal format host:port_context, e.g.doublegetQTime()Request time in milliseconds for completed requestsDetermines the type of request.Deprecated.Identifies the resource being operated on.Session identifierHost name of the Solr node logging the eventIP address of the Solr node logging the eventGets first value of a certain Solr request parameterMap of all Solr request parameters attached to the request.intPort number of the Solr node logging the eventintHTTP status code of event, i.e.getUrl()Full URL of the original request.Username of logged in user, or null if no authenticated userprotected StringnormalizeResourcePath(String resourcePath) setAutResponse(AuthorizationResponse autResponse) setBaseUrl(String baseUrl) setClientIp(String clientIp) setCollections(List<String> collections) setContext(Map<String, Object> context) setContextEntry(String key, Object value) setException(Throwable exception) setHeaders(Map<String, String> headers) setHttpMethod(String httpMethod) setHttpQueryString(String httpQueryString) setLevel(AuditEvent.Level level) setMessage(String message) setQTime(double qTime) setRequestType(AuditEvent.RequestType requestType) setResource(String resource) setSession(String session) setSolrHost(String solrHost) setSolrParams(Map<String, List<String>> solrParams) setSolrPort(int solrPort) setStatus(int status) setUsername(String username)
-
Constructor Details
-
AuditEvent
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
-
AuditEvent
public AuditEvent(AuditEvent.EventType eventType, jakarta.servlet.http.HttpServletRequest httpRequest) -
AuditEvent
protected AuditEvent() -
AuditEvent
public AuditEvent(AuditEvent.EventType eventType, Throwable exception, jakarta.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 EventTypehttpRequest- the request to initialize from
-
AuditEvent
public AuditEvent(AuditEvent.EventType eventType, jakarta.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 EventTypehttpRequest- the request to initialize fromauthorizationContext- the context to initialize from
-
AuditEvent
public AuditEvent(AuditEvent.EventType eventType, jakarta.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 EventTypehttpRequest- the request to initialize fromauthorizationContext- the context to initialize fromqTime- query timeexception- exception from query response, or null if OK
-
-
Method Details
-
getMessage
The human readable message about this event -
getLevel
Level of this event. Can be INFO, WARN or ERROR- Returns:
AuditEvent.Levelenum
-
getDate
Date that the event happened -
getUsername
Username of logged in user, or null if no authenticated user -
getSession
Session identifier -
getClientIp
IP address of the client doing the request -
getContext
A general purpose context map with potential extra information about the event -
getCollections
List of collection names involved in request -
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 -
getHttpMethod
The HTTP method. E.g. GET, POST, PUT -
getHttpQueryString
Query part of URL or null if query part -
getEventType
EventType tells the outcome of the event such as REJECTED, UNAUTHORIZED or ERROR- Returns:
AuditEvent.EventTypeenum
-
getSolrHost
Host name of the Solr node logging the event -
getSolrIp
IP address of the Solr node logging the event -
getSolrPort
public int getSolrPort()Port number of the Solr node logging the event -
getHeaders
Map of all HTTP request headers belonging to the request -
getSolrParams
Map of all Solr request parameters attached to the request. Pulled from url -
getSolrParamAsString
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
-
getAutResponse
The authorization response object from authorization plugin, or null authz has not happened -
getNodeName
Node name of Solr node, on the internal format host:port_context, e.g. 10.0.0.1:8983_solr -
getRequestType
Determines the type of request. Can be ADMIN, SEARCH, UPDATE, STREAMING, UNKNOWN- Returns:
AuditEvent.RequestTypeenum
-
getStatus
public int getStatus()HTTP status code of event, i.e. 200 = OK, 401 = unauthorized -
getQTime
public double getQTime()Request time in milliseconds for completed requests -
getException
In case of ERROR event, find the exception causing the error -
getRequestUrl
Deprecated.Please usegetBaseUrl()insteadGet baseUrl as StringBuffer for back compat with previous version- Returns:
- StringBuffer of the base url without query part
-
getUrl
Full URL of the original request. This isbaseUrl+ "?" +httpQueryString. Returns null if not set -
getBaseUrl
First part of URL of the request, but not including request parameters, or null if not set -
setBaseUrl
-
setSession
-
setClientIp
-
setContext
-
setContextEntry
-
setMessage
-
setLevel
-
setDate
-
setUsername
-
setCollections
-
setResource
-
setHttpMethod
-
setHttpQueryString
-
setSolrHost
-
setSolrPort
-
setSolrIp
-
setHeaders
-
setSolrParams
-
setAutResponse
-
setRequestType
-
setQTime
-
setStatus
-
setException
-
normalizeResourcePath
-
getBaseUrl()instead