software.amazon.awssdk.services.kms.model.GenerateDataKeyPairWithoutPlaintextResponse Maven / Gradle / Ivy
Show all versions of kms Show documentation
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package software.amazon.awssdk.services.kms.model;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkBytes;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*/
@Generated("software.amazon.awssdk:codegen")
public final class GenerateDataKeyPairWithoutPlaintextResponse extends KmsResponse implements
ToCopyableBuilder {
private static final SdkField PRIVATE_KEY_CIPHERTEXT_BLOB_FIELD = SdkField
. builder(MarshallingType.SDK_BYTES).memberName("PrivateKeyCiphertextBlob")
.getter(getter(GenerateDataKeyPairWithoutPlaintextResponse::privateKeyCiphertextBlob))
.setter(setter(Builder::privateKeyCiphertextBlob))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PrivateKeyCiphertextBlob").build())
.build();
private static final SdkField PUBLIC_KEY_FIELD = SdkField. builder(MarshallingType.SDK_BYTES)
.memberName("PublicKey").getter(getter(GenerateDataKeyPairWithoutPlaintextResponse::publicKey))
.setter(setter(Builder::publicKey))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PublicKey").build()).build();
private static final SdkField KEY_ID_FIELD = SdkField. builder(MarshallingType.STRING).memberName("KeyId")
.getter(getter(GenerateDataKeyPairWithoutPlaintextResponse::keyId)).setter(setter(Builder::keyId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("KeyId").build()).build();
private static final SdkField KEY_PAIR_SPEC_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("KeyPairSpec").getter(getter(GenerateDataKeyPairWithoutPlaintextResponse::keyPairSpecAsString))
.setter(setter(Builder::keyPairSpec))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("KeyPairSpec").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(
PRIVATE_KEY_CIPHERTEXT_BLOB_FIELD, PUBLIC_KEY_FIELD, KEY_ID_FIELD, KEY_PAIR_SPEC_FIELD));
private final SdkBytes privateKeyCiphertextBlob;
private final SdkBytes publicKey;
private final String keyId;
private final String keyPairSpec;
private GenerateDataKeyPairWithoutPlaintextResponse(BuilderImpl builder) {
super(builder);
this.privateKeyCiphertextBlob = builder.privateKeyCiphertextBlob;
this.publicKey = builder.publicKey;
this.keyId = builder.keyId;
this.keyPairSpec = builder.keyPairSpec;
}
/**
*
* The encrypted copy of the private key. When you use the HTTP API or the Amazon Web Services CLI, the value is
* Base64-encoded. Otherwise, it is not Base64-encoded.
*
*
* @return The encrypted copy of the private key. When you use the HTTP API or the Amazon Web Services CLI, the
* value is Base64-encoded. Otherwise, it is not Base64-encoded.
*/
public final SdkBytes privateKeyCiphertextBlob() {
return privateKeyCiphertextBlob;
}
/**
*
* The public key (in plaintext). When you use the HTTP API or the Amazon Web Services CLI, the value is
* Base64-encoded. Otherwise, it is not Base64-encoded.
*
*
* @return The public key (in plaintext). When you use the HTTP API or the Amazon Web Services CLI, the value is
* Base64-encoded. Otherwise, it is not Base64-encoded.
*/
public final SdkBytes publicKey() {
return publicKey;
}
/**
*
* The Amazon Resource Name (key ARN) of the KMS
* key that encrypted the private key.
*
*
* @return The Amazon Resource Name (key ARN) of
* the KMS key that encrypted the private key.
*/
public final String keyId() {
return keyId;
}
/**
*
* The type of data key pair that was generated.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #keyPairSpec} will
* return {@link DataKeyPairSpec#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #keyPairSpecAsString}.
*
*
* @return The type of data key pair that was generated.
* @see DataKeyPairSpec
*/
public final DataKeyPairSpec keyPairSpec() {
return DataKeyPairSpec.fromValue(keyPairSpec);
}
/**
*
* The type of data key pair that was generated.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #keyPairSpec} will
* return {@link DataKeyPairSpec#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #keyPairSpecAsString}.
*
*
* @return The type of data key pair that was generated.
* @see DataKeyPairSpec
*/
public final String keyPairSpecAsString() {
return keyPairSpec;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + super.hashCode();
hashCode = 31 * hashCode + Objects.hashCode(privateKeyCiphertextBlob());
hashCode = 31 * hashCode + Objects.hashCode(publicKey());
hashCode = 31 * hashCode + Objects.hashCode(keyId());
hashCode = 31 * hashCode + Objects.hashCode(keyPairSpecAsString());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return super.equals(obj) && equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof GenerateDataKeyPairWithoutPlaintextResponse)) {
return false;
}
GenerateDataKeyPairWithoutPlaintextResponse other = (GenerateDataKeyPairWithoutPlaintextResponse) obj;
return Objects.equals(privateKeyCiphertextBlob(), other.privateKeyCiphertextBlob())
&& Objects.equals(publicKey(), other.publicKey()) && Objects.equals(keyId(), other.keyId())
&& Objects.equals(keyPairSpecAsString(), other.keyPairSpecAsString());
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*/
@Override
public final String toString() {
return ToString.builder("GenerateDataKeyPairWithoutPlaintextResponse")
.add("PrivateKeyCiphertextBlob", privateKeyCiphertextBlob()).add("PublicKey", publicKey()).add("KeyId", keyId())
.add("KeyPairSpec", keyPairSpecAsString()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "PrivateKeyCiphertextBlob":
return Optional.ofNullable(clazz.cast(privateKeyCiphertextBlob()));
case "PublicKey":
return Optional.ofNullable(clazz.cast(publicKey()));
case "KeyId":
return Optional.ofNullable(clazz.cast(keyId()));
case "KeyPairSpec":
return Optional.ofNullable(clazz.cast(keyPairSpecAsString()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function