public class CredentialsProviderFactory extends Object
构造器和说明 |
---|
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.
|
public static DefaultCredentialProvider newDefaultCredentialProvider(String accessKeyId, String secretAccessKey)
accessKeyId
- Access Key ID.secretAccessKey
- Secret Access Key.DefaultCredentialProvider
instance.public DefaultCredentialProvider newDefaultCredentialProvider(String accessKeyId, String secretAccessKey, String securityToken)
accessKeyId
- Access Key ID.secretAccessKey
- Secret Access Key.securityToken
- Security Token from STS.DefaultCredentialProvider
instance.public static EnvironmentVariableCredentialsProvider newEnvironmentVariableCredentialsProvider() throws com.aliyuncs.exceptions.ClientException
EnvironmentVariableCredentialsProvider
instance.com.aliyuncs.exceptions.ClientException
- OSS Client side exception.public static SystemPropertiesCredentialsProvider newSystemPropertiesCredentialsProvider() throws com.aliyuncs.exceptions.ClientException
SystemPropertiesCredentialsProvider
instance.com.aliyuncs.exceptions.ClientException
- OSS Client side exception.public static STSAssumeRoleSessionCredentialsProvider newSTSAssumeRoleSessionCredentialsProvider(String regionId, String accessKeyId, String accessKeySecret, String roleArn) throws com.aliyuncs.exceptions.ClientException
#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.StsAssumeRoleCredentialsProvider
instance.com.aliyuncs.exceptions.ClientException
- OSS Client side exception.public static InstanceProfileCredentialsProvider newInstanceProfileCredentialsProvider(String roleName) throws com.aliyuncs.exceptions.ClientException
roleName
- Role name of the ECS binding, NOT ROLE ARN.InstanceProfileCredentialsProvider
instance.com.aliyuncs.exceptions.ClientException
- OSS Client side exception.public static STSKeyPairSessionCredentialsProvider newSTSKeyPairSessionCredentialsProvider(String regionId, String publicKeyId, String privateKey) throws com.aliyuncs.exceptions.ClientException
regionId
- RAM's available area, for more information about regionId, see
RegionIdList.publicKeyId
- Public Key ID.privateKey
- Private Key.StsKeyPairCredentialsProvider
instance.com.aliyuncs.exceptions.ClientException
- OSS Client side exception.public static CustomSessionCredentialsProvider newCustomSessionCredentialsProvider(String ossAuthServerHost) throws com.aliyuncs.exceptions.ClientException
{ "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.CustomSessionCredentialsProvider
instance.com.aliyuncs.exceptions.ClientException
Copyright © 2019. All Rights Reserved.