com.aliyun.oss.common.auth

## 类 CredentialsProviderFactory

- java.lang.Object
- - com.aliyun.oss.common.auth.CredentialsProviderFactory

-     public class CredentialsProviderFactory
      extends Object

  Credentials provider factory to share providers across potentially many clients.

- - ### 构造器概要

    构造器
    构造器和说明
    `CredentialsProviderFactory()`

  - ### 方法概要

    方法
    限定符和类型 | 方法和说明
    --- | ---
    `static CustomSessionCredentialsProvider` | `newCustomSessionCredentialsProvider(String ossAuthServerHost)` Create an instance of InstanceProfileCredentialsProvider obtained the ak/sk by the authorization server defined by the OSS.
    `static DefaultCredentialProvider` | `newDefaultCredentialProvider(String accessKeyId, String secretAccessKey)` Create an instance of DefaultCredentialProvider.
    `DefaultCredentialProvider` | `newDefaultCredentialProvider(String accessKeyId, String secretAccessKey, String securityToken)` Create an instance of DefaultCredentialProvider.
    `static EnvironmentVariableCredentialsProvider` | `newEnvironmentVariableCredentialsProvider()` Create an instance of EnvironmentVariableCredentialsProvider by reading the environment variable to obtain the ak/sk, such as OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET
    `static InstanceProfileCredentialsProvider` | `newInstanceProfileCredentialsProvider(String roleName)` Create an instance of InstanceProfileCredentialsProvider obtained the ak/sk by ECS Metadata Service.
    `static STSAssumeRoleSessionCredentialsProvider` | `newSTSAssumeRoleSessionCredentialsProvider(String regionId, String accessKeyId, String accessKeySecret, String roleArn)` Create a new STSAssumeRoleSessionCredentialsProvider, which makes a request to the Aliyun Security Token Service (STS), uses the provided `#roleArn` to assume a role and then request short lived session credentials, which will then be returned by this class's `#getCredentials()` method.
    `static STSKeyPairSessionCredentialsProvider` | `newSTSKeyPairSessionCredentialsProvider(String regionId, String publicKeyId, String privateKey)` Create an instance of InstanceProfileCredentialsProvider based on RSA key pair.
    `static SystemPropertiesCredentialsProvider` | `newSystemPropertiesCredentialsProvider()` Create an instance of EnvironmentVariableCredentialsProvider by reading the java system property used when starting up the JVM to enable the default metrics collected by the OSS SDK, such as -Doss.accessKeyId and -Doss.accessKeySecret.

    - ### 从类继承的方法 java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 构造器详细资料

    - #### CredentialsProviderFactory

          public CredentialsProviderFactory()

  - ### 方法详细资料

    - #### newDefaultCredentialProvider

          public static DefaultCredentialProvider newDefaultCredentialProvider(String accessKeyId,
                                                               String secretAccessKey)

      Create an instance of DefaultCredentialProvider.
      参数:
        `accessKeyId` - Access Key ID.
        `secretAccessKey` - Secret Access Key.
      返回:
        A `DefaultCredentialProvider` instance.

    - #### newDefaultCredentialProvider

          public DefaultCredentialProvider newDefaultCredentialProvider(String accessKeyId,
                                                               String secretAccessKey,
                                                               String securityToken)

      Create an instance of DefaultCredentialProvider.
      参数:
        `accessKeyId` - Access Key ID.
        `secretAccessKey` - Secret Access Key.
        `securityToken` - Security Token from STS.
      返回:
        A `DefaultCredentialProvider` instance.

    - #### newEnvironmentVariableCredentialsProvider

          public static EnvironmentVariableCredentialsProvider newEnvironmentVariableCredentialsProvider()
                                                                                                  throws com.aliyuncs.exceptions.ClientException

      Create an instance of EnvironmentVariableCredentialsProvider by reading the environment variable to obtain the ak/sk, such as OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET
      返回:
        A `EnvironmentVariableCredentialsProvider` instance.
      抛出:
        `com.aliyuncs.exceptions.ClientException` - OSS Client side exception.

    - #### newSystemPropertiesCredentialsProvider

          public static SystemPropertiesCredentialsProvider newSystemPropertiesCredentialsProvider()
                                                                                            throws com.aliyuncs.exceptions.ClientException

      Create an instance of EnvironmentVariableCredentialsProvider by reading the java system property used when starting up the JVM to enable the default metrics collected by the OSS SDK, such as -Doss.accessKeyId and -Doss.accessKeySecret.
      返回:
        A `SystemPropertiesCredentialsProvider` instance.
      抛出:
        `com.aliyuncs.exceptions.ClientException` - OSS Client side exception.

    - #### newSTSAssumeRoleSessionCredentialsProvider

          public static STSAssumeRoleSessionCredentialsProvider newSTSAssumeRoleSessionCredentialsProvider(String regionId,
                                                                                           String accessKeyId,
                                                                                           String accessKeySecret,
                                                                                           String roleArn)
                                                                                                    throws com.aliyuncs.exceptions.ClientException

      Create a new STSAssumeRoleSessionCredentialsProvider, which makes a request to the Aliyun Security Token Service (STS), uses the provided `#roleArn` to assume a role and then request short lived session credentials, which will then be returned by this class's `#getCredentials()` method.
      参数:
        `regionId` - RAM's available area, for more information about regionId, see RegionIdList.
        `accessKeyId` - Access Key ID of the child user.
        `accessKeySecret` - Secret Access Key of the child user.
        `roleArn` - The ARN of the Role to be assumed.
      返回:
        A `StsAssumeRoleCredentialsProvider` instance.
      抛出:
        `com.aliyuncs.exceptions.ClientException` - OSS Client side exception.

    - #### newInstanceProfileCredentialsProvider

          public static InstanceProfileCredentialsProvider newInstanceProfileCredentialsProvider(String roleName)
                                                                                          throws com.aliyuncs.exceptions.ClientException

      Create an instance of InstanceProfileCredentialsProvider obtained the ak/sk by ECS Metadata Service.
      参数:
        `roleName` - Role name of the ECS binding, NOT ROLE ARN.
      返回:
        A `InstanceProfileCredentialsProvider` instance.
      抛出:
        `com.aliyuncs.exceptions.ClientException` - OSS Client side exception.

    - #### newSTSKeyPairSessionCredentialsProvider

          public static STSKeyPairSessionCredentialsProvider newSTSKeyPairSessionCredentialsProvider(String regionId,
                                                                                     String publicKeyId,
                                                                                     String privateKey)
                                                                                              throws com.aliyuncs.exceptions.ClientException

      Create an instance of InstanceProfileCredentialsProvider based on RSA key pair.
      参数:
        `regionId` - RAM's available area, for more information about regionId, see RegionIdList.
        `publicKeyId` - Public Key ID.
        `privateKey` - Private Key.
      返回:
        A `StsKeyPairCredentialsProvider` instance.
      抛出:
        `com.aliyuncs.exceptions.ClientException` - OSS Client side exception.

    - #### newCustomSessionCredentialsProvider

          public static CustomSessionCredentialsProvider newCustomSessionCredentialsProvider(String ossAuthServerHost)
                                                                                      throws com.aliyuncs.exceptions.ClientException

      Create an instance of InstanceProfileCredentialsProvider obtained the ak/sk by the authorization server defined by the OSS. The protocol format of the authorized service is as follows:

      { "StatusCode":"200", "AccessKeyId":"STS.3p******gdasdg", "AccessKeySecret":"rpnwO9******rddgsR2YrTtI", "SecurityToken":"CAES......zZGstZGVtbzI=", "Expiration":"2017-11-06T09:16:56Z" }

      An example of the authorized service to see AuthorizedService.
      参数:
        `ossAuthServerHost` - The host of the authorized server, such as http://192.168.1.11:9090/sts/getsts.
      返回:
        A `CustomSessionCredentialsProvider` instance.
      抛出:
        `com.aliyuncs.exceptions.ClientException`

Copyright © 2020. All Rights Reserved.