forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor IdentityAwarePlugin interface to be assigned a client for ex…
…ecuting actions Signed-off-by: Craig Perkins <[email protected]>
- Loading branch information
Showing
19 changed files
with
126 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 0 additions & 49 deletions
49
plugins/identity-shiro/src/main/java/org/opensearch/identity/shiro/ShiroPluginSubject.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 0 additions & 19 deletions
19
server/src/main/java/org/opensearch/identity/PluginSubject.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 0 additions & 49 deletions
49
server/src/main/java/org/opensearch/identity/noop/NoopPluginSubject.java
This file was deleted.
Oops, something went wrong.
56 changes: 56 additions & 0 deletions
56
server/src/main/java/org/opensearch/identity/noop/RunAsSystemClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.identity.noop; | ||
|
||
import org.opensearch.action.ActionRequest; | ||
import org.opensearch.action.ActionType; | ||
import org.opensearch.client.Client; | ||
import org.opensearch.client.FilterClient; | ||
import org.opensearch.common.annotation.InternalApi; | ||
import org.opensearch.common.util.concurrent.ThreadContext; | ||
import org.opensearch.core.action.ActionListener; | ||
import org.opensearch.core.action.ActionResponse; | ||
|
||
/** | ||
* Implementation of client that will run transport actions in a stashed context | ||
* <p> | ||
* This class and related classes in this package will not return nulls or fail permissions checks | ||
* | ||
* This class is used by the NoopIdentityPlugin to initialize IdentityAwarePlugins | ||
* | ||
* @opensearch.internal | ||
*/ | ||
@InternalApi | ||
public class RunAsSystemClient extends FilterClient { | ||
public RunAsSystemClient(Client delegate) { | ||
super(delegate); | ||
} | ||
|
||
@Override | ||
protected <Request extends ActionRequest, Response extends ActionResponse> void doExecute( | ||
ActionType<Response> action, | ||
Request request, | ||
ActionListener<Response> actionListener | ||
) { | ||
ThreadContext threadContext = threadPool().getThreadContext(); | ||
|
||
try (ThreadContext.StoredContext ctx = threadContext.stashContext()) { | ||
|
||
ActionListener<Response> wrappedListener = ActionListener.wrap(r -> { | ||
ctx.restore(); | ||
actionListener.onResponse(r); | ||
}, e -> { | ||
ctx.restore(); | ||
actionListener.onFailure(e); | ||
}); | ||
|
||
super.doExecute(action, request, wrappedListener); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.