diff --git a/changelog/unreleased/SOLR-18108.yml b/changelog/unreleased/SOLR-18108.yml new file mode 100644 index 000000000000..e80fa568e029 --- /dev/null +++ b/changelog/unreleased/SOLR-18108.yml @@ -0,0 +1,8 @@ +# See https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc +title: Remove the deprecated getRequestUrl method from AuditEvent +type: removed # added, changed, fixed, deprecated, removed, dependency_update, security, other +authors: + - name: Eric Pugh +links: + - name: SOLR-18108 + url: https://issues.apache.org/jira/browse/SOLR-18108 diff --git a/solr/core/src/java/org/apache/solr/security/AuditEvent.java b/solr/core/src/java/org/apache/solr/security/AuditEvent.java index dc7de8b572b9..e3367e8d8ea2 100644 --- a/solr/core/src/java/org/apache/solr/security/AuditEvent.java +++ b/solr/core/src/java/org/apache/solr/security/AuditEvent.java @@ -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; @@ -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 */ @@ -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 @@ -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 @@ -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 @@ -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; } @@ -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; } @@ -349,7 +348,7 @@ public Map> 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 v = getSolrParams().get(key); @@ -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 @@ -580,11 +566,11 @@ protected String normalizeResourcePath(String resourcePath) { Arrays.asList(".*/select.*", ".*/query.*"); private static final List 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 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 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 SEARCH_PATH_PATTERNS = - SEARCH_PATH_REGEXES.stream().map(Pattern::compile).collect(Collectors.toList()); + SEARCH_PATH_REGEXES.stream().map(Pattern::compile).toList(); } diff --git a/solr/core/src/test/org/apache/solr/security/AuditLoggerPluginTest.java b/solr/core/src/test/org/apache/solr/security/AuditLoggerPluginTest.java index 32dec1774331..3e2b3165cca9 100644 --- a/solr/core/src/test/org/apache/solr/security/AuditLoggerPluginTest.java +++ b/solr/core/src/test/org/apache/solr/security/AuditLoggerPluginTest.java @@ -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