
AwsKmsDiscoveryKeyring_Compile.AwsKmsDiscoveryKeyring Maven / Gradle / Ivy
// Class AwsKmsDiscoveryKeyring
// Dafny class AwsKmsDiscoveryKeyring compiled into Java
package AwsKmsDiscoveryKeyring_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.*;
import AwsKmsKeyring_Compile.*;
import StrictMultiKeyring_Compile.*;
@SuppressWarnings({"unchecked", "deprecation"})
public class AwsKmsDiscoveryKeyring implements Keyring_Compile.VerifiableInterface, software.amazon.cryptography.materialproviders.internaldafny.types.IKeyring {
public AwsKmsDiscoveryKeyring() {
this._client = null;
this._discoveryFilter = Wrappers_Compile.Option.Default(software.amazon.cryptography.materialproviders.internaldafny.types.DiscoveryFilter._typeDescriptor());
this._grantTokens = dafny.DafnySequence.> empty(software.amazon.cryptography.services.kms.internaldafny.types.GrantTokenType._typeDescriptor());
}
public Wrappers_Compile.Result OnDecrypt(software.amazon.cryptography.materialproviders.internaldafny.types.OnDecryptInput input)
{
Wrappers_Compile.Result _out3;
_out3 = software.amazon.cryptography.materialproviders.internaldafny.types._Companion_IKeyring.OnDecrypt(this, input);
return _out3;
}
public Wrappers_Compile.Result OnEncrypt(software.amazon.cryptography.materialproviders.internaldafny.types.OnEncryptInput input)
{
Wrappers_Compile.Result _out3;
_out3 = software.amazon.cryptography.materialproviders.internaldafny.types._Companion_IKeyring.OnEncrypt(this, input);
return _out3;
}
public void __ctor(software.amazon.cryptography.services.kms.internaldafny.types.IKMSClient client, Wrappers_Compile.Option discoveryFilter, dafny.DafnySequence extends dafny.DafnySequence extends Character>> grantTokens)
{
(this)._client = client;
(this)._discoveryFilter = discoveryFilter;
(this)._grantTokens = grantTokens;
}
public Wrappers_Compile.Result OnEncrypt_k(software.amazon.cryptography.materialproviders.internaldafny.types.OnEncryptInput input)
{
Wrappers_Compile.Result output = (Wrappers_Compile.Result)null;
output = Wrappers_Compile.Result.create_Failure(software.amazon.cryptography.materialproviders.internaldafny.types.OnEncryptOutput._typeDescriptor(), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), software.amazon.cryptography.materialproviders.internaldafny.types.Error.create_AwsCryptographicMaterialProvidersException(dafny.DafnySequence.asString("Encryption is not supported with a Discovery Keyring.")));
return output;
}
public Wrappers_Compile.Result OnDecrypt_k(software.amazon.cryptography.materialproviders.internaldafny.types.OnDecryptInput input)
{
Wrappers_Compile.Result res = (Wrappers_Compile.Result)null;
software.amazon.cryptography.materialproviders.internaldafny.types.DecryptionMaterials _0_materials;
_0_materials = (input).dtor_materials();
dafny.DafnySequence extends software.amazon.cryptography.materialproviders.internaldafny.types.EncryptedDataKey> _1_encryptedDataKeys;
_1_encryptedDataKeys = (input).dtor_encryptedDataKeys();
software.amazon.cryptography.materialproviders.internaldafny.types.AlgorithmSuiteInfo _2_suite;
_2_suite = ((input).dtor_materials()).dtor_algorithmSuite();
Wrappers_Compile.Outcome _3_valueOrError0 = Wrappers_Compile.Outcome.Default(software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor());
_3_valueOrError0 = Wrappers_Compile.__default.Need(software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), Materials_Compile.__default.DecryptionMaterialsWithoutPlaintextDataKey(_0_materials), software.amazon.cryptography.materialproviders.internaldafny.types.Error.create_AwsCryptographicMaterialProvidersException(dafny.DafnySequence.asString("Keyring received decryption materials that already contain a plaintext data key.")));
if ((_3_valueOrError0).IsFailure(software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor())) {
res = (_3_valueOrError0).PropagateFailure(software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), software.amazon.cryptography.materialproviders.internaldafny.types.OnDecryptOutput._typeDescriptor());
return res;
}
AwsKmsEncryptedDataKeyFilter _4_edkFilter;
AwsKmsEncryptedDataKeyFilter _nw0 = new AwsKmsEncryptedDataKeyFilter();
_nw0.__ctor((this).discoveryFilter());
_4_edkFilter = _nw0;
Wrappers_Compile.Result, software.amazon.cryptography.materialproviders.internaldafny.types.Error> _5_valueOrError1 = Wrappers_Compile.Result., software.amazon.cryptography.materialproviders.internaldafny.types.Error>Default(dafny.DafnySequence._typeDescriptor(software.amazon.cryptography.materialproviders.internaldafny.types.EncryptedDataKey._typeDescriptor()), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), dafny.DafnySequence. empty(software.amazon.cryptography.materialproviders.internaldafny.types.EncryptedDataKey._typeDescriptor()));
Wrappers_Compile.Result, software.amazon.cryptography.materialproviders.internaldafny.types.Error> _out0;
_out0 = Actions_Compile.__default.FilterWithResult(software.amazon.cryptography.materialproviders.internaldafny.types.EncryptedDataKey._typeDescriptor(), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), _4_edkFilter, _1_encryptedDataKeys);
_5_valueOrError1 = _out0;
if ((_5_valueOrError1).IsFailure(dafny.DafnySequence._typeDescriptor(software.amazon.cryptography.materialproviders.internaldafny.types.EncryptedDataKey._typeDescriptor()), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor())) {
res = (_5_valueOrError1).PropagateFailure(dafny.DafnySequence._typeDescriptor(software.amazon.cryptography.materialproviders.internaldafny.types.EncryptedDataKey._typeDescriptor()), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), software.amazon.cryptography.materialproviders.internaldafny.types.OnDecryptOutput._typeDescriptor());
return res;
}
dafny.DafnySequence extends software.amazon.cryptography.materialproviders.internaldafny.types.EncryptedDataKey> _6_matchingEdks;
_6_matchingEdks = (_5_valueOrError1).Extract(dafny.DafnySequence._typeDescriptor(software.amazon.cryptography.materialproviders.internaldafny.types.EncryptedDataKey._typeDescriptor()), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor());
AwsKmsEncryptedDataKeyTransformer _7_edkTransform;
AwsKmsEncryptedDataKeyTransformer _nw1 = new AwsKmsEncryptedDataKeyTransformer();
_nw1.__ctor();
_7_edkTransform = _nw1;
Wrappers_Compile.Result, software.amazon.cryptography.materialproviders.internaldafny.types.Error> _8_valueOrError2 = Wrappers_Compile.Result., software.amazon.cryptography.materialproviders.internaldafny.types.Error>Default(dafny.DafnySequence._typeDescriptor(Constants_Compile.AwsKmsEdkHelper._typeDescriptor()), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), dafny.DafnySequence. empty(Constants_Compile.AwsKmsEdkHelper._typeDescriptor()));
Wrappers_Compile.Result, software.amazon.cryptography.materialproviders.internaldafny.types.Error> _out1;
_out1 = Actions_Compile.__default.DeterministicFlatMapWithResult(software.amazon.cryptography.materialproviders.internaldafny.types.EncryptedDataKey._typeDescriptor(), Constants_Compile.AwsKmsEdkHelper._typeDescriptor(), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), _7_edkTransform, _6_matchingEdks);
_8_valueOrError2 = _out1;
if ((_8_valueOrError2).IsFailure(dafny.DafnySequence._typeDescriptor(Constants_Compile.AwsKmsEdkHelper._typeDescriptor()), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor())) {
res = (_8_valueOrError2).PropagateFailure(dafny.DafnySequence._typeDescriptor(Constants_Compile.AwsKmsEdkHelper._typeDescriptor()), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), software.amazon.cryptography.materialproviders.internaldafny.types.OnDecryptOutput._typeDescriptor());
return res;
}
dafny.DafnySequence extends Constants_Compile.AwsKmsEdkHelper> _9_edksToAttempt;
_9_edksToAttempt = (_8_valueOrError2).Extract(dafny.DafnySequence._typeDescriptor(Constants_Compile.AwsKmsEdkHelper._typeDescriptor()), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor());
if ((java.math.BigInteger.valueOf((_9_edksToAttempt).length())).signum() == 0) {
Wrappers_Compile.Result, software.amazon.cryptography.materialproviders.internaldafny.types.Error> _10_valueOrError3 = Wrappers_Compile.Result., software.amazon.cryptography.materialproviders.internaldafny.types.Error>Default(dafny.DafnySequence._typeDescriptor(dafny.TypeDescriptor.CHAR), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), dafny.DafnySequence. empty(dafny.TypeDescriptor.CHAR));
_10_valueOrError3 = ErrorMessages_Compile.__default.IncorrectDataKeys((input).dtor_encryptedDataKeys(), ((input).dtor_materials()).dtor_algorithmSuite(), dafny.DafnySequence.asString(""));
if ((_10_valueOrError3).IsFailure(dafny.DafnySequence._typeDescriptor(dafny.TypeDescriptor.CHAR), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor())) {
res = (_10_valueOrError3).PropagateFailure(dafny.DafnySequence._typeDescriptor(dafny.TypeDescriptor.CHAR), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), software.amazon.cryptography.materialproviders.internaldafny.types.OnDecryptOutput._typeDescriptor());
return res;
}
dafny.DafnySequence extends Character> _11_errorMessage;
_11_errorMessage = (_10_valueOrError3).Extract(dafny.DafnySequence._typeDescriptor(dafny.TypeDescriptor.CHAR), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor());
res = Wrappers_Compile.Result.create_Failure(software.amazon.cryptography.materialproviders.internaldafny.types.OnDecryptOutput._typeDescriptor(), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), software.amazon.cryptography.materialproviders.internaldafny.types.Error.create_AwsCryptographicMaterialProvidersException(_11_errorMessage));
return res;
}
AwsKmsEncryptedDataKeyDecryptor _12_decryptAction;
AwsKmsEncryptedDataKeyDecryptor _nw2 = new AwsKmsEncryptedDataKeyDecryptor();
_nw2.__ctor(_0_materials, (this).client(), (this).grantTokens());
_12_decryptAction = _nw2;
Wrappers_Compile.Result> _13_outcome;
Wrappers_Compile.Result> _out2;
_out2 = Actions_Compile.__default.ReduceToSuccess(Constants_Compile.AwsKmsEdkHelper._typeDescriptor(), Materials_Compile.SealedDecryptionMaterials._typeDescriptor(), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), _12_decryptAction, _9_edksToAttempt);
_13_outcome = _out2;
Wrappers_Compile.Result> _source0 = _13_outcome;
if (_source0.is_Success()) {
software.amazon.cryptography.materialproviders.internaldafny.types.DecryptionMaterials _14___mcc_h0 = ((Wrappers_Compile.Result_Success>)_source0)._value;
software.amazon.cryptography.materialproviders.internaldafny.types.DecryptionMaterials _15_mat = _14___mcc_h0;
res = Wrappers_Compile.Result.create_Success(software.amazon.cryptography.materialproviders.internaldafny.types.OnDecryptOutput._typeDescriptor(), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), software.amazon.cryptography.materialproviders.internaldafny.types.OnDecryptOutput.create(_15_mat));
} else {
dafny.DafnySequence extends software.amazon.cryptography.materialproviders.internaldafny.types.Error> _16___mcc_h1 = ((Wrappers_Compile.Result_Failure>)_source0)._error;
dafny.DafnySequence extends software.amazon.cryptography.materialproviders.internaldafny.types.Error> _17_errors = _16___mcc_h1;
res = Wrappers_Compile.Result.create_Failure(software.amazon.cryptography.materialproviders.internaldafny.types.OnDecryptOutput._typeDescriptor(), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), software.amazon.cryptography.materialproviders.internaldafny.types.Error.create_CollectionOfErrors(_17_errors, dafny.DafnySequence.asString("No Configured KMS Key was able to decrypt the Data Key. The list of encountered Exceptions is available via `list`.")));
}
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 Wrappers_Compile.Option _discoveryFilter;
public Wrappers_Compile.Option discoveryFilter()
{
return this._discoveryFilter;
}
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(AwsKmsDiscoveryKeyring.class, () -> (AwsKmsDiscoveryKeyring) null);
public static dafny.TypeDescriptor _typeDescriptor() {
return (dafny.TypeDescriptor) (dafny.TypeDescriptor>) _TYPE;
}
@Override
public java.lang.String toString() {
return "AwsKmsDiscoveryKeyring.AwsKmsDiscoveryKeyring";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy