Class SignatureProvider
- All Implemented Interfaces:
- AuthorizationProvider,- oracle.nosql.driver.Region.RegionProvider
 An instance of AuthorizationProvider that generates and caches
 signature for each request as authorization string. A number of pieces of
 information are required for configuration. See
 SDK Configuration File
 and
 Required Keys and OCIDs
 for additional information as well as instructions on how to create required
 keys and OCIDs for configuration. The required information includes:
 
- A signing key, used to sign requests.
- A pass phrase for the key, if it is encrypted
- The fingerprint of the key pair used for signing
- The OCID of the tenancy
- The OCID of a user in the tenancy
There are three mechanisms for providing authorization information:
- Using a user's identity and optional profile. This authenticates and authorizes the application based on a specific user identity.
- Using an Instance Principal, which can be done when running on a
 compute instance in the Oracle Cloud Infrastructure (OCI). See
 createWithInstancePrincipal()and Calling Services from Instances.
- Using a Resource Principal, which is usually done when running
 in an OCI Function. See createWithResourcePrincipal()and Accessing Other Oracle Cloud Infrastructure Resources from Running Functions
 When using the first one, a User Principal, a default compartment is
 used and that is the root compartment of the user's tenancy. If a specific
 compartment is used (recommended) it can be specified as a default
 or per-request. In addition when using a User Principal compartments can
 be named by compartment name vs OCID when naming compartments and tables
 in Request classes and when naming tables in queries.
 
 When using an Instance Principal or Resource Principal a compartment
 must be specified as there is no default for these principal types. In
 addition these principal types limit the ability to use a compartment
 name vs OCID when naming compartments and tables in Request
 classes and when naming tables
 in queries.
 
When using a specific user's identity there are several options to provide the required information:
- Using a configuration file. See SDK Configuration File for details on the file contents. By default the file is stored in ~/.oci/config, but you may supply a path to another location. The configuration file may include multiple profiles. The constructors that use a configuration include
- Using information passed programmatically. The constructors that use this mechanism include
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classClaim keys in the resource principal session token(RPST).
- 
Constructor SummaryConstructorsConstructorDescriptionCreates a SignatureProvider using a default configuration file and profile.SignatureProvider(String profileName) Creates a SignatureProvider using the specified profile.SignatureProvider(String configFile, String profileName) Creates a SignatureProvider using the specified config file and profile.SignatureProvider(String tenantId, String userId, String fingerprint, File privateKeyFile, char[] passphrase) Creates a SignatureProvider using directly provided user authentication information.SignatureProvider(String tenantId, String userId, String fingerprint, File privateKeyFile, char[] passphrase, Region region) Creates a SignatureProvider using directly provided user authentication information.SignatureProvider(String tenantId, String userId, String fingerprint, String privateKey, char[] passphrase) Creates a SignatureProvider using directly provided user authentication information.SignatureProvider(oracle.nosql.driver.iam.AuthenticationProfileProvider provider) Constructor for SignatureProvider given an AuthenticationProfileProvider.SignatureProvider(oracle.nosql.driver.iam.AuthenticationProfileProvider profileProvider, int durationSeconds, int refreshAheadMs) Constructor for SignatureProvider given an AuthenticationProfileProvider and refresh details.
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()Release resources provider is using.static SignatureProviderCreates a SignatureProvider using an instance principal.static SignatureProvidercreateWithInstancePrincipal(String iamAuthUrl) Creates a SignatureProvider using an instance principal.static SignatureProvidercreateWithInstancePrincipal(String iamAuthUrl, Region region, Logger logger) Creates a SignatureProvider using an instance principal.static SignatureProvidercreateWithInstancePrincipal(Region region) Creates a SignatureProvider using an instance principal.static SignatureProvidercreateWithInstancePrincipalForDelegation(File delegationTokenFile) Creates a SignatureProvider using an instance principal with a delegation token.static SignatureProvidercreateWithInstancePrincipalForDelegation(String delegationToken) Creates a SignatureProvider using an instance principal with a delegation token.static SignatureProvidercreateWithInstancePrincipalForDelegation(String iamAuthUrl, Region region, File delegationTokenFile, Logger logger) Creates a SignatureProvider using an instance principal with a delegation token.static SignatureProvidercreateWithInstancePrincipalForDelegation(String iamAuthUrl, Region region, String delegationToken, Logger logger) Creates a SignatureProvider using an instance principal with a delegation token.static SignatureProviderCreates a SignatureProvider with Container Engine for Kubernetes (OKE) workload identity using the Kubernetes service account token at the default path/var/run/secrets/kubernetes.io/serviceaccount/token.static SignatureProvidercreateWithOkeWorkloadIdentity(File serviceAccountTokenFile, Logger logger) Creates a SignatureProvider with Container Engine for Kubernetes (OKE) workload identity using Kubernetes service account token in the specified token file.static SignatureProvidercreateWithOkeWorkloadIdentity(String serviceAccountToken, Logger logger) Creates a SignatureProvider with Container Engine for Kubernetes (OKE) workload identity using specified Kubernetes service account token string.static SignatureProviderCreates a SignatureProvider using a resource principal.static SignatureProvidercreateWithResourcePrincipal(Logger logger) Creates a SignatureProvider using a resource principal.static SignatureProviderCreates a SignatureProvider using a temporary session token read from a token file.static SignatureProvidercreateWithSessionToken(String profile) Creates a SignatureProvider using a temporary session token read from a token file.static SignatureProvidercreateWithSessionToken(String configFilePath, String profile) Creates a SignatureProvider using a temporary session token read from a token file.voidInvalidate any cached authorization strings.booleanforCloud()Indicates whether or not the instance is used for the cloud servicegetAuthorizationString(Request request) Returns an authorization string for specified request.Returns the logger of this provider if set, null if not.Returns regionResource principal session tokens carry JWT claims.voidSets a Logger instance for this provider.voidsetRequiredHeaders(String authString, Request request, io.netty.handler.codec.http.HttpHeaders headers, byte[] content) Set HTTP headers required by the provider.Methods inherited from class java.lang.Objectequals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface oracle.nosql.driver.AuthorizationProvidervalidateAuthString
- 
Constructor Details- 
SignatureProviderCreates a SignatureProvider using a default configuration file and profile. The configuration file used is~/.oci/config. See SDK Configuration File for details of the file's contents and format.When using this constructor the user has a default compartment for all tables. It is the root compartment of the user's tenancy. - Throws:
- IOException- if error loading profile from OCI configuration file
 
- 
SignatureProviderCreates a SignatureProvider using the specified profile. The configuration file used is~/.oci/config. See SDK Configuration File for details of the file's contents and format.When using this constructor the user has a default compartment for all tables. It is the root compartment of the user's tenancy. - Parameters:
- profileName- user profile name
- Throws:
- IOException- if error loading profile from OCI configuration file
 
- 
SignatureProviderCreates a SignatureProvider using the specified config file and profile. See SDK Configuration File for details of the file's contents and format.When using this constructor the user has a default compartment for all tables. It is the root compartment of the user's tenancy. - Parameters:
- configFile- path of configuration file
- profileName- user profile name
- Throws:
- IOException- if error loading profile from OCI configuration file
 
- 
SignatureProviderpublic SignatureProvider(String tenantId, String userId, String fingerprint, String privateKey, char[] passphrase) Creates a SignatureProvider using directly provided user authentication information. See Required Keys and OCIDs for details of the required parameters.When using this constructor the user has a default compartment for all tables. It is the root compartment of the user's tenancy. - Parameters:
- tenantId- tenant id
- userId- user id
- fingerprint- fingerprint of the key being used
- privateKey- the string of private key used to sign request
- passphrase- optional passphrase for the (encrypted) private key
 
- 
SignatureProviderpublic SignatureProvider(String tenantId, String userId, String fingerprint, File privateKeyFile, char[] passphrase) Creates a SignatureProvider using directly provided user authentication information. See Required Keys and OCIDs for details of the required parameters.When using this constructor the user has a default compartment for all tables. It is the root compartment of the user's tenancy. - Parameters:
- tenantId- tenant id
- userId- user id
- fingerprint- fingerprint of the key being used
- privateKeyFile- the file of the private key used to sign request
- passphrase- optional passphrase for the (encrypted) private key
 
- 
SignatureProviderpublic SignatureProvider(String tenantId, String userId, String fingerprint, File privateKeyFile, char[] passphrase, Region region) Creates a SignatureProvider using directly provided user authentication information. See Required Keys and OCIDs for details of the required parameters.When using this constructor the user has a default compartment for all tables. It is the root compartment of the user's tenancy. - Parameters:
- tenantId- tenant id
- userId- user id
- fingerprint- fingerprint of the key being used
- privateKeyFile- the file of the private key used to sign request
- passphrase- optional passphrase for the (encrypted) private key
- region- identifies the region will be accessed by the NoSQLHandle.
 
- 
SignatureProviderpublic SignatureProvider(oracle.nosql.driver.iam.AuthenticationProfileProvider provider) Constructor for SignatureProvider given an AuthenticationProfileProvider. This is for advanced use only; use of the create* methods is preferred. The SignatureProvider that generates and caches request signature using key id and private key supplied byAuthenticationProfileProvider.- Parameters:
- provider- The provider to use
 
- 
SignatureProviderpublic SignatureProvider(oracle.nosql.driver.iam.AuthenticationProfileProvider profileProvider, int durationSeconds, int refreshAheadMs) Constructor for SignatureProvider given an AuthenticationProfileProvider and refresh details. This is for advanced use only; use of the create* methods is preferred. The constructor that is able to set refresh time before signature expires.- Parameters:
- profileProvider- The provider to use
- durationSeconds- amount of time to keep signature before refresh
- refreshAheadMs- how soon before expiry to start a new refresh
 
 
- 
- 
Method Details- 
createWithInstancePrincipalCreates a SignatureProvider using an instance principal. This constructor may be used when calling the Oracle NoSQL Database Cloud Service from an Oracle Cloud compute instance. It authenticates with the instance principal and uses a security token issued by IAM to do the actual request signing.When using an instance principal the compartment id (OCID) must be specified on each request or defaulted by using NoSQLHandleConfig.setDefaultCompartment(java.lang.String). If the compartment id is not specified for an operation an exception will be thrown.- Returns:
- SignatureProvider
 
- 
createWithInstancePrincipalCreates a SignatureProvider using an instance principal. This constructor may be used when calling the Oracle NoSQL Database Cloud Service from an Oracle Cloud compute instance. It authenticates with the instance principal and uses a security token issued by IAM to do the actual request signing.When using an instance principal the compartment id (OCID) must be specified on each request or defaulted by using NoSQLHandleConfig.setDefaultCompartment(java.lang.String). If the compartment id is not specified for an operation an exception will be thrown.- Parameters:
- region- identifies the region will be accessed by the NoSQLHandle.
- Returns:
- SignatureProvider
 
- 
createWithInstancePrincipalCreates a SignatureProvider using an instance principal. This constructor may be used when calling the Oracle NoSQL Database Cloud Service from an Oracle Cloud compute instance. It authenticates with the instance principal and uses a security token issued by IAM to do the actual request signing.When using an instance principal the compartment id (OCID) must be specified on each request or defaulted by using NoSQLHandleConfig.setDefaultCompartment(java.lang.String). If the compartment id is not specified for an operation an exception will be thrown.- Parameters:
- iamAuthUrl- The URL is usually detected automatically, specify the URL if you need to overwrite the default, or the region of instance doesn't exists in registered regions listed in- Region.
- Returns:
- SignatureProvider
 
- 
createWithInstancePrincipalpublic static SignatureProvider createWithInstancePrincipal(String iamAuthUrl, Region region, Logger logger) Creates a SignatureProvider using an instance principal. This constructor may be used when calling the Oracle NoSQL Database Cloud Service from an Oracle Cloud compute instance. It authenticates with the instance principal and uses a security token issued by IAM to do the actual request signing.When using an instance principal the compartment id (OCID) must be specified on each request or defaulted by using NoSQLHandleConfig.setDefaultCompartment(java.lang.String). If the compartment id is not specified for an operation an exception will be thrown.- Parameters:
- iamAuthUrl- The URL is usually detected automatically, specify the URL if you need to overwrite the default, or the region of instance doesn't exists in registered regions listed in- Region.
- region- the region to use, it may be null
- logger- the logger used by the SignatureProvider.
- Returns:
- SignatureProvider
 
- 
createWithInstancePrincipalForDelegationCreates a SignatureProvider using an instance principal with a delegation token. This constructor may be used when calling the Oracle NoSQL Database Cloud Service from an Oracle Cloud compute instance. It authenticates with the instance principal and uses a security token issued by IAM to do the actual request signing. The delegation token allows the instance to assume the privileges of the user for which the token was created.When using an instance principal the compartment id (OCID) must be specified on each request or defaulted by using NoSQLHandleConfig.setDefaultCompartment(java.lang.String). If the compartment id is not specified for an operation an exception will be thrown.- Parameters:
- delegationToken- the string of delegation token that allows an instance to assume the privileges of a specific user and act on-behalf-of that user
- Returns:
- SignatureProvider
 
- 
createWithInstancePrincipalForDelegationpublic static SignatureProvider createWithInstancePrincipalForDelegation(String iamAuthUrl, Region region, String delegationToken, Logger logger) Creates a SignatureProvider using an instance principal with a delegation token. This constructor may be used when calling the Oracle NoSQL Database Cloud Service from an Oracle Cloud compute instance. It authenticates with the instance principal and uses a security token issued by IAM to do the actual request signing. The delegation token allows the instance to assume the privileges of the user for which the token was created.When using an instance principal the compartment id (OCID) must be specified on each request or defaulted by using NoSQLHandleConfig.setDefaultCompartment(java.lang.String). If the compartment id is not specified for an operation an exception will be thrown.- Parameters:
- iamAuthUrl- The URL is usually detected automatically, specify the URL if you need to overwrite the default, or the region of instance doesn't exists in registered regions listed in- Region.
- region- the region to use, it may be null
- delegationToken- the string of delegation token that allows an instance to assume the privileges of a specific user and act on-behalf-of that user
- logger- the logger used by the SignatureProvider.
- Returns:
- SignatureProvider
 
- 
createWithInstancePrincipalForDelegationCreates a SignatureProvider using an instance principal with a delegation token. This constructor may be used when calling the Oracle NoSQL Database Cloud Service from an Oracle Cloud compute instance. It authenticates with the instance principal and uses a security token issued by IAM to do the actual request signing. The delegation token allows the instance to assume the privileges of the user for which the token was created.When using an instance principal the compartment id (OCID) must be specified on each request or defaulted by using NoSQLHandleConfig.setDefaultCompartment(java.lang.String). If the compartment id is not specified for an operation an exception will be thrown.- Parameters:
- delegationTokenFile- the file of delegation token that allows an instance to assume the privileges of a specific user and act on-behalf-of that user. Note that the file must only contains full string of the token.
- Returns:
- SignatureProvider
 
- 
createWithInstancePrincipalForDelegationpublic static SignatureProvider createWithInstancePrincipalForDelegation(String iamAuthUrl, Region region, File delegationTokenFile, Logger logger) Creates a SignatureProvider using an instance principal with a delegation token. This constructor may be used when calling the Oracle NoSQL Database Cloud Service from an Oracle Cloud compute instance. It authenticates with the instance principal and uses a security token issued by IAM to do the actual request signing. The delegation token allows the instance to assume the privileges of the user for which the token was created.When using an instance principal the compartment id (OCID) must be specified on each request or defaulted by using NoSQLHandleConfig.setDefaultCompartment(java.lang.String). If the compartment id is not specified for an operation an exception will be thrown.- Parameters:
- iamAuthUrl- The URL is usually detected automatically, specify the URL if you need to overwrite the default, or the region of instance doesn't exists in registered regions listed in- Region.
- region- the region to use, it may be null
- delegationTokenFile- the file of delegation token that allows an instance to assume the privileges of a specific user and act on-behalf-of that user. Note that the file must only contains full string of the token.
- logger- the logger used by the SignatureProvider.
- Returns:
- SignatureProvider
 
- 
createWithResourcePrincipalCreates a SignatureProvider using a resource principal. This constructor may be used when calling the Oracle NoSQL Database Cloud Service from other Oracle Cloud service resource such as Functions. It uses a resource provider session token (RPST) that enables the resource such as function to authenticate itself.When using an resource principal the compartment id (OCID) must be specified on each request or defaulted by using NoSQLHandleConfig.setDefaultCompartment(java.lang.String). If the compartment id is not specified for an operation an exception will be thrown.See Accessing Other Oracle Cloud Infrastructure Resources from Running Functions. - Returns:
- SignatureProvider
 
- 
createWithResourcePrincipalCreates a SignatureProvider using a resource principal. This constructor may be used when calling the Oracle NoSQL Database Cloud Service from other Oracle Cloud Service resource such as Functions. It uses a resource provider session token (RPST) that enables the resource such as the function to authenticate itself.When using an resource principal the compartment id (OCID) must be specified on each request or defaulted by using NoSQLHandleConfig.setDefaultCompartment(java.lang.String). If the compartment id is not specified for an operation an exception will be thrown.See Accessing Other Oracle Cloud Infrastructure Resources from Running Functions. - Parameters:
- logger- the logger used by the SignatureProvider
- Returns:
- SignatureProvider
 
- 
createWithSessionTokenCreates a SignatureProvider using a temporary session token read from a token file. The path of token file is read from the default profile in configuration file at the default location, the value of fieldsecurity_token_file. The configuration file used is~/.oci/config. See SDK Configuration File for details of the file's contents and format.See Session Token-Based Authentication for more details of session-token-based authentication. You can use the OCI CLI to authenticate and create a token, see See Token-based Authentication for the CLI. When using this constructor the user has a default compartment for all tables. It is the root compartment of the user's tenancy. - Returns:
- SignatureProvider
 
- 
createWithSessionTokenCreates a SignatureProvider using a temporary session token read from a token file. The path of token file is read from the specified profile in configuration file at the default location, the value of fieldsecurity_token_file. The configuration file used is~/.oci/config. See SDK Configuration File for details of the file's contents and format.See Session Token-Based Authentication for more details of session-token-based authentication. You can use the OCI CLI to authenticate and create a token, see Token-based Authentication for the CLI. When using this constructor the user has a default compartment for all tables. It is the root compartment of the user's tenancy. - Parameters:
- profile- profile name used to load session token
- Returns:
- SignatureProvider
 
- 
createWithSessionTokenCreates a SignatureProvider using a temporary session token read from a token file. The path of token file is read from the specified profile in configuration file at the specified location, the value of fieldsecurity_token_file. The configuration file used is~/.oci/config. See SDK Configuration File for details of the file's contents and format.See Session Token-Based Authentication for more details of session-token-based authentication. You can use the OCI CLI to authenticate and create a token, see Token-based Authentication for the CLI. When using this constructor the user has a default compartment for all tables. It is the root compartment of the user's tenancy. - Parameters:
- configFilePath- path of configuration file
- profile- profile name used to load session token
- Returns:
- SignatureProvider
 
- 
createWithOkeWorkloadIdentityCreates a SignatureProvider with Container Engine for Kubernetes (OKE) workload identity using the Kubernetes service account token at the default path/var/run/secrets/kubernetes.io/serviceaccount/token. This provider can only be used inside Kubernetes pods.See Granting Workloads Access to OCI Resources for more details of OKE workload identity. - Returns:
- SignatureProvider
 
- 
createWithOkeWorkloadIdentitypublic static SignatureProvider createWithOkeWorkloadIdentity(String serviceAccountToken, Logger logger) Creates a SignatureProvider with Container Engine for Kubernetes (OKE) workload identity using specified Kubernetes service account token string. If token string is null, the provider will use the service account token at the default path/var/run/secrets/kubernetes.io/serviceaccount/token. This provider can only be used inside Kubernetes pods.See Granting Workloads Access to OCI Resources for more details of OKE workload identity. - Parameters:
- serviceAccountToken- Kubernetes service account token string
- logger- the logger used by the SignatureProvider
- Returns:
- SignatureProvider
 
- 
createWithOkeWorkloadIdentitypublic static SignatureProvider createWithOkeWorkloadIdentity(File serviceAccountTokenFile, Logger logger) Creates a SignatureProvider with Container Engine for Kubernetes (OKE) workload identity using Kubernetes service account token in the specified token file. If token file is null, the provider will use the service account token at the default path/var/run/secrets/kubernetes.io/serviceaccount/token. This provider can only be used inside Kubernetes pods.See Granting Workloads Access to OCI Resources for more details of OKE workload identity. - Parameters:
- serviceAccountTokenFile- Kubernetes service account token file
- logger- the logger used by the SignatureProvider
- Returns:
- SignatureProvider
 
- 
getAuthorizationStringDescription copied from interface:AuthorizationProviderReturns an authorization string for specified request. This is sent to the server in the request for authorization. Authorization information can be request-dependent.- Specified by:
- getAuthorizationStringin interface- AuthorizationProvider
- Parameters:
- request- the request being processed
- Returns:
- a string indicating that the application is authorized to perform the request
 
- 
setRequiredHeaderspublic void setRequiredHeaders(String authString, Request request, io.netty.handler.codec.http.HttpHeaders headers, byte[] content) Description copied from interface:AuthorizationProviderSet HTTP headers required by the provider.- Specified by:
- setRequiredHeadersin interface- AuthorizationProvider
- Parameters:
- authString- the authorization string for the request
- request- the request being processed
- headers- the HTTP headers
- content- the request content bytes
 
- 
flushCachepublic void flushCache()Description copied from interface:AuthorizationProviderInvalidate any cached authorization strings.- Specified by:
- flushCachein interface- AuthorizationProvider
 
- 
closepublic void close()Description copied from interface:AuthorizationProviderRelease resources provider is using.- Specified by:
- closein interface- AuthorizationProvider
 
- 
getRegionReturns region- Specified by:
- getRegionin interface- oracle.nosql.driver.Region.RegionProvider
- Returns:
- the Region to use for NoSQLHandle
 
- 
forCloudpublic boolean forCloud()Description copied from interface:AuthorizationProviderIndicates whether or not the instance is used for the cloud service- Specified by:
- forCloudin interface- AuthorizationProvider
- Returns:
- false by default
 
- 
setLoggerSets a Logger instance for this provider. If not set, the logger associated with the driver is used.- Parameters:
- logger- the logger
 
- 
getLoggerReturns the logger of this provider if set, null if not.- Returns:
- logger
 
- 
getResourcePrincipalClaimResource principal session tokens carry JWT claims. Permit the retrieval of the value from the token by given key. SeeSignatureProvider.ResourcePrincipalClaimKeys- Parameters:
- key- the name of a claim in the session token
- Returns:
- the claim value.
 
 
-