Class CryptoKey (2.57.0)

public final class CryptoKey extends GeneratedMessageV3 implements CryptoKeyOrBuilder

A CryptoKey represents a logical key that can be used for cryptographic operations.

A CryptoKey is made up of zero or more versions, which represent the actual key material used in cryptographic operations.

Protobuf type google.cloud.kms.v1.CryptoKey

Implements

CryptoKeyOrBuilder

Static Fields

CREATE_TIME_FIELD_NUMBER

public static final int CREATE_TIME_FIELD_NUMBER
Field Value
Type Description
int

CRYPTO_KEY_BACKEND_FIELD_NUMBER

public static final int CRYPTO_KEY_BACKEND_FIELD_NUMBER
Field Value
Type Description
int

DESTROY_SCHEDULED_DURATION_FIELD_NUMBER

public static final int DESTROY_SCHEDULED_DURATION_FIELD_NUMBER
Field Value
Type Description
int

IMPORT_ONLY_FIELD_NUMBER

public static final int IMPORT_ONLY_FIELD_NUMBER
Field Value
Type Description
int

KEY_ACCESS_JUSTIFICATIONS_POLICY_FIELD_NUMBER

public static final int KEY_ACCESS_JUSTIFICATIONS_POLICY_FIELD_NUMBER
Field Value
Type Description
int

LABELS_FIELD_NUMBER

public static final int LABELS_FIELD_NUMBER
Field Value
Type Description
int

NAME_FIELD_NUMBER

public static final int NAME_FIELD_NUMBER
Field Value
Type Description
int

NEXT_ROTATION_TIME_FIELD_NUMBER

public static final int NEXT_ROTATION_TIME_FIELD_NUMBER
Field Value
Type Description
int

PRIMARY_FIELD_NUMBER

public static final int PRIMARY_FIELD_NUMBER
Field Value
Type Description
int

PURPOSE_FIELD_NUMBER

public static final int PURPOSE_FIELD_NUMBER
Field Value
Type Description
int

ROTATION_PERIOD_FIELD_NUMBER

public static final int ROTATION_PERIOD_FIELD_NUMBER
Field Value
Type Description
int

VERSION_TEMPLATE_FIELD_NUMBER

public static final int VERSION_TEMPLATE_FIELD_NUMBER
Field Value
Type Description
int

Static Methods

getDefaultInstance()

public static CryptoKey getDefaultInstance()
Returns
Type Description
CryptoKey

getDescriptor()

public static final Descriptors.Descriptor getDescriptor()
Returns
Type Description
Descriptor

newBuilder()

public static CryptoKey.Builder newBuilder()
Returns
Type Description
CryptoKey.Builder

newBuilder(CryptoKey prototype)

public static CryptoKey.Builder newBuilder(CryptoKey prototype)
Parameter
Name Description
prototype CryptoKey
Returns
Type Description
CryptoKey.Builder

parseDelimitedFrom(InputStream input)

public static CryptoKey parseDelimitedFrom(InputStream input)
Parameter
Name Description
input InputStream
Returns
Type Description
CryptoKey
Exceptions
Type Description
IOException

parseDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

public static CryptoKey parseDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
input InputStream
extensionRegistry ExtensionRegistryLite
Returns
Type Description
CryptoKey
Exceptions
Type Description
IOException

parseFrom(byte[] data)

public static CryptoKey parseFrom(byte[] data)
Parameter
Name Description
data byte[]
Returns
Type Description
CryptoKey
Exceptions
Type Description
InvalidProtocolBufferException

parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry)

public static CryptoKey parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
data byte[]
extensionRegistry ExtensionRegistryLite
Returns
Type Description
CryptoKey
Exceptions
Type Description
InvalidProtocolBufferException

parseFrom(ByteString data)

public static CryptoKey parseFrom(ByteString data)
Parameter
Name Description
data ByteString
Returns
Type Description
CryptoKey
Exceptions
Type Description
InvalidProtocolBufferException

parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry)

public static CryptoKey parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
data ByteString
extensionRegistry ExtensionRegistryLite
Returns
Type Description
CryptoKey
Exceptions
Type Description
InvalidProtocolBufferException

parseFrom(CodedInputStream input)

public static CryptoKey parseFrom(CodedInputStream input)
Parameter
Name Description
input CodedInputStream
Returns
Type Description
CryptoKey
Exceptions
Type Description
IOException

parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)

public static CryptoKey parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
input CodedInputStream
extensionRegistry ExtensionRegistryLite
Returns
Type Description
CryptoKey
Exceptions
Type Description
IOException

parseFrom(InputStream input)

public static CryptoKey parseFrom(InputStream input)
Parameter
Name Description
input InputStream
Returns
Type Description
CryptoKey
Exceptions
Type Description
IOException

parseFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

public static CryptoKey parseFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
input InputStream
extensionRegistry ExtensionRegistryLite
Returns
Type Description
CryptoKey
Exceptions
Type Description
IOException

parseFrom(ByteBuffer data)

public static CryptoKey parseFrom(ByteBuffer data)
Parameter
Name Description
data ByteBuffer
Returns
Type Description
CryptoKey
Exceptions
Type Description
InvalidProtocolBufferException

parseFrom(ByteBuffer data, ExtensionRegistryLite extensionRegistry)

public static CryptoKey parseFrom(ByteBuffer data, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
data ByteBuffer
extensionRegistry ExtensionRegistryLite
Returns
Type Description
CryptoKey
Exceptions
Type Description
InvalidProtocolBufferException

parser()

public static Parser<CryptoKey> parser()
Returns
Type Description
Parser<CryptoKey>

Methods

containsLabels(String key)

public boolean containsLabels(String key)

Labels with user-defined metadata. For more information, see Labeling Keys.

map<string, string> labels = 10;

Parameter
Name Description
key String
Returns
Type Description
boolean

equals(Object obj)

public boolean equals(Object obj)
Parameter
Name Description
obj Object
Returns
Type Description
boolean
Overrides

getCreateTime()

public Timestamp getCreateTime()

Output only. The time at which this CryptoKey was created.

.google.protobuf.Timestamp create_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY];

Returns
Type Description
Timestamp

The createTime.

getCreateTimeOrBuilder()

public TimestampOrBuilder getCreateTimeOrBuilder()

Output only. The time at which this CryptoKey was created.

.google.protobuf.Timestamp create_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY];

Returns
Type Description
TimestampOrBuilder

getCryptoKeyBackend()

public String getCryptoKeyBackend()

Immutable. The resource name of the backend environment where the key material for all CryptoKeyVersions associated with this CryptoKey reside and where all related cryptographic operations are performed. Only applicable if CryptoKeyVersions have a ProtectionLevel of EXTERNAL_VPC, with the resource name in the format projects/*/locations/*/ekmConnections/*. Note, this list is non-exhaustive and may apply to additional ProtectionLevels in the future.

string crypto_key_backend = 15 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.resource_reference) = { ... }

Returns
Type Description
String

The cryptoKeyBackend.

getCryptoKeyBackendBytes()

public ByteString getCryptoKeyBackendBytes()

Immutable. The resource name of the backend environment where the key material for all CryptoKeyVersions associated with this CryptoKey reside and where all related cryptographic operations are performed. Only applicable if CryptoKeyVersions have a ProtectionLevel of EXTERNAL_VPC, with the resource name in the format projects/*/locations/*/ekmConnections/*. Note, this list is non-exhaustive and may apply to additional ProtectionLevels in the future.

string crypto_key_backend = 15 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.resource_reference) = { ... }

Returns
Type Description
ByteString

The bytes for cryptoKeyBackend.

getDefaultInstanceForType()

public CryptoKey getDefaultInstanceForType()
Returns
Type Description
CryptoKey

getDestroyScheduledDuration()

public Duration getDestroyScheduledDuration()

Immutable. The period of time that versions of this key spend in the DESTROY_SCHEDULED state before transitioning to DESTROYED. If not specified at creation time, the default duration is 30 days.

.google.protobuf.Duration destroy_scheduled_duration = 14 [(.google.api.field_behavior) = IMMUTABLE];

Returns
Type Description
Duration

The destroyScheduledDuration.

getDestroyScheduledDurationOrBuilder()

public DurationOrBuilder getDestroyScheduledDurationOrBuilder()

Immutable. The period of time that versions of this key spend in the DESTROY_SCHEDULED state before transitioning to DESTROYED. If not specified at creation time, the default duration is 30 days.

.google.protobuf.Duration destroy_scheduled_duration = 14 [(.google.api.field_behavior) = IMMUTABLE];

Returns
Type Description
DurationOrBuilder

getImportOnly()

public boolean getImportOnly()

Immutable. Whether this key may contain imported versions only.

bool import_only = 13 [(.google.api.field_behavior) = IMMUTABLE];

Returns
Type Description
boolean

The importOnly.

getKeyAccessJustificationsPolicy()

public KeyAccessJustificationsPolicy getKeyAccessJustificationsPolicy()

Optional. The policy used for Key Access Justifications Policy Enforcement. If this field is present and this key is enrolled in Key Access Justifications Policy Enforcement, the policy will be evaluated in encrypt, decrypt, and sign operations, and the operation will fail if rejected by the policy. The policy is defined by specifying zero or more allowed justification codes. https://cloud.google.com/assured-workloads/key-access-justifications/docs/justification-codes By default, this field is absent, and all justification codes are allowed.

.google.cloud.kms.v1.KeyAccessJustificationsPolicy key_access_justifications_policy = 17 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
KeyAccessJustificationsPolicy

The keyAccessJustificationsPolicy.

getKeyAccessJustificationsPolicyOrBuilder()

public KeyAccessJustificationsPolicyOrBuilder getKeyAccessJustificationsPolicyOrBuilder()

Optional. The policy used for Key Access Justifications Policy Enforcement. If this field is present and this key is enrolled in Key Access Justifications Policy Enforcement, the policy will be evaluated in encrypt, decrypt, and sign operations, and the operation will fail if rejected by the policy. The policy is defined by specifying zero or more allowed justification codes. https://cloud.google.com/assured-workloads/key-access-justifications/docs/justification-codes By default, this field is absent, and all justification codes are allowed.

.google.cloud.kms.v1.KeyAccessJustificationsPolicy key_access_justifications_policy = 17 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
KeyAccessJustificationsPolicyOrBuilder

getLabels() (deprecated)

public Map<String,String> getLabels()

Use #getLabelsMap() instead.

Returns
Type Description
Map<String,String>

getLabelsCount()

public int getLabelsCount()

Labels with user-defined metadata. For more information, see Labeling Keys.

map<string, string> labels = 10;

Returns
Type Description
int

getLabelsMap()

public Map<String,String> getLabelsMap()

Labels with user-defined metadata. For more information, see Labeling Keys.

map<string, string> labels = 10;

Returns
Type Description
Map<String,String>

getLabelsOrDefault(String key, String defaultValue)

public String getLabelsOrDefault(String key, String defaultValue)

Labels with user-defined metadata. For more information, see Labeling Keys.

map<string, string> labels = 10;

Parameters
Name Description
key String
defaultValue String
Returns
Type Description
String

getLabelsOrThrow(String key)

public String getLabelsOrThrow(String key)

Labels with user-defined metadata. For more information, see Labeling Keys.

map<string, string> labels = 10;

Parameter
Name Description
key String
Returns
Type Description
String

getName()

public String getName()

Output only. The resource name for this CryptoKey in the format projects/*/locations/*/keyRings/*/cryptoKeys/*.

string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];

Returns
Type Description
String

The name.

getNameBytes()

public ByteString getNameBytes()

Output only. The resource name for this CryptoKey in the format projects/*/locations/*/keyRings/*/cryptoKeys/*.

string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];

Returns
Type Description
ByteString

The bytes for name.

getNextRotationTime()

public Timestamp getNextRotationTime()

At next_rotation_time, the Key Management Service will automatically:

  1. Create a new version of this CryptoKey.
  2. Mark the new version as primary.

    Key rotations performed manually via CreateCryptoKeyVersion and UpdateCryptoKeyPrimaryVersion do not affect next_rotation_time.

    Keys with purpose ENCRYPT_DECRYPT support automatic rotation. For other keys, this field must be omitted.

.google.protobuf.Timestamp next_rotation_time = 7;

Returns
Type Description
Timestamp

The nextRotationTime.

getNextRotationTimeOrBuilder()

public TimestampOrBuilder getNextRotationTimeOrBuilder()

At next_rotation_time, the Key Management Service will automatically:

  1. Create a new version of this CryptoKey.
  2. Mark the new version as primary.

    Key rotations performed manually via CreateCryptoKeyVersion and UpdateCryptoKeyPrimaryVersion do not affect next_rotation_time.

    Keys with purpose ENCRYPT_DECRYPT support automatic rotation. For other keys, this field must be omitted.

.google.protobuf.Timestamp next_rotation_time = 7;

Returns
Type Description
TimestampOrBuilder

getParserForType()

public Parser<CryptoKey> getParserForType()
Returns
Type Description
Parser<CryptoKey>
Overrides

getPrimary()

public CryptoKeyVersion getPrimary()

Output only. A copy of the "primary" CryptoKeyVersion that will be used by Encrypt when this CryptoKey is given in EncryptRequest.name.

The CryptoKey's primary version can be updated via UpdateCryptoKeyPrimaryVersion.

Keys with purpose ENCRYPT_DECRYPT may have a primary. For other keys, this field will be omitted.

.google.cloud.kms.v1.CryptoKeyVersion primary = 2 [(.google.api.field_behavior) = OUTPUT_ONLY];

Returns
Type Description
CryptoKeyVersion

The primary.

getPrimaryOrBuilder()

public CryptoKeyVersionOrBuilder getPrimaryOrBuilder()

Output only. A copy of the "primary" CryptoKeyVersion that will be used by Encrypt when this CryptoKey is given in EncryptRequest.name.

The CryptoKey's primary version can be updated via UpdateCryptoKeyPrimaryVersion.

Keys with purpose ENCRYPT_DECRYPT may have a primary. For other keys, this field will be omitted.

.google.cloud.kms.v1.CryptoKeyVersion primary = 2 [(.google.api.field_behavior) = OUTPUT_ONLY];

Returns
Type Description
CryptoKeyVersionOrBuilder

getPurpose()

public CryptoKey.CryptoKeyPurpose getPurpose()

Immutable. The immutable purpose of this CryptoKey.

.google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose purpose = 3 [(.google.api.field_behavior) = IMMUTABLE];

Returns
Type Description
CryptoKey.CryptoKeyPurpose

The purpose.

getPurposeValue()

public int getPurposeValue()

Immutable. The immutable purpose of this CryptoKey.

.google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose purpose = 3 [(.google.api.field_behavior) = IMMUTABLE];

Returns
Type Description
int

The enum numeric value on the wire for purpose.

getRotationPeriod()

public Duration getRotationPeriod()

next_rotation_time will be advanced by this period when the service automatically rotates a key. Must be at least 24 hours and at most 876,000 hours.

If rotation_period is set, next_rotation_time must also be set.

Keys with purpose ENCRYPT_DECRYPT support automatic rotation. For other keys, this field must be omitted.

.google.protobuf.Duration rotation_period = 8;

Returns
Type Description
Duration

The rotationPeriod.

getRotationPeriodOrBuilder()

public DurationOrBuilder getRotationPeriodOrBuilder()

next_rotation_time will be advanced by this period when the service automatically rotates a key. Must be at least 24 hours and at most 876,000 hours.

If rotation_period is set, next_rotation_time must also be set.

Keys with purpose ENCRYPT_DECRYPT support automatic rotation. For other keys, this field must be omitted.

.google.protobuf.Duration rotation_period = 8;

Returns
Type Description
DurationOrBuilder

getRotationScheduleCase()

public CryptoKey.RotationScheduleCase getRotationScheduleCase()
Returns
Type Description
CryptoKey.RotationScheduleCase

getSerializedSize()

public int getSerializedSize()
Returns
Type Description
int
Overrides

getVersionTemplate()

public CryptoKeyVersionTemplate getVersionTemplate()

A template describing settings for new CryptoKeyVersion instances. The properties of new CryptoKeyVersion instances created by either CreateCryptoKeyVersion or auto-rotation are controlled by this template.

.google.cloud.kms.v1.CryptoKeyVersionTemplate version_template = 11;

Returns
Type Description
CryptoKeyVersionTemplate

The versionTemplate.

getVersionTemplateOrBuilder()

public CryptoKeyVersionTemplateOrBuilder getVersionTemplateOrBuilder()

A template describing settings for new CryptoKeyVersion instances. The properties of new CryptoKeyVersion instances created by either CreateCryptoKeyVersion or auto-rotation are controlled by this template.

.google.cloud.kms.v1.CryptoKeyVersionTemplate version_template = 11;

Returns
Type Description
CryptoKeyVersionTemplateOrBuilder

hasCreateTime()

public boolean hasCreateTime()

Output only. The time at which this CryptoKey was created.

.google.protobuf.Timestamp create_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY];

Returns
Type Description
boolean

Whether the createTime field is set.

hasDestroyScheduledDuration()

public boolean hasDestroyScheduledDuration()

Immutable. The period of time that versions of this key spend in the DESTROY_SCHEDULED state before transitioning to DESTROYED. If not specified at creation time, the default duration is 30 days.

.google.protobuf.Duration destroy_scheduled_duration = 14 [(.google.api.field_behavior) = IMMUTABLE];

Returns
Type Description
boolean

Whether the destroyScheduledDuration field is set.

hasKeyAccessJustificationsPolicy()

public boolean hasKeyAccessJustificationsPolicy()

Optional. The policy used for Key Access Justifications Policy Enforcement. If this field is present and this key is enrolled in Key Access Justifications Policy Enforcement, the policy will be evaluated in encrypt, decrypt, and sign operations, and the operation will fail if rejected by the policy. The policy is defined by specifying zero or more allowed justification codes. https://cloud.google.com/assured-workloads/key-access-justifications/docs/justification-codes By default, this field is absent, and all justification codes are allowed.

.google.cloud.kms.v1.KeyAccessJustificationsPolicy key_access_justifications_policy = 17 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
boolean

Whether the keyAccessJustificationsPolicy field is set.

hasNextRotationTime()

public boolean hasNextRotationTime()

At next_rotation_time, the Key Management Service will automatically:

  1. Create a new version of this CryptoKey.
  2. Mark the new version as primary.

    Key rotations performed manually via CreateCryptoKeyVersion and UpdateCryptoKeyPrimaryVersion do not affect next_rotation_time.

    Keys with purpose ENCRYPT_DECRYPT support automatic rotation. For other keys, this field must be omitted.

.google.protobuf.Timestamp next_rotation_time = 7;

Returns
Type Description
boolean

Whether the nextRotationTime field is set.

hasPrimary()

public boolean hasPrimary()

Output only. A copy of the "primary" CryptoKeyVersion that will be used by Encrypt when this CryptoKey is given in EncryptRequest.name.

The CryptoKey's primary version can be updated via UpdateCryptoKeyPrimaryVersion.

Keys with purpose ENCRYPT_DECRYPT may have a primary. For other keys, this field will be omitted.

.google.cloud.kms.v1.CryptoKeyVersion primary = 2 [(.google.api.field_behavior) = OUTPUT_ONLY];

Returns
Type Description
boolean

Whether the primary field is set.

hasRotationPeriod()

public boolean hasRotationPeriod()

next_rotation_time will be advanced by this period when the service automatically rotates a key. Must be at least 24 hours and at most 876,000 hours.

If rotation_period is set, next_rotation_time must also be set.

Keys with purpose ENCRYPT_DECRYPT support automatic rotation. For other keys, this field must be omitted.

.google.protobuf.Duration rotation_period = 8;

Returns
Type Description
boolean

Whether the rotationPeriod field is set.

hasVersionTemplate()

public boolean hasVersionTemplate()

A template describing settings for new CryptoKeyVersion instances. The properties of new CryptoKeyVersion instances created by either CreateCryptoKeyVersion or auto-rotation are controlled by this template.

.google.cloud.kms.v1.CryptoKeyVersionTemplate version_template = 11;

Returns
Type Description
boolean

Whether the versionTemplate field is set.

hashCode()

public int hashCode()
Returns
Type Description
int
Overrides

internalGetFieldAccessorTable()

protected GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()
Returns
Type Description
FieldAccessorTable
Overrides

internalGetMapFieldReflection(int number)

protected MapFieldReflectionAccessor internalGetMapFieldReflection(int number)
Parameter
Name Description
number int
Returns
Type Description
com.google.protobuf.MapFieldReflectionAccessor
Overrides
com.google.protobuf.GeneratedMessageV3.internalGetMapFieldReflection(int)

isInitialized()

public final boolean isInitialized()
Returns
Type Description
boolean
Overrides

newBuilderForType()

public CryptoKey.Builder newBuilderForType()
Returns
Type Description
CryptoKey.Builder

newBuilderForType(GeneratedMessageV3.BuilderParent parent)

protected CryptoKey.Builder newBuilderForType(GeneratedMessageV3.BuilderParent parent)
Parameter
Name Description
parent BuilderParent
Returns
Type Description
CryptoKey.Builder
Overrides

newInstance(GeneratedMessageV3.UnusedPrivateParameter unused)

protected Object newInstance(GeneratedMessageV3.UnusedPrivateParameter unused)
Parameter
Name Description
unused UnusedPrivateParameter
Returns
Type Description
Object
Overrides

toBuilder()

public CryptoKey.Builder toBuilder()
Returns
Type Description
CryptoKey.Builder

writeTo(CodedOutputStream output)

public void writeTo(CodedOutputStream output)
Parameter
Name Description
output CodedOutputStream
Overrides
Exceptions
Type Description
IOException