Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 11 additions & 25 deletions solr/core/src/java/org/apache/solr/security/AuditEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import static org.apache.solr.security.AuditEvent.EventType.ANONYMOUS;
import static org.apache.solr.security.AuditEvent.EventType.ERROR;

import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.servlet.http.HttpServletRequest;
import java.lang.invoke.MethodHandles;
import java.security.Principal;
Expand Down Expand Up @@ -100,7 +99,7 @@ public enum 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.
* from EventType but can be overridden with setters afterward.
*
* @param eventType a predefined or custom EventType
*/
Expand All @@ -121,7 +120,7 @@ protected AuditEvent() {}

/**
* 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
* details such as ip, http method etc. from the request, and username if Principal exists on the
* request.
*
* @param eventType a predefined or custom EventType
Expand Down Expand Up @@ -163,7 +162,7 @@ public AuditEvent(EventType eventType, Throwable exception, HttpServletRequest h

/**
* Event based on request and AuthorizationContext. Solr will fill in details such as collections,
* ip, http method etc from the context.
* ip, http method etc. from the context.
*
* @param eventType a predefined or custom EventType
* @param httpRequest the request to initialize from
Expand Down Expand Up @@ -192,7 +191,7 @@ public AuditEvent(

/**
* 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.
* collections, ip, http method etc. from the HTTP request and context.
*
* @param eventType a predefined or custom EventType
* @param httpRequest the request to initialize from
Expand Down Expand Up @@ -248,7 +247,7 @@ static RequestType convertType(AuthorizationContext.RequestType ctxReqType) {
}
}

/** The human readable message about this event */
/** The human-readable message about this event */
public String getMessage() {
return message;
}
Expand All @@ -267,7 +266,7 @@ public Date getDate() {
return date;
}

/** Username of logged in user, or null if no authenticated user */
/** Username of logged-in user, or null if no authenticated user */
public String getUsername() {
return username;
}
Expand Down Expand Up @@ -349,7 +348,7 @@ public Map<String, List<String>> getSolrParams() {
* Gets first value of a certain Solr request parameter
*
* @param key name of request parameter to retrieve
* @return String value of the first value, regardless of number of valies
* @return String value of the first value, regardless of number of values
*/
public String getSolrParamAsString(String key) {
List<String> v = getSolrParams().get(key);
Expand Down Expand Up @@ -393,19 +392,6 @@ public Throwable getException() {
return exception;
}

/**
* Get baseUrl as StringBuffer for back compat with previous version
*
* @deprecated Please use {@link #getBaseUrl()} instead
* @return StringBuffer of the base url without query part
*/
@Deprecated
@JsonIgnore
@SuppressWarnings("JdkObsolete")
public StringBuffer getRequestUrl() {
return new StringBuffer(baseUrl);
}

/**
* Full URL of the original request. This is {@link #baseUrl} + "?" + {@link #httpQueryString}.
* Returns null if not set
Expand Down Expand Up @@ -580,11 +566,11 @@ protected String normalizeResourcePath(String resourcePath) {
Arrays.asList(".*/select.*", ".*/query.*");

private static final List<Pattern> ADMIN_PATH_PATTERNS =
ADMIN_PATH_REGEXES.stream().map(Pattern::compile).collect(Collectors.toList());
ADMIN_PATH_REGEXES.stream().map(Pattern::compile).toList();
private static final List<Pattern> STREAMING_PATH_PATTERNS =
STREAMING_PATH_REGEXES.stream().map(Pattern::compile).collect(Collectors.toList());
STREAMING_PATH_REGEXES.stream().map(Pattern::compile).toList();
private static final List<Pattern> INDEXING_PATH_PATTERNS =
INDEXING_PATH_REGEXES.stream().map(Pattern::compile).collect(Collectors.toList());
INDEXING_PATH_REGEXES.stream().map(Pattern::compile).toList();
private static final List<Pattern> SEARCH_PATH_PATTERNS =
SEARCH_PATH_REGEXES.stream().map(Pattern::compile).collect(Collectors.toList());
SEARCH_PATH_REGEXES.stream().map(Pattern::compile).toList();
}
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,6 @@ public void jsonEventFormatter() {
@Test
public void getBaseUrl() {
assertEquals("http://myserver/mypath", EVENT_WITH_URL.getBaseUrl());
// Deprecated
assertEquals("http://myserver/mypath", EVENT_WITH_URL.getRequestUrl().toString());
}

@Test
Expand Down
Loading