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 ofAuthenticationDetailsProviderthat uses a session token for authentication.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSessionTokenAuthenticationDetailsProvider.SessionTokenstatic classSessionTokenAuthenticationDetailsProvider.SessionTokenAuthenticationDetailsProviderBuilderBuilder for SessionTokenAuthenticationDetailsProvider.static classSessionTokenAuthenticationDetailsProvider.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.protectedSessionTokenAuthenticationDetailsProvider(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.SessionTokenAuthenticationDetailsProviderBuilderbuilder()Creates a new SessionTokenAuthenticationDetailsProviderBuilder.voidclose()Stops the token refresh scheduler.StringgetFingerprint()Returns the fingerprint of the key being used.StringgetKeyId()Returns the keyId used to sign requests.StringgetPassPhrase()Deprecated.char[]getPassphraseCharacters()Returns the optional pass phrase for the (encrypted) private key, as a character array.InputStreamgetPrivateKey()Returns a new InputStream to the private key.RegiongetRegion()Returns the region.ExecutorServicegetScheduler()Returns the token refresh scheduler.StringgetSessionToken()StringgetTenantId()Returns the tenant OCID.StringgetUserId()Returns the user OCID.Stringrefresh()Refreshes the session token from the file defined in the OCI config file.booleanrefreshSessionToken()Makes a call to the Identity service to refresh the session token.voidsetSessionToken(String sessionToken)Sets the session token directly from a string.voidsetSessionTokenFromFilePath(String sessionTokenFilePath)Loads the session token from the file specified in the file path.StringtoString()
-
-
-
Constructor Detail
-
SessionTokenAuthenticationDetailsProvider
public SessionTokenAuthenticationDetailsProvider() throws IOExceptionCreates 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:
refreshin 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:BasicAuthenticationDetailsProviderReturns the keyId used to sign requests.- Specified by:
getKeyIdin interfaceBasicAuthenticationDetailsProvider- Returns:
- The keyId.
-
getPrivateKey
public InputStream getPrivateKey()
Description copied from interface:BasicAuthenticationDetailsProviderReturns a new InputStream to the private key.This stream should be closed by the caller, implementations should return new streams each time.
- Specified by:
getPrivateKeyin interfaceBasicAuthenticationDetailsProvider- Returns:
- A new InputStream.
-
getPassPhrase
@Deprecated public String getPassPhrase()
Deprecated.Description copied from interface:BasicAuthenticationDetailsProviderReturns the optional pass phrase for the (encrypted) private key.- Specified by:
getPassPhrasein interfaceBasicAuthenticationDetailsProvider- Returns:
- The pass phrase, or null if not applicable
-
getPassphraseCharacters
public char[] getPassphraseCharacters()
Description copied from interface:BasicAuthenticationDetailsProviderReturns the optional pass phrase for the (encrypted) private key, as a character array.- Specified by:
getPassphraseCharactersin interfaceBasicAuthenticationDetailsProvider- Returns:
- The pass phrase as character array, or null if not applicable
-
getFingerprint
public String getFingerprint()
Description copied from interface:AuthenticationDetailsProviderReturns the fingerprint of the key being used.- Specified by:
getFingerprintin interfaceAuthenticationDetailsProvider- Returns:
- The fingerprint.
-
getTenantId
public String getTenantId()
Description copied from interface:AuthenticationDetailsProviderReturns the tenant OCID.- Specified by:
getTenantIdin interfaceAuthenticationDetailsProvider- Returns:
- The tenant OCID.
-
getUserId
public String getUserId()
Description copied from interface:AuthenticationDetailsProviderReturns the user OCID.- Specified by:
getUserIdin interfaceAuthenticationDetailsProvider- Returns:
- The user OCID.
-
getRegion
public Region getRegion()
Description copied from interface:RegionProviderReturns the region.- Specified by:
getRegionin interfaceRegionProvider- Returns:
- Region object.
-
builder
public static SessionTokenAuthenticationDetailsProvider.SessionTokenAuthenticationDetailsProviderBuilder builder()
Creates a new SessionTokenAuthenticationDetailsProviderBuilder.- Returns:
- A new builder instance.
-
-