Package com.oracle.bmc.auth
Class SessionTokenAuthenticationDetailsProvider
- java.lang.Object
-
- com.oracle.bmc.auth.SessionTokenAuthenticationDetailsProvider
-
- All Implemented Interfaces:
AbstractAuthenticationDetailsProvider
,AuthenticationDetailsProvider
,BasicAuthenticationDetailsProvider
,RefreshableOnNotAuthenticatedProvider<String>
,RegionProvider
public class SessionTokenAuthenticationDetailsProvider extends Object implements AuthenticationDetailsProvider, RegionProvider, RefreshableOnNotAuthenticatedProvider<String>
Implementation ofAuthenticationDetailsProvider
that uses a session token for authentication.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SessionTokenAuthenticationDetailsProvider.SessionToken
static class
SessionTokenAuthenticationDetailsProvider.SessionTokenAuthenticationDetailsProviderBuilder
Builder for SessionTokenAuthenticationDetailsProvider.static class
SessionTokenAuthenticationDetailsProvider.SessionTokenRefreshRequest
-
Constructor Summary
Constructors Modifier Constructor Description SessionTokenAuthenticationDetailsProvider()
Creates a new instance using the config file at the default location and the default profile.SessionTokenAuthenticationDetailsProvider(ConfigFileReader.ConfigFile configFile)
Creates a new instance.SessionTokenAuthenticationDetailsProvider(String profile)
Creates a new instance using the config file at the default location, seeConfigFileReader.DEFAULT_FILE_PATH
.protected
SessionTokenAuthenticationDetailsProvider(String privateKeyFilePath, Region region, String regionId, String passPhrase, String tenantId, String fingerprint, String userId, String sessionTokenFilePath, String sessionToken, long initialRefreshDelay, long refreshPeriod, TimeUnit timeUnit, long sessionLifetimeHours, ScheduledExecutorService scheduler, boolean usingDefaultScheduler)
SessionTokenAuthenticationDetailsProvider(String configurationFilePath, String profile)
Creates a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static SessionTokenAuthenticationDetailsProvider.SessionTokenAuthenticationDetailsProviderBuilder
builder()
Creates a new SessionTokenAuthenticationDetailsProviderBuilder.void
close()
Stops the token refresh scheduler.String
getFingerprint()
Returns the fingerprint of the key being used.String
getKeyId()
Returns the keyId used to sign requests.String
getPassPhrase()
Deprecated.char[]
getPassphraseCharacters()
Returns the optional pass phrase for the (encrypted) private key, as a character array.InputStream
getPrivateKey()
Returns a new InputStream to the private key.Region
getRegion()
Returns the region.ExecutorService
getScheduler()
Returns the token refresh scheduler.String
getSessionToken()
String
getTenantId()
Returns the tenant OCID.String
getUserId()
Returns the user OCID.String
refresh()
Refreshes the session token from the file defined in the OCI config file.boolean
refreshSessionToken()
Makes a call to the Identity service to refresh the session token.void
setSessionToken(String sessionToken)
Sets the session token directly from a string.void
setSessionTokenFromFilePath(String sessionTokenFilePath)
Loads the session token from the file specified in the file path.String
toString()
-
-
-
Constructor Detail
-
SessionTokenAuthenticationDetailsProvider
public SessionTokenAuthenticationDetailsProvider() throws IOException
Creates a new instance using the config file at the default location and the default profile.- Throws:
IOException
- if the configuration file could not be loaded
-
SessionTokenAuthenticationDetailsProvider
public SessionTokenAuthenticationDetailsProvider(String profile) throws IOException
Creates a new instance using the config file at the default location, seeConfigFileReader.DEFAULT_FILE_PATH
.- Parameters:
profile
- profile to load, optional- Throws:
IOException
- if the configuration file could not be loaded
-
SessionTokenAuthenticationDetailsProvider
public SessionTokenAuthenticationDetailsProvider(String configurationFilePath, String profile) throws IOException
Creates a new instance.- Parameters:
configurationFilePath
- path to the OCI configuration fileprofile
- profile to load, optional- Throws:
IOException
- if the configuration file could not be loaded
-
SessionTokenAuthenticationDetailsProvider
protected SessionTokenAuthenticationDetailsProvider(String privateKeyFilePath, Region region, String regionId, String passPhrase, String tenantId, String fingerprint, String userId, String sessionTokenFilePath, String sessionToken, long initialRefreshDelay, long refreshPeriod, TimeUnit timeUnit, long sessionLifetimeHours, ScheduledExecutorService scheduler, boolean usingDefaultScheduler) throws IOException
- Throws:
IOException
-
SessionTokenAuthenticationDetailsProvider
public SessionTokenAuthenticationDetailsProvider(ConfigFileReader.ConfigFile configFile) throws IOException
Creates a new instance.- Parameters:
configFile
- The configuration file to use.- Throws:
IOException
- if the configuration file could not be loaded
-
-
Method Detail
-
setSessionToken
public void setSessionToken(String sessionToken)
Sets the session token directly from a string.- Parameters:
sessionToken
- The session token to use.
-
getSessionToken
public String getSessionToken()
- Returns:
- current session token.
-
getScheduler
public ExecutorService getScheduler()
Returns the token refresh scheduler.
-
close
public void close()
Stops the token refresh scheduler.
-
setSessionTokenFromFilePath
public void setSessionTokenFromFilePath(String sessionTokenFilePath) throws IOException
Loads the session token from the file specified in the file path.- Parameters:
sessionTokenFilePath
- The file path to set the session token from.- Throws:
IOException
-
refresh
public String refresh()
Refreshes the session token from the file defined in the OCI config file.- Specified by:
refresh
in interfaceRefreshableOnNotAuthenticatedProvider<String>
- Returns:
- the refreshed authentication data
-
refreshSessionToken
public boolean refreshSessionToken()
Makes a call to the Identity service to refresh the session token.- Returns:
- true if refresh was successful, false otherwise
-
getKeyId
public String getKeyId()
Description copied from interface:BasicAuthenticationDetailsProvider
Returns the keyId used to sign requests.- Specified by:
getKeyId
in interfaceBasicAuthenticationDetailsProvider
- Returns:
- The keyId.
-
getPrivateKey
public InputStream getPrivateKey()
Description copied from interface:BasicAuthenticationDetailsProvider
Returns a new InputStream to the private key.This stream should be closed by the caller, implementations should return new streams each time.
- Specified by:
getPrivateKey
in interfaceBasicAuthenticationDetailsProvider
- Returns:
- A new InputStream.
-
getPassPhrase
@Deprecated public String getPassPhrase()
Deprecated.Description copied from interface:BasicAuthenticationDetailsProvider
Returns the optional pass phrase for the (encrypted) private key.- Specified by:
getPassPhrase
in interfaceBasicAuthenticationDetailsProvider
- Returns:
- The pass phrase, or null if not applicable
-
getPassphraseCharacters
public char[] getPassphraseCharacters()
Description copied from interface:BasicAuthenticationDetailsProvider
Returns the optional pass phrase for the (encrypted) private key, as a character array.- Specified by:
getPassphraseCharacters
in interfaceBasicAuthenticationDetailsProvider
- Returns:
- The pass phrase as character array, or null if not applicable
-
getFingerprint
public String getFingerprint()
Description copied from interface:AuthenticationDetailsProvider
Returns the fingerprint of the key being used.- Specified by:
getFingerprint
in interfaceAuthenticationDetailsProvider
- Returns:
- The fingerprint.
-
getTenantId
public String getTenantId()
Description copied from interface:AuthenticationDetailsProvider
Returns the tenant OCID.- Specified by:
getTenantId
in interfaceAuthenticationDetailsProvider
- Returns:
- The tenant OCID.
-
getUserId
public String getUserId()
Description copied from interface:AuthenticationDetailsProvider
Returns the user OCID.- Specified by:
getUserId
in interfaceAuthenticationDetailsProvider
- Returns:
- The user OCID.
-
getRegion
public Region getRegion()
Description copied from interface:RegionProvider
Returns the region.- Specified by:
getRegion
in interfaceRegionProvider
- Returns:
- Region object.
-
builder
public static SessionTokenAuthenticationDetailsProvider.SessionTokenAuthenticationDetailsProviderBuilder builder()
Creates a new SessionTokenAuthenticationDetailsProviderBuilder.- Returns:
- A new builder instance.
-
-