Skip to content

Commit

Permalink
Spotless
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Nied <[email protected]>
  • Loading branch information
peternied committed Oct 3, 2023
1 parent 2aad250 commit 9a915e7
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
import org.opensearch.security.auth.HTTPAuthenticator;
import org.opensearch.security.filter.SecurityRequest;
import org.opensearch.security.filter.SecurityRequestChannel;
import org.opensearch.security.filter.SecurityRequestFactory.SecurityRestRequest;
import org.opensearch.security.filter.SecurityRequestFactory.SecurityRestRequestChannel;
import org.opensearch.security.filter.SecurityRequetChannelUnsupported;
import org.opensearch.security.support.ConfigConstants;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import org.opensearch.security.auditlog.config.AuditConfig;
import org.opensearch.security.dlic.rest.support.Utils;
import org.opensearch.security.filter.SecurityRequestChannel;
import org.opensearch.security.filter.SecurityRequestFactory.SecurityRestRequest;
import org.opensearch.security.filter.SecurityRequestFactory.SecurityRestRequestChannel;
import org.opensearch.security.securityconf.impl.CType;
import org.opensearch.security.support.WildcardMatcher;
Expand Down Expand Up @@ -387,7 +386,7 @@ void addRestRequestInfo(final SecurityRequestChannel request, final AuditConfig.
return;
}

final SecurityRestRequestChannel securityRestRequest = (SecurityRestRequestChannel)request;
final SecurityRestRequestChannel securityRestRequest = (SecurityRestRequestChannel) request;
final RestRequest restRequest = securityRestRequest.breakEncapsulationForRequest();

if (!(restRequest.hasContentOrSourceParam())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ public interface HTTPAuthenticator {
* If the authentication flow needs another roundtrip with the request originator do not mark it as complete.
* @throws OpenSearchSecurityException
*/
AuthCredentials extractCredentials(final SecurityRequest request, final ThreadContext context)
throws OpenSearchSecurityException;
AuthCredentials extractCredentials(final SecurityRequest request, final ThreadContext context) throws OpenSearchSecurityException;

/**
* If the {@code extractCredentials()} call was not successful or the authentication flow needs another roundtrip this method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,10 @@ private String checkAdminCertBasedAccessPermissions(RestRequest request) throws
}

// Certificate based access, Check if we have an admin TLS certificate
final SecurityRequestChannel securityRequest = SecurityRequestFactory.from(request, /* OK to be null so long as a response isn't sent */ null);
final SecurityRequestChannel securityRequest = SecurityRequestFactory.from(
request,
/* OK to be null so long as a response isn't sent */ null
);
SSLRequestHelper.SSLInfo sslInfo = SSLRequestHelper.getSSLInfo(settings, configPath, securityRequest, principalExtractor);

if (sslInfo == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ default public String header(final String headerName) {
}

public Map<String, String> params();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@ public static SecurityRequest from(final RestRequest request) {
return new SecurityRestRequest(request);
}


public static SecurityRequestChannel from(final RestRequest request, final RestChannel channel) {
return new SecurityRestRequestChannel(request, channel);
}


public static class SecurityRestRequest implements SecurityRequest {

protected final RestRequest underlyingRequest;
Expand Down Expand Up @@ -90,7 +88,7 @@ public String uri() {
public Map<String, String> params() {
return underlyingRequest.params();
}

public RestRequest breakEncapsulationForRequest() {
return underlyingRequest;
}
Expand All @@ -108,7 +106,6 @@ public static class SecurityRestRequestChannel extends SecurityRestRequest imple
underlyingChannel = channel;
}


@Override
public boolean hasCompleted() {
return hasCompleted.get();
Expand All @@ -124,7 +121,7 @@ public boolean completeWithResponse(int statusCode, Map<String, String> headers,
final BytesRestResponse restResponse = new BytesRestResponse(RestStatus.fromCode(statusCode), body);
headers.forEach(restResponse::addHeader);
underlyingChannel.sendResponse(restResponse);

return true;
} catch (final Exception e) {
log.error("Error when attempting to send response", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public TransportAddress resolve(final SecurityRequest request) throws OpenSearch

requestFromNetty = restRequest.getHttpChannel() instanceof Netty4HttpChannel;
}

if (enabled && request.getRemoteAddress().isPresent() && requestFromNetty) {
final InetSocketAddress remoteAddress = request.getRemoteAddress().get();
final InetSocketAddress isa = new InetSocketAddress(detector.detect(request, threadContext), remoteAddress.getPort());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,13 @@
import org.opensearch.common.settings.Settings;
import org.opensearch.core.xcontent.MediaType;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.rest.BytesRestResponse;
import org.opensearch.rest.RestChannel;
import org.opensearch.rest.RestRequest;
import org.opensearch.rest.RestRequest.Method;
import org.opensearch.rest.RestResponse;
import org.opensearch.core.rest.RestStatus;
import org.opensearch.security.DefaultObjectMapper;
import org.opensearch.security.filter.SecurityRequestFactory;
import org.opensearch.security.filter.SecurityRequestFactory.SecurityRestRequest;
import org.opensearch.security.filter.SecurityRequestFactory.SecurityRestRequestChannel;
import org.opensearch.security.test.helper.file.FileHelper;
import org.opensearch.security.user.AuthCredentials;
Expand Down

0 comments on commit 9a915e7

Please sign in to comment.