Skip to content

Commit

Permalink
Merge pull request #133 from bnicholesdell/implementgetaccesstoken
Browse files Browse the repository at this point in the history
Add an API to get the access token. Needed to join a replica to a cluster.
  • Loading branch information
bnicholesdell authored Sep 11, 2023
2 parents 51ece82 + 6f89643 commit 5b08adb
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,18 @@ FullResponse JoinSps(ISafeguardSessionsConnection spsConnection, String certific
*/
void logOut() throws ObjectDisposedException;

/**
* Returns a character array of the current access token which the caller can pass to other Safeguard
* methods, such as adding cluster members.
*
* @return The current access token.
* @throws ObjectDisposedException Object has already been disposed.
*/
char[] getAccessToken() throws ObjectDisposedException;

/**
* Disposes of the connection.
*
*/
void dispose();

}
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,13 @@ public ISafeguardEventListener getPersistentEventListener() throws ObjectDispose
return _connection.getPersistentEventListener();
}

@Override
public char[] getAccessToken() throws ObjectDisposedException {
return _connection.getAccessToken();
}

@Override
public void logOut() throws ObjectDisposedException {
_connection.logOut();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -312,4 +312,9 @@ public IStreamingRequest getStreamingRequest() {
return this.streamingRequest;
}

@Override
public char[] getAccessToken() throws ObjectDisposedException {
return authenticationMechanism.getAccessToken();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ public void safeguardTestConnection(ISafeguardConnection connection) {
}

try {
char[] token = connection.getAccessToken();
System.out.println(String.format("\tAccess Token: %s", new String(token)));

int remaining = connection.getAccessTokenLifetimeRemaining();
System.out.println(String.format("\tTime remaining: %d", remaining));

Expand Down

0 comments on commit 5b08adb

Please sign in to comment.