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

software.amazon.awssdk.services.kms.model.DecryptRequest Maven / Gradle / Ivy

/*
 * Copyright 2014-2019 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.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
import software.amazon.awssdk.core.SdkBytes;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.adapter.StandardMemberCopier;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.traits.MapTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructMap;
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 DecryptRequest extends KmsRequest implements ToCopyableBuilder {
    private static final SdkField CIPHERTEXT_BLOB_FIELD = SdkField. builder(MarshallingType.SDK_BYTES)
            .getter(getter(DecryptRequest::ciphertextBlob)).setter(setter(Builder::ciphertextBlob))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CiphertextBlob").build()).build();

    private static final SdkField> ENCRYPTION_CONTEXT_FIELD = SdkField
            .> builder(MarshallingType.MAP)
            .getter(getter(DecryptRequest::encryptionContext))
            .setter(setter(Builder::encryptionContext))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EncryptionContext").build(),
                    MapTrait.builder()
                            .keyLocationName("key")
                            .valueLocationName("value")
                            .valueFieldInfo(
                                    SdkField. builder(MarshallingType.STRING)
                                            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
                                                    .locationName("value").build()).build()).build()).build();

    private static final SdkField> GRANT_TOKENS_FIELD = SdkField
            .> builder(MarshallingType.LIST)
            .getter(getter(DecryptRequest::grantTokens))
            .setter(setter(Builder::grantTokens))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("GrantTokens").build(),
                    ListTrait
                            .builder()
                            .memberLocationName(null)
                            .memberFieldInfo(
                                    SdkField. builder(MarshallingType.STRING)
                                            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
                                                    .locationName("member").build()).build()).build()).build();

    private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(CIPHERTEXT_BLOB_FIELD,
            ENCRYPTION_CONTEXT_FIELD, GRANT_TOKENS_FIELD));

    private final SdkBytes ciphertextBlob;

    private final Map encryptionContext;

    private final List grantTokens;

    private DecryptRequest(BuilderImpl builder) {
        super(builder);
        this.ciphertextBlob = builder.ciphertextBlob;
        this.encryptionContext = builder.encryptionContext;
        this.grantTokens = builder.grantTokens;
    }

    /**
     * 

* Ciphertext to be decrypted. The blob includes metadata. *

* * @return Ciphertext to be decrypted. The blob includes metadata. */ public SdkBytes ciphertextBlob() { return ciphertextBlob; } /** *

* The encryption context. If this was specified in the Encrypt function, it must be specified here or the * decryption operation will fail. For more information, see Encryption * Context. *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

* * @return The encryption context. If this was specified in the Encrypt function, it must be specified here * or the decryption operation will fail. For more information, see Encryption * Context. */ public Map encryptionContext() { return encryptionContext; } /** *

* A list of grant tokens. *

*

* For more information, see Grant Tokens in the * AWS Key Management Service Developer Guide. *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

* * @return A list of grant tokens.

*

* For more information, see Grant Tokens * in the AWS Key Management Service Developer Guide. */ public List grantTokens() { return grantTokens; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(ciphertextBlob()); hashCode = 31 * hashCode + Objects.hashCode(encryptionContext()); hashCode = 31 * hashCode + Objects.hashCode(grantTokens()); return hashCode; } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof DecryptRequest)) { return false; } DecryptRequest other = (DecryptRequest) obj; return Objects.equals(ciphertextBlob(), other.ciphertextBlob()) && Objects.equals(encryptionContext(), other.encryptionContext()) && Objects.equals(grantTokens(), other.grantTokens()); } /** * 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 String toString() { return ToString.builder("DecryptRequest").add("CiphertextBlob", ciphertextBlob()) .add("EncryptionContext", encryptionContext()).add("GrantTokens", grantTokens()).build(); } public Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "CiphertextBlob": return Optional.ofNullable(clazz.cast(ciphertextBlob())); case "EncryptionContext": return Optional.ofNullable(clazz.cast(encryptionContext())); case "GrantTokens": return Optional.ofNullable(clazz.cast(grantTokens())); default: return Optional.empty(); } } @Override public List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((DecryptRequest) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends KmsRequest.Builder, SdkPojo, CopyableBuilder { /** *

* Ciphertext to be decrypted. The blob includes metadata. *

* * @param ciphertextBlob * Ciphertext to be decrypted. The blob includes metadata. * @return Returns a reference to this object so that method calls can be chained together. */ Builder ciphertextBlob(SdkBytes ciphertextBlob); /** *

* The encryption context. If this was specified in the Encrypt function, it must be specified here or * the decryption operation will fail. For more information, see Encryption * Context. *

* * @param encryptionContext * The encryption context. If this was specified in the Encrypt function, it must be specified * here or the decryption operation will fail. For more information, see Encryption * Context. * @return Returns a reference to this object so that method calls can be chained together. */ Builder encryptionContext(Map encryptionContext); /** *

* A list of grant tokens. *

*

* For more information, see Grant Tokens in * the AWS Key Management Service Developer Guide. *

* * @param grantTokens * A list of grant tokens.

*

* For more information, see Grant * Tokens in the AWS Key Management Service Developer Guide. * @return Returns a reference to this object so that method calls can be chained together. */ Builder grantTokens(Collection grantTokens); /** *

* A list of grant tokens. *

*

* For more information, see Grant Tokens in * the AWS Key Management Service Developer Guide. *

* * @param grantTokens * A list of grant tokens.

*

* For more information, see Grant * Tokens in the AWS Key Management Service Developer Guide. * @return Returns a reference to this object so that method calls can be chained together. */ Builder grantTokens(String... grantTokens); @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @Override Builder overrideConfiguration(Consumer builderConsumer); } static final class BuilderImpl extends KmsRequest.BuilderImpl implements Builder { private SdkBytes ciphertextBlob; private Map encryptionContext = DefaultSdkAutoConstructMap.getInstance(); private List grantTokens = DefaultSdkAutoConstructList.getInstance(); private BuilderImpl() { } private BuilderImpl(DecryptRequest model) { super(model); ciphertextBlob(model.ciphertextBlob); encryptionContext(model.encryptionContext); grantTokens(model.grantTokens); } public final ByteBuffer getCiphertextBlob() { return ciphertextBlob == null ? null : ciphertextBlob.asByteBuffer(); } @Override public final Builder ciphertextBlob(SdkBytes ciphertextBlob) { this.ciphertextBlob = StandardMemberCopier.copy(ciphertextBlob); return this; } public final void setCiphertextBlob(ByteBuffer ciphertextBlob) { ciphertextBlob(ciphertextBlob == null ? null : SdkBytes.fromByteBuffer(ciphertextBlob)); } public final Map getEncryptionContext() { return encryptionContext; } @Override public final Builder encryptionContext(Map encryptionContext) { this.encryptionContext = EncryptionContextTypeCopier.copy(encryptionContext); return this; } public final void setEncryptionContext(Map encryptionContext) { this.encryptionContext = EncryptionContextTypeCopier.copy(encryptionContext); } public final Collection getGrantTokens() { return grantTokens; } @Override public final Builder grantTokens(Collection grantTokens) { this.grantTokens = GrantTokenListCopier.copy(grantTokens); return this; } @Override @SafeVarargs public final Builder grantTokens(String... grantTokens) { grantTokens(Arrays.asList(grantTokens)); return this; } public final void setGrantTokens(Collection grantTokens) { this.grantTokens = GrantTokenListCopier.copy(grantTokens); } @Override public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) { super.overrideConfiguration(overrideConfiguration); return this; } @Override public Builder overrideConfiguration(Consumer builderConsumer) { super.overrideConfiguration(builderConsumer); return this; } @Override public DecryptRequest build() { return new DecryptRequest(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy