Search in sources :

Example 16 with KeyManagementServiceClient

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

the class SyncDecrypt method syncDecrypt.

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

Example 17 with KeyManagementServiceClient

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

the class SyncCreateSetEndpoint method syncCreateSetEndpoint.

public static void syncCreateSetEndpoint() throws Exception {
    // This snippet has been automatically generated for illustrative purposes only.
    // It may require modifications to work in your environment.
    KeyManagementServiceSettings keyManagementServiceSettings = KeyManagementServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
    KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create(keyManagementServiceSettings);
}
Also used : KeyManagementServiceSettings(com.google.cloud.kms.v1.KeyManagementServiceSettings) KeyManagementServiceClient(com.google.cloud.kms.v1.KeyManagementServiceClient)

Example 18 with KeyManagementServiceClient

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

the class AsyncCreateCryptoKey method asyncCreateCryptoKey.

public static void asyncCreateCryptoKey() throws Exception {
    // It may require modifications to work in your environment.
    try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
        CreateCryptoKeyRequest request = CreateCryptoKeyRequest.newBuilder().setParent(KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]").toString()).setCryptoKeyId("cryptoKeyId-1643185255").setCryptoKey(CryptoKey.newBuilder().build()).setSkipInitialVersionCreation(true).build();
        ApiFuture<CryptoKey> future = keyManagementServiceClient.createCryptoKeyCallable().futureCall(request);
        // Do something.
        CryptoKey response = future.get();
    }
}
Also used : CryptoKey(com.google.cloud.kms.v1.CryptoKey) CreateCryptoKeyRequest(com.google.cloud.kms.v1.CreateCryptoKeyRequest) KeyManagementServiceClient(com.google.cloud.kms.v1.KeyManagementServiceClient)

Example 19 with KeyManagementServiceClient

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

the class SyncCreateCryptoKey method syncCreateCryptoKey.

public static void syncCreateCryptoKey() throws Exception {
    // It may require modifications to work in your environment.
    try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
        CreateCryptoKeyRequest request = CreateCryptoKeyRequest.newBuilder().setParent(KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]").toString()).setCryptoKeyId("cryptoKeyId-1643185255").setCryptoKey(CryptoKey.newBuilder().build()).setSkipInitialVersionCreation(true).build();
        CryptoKey response = keyManagementServiceClient.createCryptoKey(request);
    }
}
Also used : CryptoKey(com.google.cloud.kms.v1.CryptoKey) CreateCryptoKeyRequest(com.google.cloud.kms.v1.CreateCryptoKeyRequest) KeyManagementServiceClient(com.google.cloud.kms.v1.KeyManagementServiceClient)

Example 20 with KeyManagementServiceClient

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

the class SyncCreateCryptoKeyKeyringnameStringCryptokey method syncCreateCryptoKeyKeyringnameStringCryptokey.

public static void syncCreateCryptoKeyKeyringnameStringCryptokey() throws Exception {
    // It may require modifications to work in your environment.
    try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
        KeyRingName parent = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]");
        String cryptoKeyId = "cryptoKeyId-1643185255";
        CryptoKey cryptoKey = CryptoKey.newBuilder().build();
        CryptoKey response = keyManagementServiceClient.createCryptoKey(parent, cryptoKeyId, cryptoKey);
    }
}
Also used : CryptoKey(com.google.cloud.kms.v1.CryptoKey) KeyRingName(com.google.cloud.kms.v1.KeyRingName) 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