日本熟妇hd丰满老熟妇,中文字幕一区二区三区在线不卡 ,亚洲成片在线观看,免费女同在线一区二区

憑據(jù)管家客戶端

更新時(shí)間:

憑據(jù)管家客戶端(SecretsManager Client)基于KMS憑據(jù)管家API封裝了業(yè)務(wù)邏輯、最佳實(shí)踐和設(shè)計(jì)模式,更易于開(kāi)發(fā)者在業(yè)務(wù)系統(tǒng)中集成。主要適用于應(yīng)用中動(dòng)態(tài)使用托管在憑據(jù)管家中的憑據(jù),告別對(duì)敏感信息的硬編碼。

功能特性

憑據(jù)管家客戶端具有以下功能特性:

  • 支持開(kāi)發(fā)者在應(yīng)用中快速集成憑據(jù)管家能力,一行代碼讀取憑據(jù)信息。

  • 封裝憑據(jù)在應(yīng)用中緩存和刷新的功能。

  • 封裝API錯(cuò)誤的重試機(jī)制,智能處理服務(wù)端錯(cuò)誤。

  • 開(kāi)放插件式設(shè)計(jì)模式,支持開(kāi)發(fā)者自定義擴(kuò)展緩存、錯(cuò)誤重試等功能模塊。

憑據(jù)管家Java客戶端

安裝SDK

憑據(jù)管家客戶端支持Java語(yǔ)言,您可以訪問(wèn)SecretsManager Client for Java開(kāi)源代碼倉(cāng)庫(kù)了解更多代碼信息。

您可以通過(guò)Maven在項(xiàng)目中使用憑據(jù)管家Java客戶端,需要添加的依賴信息如下:

<dependency>
    <groupId>com.aliyun</groupId>
    <artifactId>alibabacloud-secretsmanager-client</artifactId>
    <version>x.x.x</version>
</dependency>
說(shuō)明

憑據(jù)管家Java客戶端具體版本,請(qǐng)參見(jiàn)alibabacloud-secretsmanager-client-java

示例代碼

說(shuō)明

阿里云賬號(hào)AccessKey擁有所有OpenAPI的訪問(wèn)權(quán)限,建議您使用RAM用戶進(jìn)行API訪問(wèn)或日常運(yùn)維。強(qiáng)烈建議不要把AccessKey ID和AccessKey Secret保存到工程代碼里,否則可能導(dǎo)致AccessKey泄露,威脅您賬號(hào)下所有資源的安全。

本示例以將AccessKey配置在環(huán)境變量ALIBABA_CLOUD_ACCESS_KEY_ID和ALIBABA_CLOUD_ACCESS_KEY_SECRET的方式來(lái)實(shí)現(xiàn)身份驗(yàn)證為例。

  • 通過(guò)配置文件(secretsmanager.properties)構(gòu)建客戶端

    建議您采用基于Client Key的應(yīng)用接入點(diǎn),通過(guò)憑據(jù)管家Java SDK使用Client Key。關(guān)于如何創(chuàng)建Client Key,請(qǐng)參見(jiàn)為AAP綁定Client Key

    憑據(jù)管家Java客戶端在1.1.8及以上版本支持基于Client Key應(yīng)用接入點(diǎn)訪問(wèn)憑據(jù)管家,需要配置以下配置文件:

    ## 配置訪問(wèn)方式。
    credentials_type=client_key
    
    ## 讀取Client Key的解密密碼:支持從環(huán)境變量或者文件讀取。
    client_key_password_from_env_variable=#your client key private key password environment variable name#
    client_key_password_from_file_path=#your client key private key password file path#
    
    ## 獲取Client Key的私鑰文件。
    client_key_private_key_path=#your client key private key file path#
    
    ## 配置關(guān)聯(lián)的KMS地域。
    cache_client_region_id=[{"regionId":"#regionId#"}]

    通過(guò)配置文件(secretsmanager.properties)構(gòu)建客戶端的示例代碼如下:

    import com.aliyuncs.kms.secretsmanager.client.SecretCacheClient;
    import com.aliyuncs.kms.secretsmanager.client.SecretCacheClientBuilder;
    import com.aliyuncs.kms.secretsmanager.client.exception.CacheSecretException;
    import com.aliyuncs.kms.secretsmanager.client.model.SecretInfo;
    
    public class CacheClientEnvironmentSample {
    
        public static void main(String[] args) {
            try {
                SecretCacheClient client = SecretCacheClientBuilder.newClient();
                SecretInfo secretInfo = client.getSecretInfo("#secretName#");
                System.out.println(secretInfo);
            } catch (CacheSecretException e) {
                e.printStackTrace();
            }
        }
    }
  • 通過(guò)指定參數(shù)(Access Key、Access Secret、RegionID等)構(gòu)建客戶端

    import com.aliyuncs.kms.secretsmanager.client.SecretCacheClient;
    import com.aliyuncs.kms.secretsmanager.client.SecretCacheClientBuilder;
    import com.aliyuncs.kms.secretsmanager.client.exception.CacheSecretException;
    import com.aliyuncs.kms.secretsmanager.client.model.SecretInfo;
    import com.aliyuncs.kms.secretsmanager.client.service.BaseSecretManagerClientBuilder;
    import com.aliyuncs.kms.secretsmanager.client.utils.CredentialsProviderUtils;
    
    public class CacheClientSimpleParametersSample {
    
        public static void main(String[] args) {
            try {
                SecretCacheClient client = SecretCacheClientBuilder.newCacheClientBuilder(
                        BaseSecretManagerClientBuilder.standard().withCredentialsProvider(CredentialsProviderUtils
                                .withAccessKey(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"), System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"))).withRegion("#regionId#").build()).build();
                SecretInfo secretInfo = client.getSecretInfo("#secretName#");
                System.out.println(secretInfo);
            } catch (CacheSecretException e) {
                e.printStackTrace();
            }
        }
    }
  • 通過(guò)自定義參數(shù)構(gòu)建客戶端

    import com.aliyuncs.kms.secretsmanager.client.SecretCacheClient;
    import com.aliyuncs.kms.secretsmanager.client.SecretCacheClientBuilder;
    import com.aliyuncs.kms.secretsmanager.client.cache.FileCacheSecretStoreStrategy;
    import com.aliyuncs.kms.secretsmanager.client.exception.CacheSecretException;
    import com.aliyuncs.kms.secretsmanager.client.model.SecretInfo;
    import com.aliyuncs.kms.secretsmanager.client.service.BaseSecretManagerClientBuilder;
    import com.aliyuncs.kms.secretsmanager.client.service.DefaultRefreshSecretStrategy;
    import com.aliyuncs.kms.secretsmanager.client.service.FullJitterBackoffStrategy;
    import com.aliyuncs.kms.secretsmanager.client.utils.CredentialsProviderUtils;
    
    public class CacheClientDetailParametersSample {
    
        public static void main(String[] args) {
            try {
                SecretCacheClient client = SecretCacheClientBuilder.newCacheClientBuilder(BaseSecretManagerClientBuilder.standard()
                        .withCredentialsProvider(CredentialsProviderUtils.withAccessKey(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"), System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET")))
                        .withRegion("#regionId#")
                        .withBackoffStrategy(new FullJitterBackoffStrategy(3, 2000, 10000)).build())
                        .withCacheSecretStrategy(new FileCacheSecretStoreStrategy("#cacheSecretPath#", true, "#salt#"))
                        .withRefreshSecretStrategy(new DefaultRefreshSecretStrategy("#ttlName#"))
                        .withCacheStage("#stage#")
                        .withSecretTTL("#secretName#", 1 * 60 * 1000l)
                        .withSecretTTL("#secretName1#", 2 * 60 * 1000l).build();
                SecretInfo secretInfo = client.getSecretInfo("#secretName#");
                System.out.println(secretInfo);
            } catch (CacheSecretException e) {
                e.printStackTrace();
            }
        }
    }

憑據(jù)管家Python客戶端

安裝SDK

憑據(jù)管家客戶端支持Python語(yǔ)言,您可以訪問(wèn)SecretsManager Client for Python開(kāi)源代碼倉(cāng)庫(kù)了解更多代碼信息。

您可以執(zhí)行如下pip安裝命令,在項(xiàng)目中使用憑據(jù)管家Python客戶端。

pip install aliyun-secret-manager-client
說(shuō)明

憑據(jù)管家Python客戶端具體版本,請(qǐng)參見(jiàn)aliyun-secretsmanager-client-python

示例代碼

說(shuō)明

阿里云賬號(hào)AccessKey擁有所有OpenAPI的訪問(wèn)權(quán)限,建議您使用RAM用戶進(jìn)行API訪問(wèn)或日常運(yùn)維。強(qiáng)烈建議不要把AccessKey ID和AccessKey Secret保存到工程代碼里,否則可能導(dǎo)致AccessKey泄露,威脅您賬號(hào)下所有資源的安全。

本示例以將AccessKey配置在環(huán)境變量ALIBABA_CLOUD_ACCESS_KEY_ID和ALIBABA_CLOUD_ACCESS_KEY_SECRET的方式來(lái)實(shí)現(xiàn)身份驗(yàn)證為例。

  • 通過(guò)系統(tǒng)環(huán)境變量構(gòu)建客戶端

    from alibaba_cloud_secretsmanager_client.secret_manager_cache_client_builder import SecretManagerCacheClientBuilder
    
    if __name__ == '__main__':
        secret_cache_client = SecretManagerCacheClientBuilder.new_client()
        secret_info = secret_cache_client.get_secret_info("#secretName#")
        print(secret_info.__dict__)
  • 通過(guò)指定參數(shù)(Access Key、Access Secret、RegionID等)構(gòu)建客戶端

    from alibaba_cloud_secretsmanager_client.secret_manager_cache_client_builder import SecretManagerCacheClientBuilder
    from alibaba_cloud_secretsmanager_client.service.default_secret_manager_client_builder import DefaultSecretManagerClientBuilder
    
    if __name__ == '__main__':
        secret_cache_client = SecretManagerCacheClientBuilder.new_cache_client_builder(DefaultSecretManagerClientBuilder.standard() \
            .with_access_key(os.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"), os.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET")) \
            .with_region("#regionId#").build()) \
        .build();
        secret_info = secret_cache_client.get_secret_info("#secretName#")
        print(secret_info.__dict__)
  • 通過(guò)自定義參數(shù)構(gòu)建客戶端

    from alibaba_cloud_secretsmanager_client.secret_manager_cache_client_builder import SecretManagerCacheClientBuilder
    from alibaba_cloud_secretsmanager_client.cache.file_cache_secret_store_strategy import FileCacheSecretStoreStrategy
    from alibaba_cloud_secretsmanager_client.service.default_secret_manager_client_builder import DefaultSecretManagerClientBuilder
    from alibaba_cloud_secretsmanager_client.service.default_refresh_secret_strategy import DefaultRefreshSecretStrategy
    from alibaba_cloud_secretsmanager_client.service.full_jitter_back_off_strategy import FullJitterBackoffStrategy
    
    if __name__ == '__main__':
        secret_cache_client = SecretManagerCacheClientBuilder \
        .new_cache_client_builder(DefaultSecretManagerClientBuilder.standard().with_access_key(os.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"), os.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET")) \
             .with_back_off_strategy(FullJitterBackoffStrategy(3, 2000, 10000)) \
             .with_region("#regionId#").build()) \
         .with_cache_secret_strategy(FileCacheSecretStoreStrategy("#cacheSecretPath#", True,"#salt#")) \
         .with_refresh_secret_strategy(DefaultRefreshSecretStrategy("#ttlName#")) \
         .with_cache_stage("#stage#") \
         .with_secret_ttl("#secretName#", 1 * 60 * 1000) \
         .build()
        secret_info = secret_cache_client.get_secret_info("#secretName#")
        print(secret_info.__dict__)

憑據(jù)管家Go客戶端

安裝SDK

憑據(jù)管家客戶端支持Go語(yǔ)言,您可以訪問(wèn)SecretsManager Client for Go開(kāi)源代碼倉(cāng)庫(kù)了解更多代碼信息。

您可以執(zhí)行如下安裝命令,在項(xiàng)目中使用憑據(jù)管家Go客戶端。

 go get -u github.com/aliyun/aliyun-secretsmanager-client-go
說(shuō)明

憑據(jù)管家Go客戶端具體版本,請(qǐng)參見(jiàn)aliyun-secretsmanager-client-go

示例代碼

說(shuō)明

阿里云賬號(hào)AccessKey擁有所有OpenAPI的訪問(wèn)權(quán)限,建議您使用RAM用戶進(jìn)行API訪問(wèn)或日常運(yùn)維。強(qiáng)烈建議不要把AccessKey ID和AccessKey Secret保存到工程代碼里,否則可能導(dǎo)致AccessKey泄露,威脅您賬號(hào)下所有資源的安全。

本示例以將AccessKey配置在環(huán)境變量ALIBABA_CLOUD_ACCESS_KEY_ID和ALIBABA_CLOUD_ACCESS_KEY_SECRET的方式來(lái)實(shí)現(xiàn)身份驗(yàn)證為例。

  • 通過(guò)配置文件(secretsmanager.properties)構(gòu)建客戶端

    建議您采用基于Client Key的應(yīng)用接入點(diǎn),通過(guò)憑據(jù)管家Go SDK使用Client Key。關(guān)于如何創(chuàng)建Client Key,請(qǐng)參見(jiàn)為AAP綁定Client Key

    憑據(jù)管家Go客戶端在v1.0.1及以上版本支持基于Client Key應(yīng)用接入點(diǎn)訪問(wèn)憑據(jù)管家,需要配置以下配置文件:

    ## 配置訪問(wèn)方式。
    credentials_type=client_key
    
    ## 讀取Client Key的解密密碼:支持從環(huán)境變量或者文件讀取。
    client_key_password_from_env_variable=#your client key private key password environment variable name#
    client_key_password_from_file_path=#your client key private key password file path#
    
    ## 獲取Client Key的私鑰文件。
    client_key_private_key_path=#your client key private key file path#
    
    ## 配置關(guān)聯(lián)的KMS地域。
    cache_client_region_id=[{"regionId":"#regionId#"}]

    通過(guò)配置文件(secretsmanager.properties)構(gòu)建客戶端的示例代碼如下:

    package main
    
    import (
        "fmt"
        "github.com/aliyun/aliyun-secretsmanager-client-go/sdk"
    )
    
    func main() {
        client, err := sdk.NewClient()
        if err != nil {
            // Handle exceptions
            panic(err)
        }
        secretInfo, err := client.GetSecretInfo("#secretName#")
        if err != nil {
            // Handle exceptions
            panic(err)
        }
        fmt.Printf("SecretValue:%s\n",secretInfo.SecretValue)
    }
  • 通過(guò)指定參數(shù)(Access Key、Access Secret、RegionID等)構(gòu)建客戶端

    package main
    
    import (
        "fmt"
        "github.com/aliyun/aliyun-secretsmanager-client-go/sdk/service"
        "github.com/aliyun/aliyun-secretsmanager-client-go/sdk"
    )
    
    func main() {
        client, err := sdk.NewSecretCacheClientBuilder(service.NewDefaultSecretManagerClientBuilder().Standard().WithAccessKey(os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"), os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET")).WithRegion("#regionId#").Build()).Build()
        if err != nil {
            // Handle exceptions
            panic(err)
        }
        secretInfo, err := client.GetSecretInfo("#secretName#")
        if err != nil {
            // Handle exceptions
            panic(err)
        }
        fmt.Printf("SecretValue:%s\n",secretInfo.SecretValue)
    }
  • 通過(guò)自定義參數(shù)構(gòu)建客戶端

    package main
    
    import (
        "fmt"
        "github.com/aliyun/aliyun-secretsmanager-client-go/sdk/service"
        "github.com/aliyun/aliyun-secretsmanager-client-go/sdk"
        "github.com/aliyun/aliyun-secretsmanager-client-go/sdk/cache"
    )
    
    func main() {
        client, err := sdk.NewSecretCacheClientBuilder(
            service.NewDefaultSecretManagerClientBuilder().Standard().WithAccessKey(os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"), os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET")).WithRegion("#regionId#").WithBackoffStrategy(&service.FullJitterBackoffStrategy{RetryMaxAttempts: 3, RetryInitialIntervalMills: 2000, Capacity: 10000}).Build()).WithCacheSecretStrategy(cache.NewFileCacheSecretStoreStrategy("#cacheSecretPath#", true, "#salt#")).WithRefreshSecretStrategy(service.NewDefaultRefreshSecretStrategy("#jsonTTLPropertyName#")).WithCacheStage("ACSCurrent").WithSecretTTL("#secretName#", 1*60*1000).Build()
        if err != nil {
            // Handle exceptions
            panic(err)
        }
        secretInfo, err := client.GetSecretInfo("#secretName#")
        if err != nil {
            // Handle exceptions
            panic(err)
        }
        fmt.Printf("SecretValue:%s\n",secretInfo.SecretValue)
    }