Search in sources :

Example 31 with KeyManagementServiceClient

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

the class AsyncGetKeyRing method asyncGetKeyRing.

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

Example 32 with KeyManagementServiceClient

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

the class SyncGetLocation method syncGetLocation.

public static void syncGetLocation() throws Exception {
    // It may require modifications to work in your environment.
    try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
        GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
        Location response = keyManagementServiceClient.getLocation(request);
    }
}
Also used : GetLocationRequest(com.google.cloud.location.GetLocationRequest) KeyManagementServiceClient(com.google.cloud.kms.v1.KeyManagementServiceClient) Location(com.google.cloud.location.Location)

Example 33 with KeyManagementServiceClient

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

the class AsyncAsymmetricDecrypt method asyncAsymmetricDecrypt.

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

Example 34 with KeyManagementServiceClient

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

the class SyncAsymmetricDecrypt method syncAsymmetricDecrypt.

public static void syncAsymmetricDecrypt() throws Exception {
    // It may require modifications to work in your environment.
    try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
        AsymmetricDecryptRequest request = AsymmetricDecryptRequest.newBuilder().setName(CryptoKeyVersionName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]").toString()).setCiphertext(ByteString.EMPTY).setCiphertextCrc32C(Int64Value.newBuilder().build()).build();
        AsymmetricDecryptResponse response = keyManagementServiceClient.asymmetricDecrypt(request);
    }
}
Also used : AsymmetricDecryptRequest(com.google.cloud.kms.v1.AsymmetricDecryptRequest) AsymmetricDecryptResponse(com.google.cloud.kms.v1.AsymmetricDecryptResponse) KeyManagementServiceClient(com.google.cloud.kms.v1.KeyManagementServiceClient)

Example 35 with KeyManagementServiceClient

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

the class SyncAsymmetricSignStringDigest method syncAsymmetricSignStringDigest.

public static void syncAsymmetricSignStringDigest() throws Exception {
    // It may require modifications to work in your environment.
    try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
        String name = CryptoKeyVersionName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]").toString();
        Digest digest = Digest.newBuilder().build();
        AsymmetricSignResponse response = keyManagementServiceClient.asymmetricSign(name, digest);
    }
}
Also used : Digest(com.google.cloud.kms.v1.Digest) AsymmetricSignResponse(com.google.cloud.kms.v1.AsymmetricSignResponse) 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