-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Peter Nied <petern@amazon.com>
- Loading branch information
Showing
9 changed files
with
77 additions
and
133 deletions.
There are no files selected for viewing
39 changes: 0 additions & 39 deletions
39
server/src/main/java/org/opensearch/cluster/ApplicationManager.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
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
44 changes: 44 additions & 0 deletions
44
server/src/main/java/org/opensearch/identity/ApplicationManager.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,44 @@ | ||
/* | ||
* 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; | ||
|
||
import java.security.Principal; | ||
import java.util.concurrent.atomic.AtomicReference; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
import org.opensearch.extensions.ExtensionsManager; | ||
import org.opensearch.identity.scopes.Scope; | ||
|
||
/** | ||
* The ApplicationManager class handles the processing and resolution of multiple types of applications. Using the class, OpenSearch can | ||
* continue to resolve requests even when specific application types are disabled. For example, the ExtensionManager can be Noop in which case | ||
* the ApplicationManager is able to resolve requests for other application types still | ||
* | ||
* @opensearch.experimental | ||
*/ | ||
public class ApplicationManager { | ||
|
||
private final AtomicReference<ExtensionsManager> extensionManager = new AtomicReference<ExtensionsManager>(); | ||
|
||
public void register(final ExtensionsManager manager) { | ||
// Only allow the extension manager to be registered the first time | ||
extensionManager.compareAndSet(null, manager); | ||
} | ||
|
||
public Optional<Set<Scope>> getScopes(final Principal applicationPrincipal) { | ||
return findExtension(applicationPrincipal); | ||
} | ||
|
||
private Optional<Set<Scope>> findExtension(final Principal applicationPrincipal) { | ||
if (extensionManager.get().getExtensionIdMap().containsKey(applicationPrincipal.getName())) { | ||
return Optional.of(extensionManager.get().getExtensionIdMap().get(applicationPrincipal.getName()).getScopes()); | ||
} | ||
return Optional.empty(); | ||
} | ||
} |
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
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.