Search in sources :

Example 1 with KeyPairCredentials

use of com.aliyuncs.auth.KeyPairCredentials in project aliyun-oss-java-sdk by aliyun.

the class CredentialsProviderFactory method newSTSKeyPairSessionCredentialsProvider.

/**
 * Create an instance of InstanceProfileCredentialsProvider based on RSA key
 * pair.
 *
 * @param regionId
 *            RAM's available area, for more information about regionId, see
 *            <a href="https://help.aliyun.com/document_detail/40654.html">
 *            RegionIdList</a>.
 * @param publicKeyId
 *            Public Key ID.
 * @param privateKey
 *            Private Key.
 * @return A {@link StsKeyPairCredentialsProvider} instance.
 * @throws ClientException
 *             OSS Client side exception.
 */
public static STSKeyPairSessionCredentialsProvider newSTSKeyPairSessionCredentialsProvider(String regionId, String publicKeyId, String privateKey) throws ClientException {
    DefaultProfile profile = DefaultProfile.getProfile(regionId);
    KeyPairCredentials keyPairCredentials = new KeyPairCredentials(publicKeyId, privateKey);
    return new STSKeyPairSessionCredentialsProvider(keyPairCredentials, profile);
}
Also used : DefaultProfile(com.aliyuncs.profile.DefaultProfile) KeyPairCredentials(com.aliyuncs.auth.KeyPairCredentials)

Aggregations

KeyPairCredentials (com.aliyuncs.auth.KeyPairCredentials)1 DefaultProfile (com.aliyuncs.profile.DefaultProfile)1