Skip to content

Commit b493336

Browse files
move RemoteClusterCredentials record
1 parent 179b339 commit b493336

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/CrossClusterAccessTransportInterceptor.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,7 @@ public <T extends TransportResponse> void sendRequest(
147147
TransportRequestOptions options,
148148
TransportResponseHandler<T> handler
149149
) {
150-
final Optional<SecurityServerTransportInterceptor.RemoteClusterCredentials> remoteClusterCredentials =
151-
getRemoteClusterCredentials(connection);
150+
final Optional<RemoteClusterCredentials> remoteClusterCredentials = getRemoteClusterCredentials(connection);
152151
if (remoteClusterCredentials.isPresent()) {
153152
sendWithCrossClusterAccessHeaders(remoteClusterCredentials.get(), connection, action, request, options, handler);
154153
} else {
@@ -164,9 +163,7 @@ public <T extends TransportResponse> void sendRequest(
164163
/**
165164
* Returns cluster credentials if the connection is remote, and cluster credentials are set up for the target cluster.
166165
*/
167-
private Optional<SecurityServerTransportInterceptor.RemoteClusterCredentials> getRemoteClusterCredentials(
168-
Transport.Connection connection
169-
) {
166+
private Optional<RemoteClusterCredentials> getRemoteClusterCredentials(Transport.Connection connection) {
170167
final Optional<RemoteConnectionManager.RemoteClusterAliasWithCredentials> remoteClusterAliasWithCredentials =
171168
remoteClusterCredentialsResolver.apply(connection);
172169
if (remoteClusterAliasWithCredentials.isEmpty()) {
@@ -182,15 +179,12 @@ private Optional<SecurityServerTransportInterceptor.RemoteClusterCredentials> ge
182179
}
183180

184181
return Optional.of(
185-
new SecurityServerTransportInterceptor.RemoteClusterCredentials(
186-
remoteClusterAlias,
187-
ApiKeyService.withApiKeyPrefix(remoteClusterCredentials.toString())
188-
)
182+
new RemoteClusterCredentials(remoteClusterAlias, ApiKeyService.withApiKeyPrefix(remoteClusterCredentials.toString()))
189183
);
190184
}
191185

192186
private <T extends TransportResponse> void sendWithCrossClusterAccessHeaders(
193-
final SecurityServerTransportInterceptor.RemoteClusterCredentials remoteClusterCredentials,
187+
final RemoteClusterCredentials remoteClusterCredentials,
194188
final Transport.Connection connection,
195189
final String action,
196190
final TransportRequest request,
@@ -383,4 +377,12 @@ public Map<String, ServerTransportFilter> getProfileFilters(
383377
return Collections.unmodifiableMap(profileFilters);
384378
}
385379

380+
record RemoteClusterCredentials(String clusterAlias, String credentials) {
381+
382+
@Override
383+
public String toString() {
384+
return "RemoteClusterCredentials{clusterAlias='" + clusterAlias + "', credentials='::es_redacted::'}";
385+
}
386+
}
387+
386388
}

x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/SecurityServerTransportInterceptor.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -420,11 +420,4 @@ public void onFailure(Exception e) {
420420
}
421421
}
422422

423-
record RemoteClusterCredentials(String clusterAlias, String credentials) {
424-
425-
@Override
426-
public String toString() {
427-
return "RemoteClusterCredentials{clusterAlias='" + clusterAlias + "', credentials='::es_redacted::'}";
428-
}
429-
}
430423
}

0 commit comments

Comments
 (0)