All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.paymentcryptography.model.WrappedKey Maven / Gradle / Ivy

Go to download

The AWS Java SDK for Payment Cryptography module holds the client classes that are used for communicating with Payment Cryptography.

There is a newer version: 2.28.5
Show newest version
/*
 * 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.paymentcryptography.model;

import java.io.Serializable;
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.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;

/**
 * 

* Parameter information for generating a WrappedKeyBlock for key exchange. *

*/ @Generated("software.amazon.awssdk:codegen") public final class WrappedKey implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField WRAPPING_KEY_ARN_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("WrappingKeyArn").getter(getter(WrappedKey::wrappingKeyArn)).setter(setter(Builder::wrappingKeyArn)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("WrappingKeyArn").build()).build(); private static final SdkField WRAPPED_KEY_MATERIAL_FORMAT_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("WrappedKeyMaterialFormat").getter(getter(WrappedKey::wrappedKeyMaterialFormatAsString)) .setter(setter(Builder::wrappedKeyMaterialFormat)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("WrappedKeyMaterialFormat").build()) .build(); private static final SdkField KEY_MATERIAL_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("KeyMaterial").getter(getter(WrappedKey::keyMaterial)).setter(setter(Builder::keyMaterial)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("KeyMaterial").build()).build(); private static final SdkField KEY_CHECK_VALUE_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("KeyCheckValue").getter(getter(WrappedKey::keyCheckValue)).setter(setter(Builder::keyCheckValue)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("KeyCheckValue").build()).build(); private static final SdkField KEY_CHECK_VALUE_ALGORITHM_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("KeyCheckValueAlgorithm").getter(getter(WrappedKey::keyCheckValueAlgorithmAsString)) .setter(setter(Builder::keyCheckValueAlgorithm)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("KeyCheckValueAlgorithm").build()) .build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(WRAPPING_KEY_ARN_FIELD, WRAPPED_KEY_MATERIAL_FORMAT_FIELD, KEY_MATERIAL_FIELD, KEY_CHECK_VALUE_FIELD, KEY_CHECK_VALUE_ALGORITHM_FIELD)); private static final long serialVersionUID = 1L; private final String wrappingKeyArn; private final String wrappedKeyMaterialFormat; private final String keyMaterial; private final String keyCheckValue; private final String keyCheckValueAlgorithm; private WrappedKey(BuilderImpl builder) { this.wrappingKeyArn = builder.wrappingKeyArn; this.wrappedKeyMaterialFormat = builder.wrappedKeyMaterialFormat; this.keyMaterial = builder.keyMaterial; this.keyCheckValue = builder.keyCheckValue; this.keyCheckValueAlgorithm = builder.keyCheckValueAlgorithm; } /** *

* The KeyARN of the wrapped key. *

* * @return The KeyARN of the wrapped key. */ public final String wrappingKeyArn() { return wrappingKeyArn; } /** *

* The key block format of a wrapped key. *

*

* If the service returns an enum value that is not available in the current SDK version, * {@link #wrappedKeyMaterialFormat} will return {@link WrappedKeyMaterialFormat#UNKNOWN_TO_SDK_VERSION}. The raw * value returned by the service is available from {@link #wrappedKeyMaterialFormatAsString}. *

* * @return The key block format of a wrapped key. * @see WrappedKeyMaterialFormat */ public final WrappedKeyMaterialFormat wrappedKeyMaterialFormat() { return WrappedKeyMaterialFormat.fromValue(wrappedKeyMaterialFormat); } /** *

* The key block format of a wrapped key. *

*

* If the service returns an enum value that is not available in the current SDK version, * {@link #wrappedKeyMaterialFormat} will return {@link WrappedKeyMaterialFormat#UNKNOWN_TO_SDK_VERSION}. The raw * value returned by the service is available from {@link #wrappedKeyMaterialFormatAsString}. *

* * @return The key block format of a wrapped key. * @see WrappedKeyMaterialFormat */ public final String wrappedKeyMaterialFormatAsString() { return wrappedKeyMaterialFormat; } /** *

* Parameter information for generating a wrapped key using TR-31 or TR-34 skey exchange method. *

* * @return Parameter information for generating a wrapped key using TR-31 or TR-34 skey exchange method. */ public final String keyMaterial() { return keyMaterial; } /** *

* The key check value (KCV) is used to check if all parties holding a given key have the same key or to detect that * a key has changed. *

* * @return The key check value (KCV) is used to check if all parties holding a given key have the same key or to * detect that a key has changed. */ public final String keyCheckValue() { return keyCheckValue; } /** *

* The algorithm that Amazon Web Services Payment Cryptography uses to calculate the key check value (KCV). It is * used to validate the key integrity. *

*

* For TDES keys, the KCV is computed by encrypting 8 bytes, each with value of zero, with the key to be checked and * retaining the 3 highest order bytes of the encrypted result. For AES keys, the KCV is computed using a CMAC * algorithm where the input data is 16 bytes of zero and retaining the 3 highest order bytes of the encrypted * result. *

*

* If the service returns an enum value that is not available in the current SDK version, * {@link #keyCheckValueAlgorithm} will return {@link KeyCheckValueAlgorithm#UNKNOWN_TO_SDK_VERSION}. The raw value * returned by the service is available from {@link #keyCheckValueAlgorithmAsString}. *

* * @return The algorithm that Amazon Web Services Payment Cryptography uses to calculate the key check value (KCV). * It is used to validate the key integrity.

*

* For TDES keys, the KCV is computed by encrypting 8 bytes, each with value of zero, with the key to be * checked and retaining the 3 highest order bytes of the encrypted result. For AES keys, the KCV is * computed using a CMAC algorithm where the input data is 16 bytes of zero and retaining the 3 highest * order bytes of the encrypted result. * @see KeyCheckValueAlgorithm */ public final KeyCheckValueAlgorithm keyCheckValueAlgorithm() { return KeyCheckValueAlgorithm.fromValue(keyCheckValueAlgorithm); } /** *

* The algorithm that Amazon Web Services Payment Cryptography uses to calculate the key check value (KCV). It is * used to validate the key integrity. *

*

* For TDES keys, the KCV is computed by encrypting 8 bytes, each with value of zero, with the key to be checked and * retaining the 3 highest order bytes of the encrypted result. For AES keys, the KCV is computed using a CMAC * algorithm where the input data is 16 bytes of zero and retaining the 3 highest order bytes of the encrypted * result. *

*

* If the service returns an enum value that is not available in the current SDK version, * {@link #keyCheckValueAlgorithm} will return {@link KeyCheckValueAlgorithm#UNKNOWN_TO_SDK_VERSION}. The raw value * returned by the service is available from {@link #keyCheckValueAlgorithmAsString}. *

* * @return The algorithm that Amazon Web Services Payment Cryptography uses to calculate the key check value (KCV). * It is used to validate the key integrity.

*

* For TDES keys, the KCV is computed by encrypting 8 bytes, each with value of zero, with the key to be * checked and retaining the 3 highest order bytes of the encrypted result. For AES keys, the KCV is * computed using a CMAC algorithm where the input data is 16 bytes of zero and retaining the 3 highest * order bytes of the encrypted result. * @see KeyCheckValueAlgorithm */ public final String keyCheckValueAlgorithmAsString() { return keyCheckValueAlgorithm; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(wrappingKeyArn()); hashCode = 31 * hashCode + Objects.hashCode(wrappedKeyMaterialFormatAsString()); hashCode = 31 * hashCode + Objects.hashCode(keyMaterial()); hashCode = 31 * hashCode + Objects.hashCode(keyCheckValue()); hashCode = 31 * hashCode + Objects.hashCode(keyCheckValueAlgorithmAsString()); return hashCode; } @Override public final boolean equals(Object obj) { return equalsBySdkFields(obj); } @Override public final boolean equalsBySdkFields(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof WrappedKey)) { return false; } WrappedKey other = (WrappedKey) obj; return Objects.equals(wrappingKeyArn(), other.wrappingKeyArn()) && Objects.equals(wrappedKeyMaterialFormatAsString(), other.wrappedKeyMaterialFormatAsString()) && Objects.equals(keyMaterial(), other.keyMaterial()) && Objects.equals(keyCheckValue(), other.keyCheckValue()) && Objects.equals(keyCheckValueAlgorithmAsString(), other.keyCheckValueAlgorithmAsString()); } /** * 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("WrappedKey").add("WrappingKeyArn", wrappingKeyArn()) .add("WrappedKeyMaterialFormat", wrappedKeyMaterialFormatAsString()) .add("KeyMaterial", keyMaterial() == null ? null : "*** Sensitive Data Redacted ***") .add("KeyCheckValue", keyCheckValue()).add("KeyCheckValueAlgorithm", keyCheckValueAlgorithmAsString()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "WrappingKeyArn": return Optional.ofNullable(clazz.cast(wrappingKeyArn())); case "WrappedKeyMaterialFormat": return Optional.ofNullable(clazz.cast(wrappedKeyMaterialFormatAsString())); case "KeyMaterial": return Optional.ofNullable(clazz.cast(keyMaterial())); case "KeyCheckValue": return Optional.ofNullable(clazz.cast(keyCheckValue())); case "KeyCheckValueAlgorithm": return Optional.ofNullable(clazz.cast(keyCheckValueAlgorithmAsString())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((WrappedKey) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* The KeyARN of the wrapped key. *

* * @param wrappingKeyArn * The KeyARN of the wrapped key. * @return Returns a reference to this object so that method calls can be chained together. */ Builder wrappingKeyArn(String wrappingKeyArn); /** *

* The key block format of a wrapped key. *

* * @param wrappedKeyMaterialFormat * The key block format of a wrapped key. * @see WrappedKeyMaterialFormat * @return Returns a reference to this object so that method calls can be chained together. * @see WrappedKeyMaterialFormat */ Builder wrappedKeyMaterialFormat(String wrappedKeyMaterialFormat); /** *

* The key block format of a wrapped key. *

* * @param wrappedKeyMaterialFormat * The key block format of a wrapped key. * @see WrappedKeyMaterialFormat * @return Returns a reference to this object so that method calls can be chained together. * @see WrappedKeyMaterialFormat */ Builder wrappedKeyMaterialFormat(WrappedKeyMaterialFormat wrappedKeyMaterialFormat); /** *

* Parameter information for generating a wrapped key using TR-31 or TR-34 skey exchange method. *

* * @param keyMaterial * Parameter information for generating a wrapped key using TR-31 or TR-34 skey exchange method. * @return Returns a reference to this object so that method calls can be chained together. */ Builder keyMaterial(String keyMaterial); /** *

* The key check value (KCV) is used to check if all parties holding a given key have the same key or to detect * that a key has changed. *

* * @param keyCheckValue * The key check value (KCV) is used to check if all parties holding a given key have the same key or to * detect that a key has changed. * @return Returns a reference to this object so that method calls can be chained together. */ Builder keyCheckValue(String keyCheckValue); /** *

* The algorithm that Amazon Web Services Payment Cryptography uses to calculate the key check value (KCV). It * is used to validate the key integrity. *

*

* For TDES keys, the KCV is computed by encrypting 8 bytes, each with value of zero, with the key to be checked * and retaining the 3 highest order bytes of the encrypted result. For AES keys, the KCV is computed using a * CMAC algorithm where the input data is 16 bytes of zero and retaining the 3 highest order bytes of the * encrypted result. *

* * @param keyCheckValueAlgorithm * The algorithm that Amazon Web Services Payment Cryptography uses to calculate the key check value * (KCV). It is used to validate the key integrity.

*

* For TDES keys, the KCV is computed by encrypting 8 bytes, each with value of zero, with the key to be * checked and retaining the 3 highest order bytes of the encrypted result. For AES keys, the KCV is * computed using a CMAC algorithm where the input data is 16 bytes of zero and retaining the 3 highest * order bytes of the encrypted result. * @see KeyCheckValueAlgorithm * @return Returns a reference to this object so that method calls can be chained together. * @see KeyCheckValueAlgorithm */ Builder keyCheckValueAlgorithm(String keyCheckValueAlgorithm); /** *

* The algorithm that Amazon Web Services Payment Cryptography uses to calculate the key check value (KCV). It * is used to validate the key integrity. *

*

* For TDES keys, the KCV is computed by encrypting 8 bytes, each with value of zero, with the key to be checked * and retaining the 3 highest order bytes of the encrypted result. For AES keys, the KCV is computed using a * CMAC algorithm where the input data is 16 bytes of zero and retaining the 3 highest order bytes of the * encrypted result. *

* * @param keyCheckValueAlgorithm * The algorithm that Amazon Web Services Payment Cryptography uses to calculate the key check value * (KCV). It is used to validate the key integrity.

*

* For TDES keys, the KCV is computed by encrypting 8 bytes, each with value of zero, with the key to be * checked and retaining the 3 highest order bytes of the encrypted result. For AES keys, the KCV is * computed using a CMAC algorithm where the input data is 16 bytes of zero and retaining the 3 highest * order bytes of the encrypted result. * @see KeyCheckValueAlgorithm * @return Returns a reference to this object so that method calls can be chained together. * @see KeyCheckValueAlgorithm */ Builder keyCheckValueAlgorithm(KeyCheckValueAlgorithm keyCheckValueAlgorithm); } static final class BuilderImpl implements Builder { private String wrappingKeyArn; private String wrappedKeyMaterialFormat; private String keyMaterial; private String keyCheckValue; private String keyCheckValueAlgorithm; private BuilderImpl() { } private BuilderImpl(WrappedKey model) { wrappingKeyArn(model.wrappingKeyArn); wrappedKeyMaterialFormat(model.wrappedKeyMaterialFormat); keyMaterial(model.keyMaterial); keyCheckValue(model.keyCheckValue); keyCheckValueAlgorithm(model.keyCheckValueAlgorithm); } public final String getWrappingKeyArn() { return wrappingKeyArn; } public final void setWrappingKeyArn(String wrappingKeyArn) { this.wrappingKeyArn = wrappingKeyArn; } @Override public final Builder wrappingKeyArn(String wrappingKeyArn) { this.wrappingKeyArn = wrappingKeyArn; return this; } public final String getWrappedKeyMaterialFormat() { return wrappedKeyMaterialFormat; } public final void setWrappedKeyMaterialFormat(String wrappedKeyMaterialFormat) { this.wrappedKeyMaterialFormat = wrappedKeyMaterialFormat; } @Override public final Builder wrappedKeyMaterialFormat(String wrappedKeyMaterialFormat) { this.wrappedKeyMaterialFormat = wrappedKeyMaterialFormat; return this; } @Override public final Builder wrappedKeyMaterialFormat(WrappedKeyMaterialFormat wrappedKeyMaterialFormat) { this.wrappedKeyMaterialFormat(wrappedKeyMaterialFormat == null ? null : wrappedKeyMaterialFormat.toString()); return this; } public final String getKeyMaterial() { return keyMaterial; } public final void setKeyMaterial(String keyMaterial) { this.keyMaterial = keyMaterial; } @Override public final Builder keyMaterial(String keyMaterial) { this.keyMaterial = keyMaterial; return this; } public final String getKeyCheckValue() { return keyCheckValue; } public final void setKeyCheckValue(String keyCheckValue) { this.keyCheckValue = keyCheckValue; } @Override public final Builder keyCheckValue(String keyCheckValue) { this.keyCheckValue = keyCheckValue; return this; } public final String getKeyCheckValueAlgorithm() { return keyCheckValueAlgorithm; } public final void setKeyCheckValueAlgorithm(String keyCheckValueAlgorithm) { this.keyCheckValueAlgorithm = keyCheckValueAlgorithm; } @Override public final Builder keyCheckValueAlgorithm(String keyCheckValueAlgorithm) { this.keyCheckValueAlgorithm = keyCheckValueAlgorithm; return this; } @Override public final Builder keyCheckValueAlgorithm(KeyCheckValueAlgorithm keyCheckValueAlgorithm) { this.keyCheckValueAlgorithm(keyCheckValueAlgorithm == null ? null : keyCheckValueAlgorithm.toString()); return this; } @Override public WrappedKey build() { return new WrappedKey(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy