Skip to content

Commit

Permalink
Add interface for AuthToken
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Liang <[email protected]>
  • Loading branch information
RyanL1997 committed Jul 18, 2023
1 parent 4fdfaf7 commit a746202
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public String executor() {
// an
// extensions
// uniqueId
.toString(),
.getTokenValue(),
httpVersion
),
restExecuteOnExtensionResponseHandler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
* @opensearch.experimental
*/
public interface AuthToken {

String getTokenValue();
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,13 @@ public void revoke() {
this.password = "";
this.user = "";
}

@Override
public String getTokenValue() {
if (user == null || password == null) {
return null;
}
String usernamepassword = user + ":" + password;
return Base64.getEncoder().encodeToString(usernamepassword.getBytes(StandardCharsets.UTF_8));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,9 @@ public String getTokenIdentifier() {
public String toString() {
return "Bearer auth token with header=" + header + ", payload=" + payload + ", signature=" + signature;
}

@Override
public String getTokenValue() {
return completeToken;
}
}

0 comments on commit a746202

Please sign in to comment.