-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Interim build fix for PluginSubject related changes
Signed-off-by: Craig Perkins <[email protected]>
- Loading branch information
Showing
2 changed files
with
50 additions
and
1 deletion.
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
41 changes: 41 additions & 0 deletions
41
src/main/java/org/opensearch/security/identity/NoopPluginSubject.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,41 @@ | ||
/* | ||
* 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. | ||
* | ||
* Modifications Copyright OpenSearch Contributors. See | ||
* GitHub history for details. | ||
*/ | ||
|
||
package org.opensearch.security.identity; | ||
|
||
import java.security.Principal; | ||
import java.util.concurrent.Callable; | ||
|
||
import org.opensearch.common.util.concurrent.ThreadContext; | ||
import org.opensearch.identity.NamedPrincipal; | ||
import org.opensearch.identity.PluginSubject; | ||
import org.opensearch.threadpool.ThreadPool; | ||
|
||
public class NoopPluginSubject implements PluginSubject { | ||
private final ThreadPool threadPool; | ||
|
||
public NoopPluginSubject(ThreadPool threadPool) { | ||
super(); | ||
this.threadPool = threadPool; | ||
} | ||
|
||
@Override | ||
public Principal getPrincipal() { | ||
return NamedPrincipal.UNAUTHENTICATED; | ||
} | ||
|
||
@Override | ||
public <T> T runAs(Callable<T> callable) throws Exception { | ||
try (ThreadContext.StoredContext ctx = threadPool.getThreadContext().stashContext()) { | ||
return callable.call(); | ||
} | ||
} | ||
} |