
AwsKmsKeyring_Compile.KmsGenerateAndWrapKeyMaterial Maven / Gradle / Ivy
// Class KmsGenerateAndWrapKeyMaterial
// Dafny class KmsGenerateAndWrapKeyMaterial compiled into Java
package AwsKmsKeyring_Compile;
import software.amazon.cryptography.keystore.internaldafny.types.*;
import software.amazon.cryptography.materialproviders.internaldafny.types.*;
import AwsArnParsing_Compile.*;
import AwsKmsMrkMatchForDecrypt_Compile.*;
import AwsKmsUtils_Compile.*;
import KeyStoreErrorMessages_Compile.*;
import KmsArn_Compile.*;
import Structure_Compile.*;
import KMSKeystoreOperations_Compile.*;
import DDBKeystoreOperations_Compile.*;
import CreateKeys_Compile.*;
import CreateKeyStoreTable_Compile.*;
import GetKeys_Compile.*;
import AwsCryptographyKeyStoreOperations_Compile.*;
import software.amazon.cryptography.keystore.internaldafny.*;
import AlgorithmSuites_Compile.*;
import Materials_Compile.*;
import Keyring_Compile.*;
import MultiKeyring_Compile.*;
import AwsKmsMrkAreUnique_Compile.*;
import Constants_Compile.*;
import MaterialWrapping_Compile.*;
import CanonicalEncryptionContext_Compile.*;
import IntermediateKeyWrapping_Compile.*;
import EdkWrapping_Compile.*;
import ErrorMessages_Compile.*;
@SuppressWarnings({"unchecked", "deprecation"})
public class KmsGenerateAndWrapKeyMaterial implements MaterialWrapping_Compile.GenerateAndWrapMaterial, Actions_Compile.ActionWithResult, software.amazon.cryptography.materialproviders.internaldafny.types.Error>, Actions_Compile.Action, software.amazon.cryptography.materialproviders.internaldafny.types.Error>> {
public KmsGenerateAndWrapKeyMaterial() {
this._client = null;
this._awsKmsKey = dafny.DafnySequence. empty(dafny.TypeDescriptor.CHAR);
this._grantTokens = dafny.DafnySequence.> empty(software.amazon.cryptography.services.kms.internaldafny.types.GrantTokenType._typeDescriptor());
}
public void __ctor(software.amazon.cryptography.services.kms.internaldafny.types.IKMSClient client, dafny.DafnySequence extends Character> awsKmsKey, dafny.DafnySequence extends dafny.DafnySequence extends Character>> grantTokens)
{
(this)._client = client;
(this)._awsKmsKey = awsKmsKey;
(this)._grantTokens = grantTokens;
}
public Wrappers_Compile.Result, software.amazon.cryptography.materialproviders.internaldafny.types.Error> Invoke(MaterialWrapping_Compile.GenerateAndWrapInput input)
{
Wrappers_Compile.Result, software.amazon.cryptography.materialproviders.internaldafny.types.Error> res = Wrappers_Compile.Result., software.amazon.cryptography.materialproviders.internaldafny.types.Error>Default(MaterialWrapping_Compile.GenerateAndWrapOutput._typeDescriptor(KmsWrapInfo._typeDescriptor()), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), MaterialWrapping_Compile.GenerateAndWrapOutput.Default(KmsWrapInfo._typeDescriptor(), KmsWrapInfo.Default()));
software.amazon.cryptography.materialproviders.internaldafny.types.AlgorithmSuiteInfo _0_suite;
_0_suite = (input).dtor_algorithmSuite();
Wrappers_Compile.Result, ? extends dafny.DafnySequence extends Character>>, software.amazon.cryptography.materialproviders.internaldafny.types.Error> _1_valueOrError0 = Wrappers_Compile.Result., ? extends dafny.DafnySequence extends Character>>, software.amazon.cryptography.materialproviders.internaldafny.types.Error>Default(dafny.DafnyMap., dafny.DafnySequence extends Character>>_typeDescriptor(dafny.DafnySequence._typeDescriptor(dafny.TypeDescriptor.CHAR), dafny.DafnySequence._typeDescriptor(dafny.TypeDescriptor.CHAR)), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), dafny.DafnyMap.,dafny.DafnySequence extends Character>> empty());
_1_valueOrError0 = AwsKmsUtils_Compile.__default.StringifyEncryptionContext((input).dtor_encryptionContext());
if ((_1_valueOrError0).IsFailure(dafny.DafnyMap., dafny.DafnySequence extends Character>>_typeDescriptor(dafny.DafnySequence._typeDescriptor(dafny.TypeDescriptor.CHAR), dafny.DafnySequence._typeDescriptor(dafny.TypeDescriptor.CHAR)), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor())) {
res = (_1_valueOrError0).>PropagateFailure(dafny.DafnyMap., dafny.DafnySequence extends Character>>_typeDescriptor(dafny.DafnySequence._typeDescriptor(dafny.TypeDescriptor.CHAR), dafny.DafnySequence._typeDescriptor(dafny.TypeDescriptor.CHAR)), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), MaterialWrapping_Compile.GenerateAndWrapOutput._typeDescriptor(KmsWrapInfo._typeDescriptor()));
return res;
}
dafny.DafnyMap extends dafny.DafnySequence extends Character>, ? extends dafny.DafnySequence extends Character>> _2_stringifiedEncCtx;
_2_stringifiedEncCtx = (_1_valueOrError0).Extract(dafny.DafnyMap., dafny.DafnySequence extends Character>>_typeDescriptor(dafny.DafnySequence._typeDescriptor(dafny.TypeDescriptor.CHAR), dafny.DafnySequence._typeDescriptor(dafny.TypeDescriptor.CHAR)), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor());
software.amazon.cryptography.services.kms.internaldafny.types.GenerateDataKeyRequest _3_generatorRequest;
_3_generatorRequest = software.amazon.cryptography.services.kms.internaldafny.types.GenerateDataKeyRequest.create((this).awsKmsKey(), Wrappers_Compile.Option., ? extends dafny.DafnySequence extends Character>>>create_Some(dafny.DafnyMap., dafny.DafnySequence extends Character>>_typeDescriptor(dafny.DafnySequence._typeDescriptor(dafny.TypeDescriptor.CHAR), dafny.DafnySequence._typeDescriptor(dafny.TypeDescriptor.CHAR)), _2_stringifiedEncCtx), Wrappers_Compile.Option.create_Some(BoundedInts_Compile.int32._typeDescriptor(), AlgorithmSuites_Compile.__default.GetEncryptKeyLength(_0_suite)), Wrappers_Compile.Option.create_None(software.amazon.cryptography.services.kms.internaldafny.types.DataKeySpec._typeDescriptor()), Wrappers_Compile.Option.>>create_Some(software.amazon.cryptography.services.kms.internaldafny.types.GrantTokenList._typeDescriptor(), (this).grantTokens()), Wrappers_Compile.Option.create_None(software.amazon.cryptography.services.kms.internaldafny.types.RecipientInfo._typeDescriptor()), Wrappers_Compile.Option.create_None(dafny.TypeDescriptor.BOOLEAN));
Wrappers_Compile.Result _4_maybeGenerateResponse;
Wrappers_Compile.Result _out0;
_out0 = ((this).client()).GenerateDataKey(_3_generatorRequest);
_4_maybeGenerateResponse = _out0;
Wrappers_Compile.Result _5_valueOrError1 = Wrappers_Compile.Result.Default(software.amazon.cryptography.services.kms.internaldafny.types.GenerateDataKeyResponse._typeDescriptor(), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), software.amazon.cryptography.services.kms.internaldafny.types.GenerateDataKeyResponse.Default());
_5_valueOrError1 = (_4_maybeGenerateResponse).MapFailure(software.amazon.cryptography.services.kms.internaldafny.types.GenerateDataKeyResponse._typeDescriptor(), software.amazon.cryptography.services.kms.internaldafny.types.Error._typeDescriptor(), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), ((java.util.function.Function)(_6_e_boxed0) -> {
software.amazon.cryptography.services.kms.internaldafny.types.Error _6_e = ((software.amazon.cryptography.services.kms.internaldafny.types.Error)(java.lang.Object)(_6_e_boxed0));
return software.amazon.cryptography.materialproviders.internaldafny.types.Error.create_ComAmazonawsKms(_6_e);
}));
if ((_5_valueOrError1).IsFailure(software.amazon.cryptography.services.kms.internaldafny.types.GenerateDataKeyResponse._typeDescriptor(), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor())) {
res = (_5_valueOrError1).>PropagateFailure(software.amazon.cryptography.services.kms.internaldafny.types.GenerateDataKeyResponse._typeDescriptor(), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), MaterialWrapping_Compile.GenerateAndWrapOutput._typeDescriptor(KmsWrapInfo._typeDescriptor()));
return res;
}
software.amazon.cryptography.services.kms.internaldafny.types.GenerateDataKeyResponse _7_generateResponse;
_7_generateResponse = (_5_valueOrError1).Extract(software.amazon.cryptography.services.kms.internaldafny.types.GenerateDataKeyResponse._typeDescriptor(), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor());
Wrappers_Compile.Outcome _8_valueOrError2 = Wrappers_Compile.Outcome.Default(software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor());
_8_valueOrError2 = Wrappers_Compile.__default.Need(software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), (((_7_generateResponse).dtor_KeyId()).is_Some()) && ((AwsArnParsing_Compile.__default.ParseAwsKmsIdentifier(((_7_generateResponse).dtor_KeyId()).dtor_value())).is_Success()), software.amazon.cryptography.materialproviders.internaldafny.types.Error.create_AwsCryptographicMaterialProvidersException(dafny.DafnySequence.asString("Invalid response from KMS GenerateDataKey:: Invalid Key Id")));
if ((_8_valueOrError2).IsFailure(software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor())) {
res = (_8_valueOrError2).>PropagateFailure(software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), MaterialWrapping_Compile.GenerateAndWrapOutput._typeDescriptor(KmsWrapInfo._typeDescriptor()));
return res;
}
Wrappers_Compile.Outcome _9_valueOrError3 = Wrappers_Compile.Outcome.Default(software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor());
_9_valueOrError3 = Wrappers_Compile.__default.Need(software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), (((_7_generateResponse).dtor_Plaintext()).is_Some()) && (java.util.Objects.equals(java.math.BigInteger.valueOf(AlgorithmSuites_Compile.__default.GetEncryptKeyLength(_0_suite)), java.math.BigInteger.valueOf((((_7_generateResponse).dtor_Plaintext()).dtor_value()).length()))), software.amazon.cryptography.materialproviders.internaldafny.types.Error.create_AwsCryptographicMaterialProvidersException(dafny.DafnySequence.asString("Invalid response from AWS KMS GenerateDataKey: Invalid data key")));
if ((_9_valueOrError3).IsFailure(software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor())) {
res = (_9_valueOrError3).>PropagateFailure(software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), MaterialWrapping_Compile.GenerateAndWrapOutput._typeDescriptor(KmsWrapInfo._typeDescriptor()));
return res;
}
Wrappers_Compile.Outcome _10_valueOrError4 = Wrappers_Compile.Outcome.Default(software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor());
_10_valueOrError4 = Wrappers_Compile.__default.Need(software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), (((_7_generateResponse).dtor_CiphertextBlob()).is_Some()) && (software.amazon.cryptography.services.kms.internaldafny.types.__default.IsValid__CiphertextType(((_7_generateResponse).dtor_CiphertextBlob()).dtor_value())), software.amazon.cryptography.materialproviders.internaldafny.types.Error.create_AwsCryptographicMaterialProvidersException(dafny.DafnySequence.asString("Invalid response from AWS KMS GeneratedDataKey: Invalid ciphertext")));
if ((_10_valueOrError4).IsFailure(software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor())) {
res = (_10_valueOrError4).>PropagateFailure(software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), MaterialWrapping_Compile.GenerateAndWrapOutput._typeDescriptor(KmsWrapInfo._typeDescriptor()));
return res;
}
Wrappers_Compile.Outcome _11_valueOrError5 = Wrappers_Compile.Outcome.Default(software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor());
_11_valueOrError5 = Wrappers_Compile.__default.Need(software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), (true) && (((_7_generateResponse).dtor_CiphertextForRecipient()).is_None()), software.amazon.cryptography.materialproviders.internaldafny.types.Error.create_AwsCryptographicMaterialProvidersException(dafny.DafnySequence.asString("Invalid response from AWS KMS GeneratedDataKey: Invalid CiphertextForRecipient")));
if ((_11_valueOrError5).IsFailure(software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor())) {
res = (_11_valueOrError5).>PropagateFailure(software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), MaterialWrapping_Compile.GenerateAndWrapOutput._typeDescriptor(KmsWrapInfo._typeDescriptor()));
return res;
}
MaterialWrapping_Compile.GenerateAndWrapOutput _12_output;
_12_output = MaterialWrapping_Compile.GenerateAndWrapOutput.create(KmsWrapInfo._typeDescriptor(), ((_7_generateResponse).dtor_Plaintext()).dtor_value(), ((_7_generateResponse).dtor_CiphertextBlob()).dtor_value(), AwsKmsKeyring_Compile.KmsWrapInfo.create(((_7_generateResponse).dtor_KeyId()).dtor_value()));
res = Wrappers_Compile.Result., software.amazon.cryptography.materialproviders.internaldafny.types.Error>create_Success(MaterialWrapping_Compile.GenerateAndWrapOutput._typeDescriptor(KmsWrapInfo._typeDescriptor()), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), _12_output);
return res;
}
public software.amazon.cryptography.services.kms.internaldafny.types.IKMSClient _client;
public software.amazon.cryptography.services.kms.internaldafny.types.IKMSClient client()
{
return this._client;
}
public dafny.DafnySequence extends Character> _awsKmsKey;
public dafny.DafnySequence extends Character> awsKmsKey()
{
return this._awsKmsKey;
}
public dafny.DafnySequence extends dafny.DafnySequence extends Character>> _grantTokens;
public dafny.DafnySequence extends dafny.DafnySequence extends Character>> grantTokens()
{
return this._grantTokens;
}
private static final dafny.TypeDescriptor _TYPE = dafny.TypeDescriptor.referenceWithInitializer(KmsGenerateAndWrapKeyMaterial.class, () -> (KmsGenerateAndWrapKeyMaterial) null);
public static dafny.TypeDescriptor _typeDescriptor() {
return (dafny.TypeDescriptor) (dafny.TypeDescriptor>) _TYPE;
}
@Override
public java.lang.String toString() {
return "AwsKmsKeyring.KmsGenerateAndWrapKeyMaterial";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy