Search in sources :

Example 26 with KeyManagementServiceClient

use of com.google.cloud.kms.v1.KeyManagementServiceClient in project gapic-generator-java by googleapis.

the class AsyncGetCryptoKeyVersion method asyncGetCryptoKeyVersion.

public static void asyncGetCryptoKeyVersion() throws Exception {
    // It may require modifications to work in your environment.
    try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
        GetCryptoKeyVersionRequest request = GetCryptoKeyVersionRequest.newBuilder().setName(CryptoKeyVersionName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]").toString()).build();
        ApiFuture<CryptoKeyVersion> future = keyManagementServiceClient.getCryptoKeyVersionCallable().futureCall(request);
        // Do something.
        CryptoKeyVersion response = future.get();
    }
}
Also used : GetCryptoKeyVersionRequest(com.google.cloud.kms.v1.GetCryptoKeyVersionRequest) CryptoKeyVersion(com.google.cloud.kms.v1.CryptoKeyVersion) KeyManagementServiceClient(com.google.cloud.kms.v1.KeyManagementServiceClient)

Example 27 with KeyManagementServiceClient

use of com.google.cloud.kms.v1.KeyManagementServiceClient in project gapic-generator-java by googleapis.

the class SyncGetCryptoKeyVersion method syncGetCryptoKeyVersion.

public static void syncGetCryptoKeyVersion() throws Exception {
    // It may require modifications to work in your environment.
    try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
        GetCryptoKeyVersionRequest request = GetCryptoKeyVersionRequest.newBuilder().setName(CryptoKeyVersionName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]").toString()).build();
        CryptoKeyVersion response = keyManagementServiceClient.getCryptoKeyVersion(request);
    }
}
Also used : GetCryptoKeyVersionRequest(com.google.cloud.kms.v1.GetCryptoKeyVersionRequest) CryptoKeyVersion(com.google.cloud.kms.v1.CryptoKeyVersion) KeyManagementServiceClient(com.google.cloud.kms.v1.KeyManagementServiceClient)

Example 28 with KeyManagementServiceClient

use of com.google.cloud.kms.v1.KeyManagementServiceClient in project gapic-generator-java by googleapis.

the class AsyncGetIamPolicy method asyncGetIamPolicy.

public static void asyncGetIamPolicy() throws Exception {
    // It may require modifications to work in your environment.
    try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
        GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder().setResource(CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]").toString()).setOptions(GetPolicyOptions.newBuilder().build()).build();
        ApiFuture<Policy> future = keyManagementServiceClient.getIamPolicyCallable().futureCall(request);
        // Do something.
        Policy response = future.get();
    }
}
Also used : Policy(com.google.iam.v1.Policy) GetIamPolicyRequest(com.google.iam.v1.GetIamPolicyRequest) KeyManagementServiceClient(com.google.cloud.kms.v1.KeyManagementServiceClient)

Example 29 with KeyManagementServiceClient

use of com.google.cloud.kms.v1.KeyManagementServiceClient in project gapic-generator-java by googleapis.

the class SyncEncryptResourcenameBytestring method syncEncryptResourcenameBytestring.

public static void syncEncryptResourcenameBytestring() throws Exception {
    // It may require modifications to work in your environment.
    try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
        ResourceName name = CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]");
        ByteString plaintext = ByteString.EMPTY;
        EncryptResponse response = keyManagementServiceClient.encrypt(name, plaintext);
    }
}
Also used : EncryptResponse(com.google.cloud.kms.v1.EncryptResponse) ResourceName(com.google.api.resourcenames.ResourceName) ByteString(com.google.protobuf.ByteString) KeyManagementServiceClient(com.google.cloud.kms.v1.KeyManagementServiceClient)

Example 30 with KeyManagementServiceClient

use of com.google.cloud.kms.v1.KeyManagementServiceClient in project gapic-generator-java by googleapis.

the class SyncGetImportJobString method syncGetImportJobString.

public static void syncGetImportJobString() throws Exception {
    // It may require modifications to work in your environment.
    try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
        String name = ImportJobName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[IMPORT_JOB]").toString();
        ImportJob response = keyManagementServiceClient.getImportJob(name);
    }
}
Also used : ImportJob(com.google.cloud.kms.v1.ImportJob) KeyManagementServiceClient(com.google.cloud.kms.v1.KeyManagementServiceClient)

Aggregations

KeyManagementServiceClient (com.google.cloud.kms.v1.KeyManagementServiceClient)185 CryptoKey (com.google.cloud.kms.v1.CryptoKey)56 CryptoKeyVersion (com.google.cloud.kms.v1.CryptoKeyVersion)39 CryptoKeyVersionName (com.google.cloud.kms.v1.CryptoKeyVersionName)37 CryptoKeyName (com.google.cloud.kms.v1.CryptoKeyName)33 ByteString (com.google.protobuf.ByteString)20 KeyRingName (com.google.cloud.kms.v1.KeyRingName)17 KeyRing (com.google.cloud.kms.v1.KeyRing)16 FieldMask (com.google.protobuf.FieldMask)16 PublicKey (com.google.cloud.kms.v1.PublicKey)14 ImportJob (com.google.cloud.kms.v1.ImportJob)10 Test (org.junit.Test)10 Digest (com.google.cloud.kms.v1.Digest)8 EncryptResponse (com.google.cloud.kms.v1.EncryptResponse)8 Policy (com.google.iam.v1.Policy)8 X509EncodedKeySpec (java.security.spec.X509EncodedKeySpec)8 DecryptResponse (com.google.cloud.kms.v1.DecryptResponse)7 AsymmetricDecryptResponse (com.google.cloud.kms.v1.AsymmetricDecryptResponse)6 AsymmetricSignResponse (com.google.cloud.kms.v1.AsymmetricSignResponse)6 LocationName (com.google.cloud.kms.v1.LocationName)6