Skip to content

Commit

Permalink
Update style and fix PR comments
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Nied <petern@amazon.com>
  • Loading branch information
peternied committed Sep 28, 2022
1 parent 20f4088 commit dd2f6bd
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 24 deletions.
19 changes: 12 additions & 7 deletions server/src/main/java/org/opensearch/identity/AccessToken.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
package org.opensearch.identity;
/*
* 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.
*/

import org.joda.time.DateTime;
import org.opensearch.common.io.stream.NamedWriteable;
package org.opensearch.identity;

/**
* Tamperproof encapsulation the identity of a subject
*
*
* @opensearch.experimental
*/
public class AccessToken implements AuthenticationToken {

/** Actual implementation would be something like:
public String accessToken;
public DateTime accessTokenExpiration;
public String refreshToken;
public DateTime refreshTokenExpiration;
public DateTime refreshTokenExpiration;
*/

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
/*
* 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;

/**
* Vends out access tokens
*
* Vends out access tokens
*
* @opensearch.experimental
*/
public interface AccessTokenManager {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Authentication management for OpenSearch.
*
* Retrieve the current subject or switch to a subject
*
*
* @opensearch.experimental
* */
public interface AuthenticationManager {
Expand All @@ -23,7 +23,7 @@ public interface AuthenticationManager {
public Subject getSubject();

/**
* Get an access token manager
* Get an access token manager
* */
public AccessTokenManager getAccessTokenManager();
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
package org.opensearch.identity
/*
* 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;

/**
* Generic interface for all token formats to support to authenticate user, such as UserName/Password tokens, Access tokens, and more.
*
*
* @opensearch.experimental
*/
public interface AuthenticationToken {

}
2 changes: 1 addition & 1 deletion server/src/main/java/org/opensearch/identity/Identity.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

/**
* Application wide access for identity systems
*
*
* @opensearch.experimental
*/
public final class Identity {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

/**
* Available OpenSearch internal principals
*
*
* @opensearch.experimental
*/
public enum Principals {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

/**
* Create a principal from a string
*
*
* @opensearch.experimental
*/
class StringPrincipal implements Principal {
Expand Down
4 changes: 2 additions & 2 deletions server/src/main/java/org/opensearch/identity/Subject.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* An individual, process, or device that causes information to flow among objects or change to the system state.
*
* Used to authorize activities inside of the OpenSearch ecosystem.
*
*
* @opensearch.experimental
*/
public interface Subject {
Expand All @@ -26,7 +26,7 @@ public interface Subject {

/**
* Authentications from a token
* throws UnsupportedAuthenticationMethod
* throws UnsupportedAuthenticationMethod
* throws InvalidAuthenticationToken
* throws SubjectNotFound
* throws SubjectDisabled
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
* 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.identity.AccessToken;
Expand Down Expand Up @@ -26,5 +33,5 @@ public AccessToken generate() {
public AccessToken refresh(final AccessToken token) {
return new AccessToken();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

package org.opensearch.identity.noop;

import org.opensearch.identity.AccessTokenVendor;
import org.opensearch.identity.AccessTokenManager;
import org.opensearch.identity.AuthenticationManager;
import org.opensearch.identity.Subject;

/**
* Implementation of authentication manager that does not enforce authentication
*
* This class and related classes in this package will not return nulls or fail permissions checks
*
*
* @opensearch.internal
*/
public class NoopAuthenticationManager implements AuthenticationManager {
Expand All @@ -27,7 +27,7 @@ public Subject getSubject() {
}

@Override
public AccessTokenVendor getAccessTokenVender() {
public AccessTokenManager getAccessTokenManager() {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import java.util.Objects;

import org.opensearch.identity.Subject;
import org.opensearch.identity.AccessToken;
import org.opensearch.identity.AuthenticationToken;
import org.opensearch.identity.Principals;

Expand Down

0 comments on commit dd2f6bd

Please sign in to comment.