index
int64 0
0
| repo_id
stringlengths 26
205
| file_path
stringlengths 51
246
| content
stringlengths 8
433k
| __index_level_0__
int64 0
10k
|
---|---|---|---|---|
0 | Create_ds/mantis-api/src/main/java/io/mantisrx/api | Create_ds/mantis-api/src/main/java/io/mantisrx/api/initializers/MantisApiServerChannelInitializer.java | /*
* Copyright 2018 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License 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 io.mantisrx.api.initializers;
import com.netflix.netty.common.HttpLifecycleChannelHandler;
import com.netflix.netty.common.channel.config.ChannelConfig;
import com.netflix.netty.common.channel.config.CommonChannelConfigKeys;
import com.netflix.zuul.netty.server.BaseZuulChannelInitializer;
import com.netflix.zuul.netty.ssl.SslContextFactory;
import io.mantisrx.api.Util;
import io.mantisrx.api.push.ConnectionBroker;
import io.mantisrx.api.push.MantisSSEHandler;
import io.mantisrx.api.push.MantisWebSocketFrameHandler;
import io.mantisrx.api.tunnel.CrossRegionHandler;
import io.mantisrx.api.tunnel.MantisCrossRegionalClient;
import io.mantisrx.server.master.client.HighAvailabilityServices;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.group.ChannelGroup;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler;
import io.netty.handler.ssl.SslContext;
import io.netty.handler.ssl.SslHandler;
import io.netty.handler.stream.ChunkedWriteHandler;
import java.util.List;
import javax.net.ssl.SSLException;
import rx.Scheduler;
public class MantisApiServerChannelInitializer extends BaseZuulChannelInitializer
{
private final SslContextFactory sslContextFactory;
private final SslContext sslContext;
private final boolean isSSlFromIntermediary;
private final ConnectionBroker connectionBroker;
private final HighAvailabilityServices highAvailabilityServices;
private final MantisCrossRegionalClient mantisCrossRegionalClient;
private final Scheduler scheduler;
private final List<String> pushPrefixes;
private final boolean sslEnabled;
public MantisApiServerChannelInitializer(
String metricId,
ChannelConfig channelConfig,
ChannelConfig channelDependencies,
ChannelGroup channels,
List<String> pushPrefixes,
HighAvailabilityServices highAvailabilityServices,
MantisCrossRegionalClient mantisCrossRegionalClient,
ConnectionBroker connectionBroker,
Scheduler scheduler,
boolean sslEnabled) {
super(metricId, channelConfig, channelDependencies, channels);
this.pushPrefixes = pushPrefixes;
this.connectionBroker = connectionBroker;
this.highAvailabilityServices = highAvailabilityServices;
this.mantisCrossRegionalClient = mantisCrossRegionalClient;
this.scheduler = scheduler;
this.sslEnabled = sslEnabled;
this.isSSlFromIntermediary = channelConfig.get(CommonChannelConfigKeys.isSSlFromIntermediary);
this.sslContextFactory = channelConfig.get(CommonChannelConfigKeys.sslContextFactory);
if (sslEnabled) {
try {
sslContext = sslContextFactory.createBuilderForServer().build();
} catch (SSLException e) {
throw new RuntimeException("Error configuring SslContext!", e);
}
// Enable TLS Session Tickets support.
sslContextFactory.enableSessionTickets(sslContext);
// Setup metrics tracking the OpenSSL stats.
sslContextFactory.configureOpenSslStatsMetrics(sslContext, metricId);
} else {
sslContext = null;
}
}
@Override
protected void initChannel(Channel ch) throws Exception
{
// Configure our pipeline of ChannelHandlerS.
ChannelPipeline pipeline = ch.pipeline();
storeChannel(ch);
addTimeoutHandlers(pipeline);
addPassportHandler(pipeline);
addTcpRelatedHandlers(pipeline);
if (sslEnabled) {
SslHandler sslHandler = sslContext.newHandler(ch.alloc());
sslHandler.engine().setEnabledProtocols(sslContextFactory.getProtocols());
pipeline.addLast("ssl", sslHandler);
addSslInfoHandlers(pipeline, isSSlFromIntermediary);
addSslClientCertChecks(pipeline);
}
addHttp1Handlers(pipeline);
addHttpRelatedHandlers(pipeline);
pipeline.addLast("mantishandler", new MantisChannelHandler(pushPrefixes));
}
/**
* Adds a series of handlers for providing SSE/Websocket connections
* to Mantis Jobs.
*
* @param pipeline The netty pipeline to which push handlers should be added.
* @param url The url with which to initiate the websocket handler.
*/
protected void addPushHandlers(final ChannelPipeline pipeline, String url) {
pipeline.addLast(new ChunkedWriteHandler());
pipeline.addLast(new HttpObjectAggregator(64 * 1024));
pipeline.addLast(new MantisSSEHandler(connectionBroker, highAvailabilityServices, pushPrefixes));
pipeline.addLast(new WebSocketServerProtocolHandler(url, true));
pipeline.addLast(new MantisWebSocketFrameHandler(connectionBroker));
}
/**
* Adds a series of handlers for providing SSE/Websocket connections
* to Mantis Jobs.
*
* @param pipeline The netty pipeline to which regional handlers should be added.
*/
protected void addRegionalHandlers(final ChannelPipeline pipeline) {
pipeline.addLast(new ChunkedWriteHandler());
pipeline.addLast(new HttpObjectAggregator(10 * 1024 * 1024));
pipeline.addLast(new CrossRegionHandler(pushPrefixes, mantisCrossRegionalClient, connectionBroker, scheduler));
}
/**
* The MantisChannelHandler's job is to initialize the tail end of the pipeline differently
* depending on the URI of the request. This is largely to circumvent issues with endpoint responses
* when the push handlers preceed the Zuul handlers.
*/
@Sharable
public class MantisChannelHandler extends ChannelInboundHandlerAdapter {
private final List<String> pushPrefixes;
public MantisChannelHandler(List<String> pushPrefixes) {
this.pushPrefixes = pushPrefixes;
}
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
if (evt instanceof HttpLifecycleChannelHandler.StartEvent) {
HttpLifecycleChannelHandler.StartEvent startEvent = (HttpLifecycleChannelHandler.StartEvent) evt;
String uri = startEvent.getRequest().uri();
ChannelPipeline pipeline = ctx.pipeline();
removeEverythingAfterThis(pipeline);
if (Util.startsWithAnyOf(uri, this.pushPrefixes)) {
addPushHandlers(pipeline, uri);
} else if(uri.startsWith("/region/")) {
addRegionalHandlers(pipeline);
} else {
addZuulHandlers(pipeline);
}
}
ctx.fireUserEventTriggered(evt);
}
}
private void removeEverythingAfterThis(ChannelPipeline pipeline) {
while (pipeline.last().getClass() != MantisChannelHandler.class) {
pipeline.removeLast();
}
}
}
| 200 |
0 | Create_ds/dgs-federation-example/reviews-dgs/src/test/java/com/example/demo | Create_ds/dgs-federation-example/reviews-dgs/src/test/java/com/example/demo/datafetchers/ReviewsDatafetcherTest.java | package com.example.demo.datafetchers;
import com.example.demo.generated.client.EntitiesProjectionRoot;
import com.example.demo.generated.client.ShowRepresentation;
import com.example.demo.generated.types.Review;
import com.jayway.jsonpath.TypeRef;
import com.netflix.graphql.dgs.DgsQueryExecutor;
import com.netflix.graphql.dgs.autoconfig.DgsAutoConfiguration;
import com.netflix.graphql.dgs.client.codegen.EntitiesGraphQLQuery;
import com.netflix.graphql.dgs.client.codegen.GraphQLQueryRequest;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
@SpringBootTest(classes = {DgsAutoConfiguration.class, ReviewsDatafetcher.class})
class ReviewssDatafetcherTest {
@Autowired
DgsQueryExecutor dgsQueryExecutor;
@Test
void shows() {
Map<String,Object> representation = new HashMap<>();
representation.put("__typename", "Show");
representation.put("id", "1");
List<Map<String, Object>> representationsList = new ArrayList<>();
representationsList.add(representation);
Map<String, Object> variables = new HashMap<>();
variables.put("representations", representationsList);
List<Review> reviewsList = dgsQueryExecutor.executeAndExtractJsonPathAsObject(
"query ($representations:[_Any!]!) {" +
"_entities(representations:$representations) {" +
"... on Show {" +
" reviews {" +
" starRating" +
"}}}}",
"data['_entities'][0].reviews", variables, new TypeRef<>() {
});
assertThat(reviewsList).isNotNull();
assertThat(reviewsList.size()).isEqualTo(3);
}
@Test
void showsWithEntitiesQueryBuilder() {
EntitiesGraphQLQuery entitiesQuery = new EntitiesGraphQLQuery.Builder().addRepresentationAsVariable(ShowRepresentation.newBuilder().id("1").build()).build();
GraphQLQueryRequest request = new GraphQLQueryRequest(entitiesQuery, new EntitiesProjectionRoot().onShow().reviews().starRating());
List<Review> reviewsList = dgsQueryExecutor.executeAndExtractJsonPathAsObject(
request.serialize(),
"data['_entities'][0].reviews", entitiesQuery.getVariables(), new TypeRef<>() {
});
assertThat(reviewsList).isNotNull();
assertThat(reviewsList.size()).isEqualTo(3);
}
} | 201 |
0 | Create_ds/dgs-federation-example/reviews-dgs/src/main/java/com/example | Create_ds/dgs-federation-example/reviews-dgs/src/main/java/com/example/demo/ReviewsDgs.java | package com.example.demo;
import graphql.execution.instrumentation.tracing.TracingInstrumentation;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import graphql.execution.instrumentation.Instrumentation;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
@SpringBootApplication
public class ReviewsDgs {
public static void main(String[] args) {
SpringApplication.run(ReviewsDgs.class, args);
}
/**
* If you want to leverage Apollo Tracing, as supported by java-graphql, you can just create a bean of type {@link TracingInstrumentation}.
* In this example we added a conditional property on the bean to enable/disable the Apollo Tracing.
* Enabled by default, you can turn it off by setting `graphql.tracing.enabled=false` in your application properties.
*
* @see <a href="https://github.com/apollographql/apollo-tracing">Apollo Tracing</a>
*/
@Bean
@ConditionalOnProperty( prefix = "graphql.tracing", name = "enabled", matchIfMissing = true)
public Instrumentation tracingInstrumentation(){
return new TracingInstrumentation();
}
}
| 202 |
0 | Create_ds/dgs-federation-example/reviews-dgs/src/main/java/com/example/demo | Create_ds/dgs-federation-example/reviews-dgs/src/main/java/com/example/demo/datafetchers/ReviewsDatafetcher.java | package com.example.demo.datafetchers;
import com.example.demo.generated.types.Review;
import com.example.demo.generated.types.Show;
import com.netflix.graphql.dgs.DgsComponent;
import com.netflix.graphql.dgs.DgsData;
import com.netflix.graphql.dgs.DgsDataFetchingEnvironment;
import com.netflix.graphql.dgs.DgsEntityFetcher;
import java.util.*;
import java.util.stream.Collectors;
@DgsComponent
public class ReviewsDatafetcher {
Map<String, List<Review>> reviews = new HashMap<>();
public ReviewsDatafetcher() {
List<Review> review1 = new ArrayList<>();
review1.add(new Review(5));
review1.add(new Review(4));
review1.add(new Review(5));
reviews.put("1", review1);
List<Review> review2 = new ArrayList<>();
review2.add(new Review(3));
review2.add(new Review(5));
reviews.put("2", review2);
}
@DgsEntityFetcher(name = "Show")
public Show movie(Map<String, Object> values) {
return new Show((String) values.get("id"), null);
}
@DgsData(parentType = "Show", field = "reviews")
public List<Review> reviewsFetcher(DgsDataFetchingEnvironment dataFetchingEnvironment) {
Show show = dataFetchingEnvironment.getSource();
return reviews.get(show.getId());
}
}
| 203 |
0 | Create_ds/dgs-federation-example/shows-dgs/src/test/java/com/example/demo | Create_ds/dgs-federation-example/shows-dgs/src/test/java/com/example/demo/datafetchers/ShowsDataFetcherTests.java | /*
* Copyright 2020 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License 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 com.example.demo.datafetchers;
import com.example.demo.generated.client.ShowsGraphQLQuery;
import com.example.demo.generated.client.ShowsProjectionRoot;
import com.example.demo.generated.types.Show;
import com.example.demo.services.ShowsService;
import com.netflix.graphql.dgs.DgsQueryExecutor;
import com.netflix.graphql.dgs.autoconfig.DgsAutoConfiguration;
import com.netflix.graphql.dgs.client.codegen.GraphQLQueryRequest;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
@SpringBootTest(classes = {DgsAutoConfiguration.class, ShowsDataFetcher.class})
public class ShowsDataFetcherTests {
@Autowired
DgsQueryExecutor dgsQueryExecutor;
@MockBean
ShowsService showsService;
@BeforeEach
public void before() {
Mockito.when(showsService.shows()).thenAnswer(invocation -> List.of(new Show("1","mock title", 2020)));
}
@Test
public void showsWithQueryApi() {
GraphQLQueryRequest graphQLQueryRequest = new GraphQLQueryRequest(
new ShowsGraphQLQuery.Builder().build(),
new ShowsProjectionRoot().title()
);
List<String> titles = dgsQueryExecutor.executeAndExtractJsonPath(graphQLQueryRequest.serialize(), "data.shows[*].title");
assertThat(titles).containsExactly("mock title");
}
}
| 204 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/java | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/java/HMAC/__default.java | package HMAC;
import software.amazon.cryptography.primitives.internaldafny.types.Error;
import Wrappers_Compile.Result;
import dafny.DafnySequence;
import java.security.NoSuchAlgorithmException;
public class __default {
public static Result<DafnySequence<? extends Byte>, Error> Digest(
software.amazon.cryptography.primitives.internaldafny.types.HMacInput input
)
{
Result<HMac, Error> maybeHMac = HMac.Build(input._digestAlgorithm);
if (maybeHMac.is_Failure()) {
return Result.create_Failure(maybeHMac.dtor_error());
}
final HMac hmac = maybeHMac.Extract(HMac._typeDescriptor(), Error._typeDescriptor());
hmac.Init(input._key);
hmac.BlockUpdate(input._message);
final DafnySequence<? extends Byte> output = hmac.GetResult();
return Result.create_Success(output);
}
}
| 205 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/java | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/java/HMAC/HMac.java | package HMAC;
import software.amazon.cryptography.primitives.internaldafny.types.DigestAlgorithm;
import software.amazon.cryptography.primitives.internaldafny.types.Error;
import Wrappers_Compile.Result;
import dafny.Array;
import dafny.DafnySequence;
import org.bouncycastle.util.Bytes;
import software.amazon.cryptography.primitives.ToDafny;
import software.amazon.cryptography.primitives.model.AwsCryptographicPrimitivesError;
import javax.crypto.Mac;
import javax.crypto.ShortBufferException;
import javax.crypto.spec.SecretKeySpec;
import java.lang.IllegalStateException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.Collections;
public class HMac extends _ExternBase_HMac {
private String algorithm;
private Mac hmac;
public static Result<HMAC.HMac, Error> Build(DigestAlgorithm digest)
{
try {
final HMac output = new HMac(digest);
return Result.create_Success(output);
} catch ( NoSuchAlgorithmException ex) {
final Error err = ToDafny.Error(
AwsCryptographicPrimitivesError
.builder()
.message("Requested digest Algorithm is not supported.")
.cause(ex)
.build());
return Result.create_Failure(err);
}
}
public HMac(DigestAlgorithm digest) throws NoSuchAlgorithmException
{
if (digest.is_SHA__256()) {
algorithm = "HmacSHA256";
} else if (digest.is_SHA__384()) {
algorithm = "HmacSHA384";
} else if (digest.is_SHA__512()) {
algorithm = "HmacSHA512";
} else {
throw new NoSuchAlgorithmException();
}
hmac = Mac.getInstance(algorithm);
}
public void Init(DafnySequence<? extends Byte> key) {
final byte[] keyBytes = (byte[]) Array.unwrap(key.toArray());
try {
final SecretKeySpec secretKey = new SecretKeySpec(keyBytes, algorithm);
hmac.init(secretKey);
} catch (InvalidKeyException e) {
// Dafny preconditions should ensure it is impossible to enter here.
// In case this is ever not true, translate to a RuntimeException
// which will be bubbled up.
throw new IllegalStateException("Encountered InvalidKeyException: " + e.getMessage());
}
}
public void BlockUpdate(DafnySequence<? extends Byte> input) {
final byte[] inputBytes = (byte[]) Array.unwrap(input.toArray());
hmac.update(inputBytes);
}
public DafnySequence<? extends Byte> GetResult() {
final byte[] digest = hmac.doFinal();
return DafnySequence.fromBytes(digest);
}
}
| 206 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/java | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/java/AESEncryption/__default.java | package AESEncryption;
public class __default extends AESEncryption._ExternBase___default {
}
| 207 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/java | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/java/AESEncryption/AES_GCM.java | package AESEncryption;
import java.security.GeneralSecurityException;
import java.security.spec.AlgorithmParameterSpec;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.spec.GCMParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import software.amazon.cryptography.primitives.internaldafny.types.AESEncryptOutput;
import software.amazon.cryptography.primitives.internaldafny.types.AES__GCM;
import software.amazon.cryptography.primitives.internaldafny.types.Error;
import Random_Compile.ExternRandom;
import Wrappers_Compile.Result;
import dafny.Array;
import dafny.DafnySequence;
import software.amazon.cryptography.primitives.ToDafny;
import software.amazon.cryptography.primitives.model.OpaqueError;
public class AES_GCM {
public static Result<AESEncryptOutput, Error> AESEncryptExtern(
AES__GCM encAlg,
DafnySequence<? extends Byte> iv,
DafnySequence<? extends Byte> key,
DafnySequence<? extends Byte> msg,
DafnySequence<? extends Byte> aad
) {
byte[] keyBytes = (byte[]) Array.unwrap(key.toArray());
byte[] nonceBytes = (byte[]) Array.unwrap(iv.toArray());
byte[] plaintextBytes = (byte[]) Array.unwrap(msg.toArray());
final AlgorithmParameterSpec spec =
new GCMParameterSpec(encAlg._tagLength * 8, nonceBytes, 0, nonceBytes.length);
try {
Cipher cipher_ = Cipher.getInstance("AES/GCM/NoPadding");
SecretKey secretKey = new SecretKeySpec(keyBytes, "AES");
cipher_.init(Cipher.ENCRYPT_MODE, secretKey, spec, ExternRandom.getSecureRandom());
if (aad != null) {
byte[] aadBytes = (byte[]) Array.unwrap(aad.toArray());
cipher_.updateAAD(aadBytes);
}
byte[] cipherOutput = cipher_.doFinal(plaintextBytes);
AESEncryptOutput aesEncryptOutput = __default.EncryptionOutputFromByteSeq(
DafnySequence.fromBytes(cipherOutput),
encAlg);
return Result.create_Success(aesEncryptOutput);
} catch ( GeneralSecurityException e) {
return Result.create_Failure(ToDafny.Error(
OpaqueError.builder().obj(e).build())
);
}
}
public static Result<DafnySequence<? extends Byte>, Error> AESDecryptExtern(
AES__GCM encAlg,
DafnySequence<? extends Byte> key,
DafnySequence<? extends Byte> cipherTxt,
DafnySequence<? extends Byte> authTag,
DafnySequence<? extends Byte> iv,
DafnySequence<? extends Byte> aad
) {
byte[] keyBytes = (byte[]) Array.unwrap(key.toArray());
byte[] nonceBytes = (byte[]) Array.unwrap(iv.toArray());
byte[] ciphertextBytes = (byte[]) Array.unwrap(cipherTxt.toArray());
byte[] tagBytes = (byte[]) Array.unwrap(authTag.toArray());
byte[] ciphertextAndTag = new byte[ciphertextBytes.length + tagBytes.length];
System.arraycopy(ciphertextBytes, 0, ciphertextAndTag, 0, ciphertextBytes.length);
System.arraycopy(tagBytes, 0, ciphertextAndTag, ciphertextBytes.length, tagBytes.length);
final AlgorithmParameterSpec spec =
new GCMParameterSpec(encAlg._tagLength * 8, nonceBytes, 0, nonceBytes.length);
try {
Cipher cipher_ = Cipher.getInstance("AES/GCM/NoPadding");
SecretKey secretKey = new SecretKeySpec(keyBytes, "AES");
cipher_.init(Cipher.DECRYPT_MODE, secretKey, spec, ExternRandom.getSecureRandom());
if (aad != null) {
byte[] aadBytes = (byte[]) Array.unwrap(aad.toArray());
cipher_.updateAAD(aadBytes);
}
byte[] cipherOutput = cipher_.doFinal(ciphertextAndTag);
return Result.create_Success(DafnySequence.fromBytes(cipherOutput));
} catch ( GeneralSecurityException e) {
return Result.create_Failure(ToDafny.Error(
OpaqueError.builder().obj(e).build())
);
}
}
}
| 208 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/java | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/java/Signature/__default.java | package Signature;
public class __default extends Signature._ExternBase___default {
}
| 209 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/java | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/java/Signature/SignatureAlgorithm.java | package Signature;
import java.security.AlgorithmParameters;
import java.security.NoSuchAlgorithmException;
import java.security.spec.ECGenParameterSpec;
import java.security.spec.ECParameterSpec;
import java.security.spec.InvalidParameterSpecException;
import software.amazon.cryptography.primitives.internaldafny.types.DigestAlgorithm;
import software.amazon.cryptography.primitives.internaldafny.types.ECDSASignatureAlgorithm;
import software.amazon.cryptography.primitives.internaldafny.types.Error;
import Wrappers_Compile.Result;
import software.amazon.cryptography.primitives.ToDafny;
import software.amazon.cryptography.primitives.model.AwsCryptographicPrimitivesError;
import static Signature.ECDSA.SEC_P256;
import static Signature.ECDSA.SEC_P384;
import static Signature.ECDSA.SEC_PRIME_FIELD_PREFIX;
public enum SignatureAlgorithm {
P256(SEC_PRIME_FIELD_PREFIX+SEC_P256, DigestAlgorithm.create_SHA__256(), "NONEwithECDSA", (short) 71),
P384(SEC_PRIME_FIELD_PREFIX+SEC_P384, DigestAlgorithm.create_SHA__384(), "NONEwithECDSA", (short) 103);
public final String curve;
public final DigestAlgorithm messageDigestAlgorithm;
public final String rawSignatureAlgorithm;
public final short expectedSignatureLength;
SignatureAlgorithm(
final String curve,
final DigestAlgorithm messageDigestAlgorithm,
final String rawSignatureAlgorithm,
final short expectedSignatureLength
) {
this.curve = curve;
this.messageDigestAlgorithm = messageDigestAlgorithm;
this.rawSignatureAlgorithm = rawSignatureAlgorithm;
this.expectedSignatureLength = expectedSignatureLength;
}
static Result<SignatureAlgorithm, Error> signatureAlgorithm(ECDSASignatureAlgorithm dtor_signatureAlgorithm) {
final SignatureAlgorithm signatureAlgorithm;
//= aws-encryption-sdk-specification/framework/transitive-requirements.md#ecdsa
//# If specified to use ECDSA, the AWS Encryption SDK MUST use ECDSA with the following specifics:
//# - The elliptic curve is specified by the algorithm suite.
//# The specific curves are defined in
//# [Digital Signature Standard (DSS) (FIPS PUB 186-4)](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf).
if (dtor_signatureAlgorithm.is_ECDSA__P256()) {
signatureAlgorithm = P256;
} else if (dtor_signatureAlgorithm.is_ECDSA__P384()) {
signatureAlgorithm = P384;
} else {
return Result.create_Failure(ToDafny.Error(
AwsCryptographicPrimitivesError.builder().message(
String.format("Requested Curve is not supported. Requested %s.",
dtor_signatureAlgorithm))
.build()));
}
return Result.create_Success(signatureAlgorithm);
}
static ECParameterSpec ecParameterSpec(
SignatureAlgorithm algorithm
) throws NoSuchAlgorithmException, InvalidParameterSpecException {
final ECGenParameterSpec genParameterSpec =
new ECGenParameterSpec(algorithm.curve);
final AlgorithmParameters parameters =
AlgorithmParameters.getInstance(ECDSA.ELLIPTIC_CURVE_ALGORITHM);
parameters.init(genParameterSpec);
return parameters.getParameterSpec(ECParameterSpec.class);
}
}
| 210 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/java | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/java/Signature/ECDSA.java | package Signature;
import java.math.BigInteger;
import java.security.GeneralSecurityException;
import java.security.InvalidKeyException;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.Signature;
import java.security.SignatureException;
import java.security.interfaces.ECPrivateKey;
import java.security.interfaces.ECPublicKey;
import java.security.spec.ECGenParameterSpec;
import software.amazon.cryptography.primitives.internaldafny.types.ECDSASignatureAlgorithm;
import software.amazon.cryptography.primitives.internaldafny.types.Error;
import Digest_Compile.ExternDigest;
import Random_Compile.ExternRandom;
import Wrappers_Compile.Result;
import dafny.Array;
import dafny.DafnySequence;
import software.amazon.cryptography.primitives.ToDafny;
import software.amazon.cryptography.primitives.model.AwsCryptographicPrimitivesError;
import software.amazon.cryptography.primitives.model.OpaqueError;
import static Signature.SignatureAlgorithm.signatureAlgorithm;
public class ECDSA {
static final String ELLIPTIC_CURVE_ALGORITHM = "EC";
/* Standards for Efficient Cryptography over a prime field */
static final String SEC_PRIME_FIELD_PREFIX = "secp";
static final String SEC_P256 = "256r1";
static final String SEC_P384 = "384r1";
/* Constants used by SEC-1 v2 point compression and decompression algorithms */
static final BigInteger TWO = BigInteger.valueOf(2);
static final BigInteger THREE = BigInteger.valueOf(3);
static final BigInteger FOUR = BigInteger.valueOf(4);
public static Result<SignatureKeyPair, Error> ExternKeyGen(
ECDSASignatureAlgorithm dtor_signatureAlgorithm
) {
final Result<SignatureAlgorithm, Error> maybeSignatureAlgorithm =
signatureAlgorithm(dtor_signatureAlgorithm);
if (maybeSignatureAlgorithm.is_Failure()) {
return Result.create_Failure(maybeSignatureAlgorithm.dtor_error());
}
final ECGenParameterSpec genParameterSpec =
new ECGenParameterSpec(maybeSignatureAlgorithm.dtor_value().curve);
final SecureRandom secureRandom = ExternRandom.getSecureRandom();
final KeyPairGenerator keyGen;
try {
keyGen = KeyPairGenerator.getInstance(ELLIPTIC_CURVE_ALGORITHM);
keyGen.initialize(genParameterSpec, secureRandom);
} catch (GeneralSecurityException e) {
return Result.create_Failure(ToDafny.Error(
OpaqueError.builder().obj(e).message(e.getMessage()).cause(e).build()));
}
final KeyPair keyPair = keyGen.generateKeyPair();
// the verification key is the public key,
// this is not recorded in the spec,
// but is implied by the lack of "MUST be kept secret".
final byte[] verificationKey = PublicKeyUtils.encodeAndCompressPublicKey(
keyPair.getPublic(), dtor_signatureAlgorithm);
// the signing key is the private key, as is implied by:
//= aws-encryption-sdk-specification/framework/structures.md#signing-key
//# The value of this key MUST be kept secret.
final byte[] signingKey = PrivateKeyUtils.encodePrivateKey(
(ECPrivateKey)keyPair.getPrivate());
return Result.create_Success(SignatureKeyPair.create(
DafnySequence.fromBytes(verificationKey),
DafnySequence.fromBytes(signingKey)
));
}
public static Result<DafnySequence<? extends Byte>, Error> Sign(
ECDSASignatureAlgorithm dtor_signatureAlgorithm,
DafnySequence<? extends Byte> dtor_signingKey,
DafnySequence<? extends Byte> dtor_message
) {
final Result<SignatureAlgorithm, Error> maybeSignatureAlgorithm =
signatureAlgorithm(dtor_signatureAlgorithm);
if (maybeSignatureAlgorithm.is_Failure()) {
return Result.create_Failure(maybeSignatureAlgorithm.dtor_error());
}
SignatureAlgorithm algorithm = maybeSignatureAlgorithm.dtor_value();
final Signature signatureCipher;
try {
signatureCipher = Signature.getInstance(algorithm.rawSignatureAlgorithm);
} catch (NoSuchAlgorithmException ex) {
return Result.create_Failure(ToDafny.Error(
AwsCryptographicPrimitivesError.builder()
.message(String.format(
"Requested Signature Algorithm is not supported. Requested %s.",
algorithm.rawSignatureAlgorithm))
.cause(ex)
.build()));
}
Result<ECPrivateKey, Error> maybePrivateKey =
PrivateKeyUtils.decodePrivateKey(algorithm, dtor_signingKey);
if (maybePrivateKey.is_Failure()) {
return Result.create_Failure(maybePrivateKey.dtor_error());
}
final ECPrivateKey privateKey = maybePrivateKey.dtor_value();
final Result<byte[], Error> maybeDigest = ExternDigest.__default.internalDigest(
algorithm.messageDigestAlgorithm, dtor_message);
if (maybeDigest.is_Failure()) {
return Result.create_Failure(maybeDigest.dtor_error());
}
final byte[] digest = maybeDigest.dtor_value();
try {
signatureCipher.initSign(privateKey, ExternRandom.getSecureRandom());
} catch (InvalidKeyException ex) {
return Result.create_Failure(ToDafny.Error(
AwsCryptographicPrimitivesError.builder()
.message(String.format(
"Signature Cipher does not support provided key." +
"Signature %s" +
"Key %s",
signatureCipher, privateKey))
.cause(ex)
.build()));
}
final byte[] signatureBytes;
try {
signatureBytes = SignUtils.generateEcdsaFixedLengthSignature(
digest, signatureCipher, privateKey,
algorithm.expectedSignatureLength);
} catch (SignatureException e) {
return Result.create_Failure(ToDafny.Error(
OpaqueError.builder().obj(e).message(e.getMessage()).cause(e).build()));
}
return Result.create_Success(DafnySequence.fromBytes(signatureBytes));
}
public static Result<Boolean, Error> Verify(
ECDSASignatureAlgorithm dtor_signatureAlgorithm,
DafnySequence<? extends Byte> dtor_verificationKey,
DafnySequence<? extends Byte> dtor_message,
DafnySequence<? extends Byte> dtor_signature
) {
final Result<SignatureAlgorithm, Error> maybeSignatureAlgorithm =
signatureAlgorithm(dtor_signatureAlgorithm);
if (maybeSignatureAlgorithm.is_Failure()) {
return Result.create_Failure(maybeSignatureAlgorithm.dtor_error());
}
final SignatureAlgorithm algorithm = maybeSignatureAlgorithm.dtor_value();
Result<ECPublicKey, Error> maybePublicKey =
PublicKeyUtils.decodePublicKey(algorithm, dtor_verificationKey);
if (maybePublicKey.is_Failure()) {
return Result.create_Failure(maybePublicKey.dtor_error());
}
final ECPublicKey publicKey = maybePublicKey.dtor_value();
final Signature signatureCipher;
try {
signatureCipher = Signature.getInstance(algorithm.rawSignatureAlgorithm);
} catch (NoSuchAlgorithmException ex) {
return Result.create_Failure(ToDafny.Error(
AwsCryptographicPrimitivesError.builder()
.message(String.format(
"Requested Signature Algorithm is not supported. Requested %s.",
algorithm.rawSignatureAlgorithm))
.cause(ex)
.build()));
}
try {
signatureCipher.initVerify(publicKey);
} catch (InvalidKeyException ex) {
return Result.create_Failure(ToDafny.Error(
AwsCryptographicPrimitivesError.builder()
.message(String.format(
"Signature does not support provided key." +
"Signature %s" +
"Key %s",
signatureCipher, publicKey))
.cause(ex)
.build()));
}
final Result<byte[], Error> maybeDigest = ExternDigest.__default.internalDigest(
algorithm.messageDigestAlgorithm, dtor_message);
if (maybeDigest.is_Failure()) {
return Result.create_Failure(maybeDigest.dtor_error());
}
final byte[] digest = maybeDigest.dtor_value();
try {
signatureCipher.update(digest);
} catch (SignatureException ex) {
// For `update`, SignatureException can only be thrown if the
// signature cipher was not initialized.
// This should be impossible;
// if it happens, things are very wonky,
// and we should immediately throw.
throw new RuntimeException(ex);
}
final boolean success;
try {
// In the NET Extern,
// the signature bytes are converted via DER Deserialized.
// In the ESDK-Java@2.4.0, on decryption,
// the Signature's bytes are just handed to the cipher.
// Checking the general Java default provider,
// sun.security.util.ECUtil.decodeSignature,
// explicitly states:
// "Convert the DER encoding of R and S into a concatenation of R and S".
// Which indicates that this is correct.
final byte[] signatureAsBytes = (byte[]) Array.unwrap(dtor_signature.toArray());
success = signatureCipher.verify(signatureAsBytes);
} catch (SignatureException ex) {
return Result.create_Failure(ToDafny.Error(
AwsCryptographicPrimitivesError.builder()
.message(String.format(
"Signature Cipher does not support provided key." +
"Signature %s" +
"Key %s",
signatureCipher, publicKey))
.cause(ex)
.build()));
}
return Result.create_Success(success);
}
}
| 211 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/java | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/java/Signature/SignUtils.java | package Signature;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.DERSequence;
import java.io.IOException;
import java.security.Signature;
import java.security.SignatureException;
import java.security.interfaces.ECPrivateKey;
/** Helper methods for calculating a digital signature. */
class SignUtils {
// This is not in our spec:
// The ESDK wants a deterministic message size,
// including the signature in the footer.
// This "feature" facilitates uploading to S3,
// and use cases where "disk space" must be pre-allocated before
// receiving a data stream.
// Original Author: Bryan Donlan
static byte[] generateEcdsaFixedLengthSignature(
final byte[] digest,
final Signature signatureCipher,
final ECPrivateKey ecKey,
final short expectedLength
) throws SignatureException {
byte[] signatureBytes;
// Unfortunately, we need deterministic lengths while
// some signatures lengths are non-deterministic.
// So, we retry until we get the right length :-(
do {
signatureCipher.update(digest);
signatureBytes = signatureCipher.sign();
if (signatureBytes.length != expectedLength) {
// Most of the time, a signature of the wrong length can be fixed
// by negating s in the signature relative to the group order.
ASN1Sequence seq = ASN1Sequence.getInstance(signatureBytes);
ASN1Integer r = (ASN1Integer) seq.getObjectAt(0);
ASN1Integer s = (ASN1Integer) seq.getObjectAt(1);
s = new ASN1Integer(ecKey.getParams().getOrder().subtract(s.getPositiveValue()));
seq = new DERSequence(new ASN1Encodable[] {r, s});
try {
signatureBytes = seq.getEncoded();
} catch (IOException ex) {
throw new SignatureException(ex);
}
}
} while (signatureBytes.length != expectedLength);
return signatureBytes;
}
}
| 212 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/java | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/java/Signature/PrivateKeyUtils.java | package Signature;
import java.math.BigInteger;
import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
import java.security.interfaces.ECPrivateKey;
import java.security.spec.ECParameterSpec;
import java.security.spec.ECPrivateKeySpec;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.InvalidParameterSpecException;
import software.amazon.cryptography.primitives.internaldafny.types.Error;
import Wrappers_Compile.Result;
import dafny.Array;
import dafny.DafnySequence;
import software.amazon.cryptography.primitives.ToDafny;
import software.amazon.cryptography.primitives.model.OpaqueError;
/** Helper methods for encoding and decoding Elliptic Curve private keys. */
class PrivateKeyUtils {
// Based on our ESDK-Net implementation,
// ../../../../../net/Extern/Signature.cs#L46
// we convert the BigInteger to Byte Array with the sign.
// Bouncy Castle NET's Source code and documents are not clear if that
// is a big-endian Two's Complement or some other representation.
// Here, we are using Java's BigInteger to get
// the big-endian Two's Complement with the sign.
// However, the private key is ephemeral;
// it will always be generated and used in the same runtime.
// As such, we do not have to ensure that our different runtimes
// encode the private key identically.
static byte[] encodePrivateKey(final ECPrivateKey privateKey) {
return privateKey.getS().toByteArray();
}
static Result<ECPrivateKey, Error> decodePrivateKey(
SignatureAlgorithm algorithm,
DafnySequence<? extends Byte> dtor_signingKey
) {
final ECPrivateKey privateKey;
try {
final ECParameterSpec ecParameterSpec = SignatureAlgorithm.ecParameterSpec(algorithm);
final byte[] keyAsBytes = (byte[]) Array.unwrap(dtor_signingKey.toArray());
final ECPrivateKeySpec privateKeySpec = new ECPrivateKeySpec(
new BigInteger(keyAsBytes), ecParameterSpec);
// The following should result in
// sun.security.ec.ECKeyFactory.implGeneratePrivate
// or something equivalent.
// "generatePrivate" is a misnomer;
// it's really a deterministic factory method.
privateKey = (ECPrivateKey) KeyFactory.getInstance(ECDSA.ELLIPTIC_CURVE_ALGORITHM)
.generatePrivate(privateKeySpec);
} catch (NoSuchAlgorithmException | InvalidParameterSpecException | InvalidKeySpecException e) {
// The private key will always be generated in this runtime (Java);
// these exceptions SHOULD BE impossible.
return Result.create_Failure(ToDafny.Error(
OpaqueError.builder().obj(e).message(e.getMessage()).cause(e).build()));
}
return Result.create_Success(privateKey);
}
}
| 213 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/java | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/java/Signature/PublicKeyUtils.java | package Signature;
import java.math.BigInteger;
import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
import java.security.PublicKey;
import java.security.interfaces.ECPublicKey;
import java.security.spec.ECFieldFp;
import java.security.spec.ECParameterSpec;
import java.security.spec.ECPoint;
import java.security.spec.ECPublicKeySpec;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.InvalidParameterSpecException;
import java.util.Arrays;
import java.util.Objects;
import software.amazon.cryptography.primitives.internaldafny.types.ECDSASignatureAlgorithm;
import software.amazon.cryptography.primitives.internaldafny.types.Error;
import Wrappers_Compile.Result;
import dafny.Array;
import dafny.DafnySequence;
import software.amazon.cryptography.primitives.ToDafny;
import software.amazon.cryptography.primitives.model.AwsCryptographicPrimitivesError;
import software.amazon.cryptography.primitives.model.OpaqueError;
import static Signature.ECDSA.FOUR;
import static Signature.ECDSA.THREE;
import static Signature.ECDSA.TWO;
import static java.math.BigInteger.ONE;
import static java.math.BigInteger.ZERO;
/** Helper methods for encoding and decoding Elliptic Curve public keys. */
class PublicKeyUtils {
/**
* @param key The Elliptic Curve public key to
* encode and compress as described in SEC-1 v2 section 2.3.3
* @param dtor_signatureAlgorithm The Elliptic Curve algorithm
* @return byte[] The encoded and compressed public key
* @see <a href="http://www.secg.org/sec1-v2.pdf">http://www.secg.org/sec1-v2.pdf</a>
*/
static byte[] encodeAndCompressPublicKey(PublicKey key, ECDSASignatureAlgorithm dtor_signatureAlgorithm) {
Objects.requireNonNull(key, "key is required");
if (!(key instanceof ECPublicKey)) {
throw new IllegalArgumentException("key must be an instance of ECPublicKey");
}
final BigInteger x = ((ECPublicKey) key).getW().getAffineX();
final BigInteger y = ((ECPublicKey) key).getW().getAffineY();
final BigInteger compressedY = y.mod(TWO).equals(ZERO) ? TWO : THREE;
// The Dafny Source FieldSize methods includes the compressed Y-Byte.
final int xFieldSize = _ExternBase___default.FieldSize(dtor_signatureAlgorithm).intValueExact() - 1;
final byte[] xBytes = encodeAndCompressPublicKeyX(x, xFieldSize);
final byte[] compressedKey = new byte[xBytes.length + 1];
System.arraycopy(xBytes, 0, compressedKey, 1, xBytes.length);
compressedKey[0] = compressedY.byteValue();
return compressedKey;
}
/**
* Removes the leading zero sign byte from the byte array representation of a BigInteger (if
* present) and left pads with zeroes to produce a byte array of the given length.
*
* @param bigInteger The BigInteger to convert to a byte array
* @param length The length of the byte array, must be at least as long as the BigInteger byte
* array without the sign byte
* @return The byte array
*/
static byte[] encodeAndCompressPublicKeyX(final BigInteger bigInteger, final int length) {
byte[] rawBytes = bigInteger.toByteArray();
// If rawBytes is already the correct length, return it.
if (rawBytes.length == length) {
return rawBytes;
}
// If we're exactly one byte too large, but we have a leading zero byte, remove it and return.
if (rawBytes.length == length + 1 && rawBytes[0] == 0) {
return Arrays.copyOfRange(rawBytes, 1, rawBytes.length);
}
if (rawBytes.length > length) {
throw new IllegalArgumentException(
"Length must be at least as long as the BigInteger byte array "
+ "without the sign byte");
}
final byte[] paddedResult = new byte[length];
System.arraycopy(rawBytes, 0, paddedResult, length - rawBytes.length, rawBytes.length);
return paddedResult;
}
static Result<ECPublicKey, Error> decodePublicKey(
SignatureAlgorithm algorithm,
DafnySequence<? extends Byte> dtor_verificationKey
) {
final ECPublicKey publicKey;
try {
final ECParameterSpec ecParameterSpec = SignatureAlgorithm.ecParameterSpec(algorithm);
final byte[] keyAsBytes = (byte[]) Array.unwrap(dtor_verificationKey.toArray());
final ECPublicKeySpec publicKeySpec = new ECPublicKeySpec(
byteArrayToECPoint(keyAsBytes, ecParameterSpec), ecParameterSpec);
// The following should result in
// sun.security.ec.ECKeyFactory.implGeneratePublic
// or something equivalent.
// "generatePublic" is a misnomer;
// it's really a deterministic factory method.
publicKey = (ECPublicKey) KeyFactory.getInstance(ECDSA.ELLIPTIC_CURVE_ALGORITHM)
.generatePublic(publicKeySpec);
} catch (ECDecodingException ex) {
return Result.create_Failure(ToDafny.Error(
AwsCryptographicPrimitivesError.builder()
.message(String.format(
"Could not decode Elliptic Curve point due to: %s.",
ex.getMessage()))
.cause(ex)
.build()));
} catch ( NoSuchAlgorithmException | InvalidKeySpecException | InvalidParameterSpecException e) {
return Result.create_Failure(ToDafny.Error(
OpaqueError.builder().obj(e).message(e.getMessage()).cause(e).build()));
}
return Result.create_Success(publicKey);
}
/**
* Decodes a compressed elliptic curve point as described in SEC-1 v2 section 2.3.4.<p>
* Original Author: Wesley Rosenblum
*
* @param keyAsBytes The encoded and compressed Elliptic Curve public key.
* @param ecParameterSpec Elliptic Curve parameter spec describing the curve.
* @return The Elliptic Curve point.
* @see <a href="http://www.secg.org/sec1-v2.pdf">http://www.secg.org/sec1-v2.pdf</a>
*/
static ECPoint byteArrayToECPoint(
final byte[] keyAsBytes,
final ECParameterSpec ecParameterSpec
) throws ECDecodingException {
final BigInteger x = new BigInteger(1, Arrays.copyOfRange(keyAsBytes, 1, keyAsBytes.length));
final byte compressedY = keyAsBytes[0];
final BigInteger yOrder;
if (compressedY == TWO.byteValue()) {
yOrder = ZERO;
} else if (compressedY == THREE.byteValue()) {
yOrder = ONE;
} else {
throw new ECDecodingException("Compressed y value was invalid");
}
final BigInteger p = ((ECFieldFp) ecParameterSpec.getCurve().getField()).getP();
final BigInteger a = ecParameterSpec.getCurve().getA();
final BigInteger b = ecParameterSpec.getCurve().getB();
// alpha must be equal to y^2, this is validated below
final BigInteger alpha = x.modPow(THREE, p).add(a.multiply(x).mod(p)).add(b).mod(p);
final BigInteger beta;
if (p.mod(FOUR).equals(THREE)) {
beta = alpha.modPow(p.add(ONE).divide(FOUR), p);
} else {
throw new ECDecodingException("Curve not supported at this time");
}
//noinspection SuspiciousNameCombination
final BigInteger y = beta.mod(TWO).equals(yOrder) ? beta : p.subtract(beta);
// Validate that Y is a root of Y^2 to prevent invalid point attacks
if (!alpha.equals(y.modPow(TWO, p))) {
throw new ECDecodingException("Y was invalid");
}
return new ECPoint(x, y);
}
static class ECDecodingException extends RuntimeException {
ECDecodingException(String message) {
super(message);
}
}
}
| 214 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/java/Dafny/Aws/Cryptography | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/java/Dafny/Aws/Cryptography/Primitives/__default.java | package software.amazon.cryptography.primitives.internaldafny;
public class __default extends software.amazon.cryptography.primitives.internaldafny._ExternBase___default {
}
| 215 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/java/Dafny/Aws/Cryptography/Primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/java/Dafny/Aws/Cryptography/Primitives/Types/__default.java | package software.amazon.cryptography.primitives.internaldafny.types;
public class __default extends software.amazon.cryptography.primitives.internaldafny.types._ExternBase___default{
}
| 216 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/java | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/java/Digest_Compile/ExternDigest.java | package Digest_Compile;
import software.amazon.cryptography.primitives.internaldafny.types.DigestAlgorithm;
import software.amazon.cryptography.primitives.internaldafny.types.Error;
import Wrappers_Compile.Result;
import dafny.Array;
import dafny.DafnySequence;
import software.amazon.cryptography.primitives.ToDafny;
import software.amazon.cryptography.primitives.model.AwsCryptographicPrimitivesError;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class ExternDigest {
public static class __default {
public static Result<DafnySequence<? extends Byte>, Error> Digest(
DigestAlgorithm digestAlgorithm,
DafnySequence<? extends Byte> dtor_message
) {
final Result<byte[], Error> maybeDigest = internalDigest(digestAlgorithm, dtor_message);
if (maybeDigest.is_Failure()) {
return Result.create_Failure(maybeDigest.dtor_error());
}
return Result.create_Success(DafnySequence.fromBytes(
maybeDigest.dtor_value()));
}
public static Result<byte[], Error> internalDigest(
DigestAlgorithm digestAlgorithm,
DafnySequence<? extends Byte> dtor_message
) {
try {
final MessageDigest hash = getHash(digestAlgorithm);
final byte[] messageBytes = (byte[]) Array.unwrap(dtor_message.toArray());
hash.update(messageBytes);
final byte[] digest = hash.digest();
return Result.create_Success(digest);
} catch ( NoSuchAlgorithmException ex) {
final Error err = ToDafny.Error(
AwsCryptographicPrimitivesError
.builder()
.message("Requested digest Algorithm is not supported.")
.cause(ex)
.build());
return Result.create_Failure(err);
}
}
private static MessageDigest getHash(DigestAlgorithm digestAlgorithm) throws NoSuchAlgorithmException {
if (digestAlgorithm.is_SHA__256()) {
return MessageDigest.getInstance("SHA-256");
} else if (digestAlgorithm.is_SHA__384()) {
return MessageDigest.getInstance("SHA-384");
} else if (digestAlgorithm.is_SHA__512()) {
return MessageDigest.getInstance("SHA-512");
} else {
throw new NoSuchAlgorithmException();
}
}
}
}
| 217 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/java | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/java/RSAEncryption/__default.java | package RSAEncryption;
public class __default extends RSAEncryption._ExternBase___default {
}
| 218 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/java | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/java/RSAEncryption/RSA.java | package RSAEncryption;
import software.amazon.cryptography.primitives.internaldafny.types.Error;
import software.amazon.cryptography.primitives.internaldafny.types.RSAPaddingMode;
import Random_Compile.ExternRandom;
import Wrappers_Compile.Result;
import dafny.Array;
import dafny.DafnySequence;
import dafny.Tuple2;
import dafny.TypeDescriptor;
import org.bouncycastle.asn1.pkcs.PrivateKeyInfo;
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
import org.bouncycastle.crypto.AsymmetricBlockCipher;
import org.bouncycastle.crypto.AsymmetricCipherKeyPair;
import org.bouncycastle.crypto.KeyGenerationParameters;
import org.bouncycastle.crypto.digests.SHA1Digest;
import org.bouncycastle.crypto.digests.SHA256Digest;
import org.bouncycastle.crypto.digests.SHA384Digest;
import org.bouncycastle.crypto.digests.SHA512Digest;
import org.bouncycastle.crypto.encodings.OAEPEncoding;
import org.bouncycastle.crypto.encodings.PKCS1Encoding;
import org.bouncycastle.crypto.engines.RSABlindedEngine;
import org.bouncycastle.crypto.generators.RSAKeyPairGenerator;
import org.bouncycastle.crypto.params.AsymmetricKeyParameter;
import org.bouncycastle.crypto.params.RSAKeyGenerationParameters;
import org.bouncycastle.crypto.params.RSAKeyParameters;
import org.bouncycastle.crypto.util.PrivateKeyFactory;
import org.bouncycastle.crypto.util.PrivateKeyInfoFactory;
import org.bouncycastle.crypto.util.PublicKeyFactory;
import org.bouncycastle.crypto.util.SubjectPublicKeyInfoFactory;
import org.bouncycastle.util.io.pem.PemWriter;
import org.bouncycastle.util.io.pem.PemReader;
import org.bouncycastle.util.io.pem.PemObject;
import software.amazon.cryptography.primitives.ToDafny;
import software.amazon.cryptography.primitives.model.OpaqueError;
import java.security.SecureRandom;
import java.security.spec.X509EncodedKeySpec;
import java.nio.charset.StandardCharsets;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StringWriter;
import java.nio.ByteBuffer;
import java.math.BigInteger;
import static software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence;
public class RSA {
private static int RSA_KEY_LEN_MAX = 4096;
private static int RSA_PUBLIC_EXPONENT = 65537;
private static int RSA_CERTAINTY = 256;
private static String RSA_ERROR_MSG = String.format(
"AWS Crypto will not generate an RSA Key with length greater than %s", RSA_KEY_LEN_MAX);
public static Tuple2<DafnySequence<? extends Byte>, DafnySequence<? extends Byte>> GenerateKeyPairExtern(int lengthBits) {
try {
if (lengthBits > RSA_KEY_LEN_MAX) {
throw new RuntimeException(RSA_ERROR_MSG);
}
RSAKeyPairGenerator keygen = new RSAKeyPairGenerator();
final SecureRandom secureRandom = ExternRandom.getSecureRandom();
KeyGenerationParameters keyGenerationParameters = new RSAKeyGenerationParameters(
BigInteger.valueOf(RSA_PUBLIC_EXPONENT), secureRandom, lengthBits, RSA_CERTAINTY
);
keygen.init(keyGenerationParameters);
AsymmetricCipherKeyPair keyPair = keygen.generateKeyPair();
return Tuple2.create(
GetPemBytes(keyPair.getPublic()),
GetPemBytes(keyPair.getPrivate())
);
} catch (Exception e) {
throw new RuntimeException("Unable to create RSA Key Pair");
}
}
public static Result<Integer, Error> GetRSAKeyModulusLengthExtern(DafnySequence<? extends Byte> dtor_publicKey) {
try {
byte[] pemBytes = (byte[]) Array.unwrap(dtor_publicKey.toArray());
RSAKeyParameters keyParams = ParsePublicRsaPemBytes(pemBytes);
return Result.create_Success(keyParams.getModulus().bitLength());
} catch (Exception e) {
return Result.create_Failure(ToDafny.Error(
OpaqueError.builder().obj(e).message(e.getMessage()).cause(e).build())
);
}
}
// GetPemBytes represents a helper method that takes an AsymmetricKeyParameter and returns the corresponding
// private key or public key, PEM encoded, as UTF-8 bytes.
// Public keys are DER-encoded X.509 SubjectPublicKeyInfo, as specified in RFC 5280.
// Private keys are DER-encoded PKCS8 PrivateKeyInfo, as specified in RFC 5958.
private static DafnySequence<? extends Byte> GetPemBytes(AsymmetricKeyParameter keyParameter) throws IOException {
if (keyParameter.isPrivate()) {
PrivateKeyInfo privateKey = PrivateKeyInfoFactory.createPrivateKeyInfo(keyParameter);
StringWriter stringWriter = new StringWriter();
PemWriter pemWriter = new PemWriter(stringWriter);
pemWriter.writeObject(new PemObject("PRIVATE KEY", privateKey.getEncoded()));
pemWriter.close();
ByteBuffer outBuffer = StandardCharsets.UTF_8.encode(stringWriter.toString());
return ByteSequence(outBuffer, 0, outBuffer.limit());
} else {
SubjectPublicKeyInfo publicKey = SubjectPublicKeyInfoFactory.createSubjectPublicKeyInfo(keyParameter);
StringWriter stringWriter = new StringWriter();
PemWriter pemWriter = new PemWriter(stringWriter);
pemWriter.writeObject(new PemObject("PUBLIC KEY", publicKey.getEncoded()));
pemWriter.close();
ByteBuffer outBuffer = StandardCharsets.UTF_8.encode(stringWriter.toString());
return ByteSequence(outBuffer, 0, outBuffer.limit());
}
}
// Parses UTF8-encoded, PEM-encoded RSA Public keys.
private static RSAKeyParameters ParsePublicRsaPemBytes(byte[] pem) throws IOException {
PemReader pemReader = new PemReader(new InputStreamReader(new ByteArrayInputStream(pem)));
PemObject pemObject = pemReader.readPemObject();
byte[] content = pemObject.getContent();
RSAKeyParameters publicKeyParams = (RSAKeyParameters) PublicKeyFactory.createKey(content);
return publicKeyParams;
}
// Parses UTF8-encoded, PEM-encoded RSA Private keys.
private static RSAKeyParameters ParsePrivateRsaPemBytes(byte[] pem) throws IOException {
PemReader pemReader = new PemReader(new InputStreamReader(new ByteArrayInputStream(pem)));
PemObject pemObject = pemReader.readPemObject();
byte[] content = pemObject.getContent();
RSAKeyParameters privateKeyParams = (RSAKeyParameters) PrivateKeyFactory.createKey(content);
return privateKeyParams;
}
// GetEngineForPadding represents a helper method that takes in a RSAPaddingMode and returns a
// AsymmetricBlockCipher for the RsaBlindedEngine that uses the appropriate digest or throws a
// RSAUnsupportedPaddingSchemeException if no valid padding exists
private static AsymmetricBlockCipher GetEngineForPadding(RSAPaddingMode paddingMode) {
if (paddingMode.is_OAEP__SHA1()) {
return new OAEPEncoding(new RSABlindedEngine(), new SHA1Digest());
} else if (paddingMode.is_OAEP__SHA256()) {
return new OAEPEncoding(new RSABlindedEngine(), new SHA256Digest());
} else if (paddingMode.is_OAEP__SHA384()) {
return new OAEPEncoding(new RSABlindedEngine(), new SHA384Digest());
} else if (paddingMode.is_OAEP__SHA512()) {
return new OAEPEncoding(new RSABlindedEngine(), new SHA512Digest());
} else if (paddingMode.is_PKCS1()) {
return new PKCS1Encoding(new RSABlindedEngine());
} else {
throw new RuntimeException(String.format("Invalid RSA Padding Scheme %s", paddingMode));
}
}
public static Result<DafnySequence<? extends Byte>, Error> DecryptExtern(
RSAPaddingMode dtor_padding,
DafnySequence<? extends Byte> dtor_privateKey,
DafnySequence<? extends Byte> dtor_cipherText
) {
try {
byte[] privateKey = (byte[]) Array.unwrap(dtor_privateKey.toArray());
RSAKeyParameters keyParameter = ParsePrivateRsaPemBytes(privateKey);
byte[] ciphertext = (byte[]) Array.unwrap(dtor_cipherText.toArray());
AsymmetricBlockCipher engine = GetEngineForPadding(dtor_padding);
engine.init(false, keyParameter);
return Result.create_Success(
DafnySequence.fromBytes(
engine.processBlock(
ciphertext,
0,
ciphertext.length
)
)
);
} catch (Exception e) {
return Result.create_Failure(ToDafny.Error(
OpaqueError.builder().obj(e).message(e.getMessage()).cause(e).build())
);
}
}
public static Result<DafnySequence<? extends Byte>, Error> EncryptExtern(
RSAPaddingMode dtor_padding,
DafnySequence<? extends Byte> dtor_publicKey,
DafnySequence<? extends Byte> dtor_plaintext
) {
try {
byte[] publicKey = (byte[]) Array.unwrap(dtor_publicKey.toArray());
RSAKeyParameters publicKeyParam = ParsePublicRsaPemBytes(publicKey);
AsymmetricBlockCipher engine = GetEngineForPadding(dtor_padding);
engine.init(true, publicKeyParam);
return Result.create_Success(
DafnySequence.fromBytes(
engine.processBlock(
(byte[]) Array.unwrap(dtor_plaintext.toArray()),
0,
dtor_plaintext.toArray().length())
)
);
} catch (Exception e) {
return Result.create_Failure(ToDafny.Error(
OpaqueError.builder().obj(e).message(e.getMessage()).cause(e).build())
);
}
}
}
| 219 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/java | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/java/Random_Compile/ExternRandom.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
package Random_Compile;
import software.amazon.cryptography.primitives.internaldafny.types.Error;
import Wrappers_Compile.Result;
import dafny.DafnySequence;
import software.amazon.cryptography.primitives.ToDafny;
import software.amazon.cryptography.primitives.model.OpaqueError;
import java.security.SecureRandom;
public class ExternRandom {
public static class __default {
public static Result<DafnySequence<? extends Byte>, Error> GenerateBytes(final int len) {
try {
// We should revisit if there are limits on amount of
// bytes we can request with different crypto providers
final byte[] result = new byte[len];
final SecureRandom secureRandom = getSecureRandom();
secureRandom.nextBytes(result);
return Result.create_Success(DafnySequence.fromBytes(result));
} catch (Exception e) {
return Result.create_Failure(ToDafny.Error(
OpaqueError.builder().obj(e).cause(e).message(e.getMessage()).build()));
}
}
}
// SecureRandom objects can both be expensive to initialize and incur synchronization costs.
// This allows us to minimize both initializations and keep SecureRandom usage thread local
// to avoid lock contention.
private static final ThreadLocal<SecureRandom> LOCAL_RANDOM =
ThreadLocal.withInitial(() -> {
//= compliance/data-format/message-header.txt#2.5.1.6
//# While
//# implementations cannot guarantee complete uniqueness, implementations
//# MUST use a good source of randomness when generating messages IDs in
//# order to make the chance of duplicate IDs negligible.
final SecureRandom rnd = new SecureRandom();
rnd.nextBoolean(); // Force seeding
return rnd;
});
public static SecureRandom getSecureRandom() {
return LOCAL_RANDOM.get();
}
}
| 220 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/java | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/java/AesKdfCtr/__default.java | package AesKdfCtr;
import java.security.GeneralSecurityException;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import javax.crypto.spec.IvParameterSpec;
import Wrappers_Compile.Result;
import dafny.Array;
import dafny.DafnySequence;
import software.amazon.cryptography.primitives.ToDafny;
import software.amazon.cryptography.primitives.model.OpaqueError;
public class __default {
public static Wrappers_Compile.Result<dafny.DafnySequence<? extends Byte>, software.amazon.cryptography.primitives.internaldafny.types.Error>
AesKdfCtrStream(dafny.DafnySequence<? extends Byte> iv, dafny.DafnySequence<? extends Byte> key, int length)
{
byte[] keyBytes = (byte[]) Array.unwrap(key.toArray());
byte[] nonceBytes = (byte[]) Array.unwrap(iv.toArray());
byte[] plaintext = new byte[length];
try {
Cipher cipher = Cipher.getInstance("AES/CTR/NoPadding");
SecretKey secretKey = new SecretKeySpec(keyBytes, "AES");
IvParameterSpec ivSpec = new IvParameterSpec(nonceBytes);
cipher.init(Cipher.ENCRYPT_MODE, secretKey, ivSpec);
byte[] ciphertext = cipher.doFinal(plaintext);
return Result.create_Success(DafnySequence.fromBytes(ciphertext));
} catch ( GeneralSecurityException e) {
return Result.create_Failure(ToDafny.Error(
OpaqueError.builder().obj(e).build())
);
}
}
}
| 221 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/ToNative.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives;
import dafny.DafnySequence;
import java.lang.Boolean;
import java.lang.Byte;
import java.lang.IllegalArgumentException;
import java.lang.RuntimeException;
import java.nio.ByteBuffer;
import software.amazon.cryptography.primitives.internaldafny.types.AES__CTR;
import software.amazon.cryptography.primitives.internaldafny.types.AES__GCM;
import software.amazon.cryptography.primitives.internaldafny.types.Error;
import software.amazon.cryptography.primitives.internaldafny.types.Error_AwsCryptographicPrimitivesError;
import software.amazon.cryptography.primitives.internaldafny.types.Error_CollectionOfErrors;
import software.amazon.cryptography.primitives.internaldafny.types.Error_Opaque;
import software.amazon.cryptography.primitives.internaldafny.types.IAwsCryptographicPrimitivesClient;
import software.amazon.cryptography.primitives.model.AESDecryptInput;
import software.amazon.cryptography.primitives.model.AESEncryptInput;
import software.amazon.cryptography.primitives.model.AESEncryptOutput;
import software.amazon.cryptography.primitives.model.AES_CTR;
import software.amazon.cryptography.primitives.model.AES_GCM;
import software.amazon.cryptography.primitives.model.AesKdfCtrInput;
import software.amazon.cryptography.primitives.model.AwsCryptographicPrimitivesError;
import software.amazon.cryptography.primitives.model.CollectionOfErrors;
import software.amazon.cryptography.primitives.model.CryptoConfig;
import software.amazon.cryptography.primitives.model.DigestAlgorithm;
import software.amazon.cryptography.primitives.model.DigestInput;
import software.amazon.cryptography.primitives.model.ECDSASignInput;
import software.amazon.cryptography.primitives.model.ECDSASignatureAlgorithm;
import software.amazon.cryptography.primitives.model.ECDSAVerifyInput;
import software.amazon.cryptography.primitives.model.GenerateECDSASignatureKeyInput;
import software.amazon.cryptography.primitives.model.GenerateECDSASignatureKeyOutput;
import software.amazon.cryptography.primitives.model.GenerateRSAKeyPairInput;
import software.amazon.cryptography.primitives.model.GenerateRSAKeyPairOutput;
import software.amazon.cryptography.primitives.model.GenerateRandomBytesInput;
import software.amazon.cryptography.primitives.model.GetRSAKeyModulusLengthInput;
import software.amazon.cryptography.primitives.model.GetRSAKeyModulusLengthOutput;
import software.amazon.cryptography.primitives.model.HMacInput;
import software.amazon.cryptography.primitives.model.HkdfExpandInput;
import software.amazon.cryptography.primitives.model.HkdfExtractInput;
import software.amazon.cryptography.primitives.model.HkdfInput;
import software.amazon.cryptography.primitives.model.KdfCtrInput;
import software.amazon.cryptography.primitives.model.OpaqueError;
import software.amazon.cryptography.primitives.model.RSADecryptInput;
import software.amazon.cryptography.primitives.model.RSAEncryptInput;
import software.amazon.cryptography.primitives.model.RSAPaddingMode;
import software.amazon.cryptography.primitives.model.RSAPrivateKey;
import software.amazon.cryptography.primitives.model.RSAPublicKey;
public class ToNative {
public static OpaqueError Error(Error_Opaque dafnyValue) {
OpaqueError.Builder nativeBuilder = OpaqueError.builder();
nativeBuilder.obj(dafnyValue.dtor_obj());
return nativeBuilder.build();
}
public static CollectionOfErrors Error(Error_CollectionOfErrors dafnyValue) {
CollectionOfErrors.Builder nativeBuilder = CollectionOfErrors.builder();
nativeBuilder.list(
software.amazon.smithy.dafny.conversion.ToNative.Aggregate.GenericToList(
dafnyValue.dtor_list(),
ToNative::Error));
nativeBuilder.message(software.amazon.smithy.dafny.conversion.ToNative.Simple.String(dafnyValue.dtor_message()));
return nativeBuilder.build();
}
public static AwsCryptographicPrimitivesError Error(
Error_AwsCryptographicPrimitivesError dafnyValue) {
AwsCryptographicPrimitivesError.Builder nativeBuilder = AwsCryptographicPrimitivesError.builder();
nativeBuilder.message(software.amazon.smithy.dafny.conversion.ToNative.Simple.String(dafnyValue.dtor_message()));
return nativeBuilder.build();
}
public static RuntimeException Error(Error dafnyValue) {
if (dafnyValue.is_AwsCryptographicPrimitivesError()) {
return ToNative.Error((Error_AwsCryptographicPrimitivesError) dafnyValue);
}
if (dafnyValue.is_Opaque()) {
return ToNative.Error((Error_Opaque) dafnyValue);
}
if (dafnyValue.is_CollectionOfErrors()) {
return ToNative.Error((Error_CollectionOfErrors) dafnyValue);
}
OpaqueError.Builder nativeBuilder = OpaqueError.builder();
nativeBuilder.obj(dafnyValue);
return nativeBuilder.build();
}
public static AES_CTR AES_CTR(AES__CTR dafnyValue) {
AES_CTR.Builder nativeBuilder = AES_CTR.builder();
nativeBuilder.keyLength((dafnyValue.dtor_keyLength()));
nativeBuilder.nonceLength((dafnyValue.dtor_nonceLength()));
return nativeBuilder.build();
}
public static AES_GCM AES_GCM(AES__GCM dafnyValue) {
AES_GCM.Builder nativeBuilder = AES_GCM.builder();
nativeBuilder.keyLength((dafnyValue.dtor_keyLength()));
nativeBuilder.tagLength((dafnyValue.dtor_tagLength()));
nativeBuilder.ivLength((dafnyValue.dtor_ivLength()));
return nativeBuilder.build();
}
public static AESDecryptInput AESDecryptInput(
software.amazon.cryptography.primitives.internaldafny.types.AESDecryptInput dafnyValue) {
AESDecryptInput.Builder nativeBuilder = AESDecryptInput.builder();
nativeBuilder.encAlg(ToNative.AES_GCM(dafnyValue.dtor_encAlg()));
nativeBuilder.key(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_key()));
nativeBuilder.cipherTxt(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_cipherTxt()));
nativeBuilder.authTag(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_authTag()));
nativeBuilder.iv(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_iv()));
nativeBuilder.aad(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_aad()));
return nativeBuilder.build();
}
public static ByteBuffer AESDecryptOutput(DafnySequence<? extends Byte> dafnyValue) {
return software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue);
}
public static AESEncryptInput AESEncryptInput(
software.amazon.cryptography.primitives.internaldafny.types.AESEncryptInput dafnyValue) {
AESEncryptInput.Builder nativeBuilder = AESEncryptInput.builder();
nativeBuilder.encAlg(ToNative.AES_GCM(dafnyValue.dtor_encAlg()));
nativeBuilder.iv(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_iv()));
nativeBuilder.key(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_key()));
nativeBuilder.msg(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_msg()));
nativeBuilder.aad(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_aad()));
return nativeBuilder.build();
}
public static AESEncryptOutput AESEncryptOutput(
software.amazon.cryptography.primitives.internaldafny.types.AESEncryptOutput dafnyValue) {
AESEncryptOutput.Builder nativeBuilder = AESEncryptOutput.builder();
nativeBuilder.cipherText(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_cipherText()));
nativeBuilder.authTag(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_authTag()));
return nativeBuilder.build();
}
public static AesKdfCtrInput AesKdfCtrInput(
software.amazon.cryptography.primitives.internaldafny.types.AesKdfCtrInput dafnyValue) {
AesKdfCtrInput.Builder nativeBuilder = AesKdfCtrInput.builder();
nativeBuilder.ikm(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_ikm()));
nativeBuilder.expectedLength((dafnyValue.dtor_expectedLength()));
if (dafnyValue.dtor_nonce().is_Some()) {
nativeBuilder.nonce(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_nonce().dtor_value()));
}
return nativeBuilder.build();
}
public static ByteBuffer AesKdfCtrOutput(DafnySequence<? extends Byte> dafnyValue) {
return software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue);
}
public static CryptoConfig CryptoConfig(
software.amazon.cryptography.primitives.internaldafny.types.CryptoConfig dafnyValue) {
CryptoConfig.Builder nativeBuilder = CryptoConfig.builder();
return nativeBuilder.build();
}
public static DigestInput DigestInput(
software.amazon.cryptography.primitives.internaldafny.types.DigestInput dafnyValue) {
DigestInput.Builder nativeBuilder = DigestInput.builder();
nativeBuilder.digestAlgorithm(ToNative.DigestAlgorithm(dafnyValue.dtor_digestAlgorithm()));
nativeBuilder.message(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_message()));
return nativeBuilder.build();
}
public static ByteBuffer DigestOutput(DafnySequence<? extends Byte> dafnyValue) {
return software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue);
}
public static ECDSASignInput ECDSASignInput(
software.amazon.cryptography.primitives.internaldafny.types.ECDSASignInput dafnyValue) {
ECDSASignInput.Builder nativeBuilder = ECDSASignInput.builder();
nativeBuilder.signatureAlgorithm(ToNative.ECDSASignatureAlgorithm(dafnyValue.dtor_signatureAlgorithm()));
nativeBuilder.signingKey(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_signingKey()));
nativeBuilder.message(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_message()));
return nativeBuilder.build();
}
public static ByteBuffer ECDSASignOutput(DafnySequence<? extends Byte> dafnyValue) {
return software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue);
}
public static ECDSAVerifyInput ECDSAVerifyInput(
software.amazon.cryptography.primitives.internaldafny.types.ECDSAVerifyInput dafnyValue) {
ECDSAVerifyInput.Builder nativeBuilder = ECDSAVerifyInput.builder();
nativeBuilder.signatureAlgorithm(ToNative.ECDSASignatureAlgorithm(dafnyValue.dtor_signatureAlgorithm()));
nativeBuilder.verificationKey(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_verificationKey()));
nativeBuilder.message(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_message()));
nativeBuilder.signature(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_signature()));
return nativeBuilder.build();
}
public static Boolean ECDSAVerifyOutput(Boolean dafnyValue) {
return (dafnyValue);
}
public static GenerateECDSASignatureKeyInput GenerateECDSASignatureKeyInput(
software.amazon.cryptography.primitives.internaldafny.types.GenerateECDSASignatureKeyInput dafnyValue) {
GenerateECDSASignatureKeyInput.Builder nativeBuilder = GenerateECDSASignatureKeyInput.builder();
nativeBuilder.signatureAlgorithm(ToNative.ECDSASignatureAlgorithm(dafnyValue.dtor_signatureAlgorithm()));
return nativeBuilder.build();
}
public static GenerateECDSASignatureKeyOutput GenerateECDSASignatureKeyOutput(
software.amazon.cryptography.primitives.internaldafny.types.GenerateECDSASignatureKeyOutput dafnyValue) {
GenerateECDSASignatureKeyOutput.Builder nativeBuilder = GenerateECDSASignatureKeyOutput.builder();
nativeBuilder.signatureAlgorithm(ToNative.ECDSASignatureAlgorithm(dafnyValue.dtor_signatureAlgorithm()));
nativeBuilder.verificationKey(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_verificationKey()));
nativeBuilder.signingKey(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_signingKey()));
return nativeBuilder.build();
}
public static GenerateRandomBytesInput GenerateRandomBytesInput(
software.amazon.cryptography.primitives.internaldafny.types.GenerateRandomBytesInput dafnyValue) {
GenerateRandomBytesInput.Builder nativeBuilder = GenerateRandomBytesInput.builder();
nativeBuilder.length((dafnyValue.dtor_length()));
return nativeBuilder.build();
}
public static ByteBuffer GenerateRandomBytesOutput(DafnySequence<? extends Byte> dafnyValue) {
return software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue);
}
public static GenerateRSAKeyPairInput GenerateRSAKeyPairInput(
software.amazon.cryptography.primitives.internaldafny.types.GenerateRSAKeyPairInput dafnyValue) {
GenerateRSAKeyPairInput.Builder nativeBuilder = GenerateRSAKeyPairInput.builder();
nativeBuilder.lengthBits((dafnyValue.dtor_lengthBits()));
return nativeBuilder.build();
}
public static GenerateRSAKeyPairOutput GenerateRSAKeyPairOutput(
software.amazon.cryptography.primitives.internaldafny.types.GenerateRSAKeyPairOutput dafnyValue) {
GenerateRSAKeyPairOutput.Builder nativeBuilder = GenerateRSAKeyPairOutput.builder();
nativeBuilder.publicKey(ToNative.RSAPublicKey(dafnyValue.dtor_publicKey()));
nativeBuilder.privateKey(ToNative.RSAPrivateKey(dafnyValue.dtor_privateKey()));
return nativeBuilder.build();
}
public static GetRSAKeyModulusLengthInput GetRSAKeyModulusLengthInput(
software.amazon.cryptography.primitives.internaldafny.types.GetRSAKeyModulusLengthInput dafnyValue) {
GetRSAKeyModulusLengthInput.Builder nativeBuilder = GetRSAKeyModulusLengthInput.builder();
nativeBuilder.publicKey(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_publicKey()));
return nativeBuilder.build();
}
public static GetRSAKeyModulusLengthOutput GetRSAKeyModulusLengthOutput(
software.amazon.cryptography.primitives.internaldafny.types.GetRSAKeyModulusLengthOutput dafnyValue) {
GetRSAKeyModulusLengthOutput.Builder nativeBuilder = GetRSAKeyModulusLengthOutput.builder();
nativeBuilder.length((dafnyValue.dtor_length()));
return nativeBuilder.build();
}
public static HkdfExpandInput HkdfExpandInput(
software.amazon.cryptography.primitives.internaldafny.types.HkdfExpandInput dafnyValue) {
HkdfExpandInput.Builder nativeBuilder = HkdfExpandInput.builder();
nativeBuilder.digestAlgorithm(ToNative.DigestAlgorithm(dafnyValue.dtor_digestAlgorithm()));
nativeBuilder.prk(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_prk()));
nativeBuilder.info(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_info()));
nativeBuilder.expectedLength((dafnyValue.dtor_expectedLength()));
return nativeBuilder.build();
}
public static ByteBuffer HkdfExpandOutput(DafnySequence<? extends Byte> dafnyValue) {
return software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue);
}
public static HkdfExtractInput HkdfExtractInput(
software.amazon.cryptography.primitives.internaldafny.types.HkdfExtractInput dafnyValue) {
HkdfExtractInput.Builder nativeBuilder = HkdfExtractInput.builder();
nativeBuilder.digestAlgorithm(ToNative.DigestAlgorithm(dafnyValue.dtor_digestAlgorithm()));
if (dafnyValue.dtor_salt().is_Some()) {
nativeBuilder.salt(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_salt().dtor_value()));
}
nativeBuilder.ikm(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_ikm()));
return nativeBuilder.build();
}
public static ByteBuffer HkdfExtractOutput(DafnySequence<? extends Byte> dafnyValue) {
return software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue);
}
public static HkdfInput HkdfInput(
software.amazon.cryptography.primitives.internaldafny.types.HkdfInput dafnyValue) {
HkdfInput.Builder nativeBuilder = HkdfInput.builder();
nativeBuilder.digestAlgorithm(ToNative.DigestAlgorithm(dafnyValue.dtor_digestAlgorithm()));
if (dafnyValue.dtor_salt().is_Some()) {
nativeBuilder.salt(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_salt().dtor_value()));
}
nativeBuilder.ikm(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_ikm()));
nativeBuilder.info(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_info()));
nativeBuilder.expectedLength((dafnyValue.dtor_expectedLength()));
return nativeBuilder.build();
}
public static ByteBuffer HkdfOutput(DafnySequence<? extends Byte> dafnyValue) {
return software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue);
}
public static HMacInput HMacInput(
software.amazon.cryptography.primitives.internaldafny.types.HMacInput dafnyValue) {
HMacInput.Builder nativeBuilder = HMacInput.builder();
nativeBuilder.digestAlgorithm(ToNative.DigestAlgorithm(dafnyValue.dtor_digestAlgorithm()));
nativeBuilder.key(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_key()));
nativeBuilder.message(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_message()));
return nativeBuilder.build();
}
public static ByteBuffer HMacOutput(DafnySequence<? extends Byte> dafnyValue) {
return software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue);
}
public static KdfCtrInput KdfCtrInput(
software.amazon.cryptography.primitives.internaldafny.types.KdfCtrInput dafnyValue) {
KdfCtrInput.Builder nativeBuilder = KdfCtrInput.builder();
nativeBuilder.digestAlgorithm(ToNative.DigestAlgorithm(dafnyValue.dtor_digestAlgorithm()));
nativeBuilder.ikm(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_ikm()));
nativeBuilder.expectedLength((dafnyValue.dtor_expectedLength()));
if (dafnyValue.dtor_purpose().is_Some()) {
nativeBuilder.purpose(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_purpose().dtor_value()));
}
if (dafnyValue.dtor_nonce().is_Some()) {
nativeBuilder.nonce(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_nonce().dtor_value()));
}
return nativeBuilder.build();
}
public static ByteBuffer KdfCtrOutput(DafnySequence<? extends Byte> dafnyValue) {
return software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue);
}
public static RSADecryptInput RSADecryptInput(
software.amazon.cryptography.primitives.internaldafny.types.RSADecryptInput dafnyValue) {
RSADecryptInput.Builder nativeBuilder = RSADecryptInput.builder();
nativeBuilder.padding(ToNative.RSAPaddingMode(dafnyValue.dtor_padding()));
nativeBuilder.privateKey(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_privateKey()));
nativeBuilder.cipherText(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_cipherText()));
return nativeBuilder.build();
}
public static ByteBuffer RSADecryptOutput(DafnySequence<? extends Byte> dafnyValue) {
return software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue);
}
public static RSAEncryptInput RSAEncryptInput(
software.amazon.cryptography.primitives.internaldafny.types.RSAEncryptInput dafnyValue) {
RSAEncryptInput.Builder nativeBuilder = RSAEncryptInput.builder();
nativeBuilder.padding(ToNative.RSAPaddingMode(dafnyValue.dtor_padding()));
nativeBuilder.publicKey(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_publicKey()));
nativeBuilder.plaintext(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_plaintext()));
return nativeBuilder.build();
}
public static ByteBuffer RSAEncryptOutput(DafnySequence<? extends Byte> dafnyValue) {
return software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue);
}
public static RSAPrivateKey RSAPrivateKey(
software.amazon.cryptography.primitives.internaldafny.types.RSAPrivateKey dafnyValue) {
RSAPrivateKey.Builder nativeBuilder = RSAPrivateKey.builder();
nativeBuilder.lengthBits((dafnyValue.dtor_lengthBits()));
nativeBuilder.pem(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_pem()));
return nativeBuilder.build();
}
public static RSAPublicKey RSAPublicKey(
software.amazon.cryptography.primitives.internaldafny.types.RSAPublicKey dafnyValue) {
RSAPublicKey.Builder nativeBuilder = RSAPublicKey.builder();
nativeBuilder.lengthBits((dafnyValue.dtor_lengthBits()));
nativeBuilder.pem(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_pem()));
return nativeBuilder.build();
}
public static DigestAlgorithm DigestAlgorithm(
software.amazon.cryptography.primitives.internaldafny.types.DigestAlgorithm dafnyValue) {
if (dafnyValue.is_SHA__512()) {
return DigestAlgorithm.SHA_512;
}
if (dafnyValue.is_SHA__384()) {
return DigestAlgorithm.SHA_384;
}
if (dafnyValue.is_SHA__256()) {
return DigestAlgorithm.SHA_256;
}
throw new IllegalArgumentException("No entry of software.amazon.cryptography.primitives.model.DigestAlgorithm matches the input : " + dafnyValue);
}
public static ECDSASignatureAlgorithm ECDSASignatureAlgorithm(
software.amazon.cryptography.primitives.internaldafny.types.ECDSASignatureAlgorithm dafnyValue) {
if (dafnyValue.is_ECDSA__P384()) {
return ECDSASignatureAlgorithm.ECDSA_P384;
}
if (dafnyValue.is_ECDSA__P256()) {
return ECDSASignatureAlgorithm.ECDSA_P256;
}
throw new IllegalArgumentException("No entry of software.amazon.cryptography.primitives.model.ECDSASignatureAlgorithm matches the input : " + dafnyValue);
}
public static RSAPaddingMode RSAPaddingMode(
software.amazon.cryptography.primitives.internaldafny.types.RSAPaddingMode dafnyValue) {
if (dafnyValue.is_PKCS1()) {
return RSAPaddingMode.PKCS1;
}
if (dafnyValue.is_OAEP__SHA1()) {
return RSAPaddingMode.OAEP_SHA1;
}
if (dafnyValue.is_OAEP__SHA256()) {
return RSAPaddingMode.OAEP_SHA256;
}
if (dafnyValue.is_OAEP__SHA384()) {
return RSAPaddingMode.OAEP_SHA384;
}
if (dafnyValue.is_OAEP__SHA512()) {
return RSAPaddingMode.OAEP_SHA512;
}
throw new IllegalArgumentException("No entry of software.amazon.cryptography.primitives.model.RSAPaddingMode matches the input : " + dafnyValue);
}
public static AtomicPrimitives AwsCryptographicPrimitives(
IAwsCryptographicPrimitivesClient dafnyValue) {
return new AtomicPrimitives(dafnyValue);
}
}
| 222 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/AtomicPrimitives.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives;
import Wrappers_Compile.Result;
import dafny.DafnySequence;
import java.lang.Boolean;
import java.lang.Byte;
import java.lang.IllegalArgumentException;
import java.nio.ByteBuffer;
import java.util.Objects;
import software.amazon.cryptography.primitives.internaldafny.AtomicPrimitivesClient;
import software.amazon.cryptography.primitives.internaldafny.__default;
import software.amazon.cryptography.primitives.internaldafny.types.Error;
import software.amazon.cryptography.primitives.internaldafny.types.IAwsCryptographicPrimitivesClient;
import software.amazon.cryptography.primitives.model.AESDecryptInput;
import software.amazon.cryptography.primitives.model.AESEncryptInput;
import software.amazon.cryptography.primitives.model.AESEncryptOutput;
import software.amazon.cryptography.primitives.model.AesKdfCtrInput;
import software.amazon.cryptography.primitives.model.CryptoConfig;
import software.amazon.cryptography.primitives.model.DigestInput;
import software.amazon.cryptography.primitives.model.ECDSASignInput;
import software.amazon.cryptography.primitives.model.ECDSAVerifyInput;
import software.amazon.cryptography.primitives.model.GenerateECDSASignatureKeyInput;
import software.amazon.cryptography.primitives.model.GenerateECDSASignatureKeyOutput;
import software.amazon.cryptography.primitives.model.GenerateRSAKeyPairInput;
import software.amazon.cryptography.primitives.model.GenerateRSAKeyPairOutput;
import software.amazon.cryptography.primitives.model.GenerateRandomBytesInput;
import software.amazon.cryptography.primitives.model.GetRSAKeyModulusLengthInput;
import software.amazon.cryptography.primitives.model.GetRSAKeyModulusLengthOutput;
import software.amazon.cryptography.primitives.model.HMacInput;
import software.amazon.cryptography.primitives.model.HkdfExpandInput;
import software.amazon.cryptography.primitives.model.HkdfExtractInput;
import software.amazon.cryptography.primitives.model.HkdfInput;
import software.amazon.cryptography.primitives.model.KdfCtrInput;
import software.amazon.cryptography.primitives.model.RSADecryptInput;
import software.amazon.cryptography.primitives.model.RSAEncryptInput;
public class AtomicPrimitives {
private final IAwsCryptographicPrimitivesClient _impl;
protected AtomicPrimitives(BuilderImpl builder) {
CryptoConfig input = builder.CryptoConfig();
software.amazon.cryptography.primitives.internaldafny.types.CryptoConfig dafnyValue = ToDafny.CryptoConfig(input);
Result<AtomicPrimitivesClient, Error> result = __default.AtomicPrimitives(dafnyValue);
if (result.is_Failure()) {
throw ToNative.Error(result.dtor_error());
}
this._impl = result.dtor_value();
}
AtomicPrimitives(IAwsCryptographicPrimitivesClient impl) {
this._impl = impl;
}
public static Builder builder() {
return new BuilderImpl();
}
public ByteBuffer AESDecrypt(AESDecryptInput input) {
software.amazon.cryptography.primitives.internaldafny.types.AESDecryptInput dafnyValue = ToDafny.AESDecryptInput(input);
Result<DafnySequence<? extends Byte>, Error> result = this._impl.AESDecrypt(dafnyValue);
if (result.is_Failure()) {
throw ToNative.Error(result.dtor_error());
}
return software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(result.dtor_value());
}
public AESEncryptOutput AESEncrypt(AESEncryptInput input) {
software.amazon.cryptography.primitives.internaldafny.types.AESEncryptInput dafnyValue = ToDafny.AESEncryptInput(input);
Result<software.amazon.cryptography.primitives.internaldafny.types.AESEncryptOutput, Error> result = this._impl.AESEncrypt(dafnyValue);
if (result.is_Failure()) {
throw ToNative.Error(result.dtor_error());
}
return ToNative.AESEncryptOutput(result.dtor_value());
}
public ByteBuffer AesKdfCounterMode(AesKdfCtrInput input) {
software.amazon.cryptography.primitives.internaldafny.types.AesKdfCtrInput dafnyValue = ToDafny.AesKdfCtrInput(input);
Result<DafnySequence<? extends Byte>, Error> result = this._impl.AesKdfCounterMode(dafnyValue);
if (result.is_Failure()) {
throw ToNative.Error(result.dtor_error());
}
return software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(result.dtor_value());
}
public ByteBuffer Digest(DigestInput input) {
software.amazon.cryptography.primitives.internaldafny.types.DigestInput dafnyValue = ToDafny.DigestInput(input);
Result<DafnySequence<? extends Byte>, Error> result = this._impl.Digest(dafnyValue);
if (result.is_Failure()) {
throw ToNative.Error(result.dtor_error());
}
return software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(result.dtor_value());
}
public ByteBuffer ECDSASign(ECDSASignInput input) {
software.amazon.cryptography.primitives.internaldafny.types.ECDSASignInput dafnyValue = ToDafny.ECDSASignInput(input);
Result<DafnySequence<? extends Byte>, Error> result = this._impl.ECDSASign(dafnyValue);
if (result.is_Failure()) {
throw ToNative.Error(result.dtor_error());
}
return software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(result.dtor_value());
}
public Boolean ECDSAVerify(ECDSAVerifyInput input) {
software.amazon.cryptography.primitives.internaldafny.types.ECDSAVerifyInput dafnyValue = ToDafny.ECDSAVerifyInput(input);
Result<Boolean, Error> result = this._impl.ECDSAVerify(dafnyValue);
if (result.is_Failure()) {
throw ToNative.Error(result.dtor_error());
}
return (result.dtor_value());
}
public GenerateECDSASignatureKeyOutput GenerateECDSASignatureKey(
GenerateECDSASignatureKeyInput input) {
software.amazon.cryptography.primitives.internaldafny.types.GenerateECDSASignatureKeyInput dafnyValue = ToDafny.GenerateECDSASignatureKeyInput(input);
Result<software.amazon.cryptography.primitives.internaldafny.types.GenerateECDSASignatureKeyOutput, Error> result = this._impl.GenerateECDSASignatureKey(dafnyValue);
if (result.is_Failure()) {
throw ToNative.Error(result.dtor_error());
}
return ToNative.GenerateECDSASignatureKeyOutput(result.dtor_value());
}
public ByteBuffer GenerateRandomBytes(GenerateRandomBytesInput input) {
software.amazon.cryptography.primitives.internaldafny.types.GenerateRandomBytesInput dafnyValue = ToDafny.GenerateRandomBytesInput(input);
Result<DafnySequence<? extends Byte>, Error> result = this._impl.GenerateRandomBytes(dafnyValue);
if (result.is_Failure()) {
throw ToNative.Error(result.dtor_error());
}
return software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(result.dtor_value());
}
public GenerateRSAKeyPairOutput GenerateRSAKeyPair(GenerateRSAKeyPairInput input) {
software.amazon.cryptography.primitives.internaldafny.types.GenerateRSAKeyPairInput dafnyValue = ToDafny.GenerateRSAKeyPairInput(input);
Result<software.amazon.cryptography.primitives.internaldafny.types.GenerateRSAKeyPairOutput, Error> result = this._impl.GenerateRSAKeyPair(dafnyValue);
if (result.is_Failure()) {
throw ToNative.Error(result.dtor_error());
}
return ToNative.GenerateRSAKeyPairOutput(result.dtor_value());
}
public GetRSAKeyModulusLengthOutput GetRSAKeyModulusLength(GetRSAKeyModulusLengthInput input) {
software.amazon.cryptography.primitives.internaldafny.types.GetRSAKeyModulusLengthInput dafnyValue = ToDafny.GetRSAKeyModulusLengthInput(input);
Result<software.amazon.cryptography.primitives.internaldafny.types.GetRSAKeyModulusLengthOutput, Error> result = this._impl.GetRSAKeyModulusLength(dafnyValue);
if (result.is_Failure()) {
throw ToNative.Error(result.dtor_error());
}
return ToNative.GetRSAKeyModulusLengthOutput(result.dtor_value());
}
public ByteBuffer Hkdf(HkdfInput input) {
software.amazon.cryptography.primitives.internaldafny.types.HkdfInput dafnyValue = ToDafny.HkdfInput(input);
Result<DafnySequence<? extends Byte>, Error> result = this._impl.Hkdf(dafnyValue);
if (result.is_Failure()) {
throw ToNative.Error(result.dtor_error());
}
return software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(result.dtor_value());
}
public ByteBuffer HkdfExpand(HkdfExpandInput input) {
software.amazon.cryptography.primitives.internaldafny.types.HkdfExpandInput dafnyValue = ToDafny.HkdfExpandInput(input);
Result<DafnySequence<? extends Byte>, Error> result = this._impl.HkdfExpand(dafnyValue);
if (result.is_Failure()) {
throw ToNative.Error(result.dtor_error());
}
return software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(result.dtor_value());
}
public ByteBuffer HkdfExtract(HkdfExtractInput input) {
software.amazon.cryptography.primitives.internaldafny.types.HkdfExtractInput dafnyValue = ToDafny.HkdfExtractInput(input);
Result<DafnySequence<? extends Byte>, Error> result = this._impl.HkdfExtract(dafnyValue);
if (result.is_Failure()) {
throw ToNative.Error(result.dtor_error());
}
return software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(result.dtor_value());
}
public ByteBuffer HMac(HMacInput input) {
software.amazon.cryptography.primitives.internaldafny.types.HMacInput dafnyValue = ToDafny.HMacInput(input);
Result<DafnySequence<? extends Byte>, Error> result = this._impl.HMac(dafnyValue);
if (result.is_Failure()) {
throw ToNative.Error(result.dtor_error());
}
return software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(result.dtor_value());
}
public ByteBuffer KdfCounterMode(KdfCtrInput input) {
software.amazon.cryptography.primitives.internaldafny.types.KdfCtrInput dafnyValue = ToDafny.KdfCtrInput(input);
Result<DafnySequence<? extends Byte>, Error> result = this._impl.KdfCounterMode(dafnyValue);
if (result.is_Failure()) {
throw ToNative.Error(result.dtor_error());
}
return software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(result.dtor_value());
}
public ByteBuffer RSADecrypt(RSADecryptInput input) {
software.amazon.cryptography.primitives.internaldafny.types.RSADecryptInput dafnyValue = ToDafny.RSADecryptInput(input);
Result<DafnySequence<? extends Byte>, Error> result = this._impl.RSADecrypt(dafnyValue);
if (result.is_Failure()) {
throw ToNative.Error(result.dtor_error());
}
return software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(result.dtor_value());
}
public ByteBuffer RSAEncrypt(RSAEncryptInput input) {
software.amazon.cryptography.primitives.internaldafny.types.RSAEncryptInput dafnyValue = ToDafny.RSAEncryptInput(input);
Result<DafnySequence<? extends Byte>, Error> result = this._impl.RSAEncrypt(dafnyValue);
if (result.is_Failure()) {
throw ToNative.Error(result.dtor_error());
}
return software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(result.dtor_value());
}
protected IAwsCryptographicPrimitivesClient impl() {
return this._impl;
}
public interface Builder {
Builder CryptoConfig(CryptoConfig CryptoConfig);
CryptoConfig CryptoConfig();
AtomicPrimitives build();
}
static class BuilderImpl implements Builder {
protected CryptoConfig CryptoConfig;
protected BuilderImpl() {
}
public Builder CryptoConfig(CryptoConfig CryptoConfig) {
this.CryptoConfig = CryptoConfig;
return this;
}
public CryptoConfig CryptoConfig() {
return this.CryptoConfig;
}
public AtomicPrimitives build() {
if (Objects.isNull(this.CryptoConfig())) {
throw new IllegalArgumentException("Missing value for required field `CryptoConfig`");
}
return new AtomicPrimitives(this);
}
}
}
| 223 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/ToDafny.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives;
import Wrappers_Compile.Option;
import dafny.DafnySequence;
import java.lang.Boolean;
import java.lang.Byte;
import java.lang.Character;
import java.lang.Integer;
import java.lang.RuntimeException;
import java.nio.ByteBuffer;
import java.util.Objects;
import software.amazon.cryptography.primitives.internaldafny.types.AESDecryptInput;
import software.amazon.cryptography.primitives.internaldafny.types.AESEncryptInput;
import software.amazon.cryptography.primitives.internaldafny.types.AESEncryptOutput;
import software.amazon.cryptography.primitives.internaldafny.types.AES__CTR;
import software.amazon.cryptography.primitives.internaldafny.types.AES__GCM;
import software.amazon.cryptography.primitives.internaldafny.types.AesKdfCtrInput;
import software.amazon.cryptography.primitives.internaldafny.types.CryptoConfig;
import software.amazon.cryptography.primitives.internaldafny.types.DigestAlgorithm;
import software.amazon.cryptography.primitives.internaldafny.types.DigestInput;
import software.amazon.cryptography.primitives.internaldafny.types.ECDSASignInput;
import software.amazon.cryptography.primitives.internaldafny.types.ECDSASignatureAlgorithm;
import software.amazon.cryptography.primitives.internaldafny.types.ECDSAVerifyInput;
import software.amazon.cryptography.primitives.internaldafny.types.Error;
import software.amazon.cryptography.primitives.internaldafny.types.Error_AwsCryptographicPrimitivesError;
import software.amazon.cryptography.primitives.internaldafny.types.GenerateECDSASignatureKeyInput;
import software.amazon.cryptography.primitives.internaldafny.types.GenerateECDSASignatureKeyOutput;
import software.amazon.cryptography.primitives.internaldafny.types.GenerateRSAKeyPairInput;
import software.amazon.cryptography.primitives.internaldafny.types.GenerateRSAKeyPairOutput;
import software.amazon.cryptography.primitives.internaldafny.types.GenerateRandomBytesInput;
import software.amazon.cryptography.primitives.internaldafny.types.GetRSAKeyModulusLengthInput;
import software.amazon.cryptography.primitives.internaldafny.types.GetRSAKeyModulusLengthOutput;
import software.amazon.cryptography.primitives.internaldafny.types.HMacInput;
import software.amazon.cryptography.primitives.internaldafny.types.HkdfExpandInput;
import software.amazon.cryptography.primitives.internaldafny.types.HkdfExtractInput;
import software.amazon.cryptography.primitives.internaldafny.types.HkdfInput;
import software.amazon.cryptography.primitives.internaldafny.types.IAwsCryptographicPrimitivesClient;
import software.amazon.cryptography.primitives.internaldafny.types.KdfCtrInput;
import software.amazon.cryptography.primitives.internaldafny.types.RSADecryptInput;
import software.amazon.cryptography.primitives.internaldafny.types.RSAEncryptInput;
import software.amazon.cryptography.primitives.internaldafny.types.RSAPaddingMode;
import software.amazon.cryptography.primitives.internaldafny.types.RSAPrivateKey;
import software.amazon.cryptography.primitives.internaldafny.types.RSAPublicKey;
import software.amazon.cryptography.primitives.model.AES_CTR;
import software.amazon.cryptography.primitives.model.AES_GCM;
import software.amazon.cryptography.primitives.model.AwsCryptographicPrimitivesError;
import software.amazon.cryptography.primitives.model.CollectionOfErrors;
import software.amazon.cryptography.primitives.model.OpaqueError;
public class ToDafny {
public static Error Error(RuntimeException nativeValue) {
if (nativeValue instanceof AwsCryptographicPrimitivesError) {
return ToDafny.Error((AwsCryptographicPrimitivesError) nativeValue);
}
if (nativeValue instanceof OpaqueError) {
return ToDafny.Error((OpaqueError) nativeValue);
}
if (nativeValue instanceof CollectionOfErrors) {
return ToDafny.Error((CollectionOfErrors) nativeValue);
}
return Error.create_Opaque(nativeValue);
}
public static Error Error(OpaqueError nativeValue) {
return Error.create_Opaque(nativeValue.obj());
}
public static Error Error(CollectionOfErrors nativeValue) {
DafnySequence<? extends Error> list = software.amazon.smithy.dafny.conversion.ToDafny.Aggregate.GenericToSequence(
nativeValue.list(),
ToDafny::Error,
Error._typeDescriptor());
DafnySequence<? extends Character> message = software.amazon.smithy.dafny.conversion.ToDafny.Simple.CharacterSequence(nativeValue.getMessage());
return Error.create_CollectionOfErrors(list, message);
}
public static AES__CTR AES_CTR(AES_CTR nativeValue) {
Integer keyLength;
keyLength = (nativeValue.keyLength());
Integer nonceLength;
nonceLength = (nativeValue.nonceLength());
return new AES__CTR(keyLength, nonceLength);
}
public static AES__GCM AES_GCM(AES_GCM nativeValue) {
Integer keyLength;
keyLength = (nativeValue.keyLength());
Integer tagLength;
tagLength = (nativeValue.tagLength());
Integer ivLength;
ivLength = (nativeValue.ivLength());
return new AES__GCM(keyLength, tagLength, ivLength);
}
public static AESDecryptInput AESDecryptInput(
software.amazon.cryptography.primitives.model.AESDecryptInput nativeValue) {
AES__GCM encAlg;
encAlg = ToDafny.AES_GCM(nativeValue.encAlg());
DafnySequence<? extends Byte> key;
key = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.key());
DafnySequence<? extends Byte> cipherTxt;
cipherTxt = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.cipherTxt());
DafnySequence<? extends Byte> authTag;
authTag = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.authTag());
DafnySequence<? extends Byte> iv;
iv = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.iv());
DafnySequence<? extends Byte> aad;
aad = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.aad());
return new AESDecryptInput(encAlg, key, cipherTxt, authTag, iv, aad);
}
public static DafnySequence<? extends Byte> AESDecryptOutput(ByteBuffer nativeValue) {
DafnySequence<? extends Byte> plaintext;
plaintext = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue);
return plaintext;
}
public static AESEncryptInput AESEncryptInput(
software.amazon.cryptography.primitives.model.AESEncryptInput nativeValue) {
AES__GCM encAlg;
encAlg = ToDafny.AES_GCM(nativeValue.encAlg());
DafnySequence<? extends Byte> iv;
iv = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.iv());
DafnySequence<? extends Byte> key;
key = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.key());
DafnySequence<? extends Byte> msg;
msg = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.msg());
DafnySequence<? extends Byte> aad;
aad = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.aad());
return new AESEncryptInput(encAlg, iv, key, msg, aad);
}
public static AESEncryptOutput AESEncryptOutput(
software.amazon.cryptography.primitives.model.AESEncryptOutput nativeValue) {
DafnySequence<? extends Byte> cipherText;
cipherText = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.cipherText());
DafnySequence<? extends Byte> authTag;
authTag = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.authTag());
return new AESEncryptOutput(cipherText, authTag);
}
public static AesKdfCtrInput AesKdfCtrInput(
software.amazon.cryptography.primitives.model.AesKdfCtrInput nativeValue) {
DafnySequence<? extends Byte> ikm;
ikm = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.ikm());
Integer expectedLength;
expectedLength = (nativeValue.expectedLength());
Option<DafnySequence<? extends Byte>> nonce;
nonce = Objects.nonNull(nativeValue.nonce()) ?
Option.create_Some(software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.nonce()))
: Option.create_None();
return new AesKdfCtrInput(ikm, expectedLength, nonce);
}
public static DafnySequence<? extends Byte> AesKdfCtrOutput(ByteBuffer nativeValue) {
DafnySequence<? extends Byte> okm;
okm = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue);
return okm;
}
public static CryptoConfig CryptoConfig(
software.amazon.cryptography.primitives.model.CryptoConfig nativeValue) {
return new CryptoConfig();
}
public static DigestInput DigestInput(
software.amazon.cryptography.primitives.model.DigestInput nativeValue) {
DigestAlgorithm digestAlgorithm;
digestAlgorithm = ToDafny.DigestAlgorithm(nativeValue.digestAlgorithm());
DafnySequence<? extends Byte> message;
message = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.message());
return new DigestInput(digestAlgorithm, message);
}
public static DafnySequence<? extends Byte> DigestOutput(ByteBuffer nativeValue) {
DafnySequence<? extends Byte> digest;
digest = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue);
return digest;
}
public static ECDSASignInput ECDSASignInput(
software.amazon.cryptography.primitives.model.ECDSASignInput nativeValue) {
ECDSASignatureAlgorithm signatureAlgorithm;
signatureAlgorithm = ToDafny.ECDSASignatureAlgorithm(nativeValue.signatureAlgorithm());
DafnySequence<? extends Byte> signingKey;
signingKey = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.signingKey());
DafnySequence<? extends Byte> message;
message = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.message());
return new ECDSASignInput(signatureAlgorithm, signingKey, message);
}
public static DafnySequence<? extends Byte> ECDSASignOutput(ByteBuffer nativeValue) {
DafnySequence<? extends Byte> signature;
signature = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue);
return signature;
}
public static ECDSAVerifyInput ECDSAVerifyInput(
software.amazon.cryptography.primitives.model.ECDSAVerifyInput nativeValue) {
ECDSASignatureAlgorithm signatureAlgorithm;
signatureAlgorithm = ToDafny.ECDSASignatureAlgorithm(nativeValue.signatureAlgorithm());
DafnySequence<? extends Byte> verificationKey;
verificationKey = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.verificationKey());
DafnySequence<? extends Byte> message;
message = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.message());
DafnySequence<? extends Byte> signature;
signature = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.signature());
return new ECDSAVerifyInput(signatureAlgorithm, verificationKey, message, signature);
}
public static Boolean ECDSAVerifyOutput(Boolean nativeValue) {
Boolean success;
success = (nativeValue);
return success;
}
public static GenerateECDSASignatureKeyInput GenerateECDSASignatureKeyInput(
software.amazon.cryptography.primitives.model.GenerateECDSASignatureKeyInput nativeValue) {
ECDSASignatureAlgorithm signatureAlgorithm;
signatureAlgorithm = ToDafny.ECDSASignatureAlgorithm(nativeValue.signatureAlgorithm());
return new GenerateECDSASignatureKeyInput(signatureAlgorithm);
}
public static GenerateECDSASignatureKeyOutput GenerateECDSASignatureKeyOutput(
software.amazon.cryptography.primitives.model.GenerateECDSASignatureKeyOutput nativeValue) {
ECDSASignatureAlgorithm signatureAlgorithm;
signatureAlgorithm = ToDafny.ECDSASignatureAlgorithm(nativeValue.signatureAlgorithm());
DafnySequence<? extends Byte> verificationKey;
verificationKey = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.verificationKey());
DafnySequence<? extends Byte> signingKey;
signingKey = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.signingKey());
return new GenerateECDSASignatureKeyOutput(signatureAlgorithm, verificationKey, signingKey);
}
public static GenerateRandomBytesInput GenerateRandomBytesInput(
software.amazon.cryptography.primitives.model.GenerateRandomBytesInput nativeValue) {
Integer length;
length = (nativeValue.length());
return new GenerateRandomBytesInput(length);
}
public static DafnySequence<? extends Byte> GenerateRandomBytesOutput(ByteBuffer nativeValue) {
DafnySequence<? extends Byte> data;
data = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue);
return data;
}
public static GenerateRSAKeyPairInput GenerateRSAKeyPairInput(
software.amazon.cryptography.primitives.model.GenerateRSAKeyPairInput nativeValue) {
Integer lengthBits;
lengthBits = (nativeValue.lengthBits());
return new GenerateRSAKeyPairInput(lengthBits);
}
public static GenerateRSAKeyPairOutput GenerateRSAKeyPairOutput(
software.amazon.cryptography.primitives.model.GenerateRSAKeyPairOutput nativeValue) {
RSAPublicKey publicKey;
publicKey = ToDafny.RSAPublicKey(nativeValue.publicKey());
RSAPrivateKey privateKey;
privateKey = ToDafny.RSAPrivateKey(nativeValue.privateKey());
return new GenerateRSAKeyPairOutput(publicKey, privateKey);
}
public static GetRSAKeyModulusLengthInput GetRSAKeyModulusLengthInput(
software.amazon.cryptography.primitives.model.GetRSAKeyModulusLengthInput nativeValue) {
DafnySequence<? extends Byte> publicKey;
publicKey = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.publicKey());
return new GetRSAKeyModulusLengthInput(publicKey);
}
public static GetRSAKeyModulusLengthOutput GetRSAKeyModulusLengthOutput(
software.amazon.cryptography.primitives.model.GetRSAKeyModulusLengthOutput nativeValue) {
Integer length;
length = (nativeValue.length());
return new GetRSAKeyModulusLengthOutput(length);
}
public static HkdfExpandInput HkdfExpandInput(
software.amazon.cryptography.primitives.model.HkdfExpandInput nativeValue) {
DigestAlgorithm digestAlgorithm;
digestAlgorithm = ToDafny.DigestAlgorithm(nativeValue.digestAlgorithm());
DafnySequence<? extends Byte> prk;
prk = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.prk());
DafnySequence<? extends Byte> info;
info = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.info());
Integer expectedLength;
expectedLength = (nativeValue.expectedLength());
return new HkdfExpandInput(digestAlgorithm, prk, info, expectedLength);
}
public static DafnySequence<? extends Byte> HkdfExpandOutput(ByteBuffer nativeValue) {
DafnySequence<? extends Byte> okm;
okm = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue);
return okm;
}
public static HkdfExtractInput HkdfExtractInput(
software.amazon.cryptography.primitives.model.HkdfExtractInput nativeValue) {
DigestAlgorithm digestAlgorithm;
digestAlgorithm = ToDafny.DigestAlgorithm(nativeValue.digestAlgorithm());
Option<DafnySequence<? extends Byte>> salt;
salt = Objects.nonNull(nativeValue.salt()) ?
Option.create_Some(software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.salt()))
: Option.create_None();
DafnySequence<? extends Byte> ikm;
ikm = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.ikm());
return new HkdfExtractInput(digestAlgorithm, salt, ikm);
}
public static DafnySequence<? extends Byte> HkdfExtractOutput(ByteBuffer nativeValue) {
DafnySequence<? extends Byte> prk;
prk = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue);
return prk;
}
public static HkdfInput HkdfInput(
software.amazon.cryptography.primitives.model.HkdfInput nativeValue) {
DigestAlgorithm digestAlgorithm;
digestAlgorithm = ToDafny.DigestAlgorithm(nativeValue.digestAlgorithm());
Option<DafnySequence<? extends Byte>> salt;
salt = Objects.nonNull(nativeValue.salt()) ?
Option.create_Some(software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.salt()))
: Option.create_None();
DafnySequence<? extends Byte> ikm;
ikm = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.ikm());
DafnySequence<? extends Byte> info;
info = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.info());
Integer expectedLength;
expectedLength = (nativeValue.expectedLength());
return new HkdfInput(digestAlgorithm, salt, ikm, info, expectedLength);
}
public static DafnySequence<? extends Byte> HkdfOutput(ByteBuffer nativeValue) {
DafnySequence<? extends Byte> okm;
okm = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue);
return okm;
}
public static HMacInput HMacInput(
software.amazon.cryptography.primitives.model.HMacInput nativeValue) {
DigestAlgorithm digestAlgorithm;
digestAlgorithm = ToDafny.DigestAlgorithm(nativeValue.digestAlgorithm());
DafnySequence<? extends Byte> key;
key = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.key());
DafnySequence<? extends Byte> message;
message = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.message());
return new HMacInput(digestAlgorithm, key, message);
}
public static DafnySequence<? extends Byte> HMacOutput(ByteBuffer nativeValue) {
DafnySequence<? extends Byte> digest;
digest = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue);
return digest;
}
public static KdfCtrInput KdfCtrInput(
software.amazon.cryptography.primitives.model.KdfCtrInput nativeValue) {
DigestAlgorithm digestAlgorithm;
digestAlgorithm = ToDafny.DigestAlgorithm(nativeValue.digestAlgorithm());
DafnySequence<? extends Byte> ikm;
ikm = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.ikm());
Integer expectedLength;
expectedLength = (nativeValue.expectedLength());
Option<DafnySequence<? extends Byte>> purpose;
purpose = Objects.nonNull(nativeValue.purpose()) ?
Option.create_Some(software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.purpose()))
: Option.create_None();
Option<DafnySequence<? extends Byte>> nonce;
nonce = Objects.nonNull(nativeValue.nonce()) ?
Option.create_Some(software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.nonce()))
: Option.create_None();
return new KdfCtrInput(digestAlgorithm, ikm, expectedLength, purpose, nonce);
}
public static DafnySequence<? extends Byte> KdfCtrOutput(ByteBuffer nativeValue) {
DafnySequence<? extends Byte> okm;
okm = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue);
return okm;
}
public static RSADecryptInput RSADecryptInput(
software.amazon.cryptography.primitives.model.RSADecryptInput nativeValue) {
RSAPaddingMode padding;
padding = ToDafny.RSAPaddingMode(nativeValue.padding());
DafnySequence<? extends Byte> privateKey;
privateKey = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.privateKey());
DafnySequence<? extends Byte> cipherText;
cipherText = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.cipherText());
return new RSADecryptInput(padding, privateKey, cipherText);
}
public static DafnySequence<? extends Byte> RSADecryptOutput(ByteBuffer nativeValue) {
DafnySequence<? extends Byte> plaintext;
plaintext = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue);
return plaintext;
}
public static RSAEncryptInput RSAEncryptInput(
software.amazon.cryptography.primitives.model.RSAEncryptInput nativeValue) {
RSAPaddingMode padding;
padding = ToDafny.RSAPaddingMode(nativeValue.padding());
DafnySequence<? extends Byte> publicKey;
publicKey = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.publicKey());
DafnySequence<? extends Byte> plaintext;
plaintext = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.plaintext());
return new RSAEncryptInput(padding, publicKey, plaintext);
}
public static DafnySequence<? extends Byte> RSAEncryptOutput(ByteBuffer nativeValue) {
DafnySequence<? extends Byte> cipherText;
cipherText = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue);
return cipherText;
}
public static RSAPrivateKey RSAPrivateKey(
software.amazon.cryptography.primitives.model.RSAPrivateKey nativeValue) {
Integer lengthBits;
lengthBits = (nativeValue.lengthBits());
DafnySequence<? extends Byte> pem;
pem = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.pem());
return new RSAPrivateKey(lengthBits, pem);
}
public static RSAPublicKey RSAPublicKey(
software.amazon.cryptography.primitives.model.RSAPublicKey nativeValue) {
Integer lengthBits;
lengthBits = (nativeValue.lengthBits());
DafnySequence<? extends Byte> pem;
pem = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.pem());
return new RSAPublicKey(lengthBits, pem);
}
public static Error Error(AwsCryptographicPrimitivesError nativeValue) {
DafnySequence<? extends Character> message;
message = software.amazon.smithy.dafny.conversion.ToDafny.Simple.CharacterSequence(nativeValue.message());
return new Error_AwsCryptographicPrimitivesError(message);
}
public static DigestAlgorithm DigestAlgorithm(
software.amazon.cryptography.primitives.model.DigestAlgorithm nativeValue) {
switch (nativeValue) {
case SHA_512: {
return DigestAlgorithm.create_SHA__512();
}
case SHA_384: {
return DigestAlgorithm.create_SHA__384();
}
case SHA_256: {
return DigestAlgorithm.create_SHA__256();
}
default: {
throw new RuntimeException("Cannot convert " + nativeValue + " to software.amazon.cryptography.primitives.internaldafny.types.DigestAlgorithm.");
}
}
}
public static ECDSASignatureAlgorithm ECDSASignatureAlgorithm(
software.amazon.cryptography.primitives.model.ECDSASignatureAlgorithm nativeValue) {
switch (nativeValue) {
case ECDSA_P384: {
return ECDSASignatureAlgorithm.create_ECDSA__P384();
}
case ECDSA_P256: {
return ECDSASignatureAlgorithm.create_ECDSA__P256();
}
default: {
throw new RuntimeException("Cannot convert " + nativeValue + " to software.amazon.cryptography.primitives.internaldafny.types.ECDSASignatureAlgorithm.");
}
}
}
public static RSAPaddingMode RSAPaddingMode(
software.amazon.cryptography.primitives.model.RSAPaddingMode nativeValue) {
switch (nativeValue) {
case PKCS1: {
return RSAPaddingMode.create_PKCS1();
}
case OAEP_SHA1: {
return RSAPaddingMode.create_OAEP__SHA1();
}
case OAEP_SHA256: {
return RSAPaddingMode.create_OAEP__SHA256();
}
case OAEP_SHA384: {
return RSAPaddingMode.create_OAEP__SHA384();
}
case OAEP_SHA512: {
return RSAPaddingMode.create_OAEP__SHA512();
}
default: {
throw new RuntimeException("Cannot convert " + nativeValue + " to software.amazon.cryptography.primitives.internaldafny.types.RSAPaddingMode.");
}
}
}
public static IAwsCryptographicPrimitivesClient AwsCryptographicPrimitives(
AtomicPrimitives nativeValue) {
return nativeValue.impl();
}
}
| 224 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/GenerateRSAKeyPairOutput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
import java.util.Objects;
public class GenerateRSAKeyPairOutput {
private final RSAPublicKey publicKey;
private final RSAPrivateKey privateKey;
protected GenerateRSAKeyPairOutput(BuilderImpl builder) {
this.publicKey = builder.publicKey();
this.privateKey = builder.privateKey();
}
public RSAPublicKey publicKey() {
return this.publicKey;
}
public RSAPrivateKey privateKey() {
return this.privateKey;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder publicKey(RSAPublicKey publicKey);
RSAPublicKey publicKey();
Builder privateKey(RSAPrivateKey privateKey);
RSAPrivateKey privateKey();
GenerateRSAKeyPairOutput build();
}
static class BuilderImpl implements Builder {
protected RSAPublicKey publicKey;
protected RSAPrivateKey privateKey;
protected BuilderImpl() {
}
protected BuilderImpl(GenerateRSAKeyPairOutput model) {
this.publicKey = model.publicKey();
this.privateKey = model.privateKey();
}
public Builder publicKey(RSAPublicKey publicKey) {
this.publicKey = publicKey;
return this;
}
public RSAPublicKey publicKey() {
return this.publicKey;
}
public Builder privateKey(RSAPrivateKey privateKey) {
this.privateKey = privateKey;
return this;
}
public RSAPrivateKey privateKey() {
return this.privateKey;
}
public GenerateRSAKeyPairOutput build() {
if (Objects.isNull(this.publicKey())) {
throw new IllegalArgumentException("Missing value for required field `publicKey`");
}
if (Objects.isNull(this.privateKey())) {
throw new IllegalArgumentException("Missing value for required field `privateKey`");
}
return new GenerateRSAKeyPairOutput(this);
}
}
}
| 225 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/GenerateRandomBytesInput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
public class GenerateRandomBytesInput {
private final int length;
protected GenerateRandomBytesInput(BuilderImpl builder) {
this.length = builder.length();
}
public int length() {
return this.length;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder length(int length);
int length();
GenerateRandomBytesInput build();
}
static class BuilderImpl implements Builder {
protected int length;
private boolean _lengthSet = false;
protected BuilderImpl() {
}
protected BuilderImpl(GenerateRandomBytesInput model) {
this.length = model.length();
this._lengthSet = true;
}
public Builder length(int length) {
this.length = length;
this._lengthSet = true;
return this;
}
public int length() {
return this.length;
}
public GenerateRandomBytesInput build() {
if (!this._lengthSet) {
throw new IllegalArgumentException("Missing value for required field `length`");
}
if (this._lengthSet && this.length() < 0) {
throw new IllegalArgumentException("`length` must be greater than or equal to 0");
}
return new GenerateRandomBytesInput(this);
}
}
}
| 226 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/HkdfInput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
import java.nio.ByteBuffer;
import java.util.Objects;
public class HkdfInput {
private final DigestAlgorithm digestAlgorithm;
private final ByteBuffer salt;
private final ByteBuffer ikm;
private final ByteBuffer info;
private final int expectedLength;
protected HkdfInput(BuilderImpl builder) {
this.digestAlgorithm = builder.digestAlgorithm();
this.salt = builder.salt();
this.ikm = builder.ikm();
this.info = builder.info();
this.expectedLength = builder.expectedLength();
}
public DigestAlgorithm digestAlgorithm() {
return this.digestAlgorithm;
}
public ByteBuffer salt() {
return this.salt;
}
public ByteBuffer ikm() {
return this.ikm;
}
public ByteBuffer info() {
return this.info;
}
public int expectedLength() {
return this.expectedLength;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder digestAlgorithm(DigestAlgorithm digestAlgorithm);
DigestAlgorithm digestAlgorithm();
Builder salt(ByteBuffer salt);
ByteBuffer salt();
Builder ikm(ByteBuffer ikm);
ByteBuffer ikm();
Builder info(ByteBuffer info);
ByteBuffer info();
Builder expectedLength(int expectedLength);
int expectedLength();
HkdfInput build();
}
static class BuilderImpl implements Builder {
protected DigestAlgorithm digestAlgorithm;
protected ByteBuffer salt;
protected ByteBuffer ikm;
protected ByteBuffer info;
protected int expectedLength;
private boolean _expectedLengthSet = false;
protected BuilderImpl() {
}
protected BuilderImpl(HkdfInput model) {
this.digestAlgorithm = model.digestAlgorithm();
this.salt = model.salt();
this.ikm = model.ikm();
this.info = model.info();
this.expectedLength = model.expectedLength();
this._expectedLengthSet = true;
}
public Builder digestAlgorithm(DigestAlgorithm digestAlgorithm) {
this.digestAlgorithm = digestAlgorithm;
return this;
}
public DigestAlgorithm digestAlgorithm() {
return this.digestAlgorithm;
}
public Builder salt(ByteBuffer salt) {
this.salt = salt;
return this;
}
public ByteBuffer salt() {
return this.salt;
}
public Builder ikm(ByteBuffer ikm) {
this.ikm = ikm;
return this;
}
public ByteBuffer ikm() {
return this.ikm;
}
public Builder info(ByteBuffer info) {
this.info = info;
return this;
}
public ByteBuffer info() {
return this.info;
}
public Builder expectedLength(int expectedLength) {
this.expectedLength = expectedLength;
this._expectedLengthSet = true;
return this;
}
public int expectedLength() {
return this.expectedLength;
}
public HkdfInput build() {
if (Objects.isNull(this.digestAlgorithm())) {
throw new IllegalArgumentException("Missing value for required field `digestAlgorithm`");
}
if (Objects.isNull(this.ikm())) {
throw new IllegalArgumentException("Missing value for required field `ikm`");
}
if (Objects.isNull(this.info())) {
throw new IllegalArgumentException("Missing value for required field `info`");
}
if (!this._expectedLengthSet) {
throw new IllegalArgumentException("Missing value for required field `expectedLength`");
}
if (this._expectedLengthSet && this.expectedLength() < 0) {
throw new IllegalArgumentException("`expectedLength` must be greater than or equal to 0");
}
return new HkdfInput(this);
}
}
}
| 227 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/KdfCtrInput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
import java.nio.ByteBuffer;
import java.util.Objects;
public class KdfCtrInput {
private final DigestAlgorithm digestAlgorithm;
private final ByteBuffer ikm;
private final int expectedLength;
private final ByteBuffer purpose;
private final ByteBuffer nonce;
protected KdfCtrInput(BuilderImpl builder) {
this.digestAlgorithm = builder.digestAlgorithm();
this.ikm = builder.ikm();
this.expectedLength = builder.expectedLength();
this.purpose = builder.purpose();
this.nonce = builder.nonce();
}
public DigestAlgorithm digestAlgorithm() {
return this.digestAlgorithm;
}
public ByteBuffer ikm() {
return this.ikm;
}
public int expectedLength() {
return this.expectedLength;
}
public ByteBuffer purpose() {
return this.purpose;
}
public ByteBuffer nonce() {
return this.nonce;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder digestAlgorithm(DigestAlgorithm digestAlgorithm);
DigestAlgorithm digestAlgorithm();
Builder ikm(ByteBuffer ikm);
ByteBuffer ikm();
Builder expectedLength(int expectedLength);
int expectedLength();
Builder purpose(ByteBuffer purpose);
ByteBuffer purpose();
Builder nonce(ByteBuffer nonce);
ByteBuffer nonce();
KdfCtrInput build();
}
static class BuilderImpl implements Builder {
protected DigestAlgorithm digestAlgorithm;
protected ByteBuffer ikm;
protected int expectedLength;
private boolean _expectedLengthSet = false;
protected ByteBuffer purpose;
protected ByteBuffer nonce;
protected BuilderImpl() {
}
protected BuilderImpl(KdfCtrInput model) {
this.digestAlgorithm = model.digestAlgorithm();
this.ikm = model.ikm();
this.expectedLength = model.expectedLength();
this._expectedLengthSet = true;
this.purpose = model.purpose();
this.nonce = model.nonce();
}
public Builder digestAlgorithm(DigestAlgorithm digestAlgorithm) {
this.digestAlgorithm = digestAlgorithm;
return this;
}
public DigestAlgorithm digestAlgorithm() {
return this.digestAlgorithm;
}
public Builder ikm(ByteBuffer ikm) {
this.ikm = ikm;
return this;
}
public ByteBuffer ikm() {
return this.ikm;
}
public Builder expectedLength(int expectedLength) {
this.expectedLength = expectedLength;
this._expectedLengthSet = true;
return this;
}
public int expectedLength() {
return this.expectedLength;
}
public Builder purpose(ByteBuffer purpose) {
this.purpose = purpose;
return this;
}
public ByteBuffer purpose() {
return this.purpose;
}
public Builder nonce(ByteBuffer nonce) {
this.nonce = nonce;
return this;
}
public ByteBuffer nonce() {
return this.nonce;
}
public KdfCtrInput build() {
if (Objects.isNull(this.digestAlgorithm())) {
throw new IllegalArgumentException("Missing value for required field `digestAlgorithm`");
}
if (Objects.isNull(this.ikm())) {
throw new IllegalArgumentException("Missing value for required field `ikm`");
}
if (!this._expectedLengthSet) {
throw new IllegalArgumentException("Missing value for required field `expectedLength`");
}
if (this._expectedLengthSet && this.expectedLength() < 0) {
throw new IllegalArgumentException("`expectedLength` must be greater than or equal to 0");
}
return new KdfCtrInput(this);
}
}
}
| 228 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/GetRSAKeyModulusLengthInput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
import java.nio.ByteBuffer;
import java.util.Objects;
public class GetRSAKeyModulusLengthInput {
private final ByteBuffer publicKey;
protected GetRSAKeyModulusLengthInput(BuilderImpl builder) {
this.publicKey = builder.publicKey();
}
public ByteBuffer publicKey() {
return this.publicKey;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder publicKey(ByteBuffer publicKey);
ByteBuffer publicKey();
GetRSAKeyModulusLengthInput build();
}
static class BuilderImpl implements Builder {
protected ByteBuffer publicKey;
protected BuilderImpl() {
}
protected BuilderImpl(GetRSAKeyModulusLengthInput model) {
this.publicKey = model.publicKey();
}
public Builder publicKey(ByteBuffer publicKey) {
this.publicKey = publicKey;
return this;
}
public ByteBuffer publicKey() {
return this.publicKey;
}
public GetRSAKeyModulusLengthInput build() {
if (Objects.isNull(this.publicKey())) {
throw new IllegalArgumentException("Missing value for required field `publicKey`");
}
return new GetRSAKeyModulusLengthInput(this);
}
}
}
| 229 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/CryptoConfig.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
public class CryptoConfig {
protected CryptoConfig(BuilderImpl builder) {
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
CryptoConfig build();
}
static class BuilderImpl implements Builder {
protected BuilderImpl() {
}
protected BuilderImpl(CryptoConfig model) {
}
public CryptoConfig build() {
return new CryptoConfig(this);
}
}
}
| 230 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/HkdfExpandInput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
import java.nio.ByteBuffer;
import java.util.Objects;
public class HkdfExpandInput {
private final DigestAlgorithm digestAlgorithm;
private final ByteBuffer prk;
private final ByteBuffer info;
private final int expectedLength;
protected HkdfExpandInput(BuilderImpl builder) {
this.digestAlgorithm = builder.digestAlgorithm();
this.prk = builder.prk();
this.info = builder.info();
this.expectedLength = builder.expectedLength();
}
public DigestAlgorithm digestAlgorithm() {
return this.digestAlgorithm;
}
public ByteBuffer prk() {
return this.prk;
}
public ByteBuffer info() {
return this.info;
}
public int expectedLength() {
return this.expectedLength;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder digestAlgorithm(DigestAlgorithm digestAlgorithm);
DigestAlgorithm digestAlgorithm();
Builder prk(ByteBuffer prk);
ByteBuffer prk();
Builder info(ByteBuffer info);
ByteBuffer info();
Builder expectedLength(int expectedLength);
int expectedLength();
HkdfExpandInput build();
}
static class BuilderImpl implements Builder {
protected DigestAlgorithm digestAlgorithm;
protected ByteBuffer prk;
protected ByteBuffer info;
protected int expectedLength;
private boolean _expectedLengthSet = false;
protected BuilderImpl() {
}
protected BuilderImpl(HkdfExpandInput model) {
this.digestAlgorithm = model.digestAlgorithm();
this.prk = model.prk();
this.info = model.info();
this.expectedLength = model.expectedLength();
this._expectedLengthSet = true;
}
public Builder digestAlgorithm(DigestAlgorithm digestAlgorithm) {
this.digestAlgorithm = digestAlgorithm;
return this;
}
public DigestAlgorithm digestAlgorithm() {
return this.digestAlgorithm;
}
public Builder prk(ByteBuffer prk) {
this.prk = prk;
return this;
}
public ByteBuffer prk() {
return this.prk;
}
public Builder info(ByteBuffer info) {
this.info = info;
return this;
}
public ByteBuffer info() {
return this.info;
}
public Builder expectedLength(int expectedLength) {
this.expectedLength = expectedLength;
this._expectedLengthSet = true;
return this;
}
public int expectedLength() {
return this.expectedLength;
}
public HkdfExpandInput build() {
if (Objects.isNull(this.digestAlgorithm())) {
throw new IllegalArgumentException("Missing value for required field `digestAlgorithm`");
}
if (Objects.isNull(this.prk())) {
throw new IllegalArgumentException("Missing value for required field `prk`");
}
if (Objects.isNull(this.info())) {
throw new IllegalArgumentException("Missing value for required field `info`");
}
if (!this._expectedLengthSet) {
throw new IllegalArgumentException("Missing value for required field `expectedLength`");
}
if (this._expectedLengthSet && this.expectedLength() < 0) {
throw new IllegalArgumentException("`expectedLength` must be greater than or equal to 0");
}
return new HkdfExpandInput(this);
}
}
}
| 231 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/ECDSAVerifyInput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
import java.nio.ByteBuffer;
import java.util.Objects;
public class ECDSAVerifyInput {
private final ECDSASignatureAlgorithm signatureAlgorithm;
private final ByteBuffer verificationKey;
private final ByteBuffer message;
private final ByteBuffer signature;
protected ECDSAVerifyInput(BuilderImpl builder) {
this.signatureAlgorithm = builder.signatureAlgorithm();
this.verificationKey = builder.verificationKey();
this.message = builder.message();
this.signature = builder.signature();
}
public ECDSASignatureAlgorithm signatureAlgorithm() {
return this.signatureAlgorithm;
}
public ByteBuffer verificationKey() {
return this.verificationKey;
}
public ByteBuffer message() {
return this.message;
}
public ByteBuffer signature() {
return this.signature;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder signatureAlgorithm(ECDSASignatureAlgorithm signatureAlgorithm);
ECDSASignatureAlgorithm signatureAlgorithm();
Builder verificationKey(ByteBuffer verificationKey);
ByteBuffer verificationKey();
Builder message(ByteBuffer message);
ByteBuffer message();
Builder signature(ByteBuffer signature);
ByteBuffer signature();
ECDSAVerifyInput build();
}
static class BuilderImpl implements Builder {
protected ECDSASignatureAlgorithm signatureAlgorithm;
protected ByteBuffer verificationKey;
protected ByteBuffer message;
protected ByteBuffer signature;
protected BuilderImpl() {
}
protected BuilderImpl(ECDSAVerifyInput model) {
this.signatureAlgorithm = model.signatureAlgorithm();
this.verificationKey = model.verificationKey();
this.message = model.message();
this.signature = model.signature();
}
public Builder signatureAlgorithm(ECDSASignatureAlgorithm signatureAlgorithm) {
this.signatureAlgorithm = signatureAlgorithm;
return this;
}
public ECDSASignatureAlgorithm signatureAlgorithm() {
return this.signatureAlgorithm;
}
public Builder verificationKey(ByteBuffer verificationKey) {
this.verificationKey = verificationKey;
return this;
}
public ByteBuffer verificationKey() {
return this.verificationKey;
}
public Builder message(ByteBuffer message) {
this.message = message;
return this;
}
public ByteBuffer message() {
return this.message;
}
public Builder signature(ByteBuffer signature) {
this.signature = signature;
return this;
}
public ByteBuffer signature() {
return this.signature;
}
public ECDSAVerifyInput build() {
if (Objects.isNull(this.signatureAlgorithm())) {
throw new IllegalArgumentException("Missing value for required field `signatureAlgorithm`");
}
if (Objects.isNull(this.verificationKey())) {
throw new IllegalArgumentException("Missing value for required field `verificationKey`");
}
if (Objects.isNull(this.message())) {
throw new IllegalArgumentException("Missing value for required field `message`");
}
if (Objects.isNull(this.signature())) {
throw new IllegalArgumentException("Missing value for required field `signature`");
}
return new ECDSAVerifyInput(this);
}
}
}
| 232 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/HMacOutput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
import java.nio.ByteBuffer;
import java.util.Objects;
public class HMacOutput {
private final ByteBuffer digest;
protected HMacOutput(BuilderImpl builder) {
this.digest = builder.digest();
}
public ByteBuffer digest() {
return this.digest;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder digest(ByteBuffer digest);
ByteBuffer digest();
HMacOutput build();
}
static class BuilderImpl implements Builder {
protected ByteBuffer digest;
protected BuilderImpl() {
}
protected BuilderImpl(HMacOutput model) {
this.digest = model.digest();
}
public Builder digest(ByteBuffer digest) {
this.digest = digest;
return this;
}
public ByteBuffer digest() {
return this.digest;
}
public HMacOutput build() {
if (Objects.isNull(this.digest())) {
throw new IllegalArgumentException("Missing value for required field `digest`");
}
return new HMacOutput(this);
}
}
}
| 233 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/RSAEncryptInput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
import java.nio.ByteBuffer;
import java.util.Objects;
public class RSAEncryptInput {
private final RSAPaddingMode padding;
private final ByteBuffer publicKey;
private final ByteBuffer plaintext;
protected RSAEncryptInput(BuilderImpl builder) {
this.padding = builder.padding();
this.publicKey = builder.publicKey();
this.plaintext = builder.plaintext();
}
public RSAPaddingMode padding() {
return this.padding;
}
public ByteBuffer publicKey() {
return this.publicKey;
}
public ByteBuffer plaintext() {
return this.plaintext;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder padding(RSAPaddingMode padding);
RSAPaddingMode padding();
Builder publicKey(ByteBuffer publicKey);
ByteBuffer publicKey();
Builder plaintext(ByteBuffer plaintext);
ByteBuffer plaintext();
RSAEncryptInput build();
}
static class BuilderImpl implements Builder {
protected RSAPaddingMode padding;
protected ByteBuffer publicKey;
protected ByteBuffer plaintext;
protected BuilderImpl() {
}
protected BuilderImpl(RSAEncryptInput model) {
this.padding = model.padding();
this.publicKey = model.publicKey();
this.plaintext = model.plaintext();
}
public Builder padding(RSAPaddingMode padding) {
this.padding = padding;
return this;
}
public RSAPaddingMode padding() {
return this.padding;
}
public Builder publicKey(ByteBuffer publicKey) {
this.publicKey = publicKey;
return this;
}
public ByteBuffer publicKey() {
return this.publicKey;
}
public Builder plaintext(ByteBuffer plaintext) {
this.plaintext = plaintext;
return this;
}
public ByteBuffer plaintext() {
return this.plaintext;
}
public RSAEncryptInput build() {
if (Objects.isNull(this.padding())) {
throw new IllegalArgumentException("Missing value for required field `padding`");
}
if (Objects.isNull(this.publicKey())) {
throw new IllegalArgumentException("Missing value for required field `publicKey`");
}
if (Objects.isNull(this.plaintext())) {
throw new IllegalArgumentException("Missing value for required field `plaintext`");
}
return new RSAEncryptInput(this);
}
}
}
| 234 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/AESEncryptOutput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
import java.nio.ByteBuffer;
import java.util.Objects;
public class AESEncryptOutput {
private final ByteBuffer cipherText;
private final ByteBuffer authTag;
protected AESEncryptOutput(BuilderImpl builder) {
this.cipherText = builder.cipherText();
this.authTag = builder.authTag();
}
public ByteBuffer cipherText() {
return this.cipherText;
}
public ByteBuffer authTag() {
return this.authTag;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder cipherText(ByteBuffer cipherText);
ByteBuffer cipherText();
Builder authTag(ByteBuffer authTag);
ByteBuffer authTag();
AESEncryptOutput build();
}
static class BuilderImpl implements Builder {
protected ByteBuffer cipherText;
protected ByteBuffer authTag;
protected BuilderImpl() {
}
protected BuilderImpl(AESEncryptOutput model) {
this.cipherText = model.cipherText();
this.authTag = model.authTag();
}
public Builder cipherText(ByteBuffer cipherText) {
this.cipherText = cipherText;
return this;
}
public ByteBuffer cipherText() {
return this.cipherText;
}
public Builder authTag(ByteBuffer authTag) {
this.authTag = authTag;
return this;
}
public ByteBuffer authTag() {
return this.authTag;
}
public AESEncryptOutput build() {
if (Objects.isNull(this.cipherText())) {
throw new IllegalArgumentException("Missing value for required field `cipherText`");
}
if (Objects.isNull(this.authTag())) {
throw new IllegalArgumentException("Missing value for required field `authTag`");
}
return new AESEncryptOutput(this);
}
}
}
| 235 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/RSAPublicKey.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
import java.nio.ByteBuffer;
import java.util.Objects;
public class RSAPublicKey {
private final int lengthBits;
private final ByteBuffer pem;
protected RSAPublicKey(BuilderImpl builder) {
this.lengthBits = builder.lengthBits();
this.pem = builder.pem();
}
public int lengthBits() {
return this.lengthBits;
}
public ByteBuffer pem() {
return this.pem;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder lengthBits(int lengthBits);
int lengthBits();
Builder pem(ByteBuffer pem);
ByteBuffer pem();
RSAPublicKey build();
}
static class BuilderImpl implements Builder {
protected int lengthBits;
private boolean _lengthBitsSet = false;
protected ByteBuffer pem;
protected BuilderImpl() {
}
protected BuilderImpl(RSAPublicKey model) {
this.lengthBits = model.lengthBits();
this._lengthBitsSet = true;
this.pem = model.pem();
}
public Builder lengthBits(int lengthBits) {
this.lengthBits = lengthBits;
this._lengthBitsSet = true;
return this;
}
public int lengthBits() {
return this.lengthBits;
}
public Builder pem(ByteBuffer pem) {
this.pem = pem;
return this;
}
public ByteBuffer pem() {
return this.pem;
}
public RSAPublicKey build() {
if (!this._lengthBitsSet) {
throw new IllegalArgumentException("Missing value for required field `lengthBits`");
}
if (this._lengthBitsSet && this.lengthBits() < 81) {
throw new IllegalArgumentException("`lengthBits` must be greater than or equal to 81");
}
if (Objects.isNull(this.pem())) {
throw new IllegalArgumentException("Missing value for required field `pem`");
}
return new RSAPublicKey(this);
}
}
}
| 236 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/DigestInput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
import java.nio.ByteBuffer;
import java.util.Objects;
public class DigestInput {
private final DigestAlgorithm digestAlgorithm;
private final ByteBuffer message;
protected DigestInput(BuilderImpl builder) {
this.digestAlgorithm = builder.digestAlgorithm();
this.message = builder.message();
}
public DigestAlgorithm digestAlgorithm() {
return this.digestAlgorithm;
}
public ByteBuffer message() {
return this.message;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder digestAlgorithm(DigestAlgorithm digestAlgorithm);
DigestAlgorithm digestAlgorithm();
Builder message(ByteBuffer message);
ByteBuffer message();
DigestInput build();
}
static class BuilderImpl implements Builder {
protected DigestAlgorithm digestAlgorithm;
protected ByteBuffer message;
protected BuilderImpl() {
}
protected BuilderImpl(DigestInput model) {
this.digestAlgorithm = model.digestAlgorithm();
this.message = model.message();
}
public Builder digestAlgorithm(DigestAlgorithm digestAlgorithm) {
this.digestAlgorithm = digestAlgorithm;
return this;
}
public DigestAlgorithm digestAlgorithm() {
return this.digestAlgorithm;
}
public Builder message(ByteBuffer message) {
this.message = message;
return this;
}
public ByteBuffer message() {
return this.message;
}
public DigestInput build() {
if (Objects.isNull(this.digestAlgorithm())) {
throw new IllegalArgumentException("Missing value for required field `digestAlgorithm`");
}
if (Objects.isNull(this.message())) {
throw new IllegalArgumentException("Missing value for required field `message`");
}
return new DigestInput(this);
}
}
}
| 237 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/ECDSASignatureAlgorithm.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
public enum ECDSASignatureAlgorithm {
ECDSA_P384("ECDSA_P384"),
ECDSA_P256("ECDSA_P256");
private final String value;
private ECDSASignatureAlgorithm(String value) {
this.value = value;
}
public String toString() {
return String.valueOf(value);
}
}
| 238 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/AES_GCM.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
public class AES_GCM {
private final int keyLength;
private final int tagLength;
private final int ivLength;
protected AES_GCM(BuilderImpl builder) {
this.keyLength = builder.keyLength();
this.tagLength = builder.tagLength();
this.ivLength = builder.ivLength();
}
public int keyLength() {
return this.keyLength;
}
public int tagLength() {
return this.tagLength;
}
public int ivLength() {
return this.ivLength;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder keyLength(int keyLength);
int keyLength();
Builder tagLength(int tagLength);
int tagLength();
Builder ivLength(int ivLength);
int ivLength();
AES_GCM build();
}
static class BuilderImpl implements Builder {
protected int keyLength;
private boolean _keyLengthSet = false;
protected int tagLength;
private boolean _tagLengthSet = false;
protected int ivLength;
private boolean _ivLengthSet = false;
protected BuilderImpl() {
}
protected BuilderImpl(AES_GCM model) {
this.keyLength = model.keyLength();
this._keyLengthSet = true;
this.tagLength = model.tagLength();
this._tagLengthSet = true;
this.ivLength = model.ivLength();
this._ivLengthSet = true;
}
public Builder keyLength(int keyLength) {
this.keyLength = keyLength;
this._keyLengthSet = true;
return this;
}
public int keyLength() {
return this.keyLength;
}
public Builder tagLength(int tagLength) {
this.tagLength = tagLength;
this._tagLengthSet = true;
return this;
}
public int tagLength() {
return this.tagLength;
}
public Builder ivLength(int ivLength) {
this.ivLength = ivLength;
this._ivLengthSet = true;
return this;
}
public int ivLength() {
return this.ivLength;
}
public AES_GCM build() {
if (!this._keyLengthSet) {
throw new IllegalArgumentException("Missing value for required field `keyLength`");
}
if (this._keyLengthSet && this.keyLength() < 1) {
throw new IllegalArgumentException("`keyLength` must be greater than or equal to 1");
}
if (this._keyLengthSet && this.keyLength() > 32) {
throw new IllegalArgumentException("`keyLength` must be less than or equal to 32.");
}
if (!this._tagLengthSet) {
throw new IllegalArgumentException("Missing value for required field `tagLength`");
}
if (this._tagLengthSet && this.tagLength() < 0) {
throw new IllegalArgumentException("`tagLength` must be greater than or equal to 0");
}
if (this._tagLengthSet && this.tagLength() > 32) {
throw new IllegalArgumentException("`tagLength` must be less than or equal to 32.");
}
if (!this._ivLengthSet) {
throw new IllegalArgumentException("Missing value for required field `ivLength`");
}
if (this._ivLengthSet && this.ivLength() < 0) {
throw new IllegalArgumentException("`ivLength` must be greater than or equal to 0");
}
if (this._ivLengthSet && this.ivLength() > 255) {
throw new IllegalArgumentException("`ivLength` must be less than or equal to 255.");
}
return new AES_GCM(this);
}
}
}
| 239 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/RSAPaddingMode.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
public enum RSAPaddingMode {
PKCS1("PKCS1"),
OAEP_SHA1("OAEP_SHA1"),
OAEP_SHA256("OAEP_SHA256"),
OAEP_SHA384("OAEP_SHA384"),
OAEP_SHA512("OAEP_SHA512");
private final String value;
private RSAPaddingMode(String value) {
this.value = value;
}
public String toString() {
return String.valueOf(value);
}
}
| 240 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/RSAEncryptOutput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
import java.nio.ByteBuffer;
import java.util.Objects;
public class RSAEncryptOutput {
private final ByteBuffer cipherText;
protected RSAEncryptOutput(BuilderImpl builder) {
this.cipherText = builder.cipherText();
}
public ByteBuffer cipherText() {
return this.cipherText;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder cipherText(ByteBuffer cipherText);
ByteBuffer cipherText();
RSAEncryptOutput build();
}
static class BuilderImpl implements Builder {
protected ByteBuffer cipherText;
protected BuilderImpl() {
}
protected BuilderImpl(RSAEncryptOutput model) {
this.cipherText = model.cipherText();
}
public Builder cipherText(ByteBuffer cipherText) {
this.cipherText = cipherText;
return this;
}
public ByteBuffer cipherText() {
return this.cipherText;
}
public RSAEncryptOutput build() {
if (Objects.isNull(this.cipherText())) {
throw new IllegalArgumentException("Missing value for required field `cipherText`");
}
return new RSAEncryptOutput(this);
}
}
}
| 241 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/ECDSASignOutput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
import java.nio.ByteBuffer;
import java.util.Objects;
public class ECDSASignOutput {
private final ByteBuffer signature;
protected ECDSASignOutput(BuilderImpl builder) {
this.signature = builder.signature();
}
public ByteBuffer signature() {
return this.signature;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder signature(ByteBuffer signature);
ByteBuffer signature();
ECDSASignOutput build();
}
static class BuilderImpl implements Builder {
protected ByteBuffer signature;
protected BuilderImpl() {
}
protected BuilderImpl(ECDSASignOutput model) {
this.signature = model.signature();
}
public Builder signature(ByteBuffer signature) {
this.signature = signature;
return this;
}
public ByteBuffer signature() {
return this.signature;
}
public ECDSASignOutput build() {
if (Objects.isNull(this.signature())) {
throw new IllegalArgumentException("Missing value for required field `signature`");
}
return new ECDSASignOutput(this);
}
}
}
| 242 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/KdfCtrOutput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
import java.nio.ByteBuffer;
import java.util.Objects;
public class KdfCtrOutput {
private final ByteBuffer okm;
protected KdfCtrOutput(BuilderImpl builder) {
this.okm = builder.okm();
}
public ByteBuffer okm() {
return this.okm;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder okm(ByteBuffer okm);
ByteBuffer okm();
KdfCtrOutput build();
}
static class BuilderImpl implements Builder {
protected ByteBuffer okm;
protected BuilderImpl() {
}
protected BuilderImpl(KdfCtrOutput model) {
this.okm = model.okm();
}
public Builder okm(ByteBuffer okm) {
this.okm = okm;
return this;
}
public ByteBuffer okm() {
return this.okm;
}
public KdfCtrOutput build() {
if (Objects.isNull(this.okm())) {
throw new IllegalArgumentException("Missing value for required field `okm`");
}
return new KdfCtrOutput(this);
}
}
}
| 243 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/RSADecryptInput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
import java.nio.ByteBuffer;
import java.util.Objects;
public class RSADecryptInput {
private final RSAPaddingMode padding;
private final ByteBuffer privateKey;
private final ByteBuffer cipherText;
protected RSADecryptInput(BuilderImpl builder) {
this.padding = builder.padding();
this.privateKey = builder.privateKey();
this.cipherText = builder.cipherText();
}
public RSAPaddingMode padding() {
return this.padding;
}
public ByteBuffer privateKey() {
return this.privateKey;
}
public ByteBuffer cipherText() {
return this.cipherText;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder padding(RSAPaddingMode padding);
RSAPaddingMode padding();
Builder privateKey(ByteBuffer privateKey);
ByteBuffer privateKey();
Builder cipherText(ByteBuffer cipherText);
ByteBuffer cipherText();
RSADecryptInput build();
}
static class BuilderImpl implements Builder {
protected RSAPaddingMode padding;
protected ByteBuffer privateKey;
protected ByteBuffer cipherText;
protected BuilderImpl() {
}
protected BuilderImpl(RSADecryptInput model) {
this.padding = model.padding();
this.privateKey = model.privateKey();
this.cipherText = model.cipherText();
}
public Builder padding(RSAPaddingMode padding) {
this.padding = padding;
return this;
}
public RSAPaddingMode padding() {
return this.padding;
}
public Builder privateKey(ByteBuffer privateKey) {
this.privateKey = privateKey;
return this;
}
public ByteBuffer privateKey() {
return this.privateKey;
}
public Builder cipherText(ByteBuffer cipherText) {
this.cipherText = cipherText;
return this;
}
public ByteBuffer cipherText() {
return this.cipherText;
}
public RSADecryptInput build() {
if (Objects.isNull(this.padding())) {
throw new IllegalArgumentException("Missing value for required field `padding`");
}
if (Objects.isNull(this.privateKey())) {
throw new IllegalArgumentException("Missing value for required field `privateKey`");
}
if (Objects.isNull(this.cipherText())) {
throw new IllegalArgumentException("Missing value for required field `cipherText`");
}
return new RSADecryptInput(this);
}
}
}
| 244 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/AesKdfCtrInput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
import java.nio.ByteBuffer;
import java.util.Objects;
public class AesKdfCtrInput {
private final ByteBuffer ikm;
private final int expectedLength;
private final ByteBuffer nonce;
protected AesKdfCtrInput(BuilderImpl builder) {
this.ikm = builder.ikm();
this.expectedLength = builder.expectedLength();
this.nonce = builder.nonce();
}
public ByteBuffer ikm() {
return this.ikm;
}
public int expectedLength() {
return this.expectedLength;
}
public ByteBuffer nonce() {
return this.nonce;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder ikm(ByteBuffer ikm);
ByteBuffer ikm();
Builder expectedLength(int expectedLength);
int expectedLength();
Builder nonce(ByteBuffer nonce);
ByteBuffer nonce();
AesKdfCtrInput build();
}
static class BuilderImpl implements Builder {
protected ByteBuffer ikm;
protected int expectedLength;
private boolean _expectedLengthSet = false;
protected ByteBuffer nonce;
protected BuilderImpl() {
}
protected BuilderImpl(AesKdfCtrInput model) {
this.ikm = model.ikm();
this.expectedLength = model.expectedLength();
this._expectedLengthSet = true;
this.nonce = model.nonce();
}
public Builder ikm(ByteBuffer ikm) {
this.ikm = ikm;
return this;
}
public ByteBuffer ikm() {
return this.ikm;
}
public Builder expectedLength(int expectedLength) {
this.expectedLength = expectedLength;
this._expectedLengthSet = true;
return this;
}
public int expectedLength() {
return this.expectedLength;
}
public Builder nonce(ByteBuffer nonce) {
this.nonce = nonce;
return this;
}
public ByteBuffer nonce() {
return this.nonce;
}
public AesKdfCtrInput build() {
if (Objects.isNull(this.ikm())) {
throw new IllegalArgumentException("Missing value for required field `ikm`");
}
if (!this._expectedLengthSet) {
throw new IllegalArgumentException("Missing value for required field `expectedLength`");
}
if (this._expectedLengthSet && this.expectedLength() < 0) {
throw new IllegalArgumentException("`expectedLength` must be greater than or equal to 0");
}
return new AesKdfCtrInput(this);
}
}
}
| 245 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/HkdfOutput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
import java.nio.ByteBuffer;
import java.util.Objects;
public class HkdfOutput {
private final ByteBuffer okm;
protected HkdfOutput(BuilderImpl builder) {
this.okm = builder.okm();
}
public ByteBuffer okm() {
return this.okm;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder okm(ByteBuffer okm);
ByteBuffer okm();
HkdfOutput build();
}
static class BuilderImpl implements Builder {
protected ByteBuffer okm;
protected BuilderImpl() {
}
protected BuilderImpl(HkdfOutput model) {
this.okm = model.okm();
}
public Builder okm(ByteBuffer okm) {
this.okm = okm;
return this;
}
public ByteBuffer okm() {
return this.okm;
}
public HkdfOutput build() {
if (Objects.isNull(this.okm())) {
throw new IllegalArgumentException("Missing value for required field `okm`");
}
return new HkdfOutput(this);
}
}
}
| 246 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/HkdfExtractInput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
import java.nio.ByteBuffer;
import java.util.Objects;
public class HkdfExtractInput {
private final DigestAlgorithm digestAlgorithm;
private final ByteBuffer salt;
private final ByteBuffer ikm;
protected HkdfExtractInput(BuilderImpl builder) {
this.digestAlgorithm = builder.digestAlgorithm();
this.salt = builder.salt();
this.ikm = builder.ikm();
}
public DigestAlgorithm digestAlgorithm() {
return this.digestAlgorithm;
}
public ByteBuffer salt() {
return this.salt;
}
public ByteBuffer ikm() {
return this.ikm;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder digestAlgorithm(DigestAlgorithm digestAlgorithm);
DigestAlgorithm digestAlgorithm();
Builder salt(ByteBuffer salt);
ByteBuffer salt();
Builder ikm(ByteBuffer ikm);
ByteBuffer ikm();
HkdfExtractInput build();
}
static class BuilderImpl implements Builder {
protected DigestAlgorithm digestAlgorithm;
protected ByteBuffer salt;
protected ByteBuffer ikm;
protected BuilderImpl() {
}
protected BuilderImpl(HkdfExtractInput model) {
this.digestAlgorithm = model.digestAlgorithm();
this.salt = model.salt();
this.ikm = model.ikm();
}
public Builder digestAlgorithm(DigestAlgorithm digestAlgorithm) {
this.digestAlgorithm = digestAlgorithm;
return this;
}
public DigestAlgorithm digestAlgorithm() {
return this.digestAlgorithm;
}
public Builder salt(ByteBuffer salt) {
this.salt = salt;
return this;
}
public ByteBuffer salt() {
return this.salt;
}
public Builder ikm(ByteBuffer ikm) {
this.ikm = ikm;
return this;
}
public ByteBuffer ikm() {
return this.ikm;
}
public HkdfExtractInput build() {
if (Objects.isNull(this.digestAlgorithm())) {
throw new IllegalArgumentException("Missing value for required field `digestAlgorithm`");
}
if (Objects.isNull(this.ikm())) {
throw new IllegalArgumentException("Missing value for required field `ikm`");
}
return new HkdfExtractInput(this);
}
}
}
| 247 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/RSAPrivateKey.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
import java.nio.ByteBuffer;
import java.util.Objects;
public class RSAPrivateKey {
private final int lengthBits;
private final ByteBuffer pem;
protected RSAPrivateKey(BuilderImpl builder) {
this.lengthBits = builder.lengthBits();
this.pem = builder.pem();
}
public int lengthBits() {
return this.lengthBits;
}
public ByteBuffer pem() {
return this.pem;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder lengthBits(int lengthBits);
int lengthBits();
Builder pem(ByteBuffer pem);
ByteBuffer pem();
RSAPrivateKey build();
}
static class BuilderImpl implements Builder {
protected int lengthBits;
private boolean _lengthBitsSet = false;
protected ByteBuffer pem;
protected BuilderImpl() {
}
protected BuilderImpl(RSAPrivateKey model) {
this.lengthBits = model.lengthBits();
this._lengthBitsSet = true;
this.pem = model.pem();
}
public Builder lengthBits(int lengthBits) {
this.lengthBits = lengthBits;
this._lengthBitsSet = true;
return this;
}
public int lengthBits() {
return this.lengthBits;
}
public Builder pem(ByteBuffer pem) {
this.pem = pem;
return this;
}
public ByteBuffer pem() {
return this.pem;
}
public RSAPrivateKey build() {
if (!this._lengthBitsSet) {
throw new IllegalArgumentException("Missing value for required field `lengthBits`");
}
if (this._lengthBitsSet && this.lengthBits() < 81) {
throw new IllegalArgumentException("`lengthBits` must be greater than or equal to 81");
}
if (Objects.isNull(this.pem())) {
throw new IllegalArgumentException("Missing value for required field `pem`");
}
return new RSAPrivateKey(this);
}
}
}
| 248 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/DigestAlgorithm.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
public enum DigestAlgorithm {
SHA_512("SHA_512"),
SHA_384("SHA_384"),
SHA_256("SHA_256");
private final String value;
private DigestAlgorithm(String value) {
this.value = value;
}
public String toString() {
return String.valueOf(value);
}
}
| 249 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/OpaqueError.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
public class OpaqueError extends RuntimeException {
/**
* The unexpected object encountered. It MIGHT BE an Exception, but that is not guaranteed.
*/
private final Object obj;
protected OpaqueError(BuilderImpl builder) {
super(messageFromBuilder(builder), builder.cause());
this.obj = builder.obj();
}
private static String messageFromBuilder(Builder builder) {
if (builder.message() != null) {
return builder.message();
}
if (builder.cause() != null) {
return builder.cause().getMessage();
}
return null;
}
/**
* See {@link Throwable#getMessage()}.
*/
public String message() {
return this.getMessage();
}
/**
* See {@link Throwable#getCause()}.
*/
public Throwable cause() {
return this.getCause();
}
/**
* @return The unexpected object encountered. It MIGHT BE an Exception, but that is not guaranteed.
*/
public Object obj() {
return this.obj;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
/**
* @param message The detailed message. The detail message is saved for later retrieval by the {@link #getMessage()} method.
*/
Builder message(String message);
/**
* @return The detailed message. The detail message is saved for later retrieval by the {@link #getMessage()} method.
*/
String message();
/**
* @param cause The cause (which is saved for later retrieval by the {@link #getCause()} method). (A {@code null} value is permitted, and indicates that the cause is nonexistent or unknown.)
*/
Builder cause(Throwable cause);
/**
* @return The cause (which is saved for later retrieval by the {@link #getCause()} method). (A {@code null} value is permitted, and indicates that the cause is nonexistent or unknown.)
*/
Throwable cause();
/**
* @param obj The unexpected object encountered. It MIGHT BE an Exception, but that is not guaranteed.
*/
Builder obj(Object obj);
/**
* @return The unexpected object encountered. It MIGHT BE an Exception, but that is not guaranteed.
*/
Object obj();
OpaqueError build();
}
static class BuilderImpl implements Builder {
protected String message;
protected Throwable cause;
protected Object obj;
protected BuilderImpl() {
}
protected BuilderImpl(OpaqueError model) {
this.cause = model.getCause();
this.message = model.getMessage();
this.obj = model.obj();
}
public Builder message(String message) {
this.message = message;
return this;
}
public String message() {
return this.message;
}
public Builder cause(Throwable cause) {
this.cause = cause;
return this;
}
public Throwable cause() {
return this.cause;
}
public Builder obj(Object obj) {
this.obj = obj;
return this;
}
public Object obj() {
return this.obj;
}
public OpaqueError build() {
if (this.obj != null && this.cause == null && this.obj instanceof Throwable) {
this.cause = (Throwable) this.obj;
} else if (this.obj == null && this.cause != null) {
this.obj = this.cause;
}
return new OpaqueError(this);
}
}
}
| 250 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/HMacInput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
import java.nio.ByteBuffer;
import java.util.Objects;
public class HMacInput {
private final DigestAlgorithm digestAlgorithm;
private final ByteBuffer key;
private final ByteBuffer message;
protected HMacInput(BuilderImpl builder) {
this.digestAlgorithm = builder.digestAlgorithm();
this.key = builder.key();
this.message = builder.message();
}
public DigestAlgorithm digestAlgorithm() {
return this.digestAlgorithm;
}
public ByteBuffer key() {
return this.key;
}
public ByteBuffer message() {
return this.message;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder digestAlgorithm(DigestAlgorithm digestAlgorithm);
DigestAlgorithm digestAlgorithm();
Builder key(ByteBuffer key);
ByteBuffer key();
Builder message(ByteBuffer message);
ByteBuffer message();
HMacInput build();
}
static class BuilderImpl implements Builder {
protected DigestAlgorithm digestAlgorithm;
protected ByteBuffer key;
protected ByteBuffer message;
protected BuilderImpl() {
}
protected BuilderImpl(HMacInput model) {
this.digestAlgorithm = model.digestAlgorithm();
this.key = model.key();
this.message = model.message();
}
public Builder digestAlgorithm(DigestAlgorithm digestAlgorithm) {
this.digestAlgorithm = digestAlgorithm;
return this;
}
public DigestAlgorithm digestAlgorithm() {
return this.digestAlgorithm;
}
public Builder key(ByteBuffer key) {
this.key = key;
return this;
}
public ByteBuffer key() {
return this.key;
}
public Builder message(ByteBuffer message) {
this.message = message;
return this;
}
public ByteBuffer message() {
return this.message;
}
public HMacInput build() {
if (Objects.isNull(this.digestAlgorithm())) {
throw new IllegalArgumentException("Missing value for required field `digestAlgorithm`");
}
if (Objects.isNull(this.key())) {
throw new IllegalArgumentException("Missing value for required field `key`");
}
if (Objects.isNull(this.message())) {
throw new IllegalArgumentException("Missing value for required field `message`");
}
return new HMacInput(this);
}
}
}
| 251 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/AESDecryptOutput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
import java.nio.ByteBuffer;
import java.util.Objects;
public class AESDecryptOutput {
private final ByteBuffer plaintext;
protected AESDecryptOutput(BuilderImpl builder) {
this.plaintext = builder.plaintext();
}
public ByteBuffer plaintext() {
return this.plaintext;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder plaintext(ByteBuffer plaintext);
ByteBuffer plaintext();
AESDecryptOutput build();
}
static class BuilderImpl implements Builder {
protected ByteBuffer plaintext;
protected BuilderImpl() {
}
protected BuilderImpl(AESDecryptOutput model) {
this.plaintext = model.plaintext();
}
public Builder plaintext(ByteBuffer plaintext) {
this.plaintext = plaintext;
return this;
}
public ByteBuffer plaintext() {
return this.plaintext;
}
public AESDecryptOutput build() {
if (Objects.isNull(this.plaintext())) {
throw new IllegalArgumentException("Missing value for required field `plaintext`");
}
return new AESDecryptOutput(this);
}
}
}
| 252 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/AES_CTR.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
public class AES_CTR {
private final int keyLength;
private final int nonceLength;
protected AES_CTR(BuilderImpl builder) {
this.keyLength = builder.keyLength();
this.nonceLength = builder.nonceLength();
}
public int keyLength() {
return this.keyLength;
}
public int nonceLength() {
return this.nonceLength;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder keyLength(int keyLength);
int keyLength();
Builder nonceLength(int nonceLength);
int nonceLength();
AES_CTR build();
}
static class BuilderImpl implements Builder {
protected int keyLength;
private boolean _keyLengthSet = false;
protected int nonceLength;
private boolean _nonceLengthSet = false;
protected BuilderImpl() {
}
protected BuilderImpl(AES_CTR model) {
this.keyLength = model.keyLength();
this._keyLengthSet = true;
this.nonceLength = model.nonceLength();
this._nonceLengthSet = true;
}
public Builder keyLength(int keyLength) {
this.keyLength = keyLength;
this._keyLengthSet = true;
return this;
}
public int keyLength() {
return this.keyLength;
}
public Builder nonceLength(int nonceLength) {
this.nonceLength = nonceLength;
this._nonceLengthSet = true;
return this;
}
public int nonceLength() {
return this.nonceLength;
}
public AES_CTR build() {
if (!this._keyLengthSet) {
throw new IllegalArgumentException("Missing value for required field `keyLength`");
}
if (this._keyLengthSet && this.keyLength() < 1) {
throw new IllegalArgumentException("`keyLength` must be greater than or equal to 1");
}
if (this._keyLengthSet && this.keyLength() > 32) {
throw new IllegalArgumentException("`keyLength` must be less than or equal to 32.");
}
if (!this._nonceLengthSet) {
throw new IllegalArgumentException("Missing value for required field `nonceLength`");
}
if (this._nonceLengthSet && this.nonceLength() < 0) {
throw new IllegalArgumentException("`nonceLength` must be greater than or equal to 0");
}
if (this._nonceLengthSet && this.nonceLength() > 255) {
throw new IllegalArgumentException("`nonceLength` must be less than or equal to 255.");
}
return new AES_CTR(this);
}
}
}
| 253 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/RSADecryptOutput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
import java.nio.ByteBuffer;
import java.util.Objects;
public class RSADecryptOutput {
private final ByteBuffer plaintext;
protected RSADecryptOutput(BuilderImpl builder) {
this.plaintext = builder.plaintext();
}
public ByteBuffer plaintext() {
return this.plaintext;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder plaintext(ByteBuffer plaintext);
ByteBuffer plaintext();
RSADecryptOutput build();
}
static class BuilderImpl implements Builder {
protected ByteBuffer plaintext;
protected BuilderImpl() {
}
protected BuilderImpl(RSADecryptOutput model) {
this.plaintext = model.plaintext();
}
public Builder plaintext(ByteBuffer plaintext) {
this.plaintext = plaintext;
return this;
}
public ByteBuffer plaintext() {
return this.plaintext;
}
public RSADecryptOutput build() {
if (Objects.isNull(this.plaintext())) {
throw new IllegalArgumentException("Missing value for required field `plaintext`");
}
return new RSADecryptOutput(this);
}
}
}
| 254 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/ECDSAVerifyOutput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
import java.util.Objects;
public class ECDSAVerifyOutput {
private final Boolean success;
protected ECDSAVerifyOutput(BuilderImpl builder) {
this.success = builder.success();
}
public Boolean success() {
return this.success;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder success(Boolean success);
Boolean success();
ECDSAVerifyOutput build();
}
static class BuilderImpl implements Builder {
protected Boolean success;
protected BuilderImpl() {
}
protected BuilderImpl(ECDSAVerifyOutput model) {
this.success = model.success();
}
public Builder success(Boolean success) {
this.success = success;
return this;
}
public Boolean success() {
return this.success;
}
public ECDSAVerifyOutput build() {
if (Objects.isNull(this.success())) {
throw new IllegalArgumentException("Missing value for required field `success`");
}
return new ECDSAVerifyOutput(this);
}
}
}
| 255 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/AwsCryptographicPrimitivesError.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
import java.util.Objects;
public class AwsCryptographicPrimitivesError extends RuntimeException {
protected AwsCryptographicPrimitivesError(BuilderImpl builder) {
super(messageFromBuilder(builder), builder.cause());
}
private static String messageFromBuilder(Builder builder) {
if (builder.message() != null) {
return builder.message();
}
if (builder.cause() != null) {
return builder.cause().getMessage();
}
return null;
}
/**
* See {@link Throwable#getMessage()}.
*/
public String message() {
return this.getMessage();
}
/**
* See {@link Throwable#getCause()}.
*/
public Throwable cause() {
return this.getCause();
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
/**
* @param message The detailed message. The detail message is saved for later retrieval by the {@link #getMessage()} method.
*/
Builder message(String message);
/**
* @return The detailed message. The detail message is saved for later retrieval by the {@link #getMessage()} method.
*/
String message();
/**
* @param cause The cause (which is saved for later retrieval by the {@link #getCause()} method). (A {@code null} value is permitted, and indicates that the cause is nonexistent or unknown.)
*/
Builder cause(Throwable cause);
/**
* @return The cause (which is saved for later retrieval by the {@link #getCause()} method). (A {@code null} value is permitted, and indicates that the cause is nonexistent or unknown.)
*/
Throwable cause();
AwsCryptographicPrimitivesError build();
}
static class BuilderImpl implements Builder {
protected String message;
protected Throwable cause;
protected BuilderImpl() {
}
protected BuilderImpl(AwsCryptographicPrimitivesError model) {
this.message = model.message();
this.cause = model.cause();
}
public Builder message(String message) {
this.message = message;
return this;
}
public String message() {
return this.message;
}
public Builder cause(Throwable cause) {
this.cause = cause;
return this;
}
public Throwable cause() {
return this.cause;
}
public AwsCryptographicPrimitivesError build() {
if (Objects.isNull(this.message())) {
throw new IllegalArgumentException("Missing value for required field `message`");
}
return new AwsCryptographicPrimitivesError(this);
}
}
}
| 256 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/AESEncryptInput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
import java.nio.ByteBuffer;
import java.util.Objects;
public class AESEncryptInput {
private final AES_GCM encAlg;
private final ByteBuffer iv;
private final ByteBuffer key;
private final ByteBuffer msg;
private final ByteBuffer aad;
protected AESEncryptInput(BuilderImpl builder) {
this.encAlg = builder.encAlg();
this.iv = builder.iv();
this.key = builder.key();
this.msg = builder.msg();
this.aad = builder.aad();
}
public AES_GCM encAlg() {
return this.encAlg;
}
public ByteBuffer iv() {
return this.iv;
}
public ByteBuffer key() {
return this.key;
}
public ByteBuffer msg() {
return this.msg;
}
public ByteBuffer aad() {
return this.aad;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder encAlg(AES_GCM encAlg);
AES_GCM encAlg();
Builder iv(ByteBuffer iv);
ByteBuffer iv();
Builder key(ByteBuffer key);
ByteBuffer key();
Builder msg(ByteBuffer msg);
ByteBuffer msg();
Builder aad(ByteBuffer aad);
ByteBuffer aad();
AESEncryptInput build();
}
static class BuilderImpl implements Builder {
protected AES_GCM encAlg;
protected ByteBuffer iv;
protected ByteBuffer key;
protected ByteBuffer msg;
protected ByteBuffer aad;
protected BuilderImpl() {
}
protected BuilderImpl(AESEncryptInput model) {
this.encAlg = model.encAlg();
this.iv = model.iv();
this.key = model.key();
this.msg = model.msg();
this.aad = model.aad();
}
public Builder encAlg(AES_GCM encAlg) {
this.encAlg = encAlg;
return this;
}
public AES_GCM encAlg() {
return this.encAlg;
}
public Builder iv(ByteBuffer iv) {
this.iv = iv;
return this;
}
public ByteBuffer iv() {
return this.iv;
}
public Builder key(ByteBuffer key) {
this.key = key;
return this;
}
public ByteBuffer key() {
return this.key;
}
public Builder msg(ByteBuffer msg) {
this.msg = msg;
return this;
}
public ByteBuffer msg() {
return this.msg;
}
public Builder aad(ByteBuffer aad) {
this.aad = aad;
return this;
}
public ByteBuffer aad() {
return this.aad;
}
public AESEncryptInput build() {
if (Objects.isNull(this.encAlg())) {
throw new IllegalArgumentException("Missing value for required field `encAlg`");
}
if (Objects.isNull(this.iv())) {
throw new IllegalArgumentException("Missing value for required field `iv`");
}
if (Objects.isNull(this.key())) {
throw new IllegalArgumentException("Missing value for required field `key`");
}
if (Objects.isNull(this.msg())) {
throw new IllegalArgumentException("Missing value for required field `msg`");
}
if (Objects.isNull(this.aad())) {
throw new IllegalArgumentException("Missing value for required field `aad`");
}
return new AESEncryptInput(this);
}
}
}
| 257 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/GenerateRSAKeyPairInput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
public class GenerateRSAKeyPairInput {
private final int lengthBits;
protected GenerateRSAKeyPairInput(BuilderImpl builder) {
this.lengthBits = builder.lengthBits();
}
public int lengthBits() {
return this.lengthBits;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder lengthBits(int lengthBits);
int lengthBits();
GenerateRSAKeyPairInput build();
}
static class BuilderImpl implements Builder {
protected int lengthBits;
private boolean _lengthBitsSet = false;
protected BuilderImpl() {
}
protected BuilderImpl(GenerateRSAKeyPairInput model) {
this.lengthBits = model.lengthBits();
this._lengthBitsSet = true;
}
public Builder lengthBits(int lengthBits) {
this.lengthBits = lengthBits;
this._lengthBitsSet = true;
return this;
}
public int lengthBits() {
return this.lengthBits;
}
public GenerateRSAKeyPairInput build() {
if (!this._lengthBitsSet) {
throw new IllegalArgumentException("Missing value for required field `lengthBits`");
}
if (this._lengthBitsSet && this.lengthBits() < 81) {
throw new IllegalArgumentException("`lengthBits` must be greater than or equal to 81");
}
if (this._lengthBitsSet && this.lengthBits() > 4096) {
throw new IllegalArgumentException("`lengthBits` must be less than or equal to 4096.");
}
return new GenerateRSAKeyPairInput(this);
}
}
}
| 258 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/GenerateECDSASignatureKeyOutput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
import java.nio.ByteBuffer;
import java.util.Objects;
public class GenerateECDSASignatureKeyOutput {
private final ECDSASignatureAlgorithm signatureAlgorithm;
private final ByteBuffer verificationKey;
private final ByteBuffer signingKey;
protected GenerateECDSASignatureKeyOutput(BuilderImpl builder) {
this.signatureAlgorithm = builder.signatureAlgorithm();
this.verificationKey = builder.verificationKey();
this.signingKey = builder.signingKey();
}
public ECDSASignatureAlgorithm signatureAlgorithm() {
return this.signatureAlgorithm;
}
public ByteBuffer verificationKey() {
return this.verificationKey;
}
public ByteBuffer signingKey() {
return this.signingKey;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder signatureAlgorithm(ECDSASignatureAlgorithm signatureAlgorithm);
ECDSASignatureAlgorithm signatureAlgorithm();
Builder verificationKey(ByteBuffer verificationKey);
ByteBuffer verificationKey();
Builder signingKey(ByteBuffer signingKey);
ByteBuffer signingKey();
GenerateECDSASignatureKeyOutput build();
}
static class BuilderImpl implements Builder {
protected ECDSASignatureAlgorithm signatureAlgorithm;
protected ByteBuffer verificationKey;
protected ByteBuffer signingKey;
protected BuilderImpl() {
}
protected BuilderImpl(GenerateECDSASignatureKeyOutput model) {
this.signatureAlgorithm = model.signatureAlgorithm();
this.verificationKey = model.verificationKey();
this.signingKey = model.signingKey();
}
public Builder signatureAlgorithm(ECDSASignatureAlgorithm signatureAlgorithm) {
this.signatureAlgorithm = signatureAlgorithm;
return this;
}
public ECDSASignatureAlgorithm signatureAlgorithm() {
return this.signatureAlgorithm;
}
public Builder verificationKey(ByteBuffer verificationKey) {
this.verificationKey = verificationKey;
return this;
}
public ByteBuffer verificationKey() {
return this.verificationKey;
}
public Builder signingKey(ByteBuffer signingKey) {
this.signingKey = signingKey;
return this;
}
public ByteBuffer signingKey() {
return this.signingKey;
}
public GenerateECDSASignatureKeyOutput build() {
if (Objects.isNull(this.signatureAlgorithm())) {
throw new IllegalArgumentException("Missing value for required field `signatureAlgorithm`");
}
if (Objects.isNull(this.verificationKey())) {
throw new IllegalArgumentException("Missing value for required field `verificationKey`");
}
if (Objects.isNull(this.signingKey())) {
throw new IllegalArgumentException("Missing value for required field `signingKey`");
}
return new GenerateECDSASignatureKeyOutput(this);
}
}
}
| 259 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/HkdfExtractOutput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
import java.nio.ByteBuffer;
import java.util.Objects;
public class HkdfExtractOutput {
private final ByteBuffer prk;
protected HkdfExtractOutput(BuilderImpl builder) {
this.prk = builder.prk();
}
public ByteBuffer prk() {
return this.prk;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder prk(ByteBuffer prk);
ByteBuffer prk();
HkdfExtractOutput build();
}
static class BuilderImpl implements Builder {
protected ByteBuffer prk;
protected BuilderImpl() {
}
protected BuilderImpl(HkdfExtractOutput model) {
this.prk = model.prk();
}
public Builder prk(ByteBuffer prk) {
this.prk = prk;
return this;
}
public ByteBuffer prk() {
return this.prk;
}
public HkdfExtractOutput build() {
if (Objects.isNull(this.prk())) {
throw new IllegalArgumentException("Missing value for required field `prk`");
}
return new HkdfExtractOutput(this);
}
}
}
| 260 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/GenerateECDSASignatureKeyInput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
import java.util.Objects;
public class GenerateECDSASignatureKeyInput {
private final ECDSASignatureAlgorithm signatureAlgorithm;
protected GenerateECDSASignatureKeyInput(BuilderImpl builder) {
this.signatureAlgorithm = builder.signatureAlgorithm();
}
public ECDSASignatureAlgorithm signatureAlgorithm() {
return this.signatureAlgorithm;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder signatureAlgorithm(ECDSASignatureAlgorithm signatureAlgorithm);
ECDSASignatureAlgorithm signatureAlgorithm();
GenerateECDSASignatureKeyInput build();
}
static class BuilderImpl implements Builder {
protected ECDSASignatureAlgorithm signatureAlgorithm;
protected BuilderImpl() {
}
protected BuilderImpl(GenerateECDSASignatureKeyInput model) {
this.signatureAlgorithm = model.signatureAlgorithm();
}
public Builder signatureAlgorithm(ECDSASignatureAlgorithm signatureAlgorithm) {
this.signatureAlgorithm = signatureAlgorithm;
return this;
}
public ECDSASignatureAlgorithm signatureAlgorithm() {
return this.signatureAlgorithm;
}
public GenerateECDSASignatureKeyInput build() {
if (Objects.isNull(this.signatureAlgorithm())) {
throw new IllegalArgumentException("Missing value for required field `signatureAlgorithm`");
}
return new GenerateECDSASignatureKeyInput(this);
}
}
}
| 261 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/AESDecryptInput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
import java.nio.ByteBuffer;
import java.util.Objects;
public class AESDecryptInput {
private final AES_GCM encAlg;
private final ByteBuffer key;
private final ByteBuffer cipherTxt;
private final ByteBuffer authTag;
private final ByteBuffer iv;
private final ByteBuffer aad;
protected AESDecryptInput(BuilderImpl builder) {
this.encAlg = builder.encAlg();
this.key = builder.key();
this.cipherTxt = builder.cipherTxt();
this.authTag = builder.authTag();
this.iv = builder.iv();
this.aad = builder.aad();
}
public AES_GCM encAlg() {
return this.encAlg;
}
public ByteBuffer key() {
return this.key;
}
public ByteBuffer cipherTxt() {
return this.cipherTxt;
}
public ByteBuffer authTag() {
return this.authTag;
}
public ByteBuffer iv() {
return this.iv;
}
public ByteBuffer aad() {
return this.aad;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder encAlg(AES_GCM encAlg);
AES_GCM encAlg();
Builder key(ByteBuffer key);
ByteBuffer key();
Builder cipherTxt(ByteBuffer cipherTxt);
ByteBuffer cipherTxt();
Builder authTag(ByteBuffer authTag);
ByteBuffer authTag();
Builder iv(ByteBuffer iv);
ByteBuffer iv();
Builder aad(ByteBuffer aad);
ByteBuffer aad();
AESDecryptInput build();
}
static class BuilderImpl implements Builder {
protected AES_GCM encAlg;
protected ByteBuffer key;
protected ByteBuffer cipherTxt;
protected ByteBuffer authTag;
protected ByteBuffer iv;
protected ByteBuffer aad;
protected BuilderImpl() {
}
protected BuilderImpl(AESDecryptInput model) {
this.encAlg = model.encAlg();
this.key = model.key();
this.cipherTxt = model.cipherTxt();
this.authTag = model.authTag();
this.iv = model.iv();
this.aad = model.aad();
}
public Builder encAlg(AES_GCM encAlg) {
this.encAlg = encAlg;
return this;
}
public AES_GCM encAlg() {
return this.encAlg;
}
public Builder key(ByteBuffer key) {
this.key = key;
return this;
}
public ByteBuffer key() {
return this.key;
}
public Builder cipherTxt(ByteBuffer cipherTxt) {
this.cipherTxt = cipherTxt;
return this;
}
public ByteBuffer cipherTxt() {
return this.cipherTxt;
}
public Builder authTag(ByteBuffer authTag) {
this.authTag = authTag;
return this;
}
public ByteBuffer authTag() {
return this.authTag;
}
public Builder iv(ByteBuffer iv) {
this.iv = iv;
return this;
}
public ByteBuffer iv() {
return this.iv;
}
public Builder aad(ByteBuffer aad) {
this.aad = aad;
return this;
}
public ByteBuffer aad() {
return this.aad;
}
public AESDecryptInput build() {
if (Objects.isNull(this.encAlg())) {
throw new IllegalArgumentException("Missing value for required field `encAlg`");
}
if (Objects.isNull(this.key())) {
throw new IllegalArgumentException("Missing value for required field `key`");
}
if (Objects.isNull(this.cipherTxt())) {
throw new IllegalArgumentException("Missing value for required field `cipherTxt`");
}
if (Objects.isNull(this.authTag())) {
throw new IllegalArgumentException("Missing value for required field `authTag`");
}
if (Objects.isNull(this.iv())) {
throw new IllegalArgumentException("Missing value for required field `iv`");
}
if (Objects.isNull(this.aad())) {
throw new IllegalArgumentException("Missing value for required field `aad`");
}
return new AESDecryptInput(this);
}
}
}
| 262 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/DigestOutput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
import java.nio.ByteBuffer;
import java.util.Objects;
public class DigestOutput {
private final ByteBuffer digest;
protected DigestOutput(BuilderImpl builder) {
this.digest = builder.digest();
}
public ByteBuffer digest() {
return this.digest;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder digest(ByteBuffer digest);
ByteBuffer digest();
DigestOutput build();
}
static class BuilderImpl implements Builder {
protected ByteBuffer digest;
protected BuilderImpl() {
}
protected BuilderImpl(DigestOutput model) {
this.digest = model.digest();
}
public Builder digest(ByteBuffer digest) {
this.digest = digest;
return this;
}
public ByteBuffer digest() {
return this.digest;
}
public DigestOutput build() {
if (Objects.isNull(this.digest())) {
throw new IllegalArgumentException("Missing value for required field `digest`");
}
return new DigestOutput(this);
}
}
}
| 263 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/ECDSASignInput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
import java.nio.ByteBuffer;
import java.util.Objects;
public class ECDSASignInput {
private final ECDSASignatureAlgorithm signatureAlgorithm;
private final ByteBuffer signingKey;
private final ByteBuffer message;
protected ECDSASignInput(BuilderImpl builder) {
this.signatureAlgorithm = builder.signatureAlgorithm();
this.signingKey = builder.signingKey();
this.message = builder.message();
}
public ECDSASignatureAlgorithm signatureAlgorithm() {
return this.signatureAlgorithm;
}
public ByteBuffer signingKey() {
return this.signingKey;
}
public ByteBuffer message() {
return this.message;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder signatureAlgorithm(ECDSASignatureAlgorithm signatureAlgorithm);
ECDSASignatureAlgorithm signatureAlgorithm();
Builder signingKey(ByteBuffer signingKey);
ByteBuffer signingKey();
Builder message(ByteBuffer message);
ByteBuffer message();
ECDSASignInput build();
}
static class BuilderImpl implements Builder {
protected ECDSASignatureAlgorithm signatureAlgorithm;
protected ByteBuffer signingKey;
protected ByteBuffer message;
protected BuilderImpl() {
}
protected BuilderImpl(ECDSASignInput model) {
this.signatureAlgorithm = model.signatureAlgorithm();
this.signingKey = model.signingKey();
this.message = model.message();
}
public Builder signatureAlgorithm(ECDSASignatureAlgorithm signatureAlgorithm) {
this.signatureAlgorithm = signatureAlgorithm;
return this;
}
public ECDSASignatureAlgorithm signatureAlgorithm() {
return this.signatureAlgorithm;
}
public Builder signingKey(ByteBuffer signingKey) {
this.signingKey = signingKey;
return this;
}
public ByteBuffer signingKey() {
return this.signingKey;
}
public Builder message(ByteBuffer message) {
this.message = message;
return this;
}
public ByteBuffer message() {
return this.message;
}
public ECDSASignInput build() {
if (Objects.isNull(this.signatureAlgorithm())) {
throw new IllegalArgumentException("Missing value for required field `signatureAlgorithm`");
}
if (Objects.isNull(this.signingKey())) {
throw new IllegalArgumentException("Missing value for required field `signingKey`");
}
if (Objects.isNull(this.message())) {
throw new IllegalArgumentException("Missing value for required field `message`");
}
return new ECDSASignInput(this);
}
}
}
| 264 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/GetRSAKeyModulusLengthOutput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
public class GetRSAKeyModulusLengthOutput {
private final int length;
protected GetRSAKeyModulusLengthOutput(BuilderImpl builder) {
this.length = builder.length();
}
public int length() {
return this.length;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder length(int length);
int length();
GetRSAKeyModulusLengthOutput build();
}
static class BuilderImpl implements Builder {
protected int length;
private boolean _lengthSet = false;
protected BuilderImpl() {
}
protected BuilderImpl(GetRSAKeyModulusLengthOutput model) {
this.length = model.length();
this._lengthSet = true;
}
public Builder length(int length) {
this.length = length;
this._lengthSet = true;
return this;
}
public int length() {
return this.length;
}
public GetRSAKeyModulusLengthOutput build() {
if (!this._lengthSet) {
throw new IllegalArgumentException("Missing value for required field `length`");
}
if (this._lengthSet && this.length() < 81) {
throw new IllegalArgumentException("`length` must be greater than or equal to 81");
}
return new GetRSAKeyModulusLengthOutput(this);
}
}
}
| 265 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/HkdfExpandOutput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
import java.nio.ByteBuffer;
import java.util.Objects;
public class HkdfExpandOutput {
private final ByteBuffer okm;
protected HkdfExpandOutput(BuilderImpl builder) {
this.okm = builder.okm();
}
public ByteBuffer okm() {
return this.okm;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder okm(ByteBuffer okm);
ByteBuffer okm();
HkdfExpandOutput build();
}
static class BuilderImpl implements Builder {
protected ByteBuffer okm;
protected BuilderImpl() {
}
protected BuilderImpl(HkdfExpandOutput model) {
this.okm = model.okm();
}
public Builder okm(ByteBuffer okm) {
this.okm = okm;
return this;
}
public ByteBuffer okm() {
return this.okm;
}
public HkdfExpandOutput build() {
if (Objects.isNull(this.okm())) {
throw new IllegalArgumentException("Missing value for required field `okm`");
}
return new HkdfExpandOutput(this);
}
}
}
| 266 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/GenerateRandomBytesOutput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
import java.nio.ByteBuffer;
import java.util.Objects;
public class GenerateRandomBytesOutput {
private final ByteBuffer data;
protected GenerateRandomBytesOutput(BuilderImpl builder) {
this.data = builder.data();
}
public ByteBuffer data() {
return this.data;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder data(ByteBuffer data);
ByteBuffer data();
GenerateRandomBytesOutput build();
}
static class BuilderImpl implements Builder {
protected ByteBuffer data;
protected BuilderImpl() {
}
protected BuilderImpl(GenerateRandomBytesOutput model) {
this.data = model.data();
}
public Builder data(ByteBuffer data) {
this.data = data;
return this;
}
public ByteBuffer data() {
return this.data;
}
public GenerateRandomBytesOutput build() {
if (Objects.isNull(this.data())) {
throw new IllegalArgumentException("Missing value for required field `data`");
}
return new GenerateRandomBytesOutput(this);
}
}
}
| 267 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/AesKdfCtrOutput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
import java.nio.ByteBuffer;
import java.util.Objects;
public class AesKdfCtrOutput {
private final ByteBuffer okm;
protected AesKdfCtrOutput(BuilderImpl builder) {
this.okm = builder.okm();
}
public ByteBuffer okm() {
return this.okm;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder okm(ByteBuffer okm);
ByteBuffer okm();
AesKdfCtrOutput build();
}
static class BuilderImpl implements Builder {
protected ByteBuffer okm;
protected BuilderImpl() {
}
protected BuilderImpl(AesKdfCtrOutput model) {
this.okm = model.okm();
}
public Builder okm(ByteBuffer okm) {
this.okm = okm;
return this;
}
public ByteBuffer okm() {
return this.okm;
}
public AesKdfCtrOutput build() {
if (Objects.isNull(this.okm())) {
throw new IllegalArgumentException("Missing value for required field `okm`");
}
return new AesKdfCtrOutput(this);
}
}
}
| 268 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographyPrimitives/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/primitives/model/CollectionOfErrors.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.primitives.model;
import java.util.List;
public class CollectionOfErrors extends RuntimeException {
/**
* The list of Exceptions encountered.
*/
private final List<RuntimeException> list;
protected CollectionOfErrors(BuilderImpl builder) {
super(messageFromBuilder(builder), builder.cause());
this.list = builder.list();
}
private static String messageFromBuilder(Builder builder) {
if (builder.message() != null) {
return builder.message();
}
if (builder.cause() != null) {
return builder.cause().getMessage();
}
return null;
}
/**
* See {@link Throwable#getMessage()}.
*/
public String message() {
return this.getMessage();
}
/**
* See {@link Throwable#getCause()}.
*/
public Throwable cause() {
return this.getCause();
}
/**
* @return The list of Exceptions encountered.
*/
public List<RuntimeException> list() {
return this.list;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
/**
* @param message The detailed message. The detail message is saved for later retrieval by the {@link #getMessage()} method.
*/
Builder message(String message);
/**
* @return The detailed message. The detail message is saved for later retrieval by the {@link #getMessage()} method.
*/
String message();
/**
* @param cause The cause (which is saved for later retrieval by the {@link #getCause()} method). (A {@code null} value is permitted, and indicates that the cause is nonexistent or unknown.)
*/
Builder cause(Throwable cause);
/**
* @return The cause (which is saved for later retrieval by the {@link #getCause()} method). (A {@code null} value is permitted, and indicates that the cause is nonexistent or unknown.)
*/
Throwable cause();
/**
* @param list The list of Exceptions encountered.
*/
Builder list(List<RuntimeException> list);
/**
* @return The list of Exceptions encountered.
*/
List<RuntimeException> list();
CollectionOfErrors build();
}
static class BuilderImpl implements Builder {
protected String message;
protected Throwable cause;
protected List<RuntimeException> list;
protected BuilderImpl() {
}
protected BuilderImpl(CollectionOfErrors model) {
this.cause = model.getCause();
this.message = model.getMessage();
this.list = model.list();
}
public Builder message(String message) {
this.message = message;
return this;
}
public String message() {
return this.message;
}
public Builder cause(Throwable cause) {
this.cause = cause;
return this;
}
public Throwable cause() {
return this.cause;
}
public Builder list(List<RuntimeException> list) {
this.list = list;
return this;
}
public List<RuntimeException> list() {
return this.list;
}
public CollectionOfErrors build() {
return new CollectionOfErrors(this);
}
}
}
| 269 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/StandardLibrary/runtimes/java/src/main/java | Create_ds/aws-cryptographic-material-providers-library-java/StandardLibrary/runtimes/java/src/main/java/UTF8/__default.java | package UTF8;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.CharacterCodingException;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.StandardCharsets;
import Wrappers_Compile.Result;
import dafny.DafnySequence;
import static software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence;
import static software.amazon.smithy.dafny.conversion.ToDafny.Simple.CharacterSequence;
import static software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer;
import static software.amazon.smithy.dafny.conversion.ToNative.Simple.String;
// The only way to keep this thread/concurrent safe/ is
// to create a new Coder everytime.
// If we wanted to increase performance,
// we could declare this NOT thread/concurrent safe,
// and reset the coder everytime.
public class __default extends UTF8._ExternBase___default {
// This is largely copied from Polymorph's dafny-java-conversion:
// software.amazon.smithy.dafny.conversion.ToDafny.Simple.DafnyUtf8Bytes
public static Result<
DafnySequence<? extends Byte>,
DafnySequence<? extends Character>> Encode(
final DafnySequence<? extends Character> s) {
Charset utf8 = StandardCharsets.UTF_8;
// See thread/concurrent safe comment above class
CharsetEncoder coder = utf8.newEncoder();
CharBuffer inBuffer = CharBuffer.wrap(String(s));
inBuffer.position(0);
try {
ByteBuffer outBuffer = coder.encode(inBuffer);
// outBuffer's capacity can be much higher than the limit.
// By taking just the limit, we ensure we do not include
// any allocated but un-filled space.
return Result.create_Success(
(DafnySequence<? extends Byte>) ByteSequence(outBuffer, 0, outBuffer.limit()));
} catch (CharacterCodingException ex) {
return Result.create_Failure(
(DafnySequence<? extends Character>) CharacterSequence("Could not encode input to Dafny Bytes."));
}
}
// This is largely copied from Polymorph's dafny-java-conversion:
// software.amazon.smithy.dafny.conversion.ToNative.Simple.DafnyUtf8Bytes
public static Result<
DafnySequence<? extends Character>,
DafnySequence<? extends Character>> Decode(
final DafnySequence<? extends Byte> s) {
Charset utf8 = StandardCharsets.UTF_8;
// See thread/concurrent safe comment above class
CharsetDecoder coder = utf8.newDecoder();
ByteBuffer inBuffer = ByteBuffer(s);
inBuffer.position(0);
try {
CharBuffer outBuffer = coder.decode(inBuffer);
outBuffer.position(0);
return Result.create_Success(
(DafnySequence<? extends Character>) CharacterSequence(outBuffer.toString()));
} catch (CharacterCodingException ex) {
return Result.create_Failure(
(DafnySequence<? extends Character>) CharacterSequence("Could not encode input to Dafny Bytes."));
}
}
}
| 270 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/StandardLibrary/runtimes/java/src/main/java | Create_ds/aws-cryptographic-material-providers-library-java/StandardLibrary/runtimes/java/src/main/java/Time/__default.java | package Time;
import Wrappers_Compile.Result;
import dafny.DafnySequence;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
public class __default {
public static Long CurrentRelativeTime() {
return System.currentTimeMillis() / 1000;
}
public static Result<DafnySequence<? extends Character>, DafnySequence<? extends Character>> GetCurrentTimeStamp() {
try {
TimeZone tz = TimeZone.getTimeZone("UTC");
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss:SSSSSS'Z'"); // Quoted "Z" to indicate UTC, no timezone offset
df.setTimeZone(tz);
return Result.create_Success(software.amazon.smithy.dafny.conversion.ToDafny.Simple.CharacterSequence(df.format(new Date())));
} catch (Exception var1) {
return Result.create_Failure(software.amazon.smithy.dafny.conversion.ToDafny.Simple.CharacterSequence("Could not generate a timestamp in ISO8601."));
}
}
}
| 271 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/StandardLibrary/runtimes/java/src/main/java | Create_ds/aws-cryptographic-material-providers-library-java/StandardLibrary/runtimes/java/src/main/java/ConcurrentCall/__default.java | package ConcurrentCall;
import Wrappers_Compile.Result;
import dafny.DafnySequence;
import ConcurrentCall.Callee;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
public class __default {
public __default() {
}
public static void ConcurrentCall(Callee callee, int serialIters, int concurrentIters)
{
ExecutorService pool = Executors.newFixedThreadPool(concurrentIters);
for(int i = 0; i < concurrentIters; i++) {
final int ii = i;
pool.execute(() -> {
for(int j = 0; j < serialIters; ++j) {
callee.call(j, ii);
}
}
);
}
pool.shutdown();
try {pool.awaitTermination(120, TimeUnit.SECONDS);} catch (Exception e) {}
}
private static final dafny.TypeDescriptor<__default> _TYPE = dafny.TypeDescriptor.<__default>referenceWithInitializer(__default.class, () -> (__default) null);
public static dafny.TypeDescriptor<__default> _typeDescriptor() {
return (dafny.TypeDescriptor<__default>) (dafny.TypeDescriptor<?>) _TYPE;
}
@Override
public java.lang.String toString() {
return "ConcurrentCall._default";
}
}
| 272 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/StandardLibrary/runtimes/java/src/main/java | Create_ds/aws-cryptographic-material-providers-library-java/StandardLibrary/runtimes/java/src/main/java/SortedSets/__default.java | package SortedSets;
import dafny.DafnySequence;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.ArrayList;
public class __default {
public static <T> dafny.DafnySequence<? extends dafny.DafnySequence<? extends T>>
SetToOrderedSequence(
dafny.TypeDescriptor<T> td_T,
dafny.DafnySet<? extends dafny.DafnySequence<? extends T>> inputSet,
dafny.Function2<T, T, Boolean> less)
{
dafny.DafnySequence<? extends T>[] outputArray = new DafnySequence[inputSet.size()];
outputArray = inputSet.Elements().toArray(outputArray);
LexicographicComparer<T> cmp = new LexicographicComparer<T>(less);
Arrays.sort(outputArray, cmp);
return DafnySequence.fromRawArray(DafnySequence._typeDescriptor(td_T), outputArray);
}
public static <T> dafny.DafnySequence<? extends dafny.DafnySequence<? extends T>>
SetToOrderedSequence2(
dafny.TypeDescriptor<T> _td_T,
dafny.DafnySet<? extends dafny.DafnySequence<? extends T>> s,
dafny.Function2<T, T, Boolean> less)
{
return SetToOrderedSequence(_td_T, s, less);
}
public static <T> dafny.DafnySequence<? extends T>
SetToSequence(
dafny.TypeDescriptor<T> td_T,
dafny.DafnySet<? extends T> inputSet)
{
return DafnySequence.fromList(td_T, new ArrayList<T>(inputSet.Elements()));
}
}
class LexicographicComparer <T> implements Comparator<dafny.DafnySequence<? extends T>> {
private dafny.Function2<T, T, Boolean> less;
public LexicographicComparer(dafny.Function2<T, T, Boolean> less) {
this.less = less;
}
public int compare(dafny.DafnySequence<? extends T> x, dafny.DafnySequence<? extends T> y) {
for (int i = 0; i < x.length() && i < y.length(); i++) {
if (less.apply(x.select(i), y.select(i))) {
return -1;
}
if (this.less.apply(y.select(i), x.select(i))) {
return 1;
}
}
// Reached the end of one array. Either they are equal, or the
// one which is shorter should be considered "less than"
return Integer.compare(x.length(), y.length());
}
}
| 273 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/StandardLibrary/runtimes/java/src/main/java | Create_ds/aws-cryptographic-material-providers-library-java/StandardLibrary/runtimes/java/src/main/java/DafnyLibraries/FileIO.java | /*******************************************************************************
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/
package DafnyLibraries;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import dafny.DafnySequence;
import dafny.Tuple2;
import dafny.Tuple3;
import dafny.TypeDescriptor;
public class FileIO {
/**
* Attempts to read all bytes from the file at {@code path}, and returns a tuple of the following values:
* <dl>
* <dt>{@code isError}</dt>
* <dd>true iff an exception was thrown during path string conversion or when reading the file</dd>
* <dt>{@code bytesRead}</dt>
* <dd>the sequence of bytes read from the file, or an empty sequence if {@code isError} is true</dd>
* <dt>{@code errorMsg}</dt>
* <dd>the error message of the thrown exception if {@code isError} is true, or an empty sequence otherwise</dd>
* </dl>
* <p>
* We return these values individually because {@code Result} is not defined in the runtime but instead in library code.
* It is the responsibility of library code to construct an equivalent {@code Result} value.
*/
public static Tuple3<Boolean, DafnySequence<? extends Byte>, DafnySequence<? extends Character>>
INTERNAL_ReadBytesFromFile(DafnySequence<? extends Character> path) {
try {
final Path pathObj = dafnyStringToPath(path);
final DafnySequence<Byte> readBytes = DafnySequence.fromBytes(Files.readAllBytes(pathObj));
return Tuple3.create(false, readBytes, DafnySequence.empty(TypeDescriptor.CHAR));
} catch (Exception ex) {
return Tuple3.create(true, DafnySequence.empty(TypeDescriptor.BYTE), stackTraceToDafnyString(ex));
}
}
/**
* Attempts to write {@code bytes} to the file at {@code path}, creating nonexistent parent directories as necessary,
* and returns a tuple of the following values:
* <dl>
* <dt>{@code isError}</dt>
* <dd>true iff an exception was thrown during path string conversion or when writing to the file</dd>
* <dt>{@code errorMsg}</dt>
* <dd>the error message of the thrown exception if {@code isError} is true, or an empty sequence otherwise</dd>
* </dl>
* <p>
* We return these values individually because {@code Result} is not defined in the runtime but instead in library code.
* It is the responsibility of library code to construct an equivalent {@code Result} value.
*/
public static Tuple2<Boolean, DafnySequence<? extends Character>>
INTERNAL_WriteBytesToFile(DafnySequence<? extends Character> path, DafnySequence<? extends Byte> bytes) {
try {
final Path pathObj = dafnyStringToPath(path);
createParentDirs(pathObj);
// It's safe to cast `bytes` to `DafnySequence<Byte>` since the cast value is immediately consumed
@SuppressWarnings("unchecked")
final byte[] byteArr = DafnySequence.toByteArray((DafnySequence<Byte>) bytes);
Files.write(pathObj, byteArr);
return Tuple2.create(false, DafnySequence.empty(TypeDescriptor.CHAR));
} catch (Exception ex) {
return Tuple2.create(true, stackTraceToDafnyString(ex));
}
}
/**
* Returns a Path constructed from the given Dafny string.
*/
private static final Path dafnyStringToPath(final DafnySequence<? extends Character> path) {
return Paths.get(new String((char[]) path.toArray().unwrap()));
}
/**
* Creates the nonexistent parent directory(-ies) of the given path.
*/
private static final void createParentDirs(final Path path) throws IOException {
final Path parentDir = path.toAbsolutePath().getParent();
if (parentDir == null) {
return;
}
Files.createDirectories(parentDir);
}
private static final DafnySequence<Character> stackTraceToDafnyString(final Throwable t) {
final StringWriter stringWriter = new StringWriter();
final PrintWriter printWriter = new PrintWriter(stringWriter);
t.printStackTrace(printWriter);
final String str = stringWriter.toString();
return DafnySequence.of(str.toCharArray());
}
}
| 274 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/StandardLibrary/runtimes/java/src/main/java | Create_ds/aws-cryptographic-material-providers-library-java/StandardLibrary/runtimes/java/src/main/java/DafnyLibraries/MutableMap.java | package DafnyLibraries;
import dafny.DafnySet;
import dafny.DafnyMap;
import dafny.Tuple2;
import java.util.concurrent.*;
import java.util.ArrayList;
import java.util.Map;
import java.math.BigInteger;
public class MutableMap<K,V> extends DafnyLibraries._ExternBase_MutableMap<K,V> {
private ConcurrentHashMap<K,V> m;
public MutableMap(dafny.TypeDescriptor<K> _td_K, dafny.TypeDescriptor<V> _td_V) {
super(_td_K, _td_V);
m = new ConcurrentHashMap<K,V>();
}
@Override
public DafnyMap<K,V> content() {
return new DafnyMap<K,V>(m);
}
@Override
public void Put(K k, V v) {
m.put(k, v);
}
@Override
public DafnySet<? extends K> Keys() {
return new DafnySet(m.keySet());
}
@Override
public boolean HasKey(K k) {
return m.containsKey(k);
}
@Override
public DafnySet<? extends V> Values() {
return new DafnySet(m.values());
}
@Override
public DafnySet<? extends Tuple2<K,V>> Items() {
ArrayList<Tuple2<K, V>> list = new ArrayList<Tuple2<K, V>>();
for (Map.Entry<K, V> entry : m.entrySet()) {
list.add(new Tuple2<K, V>(entry.getKey(), entry.getValue()));
}
return new DafnySet<Tuple2<K, V>>(list);
}
@Override
public V Select(K k) {
return m.get(k);
}
@Override
public void Remove(K k) {
m.remove(k);
}
@Override
public BigInteger Size() {
return BigInteger.valueOf(m.size());
}
} | 275 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/StandardLibrary/runtimes/java/src/main/java | Create_ds/aws-cryptographic-material-providers-library-java/StandardLibrary/runtimes/java/src/main/java/UUID/__default.java | package UUID;
import Wrappers_Compile.Result;
import dafny.Array;
import dafny.DafnySequence;
import java.nio.ByteBuffer;
import java.util.UUID;
import static software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence;
import static software.amazon.smithy.dafny.conversion.ToDafny.Simple.CharacterSequence;
import static software.amazon.smithy.dafny.conversion.ToNative.Simple.String;
public class __default {
public static Result<
DafnySequence<? extends Byte>,
DafnySequence<? extends Character>> ToByteArray(
final DafnySequence<? extends Character> s)
{
try {
UUID fromString = UUID.fromString(String(s));
ByteBuffer byteBuffer = ByteBuffer.wrap(new byte[16]);
// In Java the UUID construction stores the 8 most significant bytes
// and the 8 least significant bytes that add up to 16 byte UUID.
byteBuffer.putLong(fromString.getMostSignificantBits());
byteBuffer.putLong(fromString.getLeastSignificantBits());
return Result.create_Success(
(DafnySequence<? extends Byte>) ByteSequence(byteBuffer)
);
} catch (Exception e) {
return Result.create_Failure(
(DafnySequence<? extends Character>) CharacterSequence("Could not convert UUID to byte array.")
);
}
}
public static Result<
DafnySequence<? extends Character>,
DafnySequence<? extends Character>> FromByteArray(
final DafnySequence<? extends Byte> b)
{
try {
ByteBuffer byteBuffer = ByteBuffer.wrap((byte[]) Array.unwrap(b.toArray()));
// In order to create a UUID in Java we need to supply
// the most significant bytes and the least significant bytes
// the construction calls for longs since it represents 8 bytes
// 8 + 8 = 16 that make up the 16 bytes of the UUID construction.
long high = byteBuffer.getLong();
long low = byteBuffer.getLong();
UUID fromByte = new UUID(high, low);
return Result.create_Success(
(DafnySequence<? extends Character>) CharacterSequence(fromByte.toString())
);
} catch (Exception e) {
return Result.create_Failure(
(DafnySequence<? extends Character>) CharacterSequence("Could not convert byte array to UUID.")
);
}
}
public static Result<
DafnySequence<? extends Character>,
DafnySequence<? extends Character>> GenerateUUID()
{
try {
UUID uuid = UUID.randomUUID();
return Result.create_Success(
(DafnySequence<? extends Character>) CharacterSequence(uuid.toString())
);
} catch (Exception e) {
return Result.create_Failure(
(DafnySequence<? extends Character>) CharacterSequence("Could not generate a UUID.")
);
}
}
}
| 276 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/test/LocalCMCTests.java | import org.testng.annotations.Test;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.HashMap;
import Random_Compile.ExternRandom;
import software.amazon.cryptography.keystore.model.BeaconKeyMaterials;
import software.amazon.cryptography.materialproviders.ICryptographicMaterialsCache;
import software.amazon.cryptography.materialproviders.MaterialProviders;
import software.amazon.cryptography.materialproviders.model.CacheType;
import software.amazon.cryptography.materialproviders.model.CreateCryptographicMaterialsCacheInput;
import software.amazon.cryptography.materialproviders.model.DefaultCache;
import software.amazon.cryptography.materialproviders.model.EntryDoesNotExist;
import software.amazon.cryptography.materialproviders.model.GetCacheEntryInput;
import software.amazon.cryptography.materialproviders.model.GetCacheEntryOutput;
import software.amazon.cryptography.materialproviders.model.MaterialProvidersConfig;
import software.amazon.cryptography.materialproviders.model.Materials;
import software.amazon.cryptography.materialproviders.model.PutCacheEntryInput;
public class LocalCMCTests {
static private final ICryptographicMaterialsCache test = MaterialProviders
.builder()
.MaterialProvidersConfig(MaterialProvidersConfig.builder().build())
.build()
.CreateCryptographicMaterialsCache(CreateCryptographicMaterialsCacheInput
.builder()
.cache(CacheType.builder().Default(DefaultCache.builder().entryCapacity(10).build()).build())
.build()
);
static private final List<String> identifies = Collections.unmodifiableList(Arrays.asList(
"one",
"two",
"three",
"four",
"five",
"six",
"seven",
"eight",
"nine",
"ten",
"eleven",
"twelve",
"thirteen",
"fourteen",
"fifteen",
"sixteen",
"seventeen",
"eighteen",
"nineteen",
"twenty",
"twenty one"
));
private static final int IDS_SIZE = identifies.size();
@Test(threadPoolSize = 10, invocationCount = 300000, timeOut = 10000)
public void TestALotOfAdding() {
Random rand = ExternRandom.getSecureRandom();
String beaconKeyIdentifier = identifies.get(rand.nextInt(IDS_SIZE));
ByteBuffer cacheIdentifier = ByteBuffer.wrap(beaconKeyIdentifier.getBytes(StandardCharsets.UTF_8));
GetCacheEntryInput getCacheEntryInput = GetCacheEntryInput
.builder()
.identifier(cacheIdentifier)
.build();
try {
GetCacheEntryOutput getCacheEntryOutput = test.GetCacheEntry(getCacheEntryInput);
// assertEquals(getCacheEntryOutput.materials().BeaconKey().beaconKey(), binaryData);
// assertEquals(getCacheEntryOutput.materials().BeaconKey().beaconKeyIdentifier(), stringData);
// System.out.println("are equal");
} catch (EntryDoesNotExist ex) {
Materials materials = Materials
.builder()
.BeaconKey(BeaconKeyMaterials
.builder()
.beaconKeyIdentifier(beaconKeyIdentifier)
// The cacheIdentifier is used as the material
// because we are not testing the cryptography here.
.beaconKey(cacheIdentifier)
.encryptionContext(new HashMap<String, String>())
.build())
.build();
PutCacheEntryInput putCacheEntryInput = PutCacheEntryInput
.builder()
.identifier(cacheIdentifier)
.creationTime(Instant.now().getEpochSecond())
.expiryTime(Instant.now().getEpochSecond() + 1)
.materials(materials)
.build();
test.PutCacheEntry(putCacheEntryInput);
}
}
}
| 277 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/java/software/amazon/cryptography | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/java/software/amazon/cryptography/keystore/__default.java | package software.amazon.cryptography.keystore.internaldafny;
public class __default extends software.amazon.cryptography.keystore.internaldafny._ExternBase___default {
}
| 278 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/java/software/amazon/cryptography/keystore | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/java/software/amazon/cryptography/keystore/types/__default.java | package software.amazon.cryptography.keystore.internaldafny.types;
public class __default extends software.amazon.cryptography.keystore.internaldafny._ExternBase___default {
}
| 279 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/java/software/amazon/cryptography/internaldafny | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/java/software/amazon/cryptography/internaldafny/SynchronizedLocalCMC/SynchronizedLocalCMC.java | package software.amazon.cryptography.internaldafny.SynchronizedLocalCMC;
import LocalCMC_Compile.LocalCMC;
@SuppressWarnings({"unchecked", "deprecation"})
public class SynchronizedLocalCMC implements software.amazon.cryptography.materialproviders.internaldafny.types.ICryptographicMaterialsCache {
private LocalCMC wrapped;
public SynchronizedLocalCMC(LocalCMC wrapped)
{
(this).wrapped = wrapped;
}
public synchronized Wrappers_Compile.Result<dafny.Tuple0, software.amazon.cryptography.materialproviders.internaldafny.types.Error> PutCacheEntry(software.amazon.cryptography.materialproviders.internaldafny.types.PutCacheEntryInput input)
{
return wrapped.PutCacheEntry(input);
}
public synchronized Wrappers_Compile.Result<dafny.Tuple0, software.amazon.cryptography.materialproviders.internaldafny.types.Error> UpdateUsageMetadata(software.amazon.cryptography.materialproviders.internaldafny.types.UpdateUsageMetadataInput input)
{
return wrapped.UpdateUsageMetadata(input);
}
public synchronized Wrappers_Compile.Result<software.amazon.cryptography.materialproviders.internaldafny.types.GetCacheEntryOutput, software.amazon.cryptography.materialproviders.internaldafny.types.Error> GetCacheEntry(software.amazon.cryptography.materialproviders.internaldafny.types.GetCacheEntryInput input)
{
return wrapped.GetCacheEntry(input);
}
public synchronized Wrappers_Compile.Result<dafny.Tuple0, software.amazon.cryptography.materialproviders.internaldafny.types.Error> DeleteCacheEntry(software.amazon.cryptography.materialproviders.internaldafny.types.DeleteCacheEntryInput input)
{
return wrapped.DeleteCacheEntry(input);
}
public synchronized Wrappers_Compile.Result<dafny.Tuple0, software.amazon.cryptography.materialproviders.internaldafny.types.Error> PutCacheEntry_k(software.amazon.cryptography.materialproviders.internaldafny.types.PutCacheEntryInput input)
{
return wrapped.PutCacheEntry(input);
}
public synchronized Wrappers_Compile.Result<dafny.Tuple0, software.amazon.cryptography.materialproviders.internaldafny.types.Error> UpdateUsageMetadata_k(software.amazon.cryptography.materialproviders.internaldafny.types.UpdateUsageMetadataInput input)
{
return wrapped.UpdateUsageMetadata(input);
}
public synchronized Wrappers_Compile.Result<software.amazon.cryptography.materialproviders.internaldafny.types.GetCacheEntryOutput, software.amazon.cryptography.materialproviders.internaldafny.types.Error> GetCacheEntry_k(software.amazon.cryptography.materialproviders.internaldafny.types.GetCacheEntryInput input)
{
return wrapped.GetCacheEntry(input);
}
public synchronized Wrappers_Compile.Result<dafny.Tuple0, software.amazon.cryptography.materialproviders.internaldafny.types.Error> DeleteCacheEntry_k(software.amazon.cryptography.materialproviders.internaldafny.types.DeleteCacheEntryInput input)
{
return wrapped.DeleteCacheEntry(input);
}
@Override
public java.lang.String toString() {
return "LocalCMC_Compile.SynchronizedLocalCMC";
}
}
| 280 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/java/software/amazon/cryptography/internaldafny | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/java/software/amazon/cryptography/internaldafny/StormTrackingCMC/StormTrackingCMC.java | package software.amazon.cryptography.internaldafny.StormTrackingCMC;
import StormTracker_Compile.StormTracker;
import StormTracker_Compile.CacheState;
import software.amazon.cryptography.materialproviders.internaldafny.types.*;
import software.amazon.cryptography.materialproviders.internaldafny.*;
@SuppressWarnings({ "unchecked", "deprecation" })
public class StormTrackingCMC
implements software.amazon.cryptography.materialproviders.internaldafny.types.ICryptographicMaterialsCache {
private StormTracker wrapped;
public StormTrackingCMC(StormTracker wrapped) {
(this).wrapped = wrapped;
}
public synchronized Wrappers_Compile.Result<dafny.Tuple0, software.amazon.cryptography.materialproviders.internaldafny.types.Error> PutCacheEntry(
software.amazon.cryptography.materialproviders.internaldafny.types.PutCacheEntryInput input) {
return wrapped.PutCacheEntry(input);
}
public synchronized Wrappers_Compile.Result<dafny.Tuple0, software.amazon.cryptography.materialproviders.internaldafny.types.Error> UpdateUsageMetadata(
software.amazon.cryptography.materialproviders.internaldafny.types.UpdateUsageMetadataInput input) {
return wrapped.UpdateUsageMetadata(input);
}
// NOT synchronized, as some sleeping might be involved
public Wrappers_Compile.Result<software.amazon.cryptography.materialproviders.internaldafny.types.GetCacheEntryOutput, software.amazon.cryptography.materialproviders.internaldafny.types.Error> GetCacheEntry(
software.amazon.cryptography.materialproviders.internaldafny.types.GetCacheEntryInput input) {
return GetCacheEntry_k(input);
}
public synchronized Wrappers_Compile.Result<dafny.Tuple0, software.amazon.cryptography.materialproviders.internaldafny.types.Error> DeleteCacheEntry(
software.amazon.cryptography.materialproviders.internaldafny.types.DeleteCacheEntryInput input) {
return wrapped.DeleteCacheEntry(input);
}
public synchronized Wrappers_Compile.Result<dafny.Tuple0, software.amazon.cryptography.materialproviders.internaldafny.types.Error> PutCacheEntry_k(
software.amazon.cryptography.materialproviders.internaldafny.types.PutCacheEntryInput input) {
return wrapped.PutCacheEntry(input);
}
public synchronized Wrappers_Compile.Result<dafny.Tuple0, software.amazon.cryptography.materialproviders.internaldafny.types.Error> UpdateUsageMetadata_k(
software.amazon.cryptography.materialproviders.internaldafny.types.UpdateUsageMetadataInput input) {
return wrapped.UpdateUsageMetadata(input);
}
// This is the synchronization for GetCacheEntry and GetCacheEntry_k
public synchronized Wrappers_Compile.Result<CacheState, software.amazon.cryptography.materialproviders.internaldafny.types.Error> GetFromCacheInner(
software.amazon.cryptography.materialproviders.internaldafny.types.GetCacheEntryInput input) {
return wrapped.GetFromCache(input);
}
// NOT synchronized, because we sleep. Calls GetFromCache which IS synchronized.
public Wrappers_Compile.Result<software.amazon.cryptography.materialproviders.internaldafny.types.GetCacheEntryOutput, software.amazon.cryptography.materialproviders.internaldafny.types.Error>
GetCacheEntry_k(software.amazon.cryptography.materialproviders.internaldafny.types.GetCacheEntryInput input)
{
while (true) {
Wrappers_Compile.Result<CacheState, software.amazon.cryptography.materialproviders.internaldafny.types.Error>
result = GetFromCacheInner(input);
if (result.is_Failure()) {
return Wrappers_Compile.Result.create_Failure((result).dtor_error());
} else if (result.dtor_value().is_Full()) {
return Wrappers_Compile.Result.create_Success(result.dtor_value().dtor_data());
} else if (result.dtor_value().is_EmptyFetch()) {
return Wrappers_Compile.Result
.create_Failure(software.amazon.cryptography.materialproviders.internaldafny.types.Error
.create_EntryDoesNotExist(dafny.DafnySequence.asString("Entry does not exist")));
} else {
try {Thread.sleep(wrapped.sleepMilli);} catch (Exception e) {}
}
}
}
public synchronized Wrappers_Compile.Result<dafny.Tuple0, software.amazon.cryptography.materialproviders.internaldafny.types.Error> DeleteCacheEntry_k(
software.amazon.cryptography.materialproviders.internaldafny.types.DeleteCacheEntryInput input) {
return wrapped.DeleteCacheEntry(input);
}
@Override
public java.lang.String toString() {
return "StormTracker_Compile.StormTrackerCMC";
}
}
| 281 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/java/software/amazon/cryptography | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/java/software/amazon/cryptography/materialproviders/__default.java | package software.amazon.cryptography.materialproviders.internaldafny;
public class __default extends software.amazon.cryptography.materialproviders.internaldafny._ExternBase___default {
}
| 282 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/java/software/amazon/cryptography/materialproviders | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/java/software/amazon/cryptography/materialproviders/types/__default.java | package software.amazon.cryptography.materialproviders.internaldafny.types;
public class __default extends software.amazon.cryptography.materialproviders.internaldafny._ExternBase___default {
}
| 283 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystore/ToNative.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.keystore;
import dafny.DafnyMap;
import dafny.DafnySequence;
import java.lang.Byte;
import java.lang.Character;
import java.lang.RuntimeException;
import java.lang.String;
import java.nio.ByteBuffer;
import java.util.List;
import java.util.Map;
import software.amazon.cryptography.keystore.internaldafny.types.Error;
import software.amazon.cryptography.keystore.internaldafny.types.Error_CollectionOfErrors;
import software.amazon.cryptography.keystore.internaldafny.types.Error_KeyStoreException;
import software.amazon.cryptography.keystore.internaldafny.types.Error_Opaque;
import software.amazon.cryptography.keystore.internaldafny.types.IKeyStoreClient;
import software.amazon.cryptography.keystore.model.BeaconKeyMaterials;
import software.amazon.cryptography.keystore.model.BranchKeyMaterials;
import software.amazon.cryptography.keystore.model.CollectionOfErrors;
import software.amazon.cryptography.keystore.model.CreateKeyInput;
import software.amazon.cryptography.keystore.model.CreateKeyOutput;
import software.amazon.cryptography.keystore.model.CreateKeyStoreInput;
import software.amazon.cryptography.keystore.model.CreateKeyStoreOutput;
import software.amazon.cryptography.keystore.model.GetActiveBranchKeyInput;
import software.amazon.cryptography.keystore.model.GetActiveBranchKeyOutput;
import software.amazon.cryptography.keystore.model.GetBeaconKeyInput;
import software.amazon.cryptography.keystore.model.GetBeaconKeyOutput;
import software.amazon.cryptography.keystore.model.GetBranchKeyVersionInput;
import software.amazon.cryptography.keystore.model.GetBranchKeyVersionOutput;
import software.amazon.cryptography.keystore.model.GetKeyStoreInfoOutput;
import software.amazon.cryptography.keystore.model.KMSConfiguration;
import software.amazon.cryptography.keystore.model.KeyStoreConfig;
import software.amazon.cryptography.keystore.model.KeyStoreException;
import software.amazon.cryptography.keystore.model.OpaqueError;
import software.amazon.cryptography.keystore.model.VersionKeyInput;
import software.amazon.cryptography.keystore.model.VersionKeyOutput;
public class ToNative {
public static OpaqueError Error(Error_Opaque dafnyValue) {
OpaqueError.Builder nativeBuilder = OpaqueError.builder();
nativeBuilder.obj(dafnyValue.dtor_obj());
return nativeBuilder.build();
}
public static CollectionOfErrors Error(Error_CollectionOfErrors dafnyValue) {
CollectionOfErrors.Builder nativeBuilder = CollectionOfErrors.builder();
nativeBuilder.list(
software.amazon.smithy.dafny.conversion.ToNative.Aggregate.GenericToList(
dafnyValue.dtor_list(),
ToNative::Error));
nativeBuilder.message(software.amazon.smithy.dafny.conversion.ToNative.Simple.String(dafnyValue.dtor_message()));
return nativeBuilder.build();
}
public static KeyStoreException Error(Error_KeyStoreException dafnyValue) {
KeyStoreException.Builder nativeBuilder = KeyStoreException.builder();
nativeBuilder.message(software.amazon.smithy.dafny.conversion.ToNative.Simple.String(dafnyValue.dtor_message()));
return nativeBuilder.build();
}
public static RuntimeException Error(Error dafnyValue) {
if (dafnyValue.is_KeyStoreException()) {
return ToNative.Error((Error_KeyStoreException) dafnyValue);
}
if (dafnyValue.is_Opaque()) {
return ToNative.Error((Error_Opaque) dafnyValue);
}
if (dafnyValue.is_CollectionOfErrors()) {
return ToNative.Error((Error_CollectionOfErrors) dafnyValue);
}
if (dafnyValue.is_ComAmazonawsDynamodb()) {
return software.amazon.cryptography.services.dynamodb.internaldafny.ToNative.Error(dafnyValue.dtor_ComAmazonawsDynamodb());
}
if (dafnyValue.is_ComAmazonawsKms()) {
return software.amazon.cryptography.services.kms.internaldafny.ToNative.Error(dafnyValue.dtor_ComAmazonawsKms());
}
OpaqueError.Builder nativeBuilder = OpaqueError.builder();
nativeBuilder.obj(dafnyValue);
return nativeBuilder.build();
}
public static BeaconKeyMaterials BeaconKeyMaterials(
software.amazon.cryptography.keystore.internaldafny.types.BeaconKeyMaterials dafnyValue) {
BeaconKeyMaterials.Builder nativeBuilder = BeaconKeyMaterials.builder();
nativeBuilder.beaconKeyIdentifier(software.amazon.smithy.dafny.conversion.ToNative.Simple.String(dafnyValue.dtor_beaconKeyIdentifier()));
nativeBuilder.encryptionContext(ToNative.EncryptionContext(dafnyValue.dtor_encryptionContext()));
if (dafnyValue.dtor_beaconKey().is_Some()) {
nativeBuilder.beaconKey(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_beaconKey().dtor_value()));
}
if (dafnyValue.dtor_hmacKeys().is_Some()) {
nativeBuilder.hmacKeys(ToNative.HmacKeyMap(dafnyValue.dtor_hmacKeys().dtor_value()));
}
return nativeBuilder.build();
}
public static BranchKeyMaterials BranchKeyMaterials(
software.amazon.cryptography.keystore.internaldafny.types.BranchKeyMaterials dafnyValue) {
BranchKeyMaterials.Builder nativeBuilder = BranchKeyMaterials.builder();
nativeBuilder.branchKeyIdentifier(software.amazon.smithy.dafny.conversion.ToNative.Simple.String(dafnyValue.dtor_branchKeyIdentifier()));
nativeBuilder.branchKeyVersion(software.amazon.smithy.dafny.conversion.ToNative.Simple.DafnyUtf8Bytes(dafnyValue.dtor_branchKeyVersion()));
nativeBuilder.encryptionContext(ToNative.EncryptionContext(dafnyValue.dtor_encryptionContext()));
nativeBuilder.branchKey(software.amazon.smithy.dafny.conversion.ToNative.Simple.ByteBuffer(dafnyValue.dtor_branchKey()));
return nativeBuilder.build();
}
public static CreateKeyInput CreateKeyInput(
software.amazon.cryptography.keystore.internaldafny.types.CreateKeyInput dafnyValue) {
CreateKeyInput.Builder nativeBuilder = CreateKeyInput.builder();
if (dafnyValue.dtor_branchKeyIdentifier().is_Some()) {
nativeBuilder.branchKeyIdentifier(software.amazon.smithy.dafny.conversion.ToNative.Simple.String(dafnyValue.dtor_branchKeyIdentifier().dtor_value()));
}
if (dafnyValue.dtor_encryptionContext().is_Some()) {
nativeBuilder.encryptionContext(ToNative.EncryptionContext(dafnyValue.dtor_encryptionContext().dtor_value()));
}
return nativeBuilder.build();
}
public static CreateKeyOutput CreateKeyOutput(
software.amazon.cryptography.keystore.internaldafny.types.CreateKeyOutput dafnyValue) {
CreateKeyOutput.Builder nativeBuilder = CreateKeyOutput.builder();
nativeBuilder.branchKeyIdentifier(software.amazon.smithy.dafny.conversion.ToNative.Simple.String(dafnyValue.dtor_branchKeyIdentifier()));
return nativeBuilder.build();
}
public static CreateKeyStoreInput CreateKeyStoreInput(
software.amazon.cryptography.keystore.internaldafny.types.CreateKeyStoreInput dafnyValue) {
CreateKeyStoreInput.Builder nativeBuilder = CreateKeyStoreInput.builder();
return nativeBuilder.build();
}
public static CreateKeyStoreOutput CreateKeyStoreOutput(
software.amazon.cryptography.keystore.internaldafny.types.CreateKeyStoreOutput dafnyValue) {
CreateKeyStoreOutput.Builder nativeBuilder = CreateKeyStoreOutput.builder();
nativeBuilder.tableArn(software.amazon.smithy.dafny.conversion.ToNative.Simple.String(dafnyValue.dtor_tableArn()));
return nativeBuilder.build();
}
public static GetActiveBranchKeyInput GetActiveBranchKeyInput(
software.amazon.cryptography.keystore.internaldafny.types.GetActiveBranchKeyInput dafnyValue) {
GetActiveBranchKeyInput.Builder nativeBuilder = GetActiveBranchKeyInput.builder();
nativeBuilder.branchKeyIdentifier(software.amazon.smithy.dafny.conversion.ToNative.Simple.String(dafnyValue.dtor_branchKeyIdentifier()));
return nativeBuilder.build();
}
public static GetActiveBranchKeyOutput GetActiveBranchKeyOutput(
software.amazon.cryptography.keystore.internaldafny.types.GetActiveBranchKeyOutput dafnyValue) {
GetActiveBranchKeyOutput.Builder nativeBuilder = GetActiveBranchKeyOutput.builder();
nativeBuilder.branchKeyMaterials(ToNative.BranchKeyMaterials(dafnyValue.dtor_branchKeyMaterials()));
return nativeBuilder.build();
}
public static GetBeaconKeyInput GetBeaconKeyInput(
software.amazon.cryptography.keystore.internaldafny.types.GetBeaconKeyInput dafnyValue) {
GetBeaconKeyInput.Builder nativeBuilder = GetBeaconKeyInput.builder();
nativeBuilder.branchKeyIdentifier(software.amazon.smithy.dafny.conversion.ToNative.Simple.String(dafnyValue.dtor_branchKeyIdentifier()));
return nativeBuilder.build();
}
public static GetBeaconKeyOutput GetBeaconKeyOutput(
software.amazon.cryptography.keystore.internaldafny.types.GetBeaconKeyOutput dafnyValue) {
GetBeaconKeyOutput.Builder nativeBuilder = GetBeaconKeyOutput.builder();
nativeBuilder.beaconKeyMaterials(ToNative.BeaconKeyMaterials(dafnyValue.dtor_beaconKeyMaterials()));
return nativeBuilder.build();
}
public static GetBranchKeyVersionInput GetBranchKeyVersionInput(
software.amazon.cryptography.keystore.internaldafny.types.GetBranchKeyVersionInput dafnyValue) {
GetBranchKeyVersionInput.Builder nativeBuilder = GetBranchKeyVersionInput.builder();
nativeBuilder.branchKeyIdentifier(software.amazon.smithy.dafny.conversion.ToNative.Simple.String(dafnyValue.dtor_branchKeyIdentifier()));
nativeBuilder.branchKeyVersion(software.amazon.smithy.dafny.conversion.ToNative.Simple.String(dafnyValue.dtor_branchKeyVersion()));
return nativeBuilder.build();
}
public static GetBranchKeyVersionOutput GetBranchKeyVersionOutput(
software.amazon.cryptography.keystore.internaldafny.types.GetBranchKeyVersionOutput dafnyValue) {
GetBranchKeyVersionOutput.Builder nativeBuilder = GetBranchKeyVersionOutput.builder();
nativeBuilder.branchKeyMaterials(ToNative.BranchKeyMaterials(dafnyValue.dtor_branchKeyMaterials()));
return nativeBuilder.build();
}
public static GetKeyStoreInfoOutput GetKeyStoreInfoOutput(
software.amazon.cryptography.keystore.internaldafny.types.GetKeyStoreInfoOutput dafnyValue) {
GetKeyStoreInfoOutput.Builder nativeBuilder = GetKeyStoreInfoOutput.builder();
nativeBuilder.keyStoreId(software.amazon.smithy.dafny.conversion.ToNative.Simple.String(dafnyValue.dtor_keyStoreId()));
nativeBuilder.keyStoreName(software.amazon.smithy.dafny.conversion.ToNative.Simple.String(dafnyValue.dtor_keyStoreName()));
nativeBuilder.logicalKeyStoreName(software.amazon.smithy.dafny.conversion.ToNative.Simple.String(dafnyValue.dtor_logicalKeyStoreName()));
nativeBuilder.grantTokens(ToNative.GrantTokenList(dafnyValue.dtor_grantTokens()));
nativeBuilder.kmsConfiguration(ToNative.KMSConfiguration(dafnyValue.dtor_kmsConfiguration()));
return nativeBuilder.build();
}
public static KeyStoreConfig KeyStoreConfig(
software.amazon.cryptography.keystore.internaldafny.types.KeyStoreConfig dafnyValue) {
KeyStoreConfig.Builder nativeBuilder = KeyStoreConfig.builder();
nativeBuilder.ddbTableName(software.amazon.smithy.dafny.conversion.ToNative.Simple.String(dafnyValue.dtor_ddbTableName()));
nativeBuilder.kmsConfiguration(ToNative.KMSConfiguration(dafnyValue.dtor_kmsConfiguration()));
nativeBuilder.logicalKeyStoreName(software.amazon.smithy.dafny.conversion.ToNative.Simple.String(dafnyValue.dtor_logicalKeyStoreName()));
if (dafnyValue.dtor_id().is_Some()) {
nativeBuilder.id(software.amazon.smithy.dafny.conversion.ToNative.Simple.String(dafnyValue.dtor_id().dtor_value()));
}
if (dafnyValue.dtor_grantTokens().is_Some()) {
nativeBuilder.grantTokens(ToNative.GrantTokenList(dafnyValue.dtor_grantTokens().dtor_value()));
}
if (dafnyValue.dtor_ddbClient().is_Some()) {
nativeBuilder.ddbClient(software.amazon.cryptography.services.dynamodb.internaldafny.ToNative.DynamoDB_20120810(dafnyValue.dtor_ddbClient().dtor_value()));
}
if (dafnyValue.dtor_kmsClient().is_Some()) {
nativeBuilder.kmsClient(software.amazon.cryptography.services.kms.internaldafny.ToNative.TrentService(dafnyValue.dtor_kmsClient().dtor_value()));
}
return nativeBuilder.build();
}
public static VersionKeyInput VersionKeyInput(
software.amazon.cryptography.keystore.internaldafny.types.VersionKeyInput dafnyValue) {
VersionKeyInput.Builder nativeBuilder = VersionKeyInput.builder();
nativeBuilder.branchKeyIdentifier(software.amazon.smithy.dafny.conversion.ToNative.Simple.String(dafnyValue.dtor_branchKeyIdentifier()));
return nativeBuilder.build();
}
public static VersionKeyOutput VersionKeyOutput(
software.amazon.cryptography.keystore.internaldafny.types.VersionKeyOutput dafnyValue) {
VersionKeyOutput.Builder nativeBuilder = VersionKeyOutput.builder();
return nativeBuilder.build();
}
public static KMSConfiguration KMSConfiguration(
software.amazon.cryptography.keystore.internaldafny.types.KMSConfiguration dafnyValue) {
KMSConfiguration.Builder nativeBuilder = KMSConfiguration.builder();
if (dafnyValue.is_kmsKeyArn()) {
nativeBuilder.kmsKeyArn(software.amazon.smithy.dafny.conversion.ToNative.Simple.String(dafnyValue.dtor_kmsKeyArn()));
}
return nativeBuilder.build();
}
public static List<String> GrantTokenList(
DafnySequence<? extends DafnySequence<? extends Character>> dafnyValue) {
return software.amazon.smithy.dafny.conversion.ToNative.Aggregate.GenericToList(
dafnyValue,
software.amazon.smithy.dafny.conversion.ToNative.Simple::String);
}
public static Map<String, String> EncryptionContext(
DafnyMap<? extends DafnySequence<? extends Byte>, ? extends DafnySequence<? extends Byte>> dafnyValue) {
return software.amazon.smithy.dafny.conversion.ToNative.Aggregate.GenericToMap(
dafnyValue,
software.amazon.smithy.dafny.conversion.ToNative.Simple::DafnyUtf8Bytes,
software.amazon.smithy.dafny.conversion.ToNative.Simple::DafnyUtf8Bytes);
}
public static Map<String, ByteBuffer> HmacKeyMap(
DafnyMap<? extends DafnySequence<? extends Character>, ? extends DafnySequence<? extends Byte>> dafnyValue) {
return software.amazon.smithy.dafny.conversion.ToNative.Aggregate.GenericToMap(
dafnyValue,
software.amazon.smithy.dafny.conversion.ToNative.Simple::String,
software.amazon.smithy.dafny.conversion.ToNative.Simple::ByteBuffer);
}
public static KeyStore KeyStore(IKeyStoreClient dafnyValue) {
return new KeyStore(dafnyValue);
}
}
| 284 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystore/ToDafny.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.keystore;
import Wrappers_Compile.Option;
import dafny.DafnyMap;
import dafny.DafnySequence;
import dafny.TypeDescriptor;
import java.lang.Byte;
import java.lang.Character;
import java.lang.IllegalArgumentException;
import java.lang.RuntimeException;
import java.lang.String;
import java.nio.ByteBuffer;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import software.amazon.cryptography.keystore.internaldafny.types.BeaconKeyMaterials;
import software.amazon.cryptography.keystore.internaldafny.types.BranchKeyMaterials;
import software.amazon.cryptography.keystore.internaldafny.types.CreateKeyInput;
import software.amazon.cryptography.keystore.internaldafny.types.CreateKeyOutput;
import software.amazon.cryptography.keystore.internaldafny.types.CreateKeyStoreInput;
import software.amazon.cryptography.keystore.internaldafny.types.CreateKeyStoreOutput;
import software.amazon.cryptography.keystore.internaldafny.types.Error;
import software.amazon.cryptography.keystore.internaldafny.types.Error_KeyStoreException;
import software.amazon.cryptography.keystore.internaldafny.types.GetActiveBranchKeyInput;
import software.amazon.cryptography.keystore.internaldafny.types.GetActiveBranchKeyOutput;
import software.amazon.cryptography.keystore.internaldafny.types.GetBeaconKeyInput;
import software.amazon.cryptography.keystore.internaldafny.types.GetBeaconKeyOutput;
import software.amazon.cryptography.keystore.internaldafny.types.GetBranchKeyVersionInput;
import software.amazon.cryptography.keystore.internaldafny.types.GetBranchKeyVersionOutput;
import software.amazon.cryptography.keystore.internaldafny.types.GetKeyStoreInfoOutput;
import software.amazon.cryptography.keystore.internaldafny.types.IKeyStoreClient;
import software.amazon.cryptography.keystore.internaldafny.types.KMSConfiguration;
import software.amazon.cryptography.keystore.internaldafny.types.KeyStoreConfig;
import software.amazon.cryptography.keystore.internaldafny.types.VersionKeyInput;
import software.amazon.cryptography.keystore.internaldafny.types.VersionKeyOutput;
import software.amazon.cryptography.keystore.model.CollectionOfErrors;
import software.amazon.cryptography.keystore.model.KeyStoreException;
import software.amazon.cryptography.keystore.model.OpaqueError;
import software.amazon.cryptography.services.dynamodb.internaldafny.types.IDynamoDBClient;
import software.amazon.cryptography.services.kms.internaldafny.types.IKMSClient;
public class ToDafny {
public static Error Error(RuntimeException nativeValue) {
if (nativeValue instanceof KeyStoreException) {
return ToDafny.Error((KeyStoreException) nativeValue);
}
if (nativeValue instanceof OpaqueError) {
return ToDafny.Error((OpaqueError) nativeValue);
}
if (nativeValue instanceof CollectionOfErrors) {
return ToDafny.Error((CollectionOfErrors) nativeValue);
}
return Error.create_Opaque(nativeValue);
}
public static Error Error(OpaqueError nativeValue) {
return Error.create_Opaque(nativeValue.obj());
}
public static Error Error(CollectionOfErrors nativeValue) {
DafnySequence<? extends Error> list = software.amazon.smithy.dafny.conversion.ToDafny.Aggregate.GenericToSequence(
nativeValue.list(),
ToDafny::Error,
Error._typeDescriptor());
DafnySequence<? extends Character> message = software.amazon.smithy.dafny.conversion.ToDafny.Simple.CharacterSequence(nativeValue.getMessage());
return Error.create_CollectionOfErrors(list, message);
}
public static BeaconKeyMaterials BeaconKeyMaterials(
software.amazon.cryptography.keystore.model.BeaconKeyMaterials nativeValue) {
DafnySequence<? extends Character> beaconKeyIdentifier;
beaconKeyIdentifier = software.amazon.smithy.dafny.conversion.ToDafny.Simple.CharacterSequence(nativeValue.beaconKeyIdentifier());
DafnyMap<? extends DafnySequence<? extends Byte>, ? extends DafnySequence<? extends Byte>> encryptionContext;
encryptionContext = ToDafny.EncryptionContext(nativeValue.encryptionContext());
Option<DafnySequence<? extends Byte>> beaconKey;
beaconKey = Objects.nonNull(nativeValue.beaconKey()) ?
Option.create_Some(software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.beaconKey()))
: Option.create_None();
Option<DafnyMap<? extends DafnySequence<? extends Character>, ? extends DafnySequence<? extends Byte>>> hmacKeys;
hmacKeys = (Objects.nonNull(nativeValue.hmacKeys()) && nativeValue.hmacKeys().size() > 0) ?
Option.create_Some(ToDafny.HmacKeyMap(nativeValue.hmacKeys()))
: Option.create_None();
return new BeaconKeyMaterials(beaconKeyIdentifier, encryptionContext, beaconKey, hmacKeys);
}
public static BranchKeyMaterials BranchKeyMaterials(
software.amazon.cryptography.keystore.model.BranchKeyMaterials nativeValue) {
DafnySequence<? extends Character> branchKeyIdentifier;
branchKeyIdentifier = software.amazon.smithy.dafny.conversion.ToDafny.Simple.CharacterSequence(nativeValue.branchKeyIdentifier());
DafnySequence<? extends Byte> branchKeyVersion;
branchKeyVersion = software.amazon.smithy.dafny.conversion.ToDafny.Simple.DafnyUtf8Bytes(nativeValue.branchKeyVersion());
DafnyMap<? extends DafnySequence<? extends Byte>, ? extends DafnySequence<? extends Byte>> encryptionContext;
encryptionContext = ToDafny.EncryptionContext(nativeValue.encryptionContext());
DafnySequence<? extends Byte> branchKey;
branchKey = software.amazon.smithy.dafny.conversion.ToDafny.Simple.ByteSequence(nativeValue.branchKey());
return new BranchKeyMaterials(branchKeyIdentifier, branchKeyVersion, encryptionContext, branchKey);
}
public static CreateKeyInput CreateKeyInput(
software.amazon.cryptography.keystore.model.CreateKeyInput nativeValue) {
Option<DafnySequence<? extends Character>> branchKeyIdentifier;
branchKeyIdentifier = Objects.nonNull(nativeValue.branchKeyIdentifier()) ?
Option.create_Some(software.amazon.smithy.dafny.conversion.ToDafny.Simple.CharacterSequence(nativeValue.branchKeyIdentifier()))
: Option.create_None();
Option<DafnyMap<? extends DafnySequence<? extends Byte>, ? extends DafnySequence<? extends Byte>>> encryptionContext;
encryptionContext = (Objects.nonNull(nativeValue.encryptionContext()) && nativeValue.encryptionContext().size() > 0) ?
Option.create_Some(ToDafny.EncryptionContext(nativeValue.encryptionContext()))
: Option.create_None();
return new CreateKeyInput(branchKeyIdentifier, encryptionContext);
}
public static CreateKeyOutput CreateKeyOutput(
software.amazon.cryptography.keystore.model.CreateKeyOutput nativeValue) {
DafnySequence<? extends Character> branchKeyIdentifier;
branchKeyIdentifier = software.amazon.smithy.dafny.conversion.ToDafny.Simple.CharacterSequence(nativeValue.branchKeyIdentifier());
return new CreateKeyOutput(branchKeyIdentifier);
}
public static CreateKeyStoreInput CreateKeyStoreInput(
software.amazon.cryptography.keystore.model.CreateKeyStoreInput nativeValue) {
return new CreateKeyStoreInput();
}
public static CreateKeyStoreOutput CreateKeyStoreOutput(
software.amazon.cryptography.keystore.model.CreateKeyStoreOutput nativeValue) {
DafnySequence<? extends Character> tableArn;
tableArn = software.amazon.smithy.dafny.conversion.ToDafny.Simple.CharacterSequence(nativeValue.tableArn());
return new CreateKeyStoreOutput(tableArn);
}
public static GetActiveBranchKeyInput GetActiveBranchKeyInput(
software.amazon.cryptography.keystore.model.GetActiveBranchKeyInput nativeValue) {
DafnySequence<? extends Character> branchKeyIdentifier;
branchKeyIdentifier = software.amazon.smithy.dafny.conversion.ToDafny.Simple.CharacterSequence(nativeValue.branchKeyIdentifier());
return new GetActiveBranchKeyInput(branchKeyIdentifier);
}
public static GetActiveBranchKeyOutput GetActiveBranchKeyOutput(
software.amazon.cryptography.keystore.model.GetActiveBranchKeyOutput nativeValue) {
BranchKeyMaterials branchKeyMaterials;
branchKeyMaterials = ToDafny.BranchKeyMaterials(nativeValue.branchKeyMaterials());
return new GetActiveBranchKeyOutput(branchKeyMaterials);
}
public static GetBeaconKeyInput GetBeaconKeyInput(
software.amazon.cryptography.keystore.model.GetBeaconKeyInput nativeValue) {
DafnySequence<? extends Character> branchKeyIdentifier;
branchKeyIdentifier = software.amazon.smithy.dafny.conversion.ToDafny.Simple.CharacterSequence(nativeValue.branchKeyIdentifier());
return new GetBeaconKeyInput(branchKeyIdentifier);
}
public static GetBeaconKeyOutput GetBeaconKeyOutput(
software.amazon.cryptography.keystore.model.GetBeaconKeyOutput nativeValue) {
BeaconKeyMaterials beaconKeyMaterials;
beaconKeyMaterials = ToDafny.BeaconKeyMaterials(nativeValue.beaconKeyMaterials());
return new GetBeaconKeyOutput(beaconKeyMaterials);
}
public static GetBranchKeyVersionInput GetBranchKeyVersionInput(
software.amazon.cryptography.keystore.model.GetBranchKeyVersionInput nativeValue) {
DafnySequence<? extends Character> branchKeyIdentifier;
branchKeyIdentifier = software.amazon.smithy.dafny.conversion.ToDafny.Simple.CharacterSequence(nativeValue.branchKeyIdentifier());
DafnySequence<? extends Character> branchKeyVersion;
branchKeyVersion = software.amazon.smithy.dafny.conversion.ToDafny.Simple.CharacterSequence(nativeValue.branchKeyVersion());
return new GetBranchKeyVersionInput(branchKeyIdentifier, branchKeyVersion);
}
public static GetBranchKeyVersionOutput GetBranchKeyVersionOutput(
software.amazon.cryptography.keystore.model.GetBranchKeyVersionOutput nativeValue) {
BranchKeyMaterials branchKeyMaterials;
branchKeyMaterials = ToDafny.BranchKeyMaterials(nativeValue.branchKeyMaterials());
return new GetBranchKeyVersionOutput(branchKeyMaterials);
}
public static GetKeyStoreInfoOutput GetKeyStoreInfoOutput(
software.amazon.cryptography.keystore.model.GetKeyStoreInfoOutput nativeValue) {
DafnySequence<? extends Character> keyStoreId;
keyStoreId = software.amazon.smithy.dafny.conversion.ToDafny.Simple.CharacterSequence(nativeValue.keyStoreId());
DafnySequence<? extends Character> keyStoreName;
keyStoreName = software.amazon.smithy.dafny.conversion.ToDafny.Simple.CharacterSequence(nativeValue.keyStoreName());
DafnySequence<? extends Character> logicalKeyStoreName;
logicalKeyStoreName = software.amazon.smithy.dafny.conversion.ToDafny.Simple.CharacterSequence(nativeValue.logicalKeyStoreName());
DafnySequence<? extends DafnySequence<? extends Character>> grantTokens;
grantTokens = ToDafny.GrantTokenList(nativeValue.grantTokens());
KMSConfiguration kmsConfiguration;
kmsConfiguration = ToDafny.KMSConfiguration(nativeValue.kmsConfiguration());
return new GetKeyStoreInfoOutput(keyStoreId, keyStoreName, logicalKeyStoreName, grantTokens, kmsConfiguration);
}
public static KeyStoreConfig KeyStoreConfig(
software.amazon.cryptography.keystore.model.KeyStoreConfig nativeValue) {
DafnySequence<? extends Character> ddbTableName;
ddbTableName = software.amazon.smithy.dafny.conversion.ToDafny.Simple.CharacterSequence(nativeValue.ddbTableName());
KMSConfiguration kmsConfiguration;
kmsConfiguration = ToDafny.KMSConfiguration(nativeValue.kmsConfiguration());
DafnySequence<? extends Character> logicalKeyStoreName;
logicalKeyStoreName = software.amazon.smithy.dafny.conversion.ToDafny.Simple.CharacterSequence(nativeValue.logicalKeyStoreName());
Option<DafnySequence<? extends Character>> id;
id = Objects.nonNull(nativeValue.id()) ?
Option.create_Some(software.amazon.smithy.dafny.conversion.ToDafny.Simple.CharacterSequence(nativeValue.id()))
: Option.create_None();
Option<DafnySequence<? extends DafnySequence<? extends Character>>> grantTokens;
grantTokens = (Objects.nonNull(nativeValue.grantTokens()) && nativeValue.grantTokens().size() > 0) ?
Option.create_Some(ToDafny.GrantTokenList(nativeValue.grantTokens()))
: Option.create_None();
Option<IDynamoDBClient> ddbClient;
ddbClient = Objects.nonNull(nativeValue.ddbClient()) ?
Option.create_Some(software.amazon.cryptography.services.dynamodb.internaldafny.ToDafny.DynamoDB_20120810(nativeValue.ddbClient()))
: Option.create_None();
Option<IKMSClient> kmsClient;
kmsClient = Objects.nonNull(nativeValue.kmsClient()) ?
Option.create_Some(software.amazon.cryptography.services.kms.internaldafny.ToDafny.TrentService(nativeValue.kmsClient()))
: Option.create_None();
return new KeyStoreConfig(ddbTableName, kmsConfiguration, logicalKeyStoreName, id, grantTokens, ddbClient, kmsClient);
}
public static VersionKeyInput VersionKeyInput(
software.amazon.cryptography.keystore.model.VersionKeyInput nativeValue) {
DafnySequence<? extends Character> branchKeyIdentifier;
branchKeyIdentifier = software.amazon.smithy.dafny.conversion.ToDafny.Simple.CharacterSequence(nativeValue.branchKeyIdentifier());
return new VersionKeyInput(branchKeyIdentifier);
}
public static VersionKeyOutput VersionKeyOutput(
software.amazon.cryptography.keystore.model.VersionKeyOutput nativeValue) {
return new VersionKeyOutput();
}
public static Error Error(KeyStoreException nativeValue) {
DafnySequence<? extends Character> message;
message = software.amazon.smithy.dafny.conversion.ToDafny.Simple.CharacterSequence(nativeValue.message());
return new Error_KeyStoreException(message);
}
public static KMSConfiguration KMSConfiguration(
software.amazon.cryptography.keystore.model.KMSConfiguration nativeValue) {
if (Objects.nonNull(nativeValue.kmsKeyArn())) {
return KMSConfiguration.create(software.amazon.smithy.dafny.conversion.ToDafny.Simple.CharacterSequence(nativeValue.kmsKeyArn()));
}
throw new IllegalArgumentException("Cannot convert " + nativeValue + " to software.amazon.cryptography.keystore.internaldafny.types.KMSConfiguration.");
}
public static DafnySequence<? extends DafnySequence<? extends Character>> GrantTokenList(
List<String> nativeValue) {
return software.amazon.smithy.dafny.conversion.ToDafny.Aggregate.GenericToSequence(
nativeValue,
software.amazon.smithy.dafny.conversion.ToDafny.Simple::CharacterSequence,
DafnySequence._typeDescriptor(TypeDescriptor.CHAR));
}
public static DafnyMap<? extends DafnySequence<? extends Byte>, ? extends DafnySequence<? extends Byte>> EncryptionContext(
Map<String, String> nativeValue) {
return software.amazon.smithy.dafny.conversion.ToDafny.Aggregate.GenericToMap(
nativeValue,
software.amazon.smithy.dafny.conversion.ToDafny.Simple::DafnyUtf8Bytes,
software.amazon.smithy.dafny.conversion.ToDafny.Simple::DafnyUtf8Bytes);
}
public static DafnyMap<? extends DafnySequence<? extends Character>, ? extends DafnySequence<? extends Byte>> HmacKeyMap(
Map<String, ByteBuffer> nativeValue) {
return software.amazon.smithy.dafny.conversion.ToDafny.Aggregate.GenericToMap(
nativeValue,
software.amazon.smithy.dafny.conversion.ToDafny.Simple::CharacterSequence,
software.amazon.smithy.dafny.conversion.ToDafny.Simple::ByteSequence);
}
public static IKeyStoreClient KeyStore(KeyStore nativeValue) {
return nativeValue.impl();
}
}
| 285 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystore/KeyStore.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.keystore;
import Wrappers_Compile.Result;
import java.lang.IllegalArgumentException;
import java.util.Objects;
import software.amazon.cryptography.keystore.internaldafny.KeyStoreClient;
import software.amazon.cryptography.keystore.internaldafny.__default;
import software.amazon.cryptography.keystore.internaldafny.types.Error;
import software.amazon.cryptography.keystore.internaldafny.types.IKeyStoreClient;
import software.amazon.cryptography.keystore.model.CreateKeyInput;
import software.amazon.cryptography.keystore.model.CreateKeyOutput;
import software.amazon.cryptography.keystore.model.CreateKeyStoreInput;
import software.amazon.cryptography.keystore.model.CreateKeyStoreOutput;
import software.amazon.cryptography.keystore.model.GetActiveBranchKeyInput;
import software.amazon.cryptography.keystore.model.GetActiveBranchKeyOutput;
import software.amazon.cryptography.keystore.model.GetBeaconKeyInput;
import software.amazon.cryptography.keystore.model.GetBeaconKeyOutput;
import software.amazon.cryptography.keystore.model.GetBranchKeyVersionInput;
import software.amazon.cryptography.keystore.model.GetBranchKeyVersionOutput;
import software.amazon.cryptography.keystore.model.GetKeyStoreInfoOutput;
import software.amazon.cryptography.keystore.model.KeyStoreConfig;
import software.amazon.cryptography.keystore.model.VersionKeyInput;
import software.amazon.cryptography.keystore.model.VersionKeyOutput;
public class KeyStore {
private final IKeyStoreClient _impl;
protected KeyStore(BuilderImpl builder) {
KeyStoreConfig input = builder.KeyStoreConfig();
software.amazon.cryptography.keystore.internaldafny.types.KeyStoreConfig dafnyValue = ToDafny.KeyStoreConfig(input);
Result<KeyStoreClient, Error> result = __default.KeyStore(dafnyValue);
if (result.is_Failure()) {
throw ToNative.Error(result.dtor_error());
}
this._impl = result.dtor_value();
}
KeyStore(IKeyStoreClient impl) {
this._impl = impl;
}
public static Builder builder() {
return new BuilderImpl();
}
/**
* Create a new Branch Key in the Key Store. Additionally create a Beacon Key that is tied to this Branch Key.
* @return Outputs for Branch Key creation.
*/
public CreateKeyOutput CreateKey(CreateKeyInput input) {
software.amazon.cryptography.keystore.internaldafny.types.CreateKeyInput dafnyValue = ToDafny.CreateKeyInput(input);
Result<software.amazon.cryptography.keystore.internaldafny.types.CreateKeyOutput, Error> result = this._impl.CreateKey(dafnyValue);
if (result.is_Failure()) {
throw ToNative.Error(result.dtor_error());
}
return ToNative.CreateKeyOutput(result.dtor_value());
}
/**
* Create the DynamoDB table that backs this Key Store based on the Key Store configuration. If a table already exists, validate it is configured as expected.
* @return Outputs for Key Store DynamoDB table creation.
*/
public CreateKeyStoreOutput CreateKeyStore(CreateKeyStoreInput input) {
software.amazon.cryptography.keystore.internaldafny.types.CreateKeyStoreInput dafnyValue = ToDafny.CreateKeyStoreInput(input);
Result<software.amazon.cryptography.keystore.internaldafny.types.CreateKeyStoreOutput, Error> result = this._impl.CreateKeyStore(dafnyValue);
if (result.is_Failure()) {
throw ToNative.Error(result.dtor_error());
}
return ToNative.CreateKeyStoreOutput(result.dtor_value());
}
/**
* Get the ACTIVE version for a particular Branch Key from the Key Store.
*
* @param input Inputs for getting a Branch Key's ACTIVE version.
* @return Outputs for getting a Branch Key's ACTIVE version.
*/
public GetActiveBranchKeyOutput GetActiveBranchKey(GetActiveBranchKeyInput input) {
software.amazon.cryptography.keystore.internaldafny.types.GetActiveBranchKeyInput dafnyValue = ToDafny.GetActiveBranchKeyInput(input);
Result<software.amazon.cryptography.keystore.internaldafny.types.GetActiveBranchKeyOutput, Error> result = this._impl.GetActiveBranchKey(dafnyValue);
if (result.is_Failure()) {
throw ToNative.Error(result.dtor_error());
}
return ToNative.GetActiveBranchKeyOutput(result.dtor_value());
}
/**
* Get a Beacon Key from the Key Store.
*
* @param input Inputs for getting a Beacon Key
* @return Outputs for getting a Beacon Key
*/
public GetBeaconKeyOutput GetBeaconKey(GetBeaconKeyInput input) {
software.amazon.cryptography.keystore.internaldafny.types.GetBeaconKeyInput dafnyValue = ToDafny.GetBeaconKeyInput(input);
Result<software.amazon.cryptography.keystore.internaldafny.types.GetBeaconKeyOutput, Error> result = this._impl.GetBeaconKey(dafnyValue);
if (result.is_Failure()) {
throw ToNative.Error(result.dtor_error());
}
return ToNative.GetBeaconKeyOutput(result.dtor_value());
}
/**
* Get a particular version of a Branch Key from the Key Store.
*
* @param input Inputs for getting a version of a Branch Key.
* @return Outputs for getting a version of a Branch Key.
*/
public GetBranchKeyVersionOutput GetBranchKeyVersion(GetBranchKeyVersionInput input) {
software.amazon.cryptography.keystore.internaldafny.types.GetBranchKeyVersionInput dafnyValue = ToDafny.GetBranchKeyVersionInput(input);
Result<software.amazon.cryptography.keystore.internaldafny.types.GetBranchKeyVersionOutput, Error> result = this._impl.GetBranchKeyVersion(dafnyValue);
if (result.is_Failure()) {
throw ToNative.Error(result.dtor_error());
}
return ToNative.GetBranchKeyVersionOutput(result.dtor_value());
}
/**
* Returns the configuration information for a Key Store.
* @return The configuration information for a Key Store.
*/
public GetKeyStoreInfoOutput GetKeyStoreInfo() {
Result<software.amazon.cryptography.keystore.internaldafny.types.GetKeyStoreInfoOutput, Error> result = this._impl.GetKeyStoreInfo();
if (result.is_Failure()) {
throw ToNative.Error(result.dtor_error());
}
return ToNative.GetKeyStoreInfoOutput(result.dtor_value());
}
/**
* Create a new ACTIVE version of an existing Branch Key in the Key Store, and set the previously ACTIVE version to DECRYPT_ONLY.
*
* @param input Inputs for versioning a Branch Key.
* @return Outputs for versioning a Branch Key.
*/
public VersionKeyOutput VersionKey(VersionKeyInput input) {
software.amazon.cryptography.keystore.internaldafny.types.VersionKeyInput dafnyValue = ToDafny.VersionKeyInput(input);
Result<software.amazon.cryptography.keystore.internaldafny.types.VersionKeyOutput, Error> result = this._impl.VersionKey(dafnyValue);
if (result.is_Failure()) {
throw ToNative.Error(result.dtor_error());
}
return ToNative.VersionKeyOutput(result.dtor_value());
}
protected IKeyStoreClient impl() {
return this._impl;
}
public interface Builder {
Builder KeyStoreConfig(KeyStoreConfig KeyStoreConfig);
KeyStoreConfig KeyStoreConfig();
KeyStore build();
}
static class BuilderImpl implements Builder {
protected KeyStoreConfig KeyStoreConfig;
protected BuilderImpl() {
}
public Builder KeyStoreConfig(KeyStoreConfig KeyStoreConfig) {
this.KeyStoreConfig = KeyStoreConfig;
return this;
}
public KeyStoreConfig KeyStoreConfig() {
return this.KeyStoreConfig;
}
public KeyStore build() {
if (Objects.isNull(this.KeyStoreConfig())) {
throw new IllegalArgumentException("Missing value for required field `KeyStoreConfig`");
}
return new KeyStore(this);
}
}
}
| 286 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystore | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystore/model/GetBeaconKeyOutput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.keystore.model;
import java.util.Objects;
/**
* Outputs for getting a Beacon Key
*/
public class GetBeaconKeyOutput {
/**
* The materials for the Beacon Key.
*/
private final BeaconKeyMaterials beaconKeyMaterials;
protected GetBeaconKeyOutput(BuilderImpl builder) {
this.beaconKeyMaterials = builder.beaconKeyMaterials();
}
/**
* @return The materials for the Beacon Key.
*/
public BeaconKeyMaterials beaconKeyMaterials() {
return this.beaconKeyMaterials;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
/**
* @param beaconKeyMaterials The materials for the Beacon Key.
*/
Builder beaconKeyMaterials(BeaconKeyMaterials beaconKeyMaterials);
/**
* @return The materials for the Beacon Key.
*/
BeaconKeyMaterials beaconKeyMaterials();
GetBeaconKeyOutput build();
}
static class BuilderImpl implements Builder {
protected BeaconKeyMaterials beaconKeyMaterials;
protected BuilderImpl() {
}
protected BuilderImpl(GetBeaconKeyOutput model) {
this.beaconKeyMaterials = model.beaconKeyMaterials();
}
public Builder beaconKeyMaterials(BeaconKeyMaterials beaconKeyMaterials) {
this.beaconKeyMaterials = beaconKeyMaterials;
return this;
}
public BeaconKeyMaterials beaconKeyMaterials() {
return this.beaconKeyMaterials;
}
public GetBeaconKeyOutput build() {
if (Objects.isNull(this.beaconKeyMaterials())) {
throw new IllegalArgumentException("Missing value for required field `beaconKeyMaterials`");
}
return new GetBeaconKeyOutput(this);
}
}
}
| 287 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystore | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystore/model/KeyStoreException.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.keystore.model;
import java.util.Objects;
public class KeyStoreException extends RuntimeException {
protected KeyStoreException(BuilderImpl builder) {
super(messageFromBuilder(builder), builder.cause());
}
private static String messageFromBuilder(Builder builder) {
if (builder.message() != null) {
return builder.message();
}
if (builder.cause() != null) {
return builder.cause().getMessage();
}
return null;
}
/**
* See {@link Throwable#getMessage()}.
*/
public String message() {
return this.getMessage();
}
/**
* See {@link Throwable#getCause()}.
*/
public Throwable cause() {
return this.getCause();
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
/**
* @param message The detailed message. The detail message is saved for later retrieval by the {@link #getMessage()} method.
*/
Builder message(String message);
/**
* @return The detailed message. The detail message is saved for later retrieval by the {@link #getMessage()} method.
*/
String message();
/**
* @param cause The cause (which is saved for later retrieval by the {@link #getCause()} method). (A {@code null} value is permitted, and indicates that the cause is nonexistent or unknown.)
*/
Builder cause(Throwable cause);
/**
* @return The cause (which is saved for later retrieval by the {@link #getCause()} method). (A {@code null} value is permitted, and indicates that the cause is nonexistent or unknown.)
*/
Throwable cause();
KeyStoreException build();
}
static class BuilderImpl implements Builder {
protected String message;
protected Throwable cause;
protected BuilderImpl() {
}
protected BuilderImpl(KeyStoreException model) {
this.message = model.message();
this.cause = model.cause();
}
public Builder message(String message) {
this.message = message;
return this;
}
public String message() {
return this.message;
}
public Builder cause(Throwable cause) {
this.cause = cause;
return this;
}
public Throwable cause() {
return this.cause;
}
public KeyStoreException build() {
if (Objects.isNull(this.message())) {
throw new IllegalArgumentException("Missing value for required field `message`");
}
return new KeyStoreException(this);
}
}
}
| 288 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystore | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystore/model/BeaconKeyMaterials.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.keystore.model;
import java.nio.ByteBuffer;
import java.util.Map;
import java.util.Objects;
public class BeaconKeyMaterials {
private final String beaconKeyIdentifier;
private final Map<String, String> encryptionContext;
private final ByteBuffer beaconKey;
private final Map<String, ByteBuffer> hmacKeys;
protected BeaconKeyMaterials(BuilderImpl builder) {
this.beaconKeyIdentifier = builder.beaconKeyIdentifier();
this.encryptionContext = builder.encryptionContext();
this.beaconKey = builder.beaconKey();
this.hmacKeys = builder.hmacKeys();
}
public String beaconKeyIdentifier() {
return this.beaconKeyIdentifier;
}
public Map<String, String> encryptionContext() {
return this.encryptionContext;
}
public ByteBuffer beaconKey() {
return this.beaconKey;
}
public Map<String, ByteBuffer> hmacKeys() {
return this.hmacKeys;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder beaconKeyIdentifier(String beaconKeyIdentifier);
String beaconKeyIdentifier();
Builder encryptionContext(Map<String, String> encryptionContext);
Map<String, String> encryptionContext();
Builder beaconKey(ByteBuffer beaconKey);
ByteBuffer beaconKey();
Builder hmacKeys(Map<String, ByteBuffer> hmacKeys);
Map<String, ByteBuffer> hmacKeys();
BeaconKeyMaterials build();
}
static class BuilderImpl implements Builder {
protected String beaconKeyIdentifier;
protected Map<String, String> encryptionContext;
protected ByteBuffer beaconKey;
protected Map<String, ByteBuffer> hmacKeys;
protected BuilderImpl() {
}
protected BuilderImpl(BeaconKeyMaterials model) {
this.beaconKeyIdentifier = model.beaconKeyIdentifier();
this.encryptionContext = model.encryptionContext();
this.beaconKey = model.beaconKey();
this.hmacKeys = model.hmacKeys();
}
public Builder beaconKeyIdentifier(String beaconKeyIdentifier) {
this.beaconKeyIdentifier = beaconKeyIdentifier;
return this;
}
public String beaconKeyIdentifier() {
return this.beaconKeyIdentifier;
}
public Builder encryptionContext(Map<String, String> encryptionContext) {
this.encryptionContext = encryptionContext;
return this;
}
public Map<String, String> encryptionContext() {
return this.encryptionContext;
}
public Builder beaconKey(ByteBuffer beaconKey) {
this.beaconKey = beaconKey;
return this;
}
public ByteBuffer beaconKey() {
return this.beaconKey;
}
public Builder hmacKeys(Map<String, ByteBuffer> hmacKeys) {
this.hmacKeys = hmacKeys;
return this;
}
public Map<String, ByteBuffer> hmacKeys() {
return this.hmacKeys;
}
public BeaconKeyMaterials build() {
if (Objects.isNull(this.beaconKeyIdentifier())) {
throw new IllegalArgumentException("Missing value for required field `beaconKeyIdentifier`");
}
if (Objects.isNull(this.encryptionContext())) {
throw new IllegalArgumentException("Missing value for required field `encryptionContext`");
}
return new BeaconKeyMaterials(this);
}
}
}
| 289 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystore | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystore/model/GetBranchKeyVersionOutput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.keystore.model;
import java.util.Objects;
/**
* Outputs for getting a version of a Branch Key.
*/
public class GetBranchKeyVersionOutput {
/**
* The materials for the Branch Key.
*/
private final BranchKeyMaterials branchKeyMaterials;
protected GetBranchKeyVersionOutput(BuilderImpl builder) {
this.branchKeyMaterials = builder.branchKeyMaterials();
}
/**
* @return The materials for the Branch Key.
*/
public BranchKeyMaterials branchKeyMaterials() {
return this.branchKeyMaterials;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
/**
* @param branchKeyMaterials The materials for the Branch Key.
*/
Builder branchKeyMaterials(BranchKeyMaterials branchKeyMaterials);
/**
* @return The materials for the Branch Key.
*/
BranchKeyMaterials branchKeyMaterials();
GetBranchKeyVersionOutput build();
}
static class BuilderImpl implements Builder {
protected BranchKeyMaterials branchKeyMaterials;
protected BuilderImpl() {
}
protected BuilderImpl(GetBranchKeyVersionOutput model) {
this.branchKeyMaterials = model.branchKeyMaterials();
}
public Builder branchKeyMaterials(BranchKeyMaterials branchKeyMaterials) {
this.branchKeyMaterials = branchKeyMaterials;
return this;
}
public BranchKeyMaterials branchKeyMaterials() {
return this.branchKeyMaterials;
}
public GetBranchKeyVersionOutput build() {
if (Objects.isNull(this.branchKeyMaterials())) {
throw new IllegalArgumentException("Missing value for required field `branchKeyMaterials`");
}
return new GetBranchKeyVersionOutput(this);
}
}
}
| 290 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystore | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystore/model/GetBeaconKeyInput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.keystore.model;
import java.util.Objects;
/**
* Inputs for getting a Beacon Key
*/
public class GetBeaconKeyInput {
/**
* The identifier of the Branch Key the Beacon Key is associated with.
*/
private final String branchKeyIdentifier;
protected GetBeaconKeyInput(BuilderImpl builder) {
this.branchKeyIdentifier = builder.branchKeyIdentifier();
}
/**
* @return The identifier of the Branch Key the Beacon Key is associated with.
*/
public String branchKeyIdentifier() {
return this.branchKeyIdentifier;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
/**
* @param branchKeyIdentifier The identifier of the Branch Key the Beacon Key is associated with.
*/
Builder branchKeyIdentifier(String branchKeyIdentifier);
/**
* @return The identifier of the Branch Key the Beacon Key is associated with.
*/
String branchKeyIdentifier();
GetBeaconKeyInput build();
}
static class BuilderImpl implements Builder {
protected String branchKeyIdentifier;
protected BuilderImpl() {
}
protected BuilderImpl(GetBeaconKeyInput model) {
this.branchKeyIdentifier = model.branchKeyIdentifier();
}
public Builder branchKeyIdentifier(String branchKeyIdentifier) {
this.branchKeyIdentifier = branchKeyIdentifier;
return this;
}
public String branchKeyIdentifier() {
return this.branchKeyIdentifier;
}
public GetBeaconKeyInput build() {
if (Objects.isNull(this.branchKeyIdentifier())) {
throw new IllegalArgumentException("Missing value for required field `branchKeyIdentifier`");
}
return new GetBeaconKeyInput(this);
}
}
}
| 291 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystore | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystore/model/VersionKeyInput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.keystore.model;
import java.util.Objects;
/**
* Inputs for versioning a Branch Key.
*/
public class VersionKeyInput {
/**
* The identifier for the Branch Key to be versioned.
*/
private final String branchKeyIdentifier;
protected VersionKeyInput(BuilderImpl builder) {
this.branchKeyIdentifier = builder.branchKeyIdentifier();
}
/**
* @return The identifier for the Branch Key to be versioned.
*/
public String branchKeyIdentifier() {
return this.branchKeyIdentifier;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
/**
* @param branchKeyIdentifier The identifier for the Branch Key to be versioned.
*/
Builder branchKeyIdentifier(String branchKeyIdentifier);
/**
* @return The identifier for the Branch Key to be versioned.
*/
String branchKeyIdentifier();
VersionKeyInput build();
}
static class BuilderImpl implements Builder {
protected String branchKeyIdentifier;
protected BuilderImpl() {
}
protected BuilderImpl(VersionKeyInput model) {
this.branchKeyIdentifier = model.branchKeyIdentifier();
}
public Builder branchKeyIdentifier(String branchKeyIdentifier) {
this.branchKeyIdentifier = branchKeyIdentifier;
return this;
}
public String branchKeyIdentifier() {
return this.branchKeyIdentifier;
}
public VersionKeyInput build() {
if (Objects.isNull(this.branchKeyIdentifier())) {
throw new IllegalArgumentException("Missing value for required field `branchKeyIdentifier`");
}
return new VersionKeyInput(this);
}
}
}
| 292 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystore | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystore/model/KMSConfiguration.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.keystore.model;
import java.util.Objects;
public class KMSConfiguration {
private final String kmsKeyArn;
protected KMSConfiguration(BuilderImpl builder) {
this.kmsKeyArn = builder.kmsKeyArn();
}
public String kmsKeyArn() {
return this.kmsKeyArn;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
Builder kmsKeyArn(String kmsKeyArn);
String kmsKeyArn();
KMSConfiguration build();
}
static class BuilderImpl implements Builder {
protected String kmsKeyArn;
protected BuilderImpl() {
}
protected BuilderImpl(KMSConfiguration model) {
this.kmsKeyArn = model.kmsKeyArn();
}
public Builder kmsKeyArn(String kmsKeyArn) {
this.kmsKeyArn = kmsKeyArn;
return this;
}
public String kmsKeyArn() {
return this.kmsKeyArn;
}
public KMSConfiguration build() {
if (Objects.nonNull(this.kmsKeyArn()) && this.kmsKeyArn().length() < 1) {
throw new IllegalArgumentException("The size of `kmsKeyArn` must be greater than or equal to 1");
}
if (Objects.nonNull(this.kmsKeyArn()) && this.kmsKeyArn().length() > 2048) {
throw new IllegalArgumentException("The size of `kmsKeyArn` must be less than or equal to 2048");
}
if (!onlyOneNonNull()) {
throw new IllegalArgumentException("`KMSConfiguration` is a Union. A Union MUST have one and only one value set.");
}
return new KMSConfiguration(this);
}
private boolean onlyOneNonNull() {
Object[] allValues = {this.kmsKeyArn};
boolean haveOneNonNull = false;
for (Object o : allValues) {
if (Objects.nonNull(o)) {
if (haveOneNonNull) {
return false;
}
haveOneNonNull = true;
}
}
return haveOneNonNull;
}
}
}
| 293 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystore | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystore/model/OpaqueError.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.keystore.model;
public class OpaqueError extends RuntimeException {
/**
* The unexpected object encountered. It MIGHT BE an Exception, but that is not guaranteed.
*/
private final Object obj;
protected OpaqueError(BuilderImpl builder) {
super(messageFromBuilder(builder), builder.cause());
this.obj = builder.obj();
}
private static String messageFromBuilder(Builder builder) {
if (builder.message() != null) {
return builder.message();
}
if (builder.cause() != null) {
return builder.cause().getMessage();
}
return null;
}
/**
* See {@link Throwable#getMessage()}.
*/
public String message() {
return this.getMessage();
}
/**
* See {@link Throwable#getCause()}.
*/
public Throwable cause() {
return this.getCause();
}
/**
* @return The unexpected object encountered. It MIGHT BE an Exception, but that is not guaranteed.
*/
public Object obj() {
return this.obj;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
/**
* @param message The detailed message. The detail message is saved for later retrieval by the {@link #getMessage()} method.
*/
Builder message(String message);
/**
* @return The detailed message. The detail message is saved for later retrieval by the {@link #getMessage()} method.
*/
String message();
/**
* @param cause The cause (which is saved for later retrieval by the {@link #getCause()} method). (A {@code null} value is permitted, and indicates that the cause is nonexistent or unknown.)
*/
Builder cause(Throwable cause);
/**
* @return The cause (which is saved for later retrieval by the {@link #getCause()} method). (A {@code null} value is permitted, and indicates that the cause is nonexistent or unknown.)
*/
Throwable cause();
/**
* @param obj The unexpected object encountered. It MIGHT BE an Exception, but that is not guaranteed.
*/
Builder obj(Object obj);
/**
* @return The unexpected object encountered. It MIGHT BE an Exception, but that is not guaranteed.
*/
Object obj();
OpaqueError build();
}
static class BuilderImpl implements Builder {
protected String message;
protected Throwable cause;
protected Object obj;
protected BuilderImpl() {
}
protected BuilderImpl(OpaqueError model) {
this.cause = model.getCause();
this.message = model.getMessage();
this.obj = model.obj();
}
public Builder message(String message) {
this.message = message;
return this;
}
public String message() {
return this.message;
}
public Builder cause(Throwable cause) {
this.cause = cause;
return this;
}
public Throwable cause() {
return this.cause;
}
public Builder obj(Object obj) {
this.obj = obj;
return this;
}
public Object obj() {
return this.obj;
}
public OpaqueError build() {
if (this.obj != null && this.cause == null && this.obj instanceof Throwable) {
this.cause = (Throwable) this.obj;
} else if (this.obj == null && this.cause != null) {
this.obj = this.cause;
}
return new OpaqueError(this);
}
}
}
| 294 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystore | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystore/model/BranchKeyStatusResolutionInput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.keystore.model;
import java.util.Objects;
/**
* Inputs for resolving a multiple ACTIVE versions state.
*/
public class BranchKeyStatusResolutionInput {
/**
* The identifier for the Branch Key which has more than one ACTIVE version
*/
private final String branchKeyIdentifier;
protected BranchKeyStatusResolutionInput(BuilderImpl builder) {
this.branchKeyIdentifier = builder.branchKeyIdentifier();
}
/**
* @return The identifier for the Branch Key which has more than one ACTIVE version
*/
public String branchKeyIdentifier() {
return this.branchKeyIdentifier;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
/**
* @param branchKeyIdentifier The identifier for the Branch Key which has more than one ACTIVE version
*/
Builder branchKeyIdentifier(String branchKeyIdentifier);
/**
* @return The identifier for the Branch Key which has more than one ACTIVE version
*/
String branchKeyIdentifier();
BranchKeyStatusResolutionInput build();
}
static class BuilderImpl implements Builder {
protected String branchKeyIdentifier;
protected BuilderImpl() {
}
protected BuilderImpl(BranchKeyStatusResolutionInput model) {
this.branchKeyIdentifier = model.branchKeyIdentifier();
}
public Builder branchKeyIdentifier(String branchKeyIdentifier) {
this.branchKeyIdentifier = branchKeyIdentifier;
return this;
}
public String branchKeyIdentifier() {
return this.branchKeyIdentifier;
}
public BranchKeyStatusResolutionInput build() {
if (Objects.isNull(this.branchKeyIdentifier())) {
throw new IllegalArgumentException("Missing value for required field `branchKeyIdentifier`");
}
return new BranchKeyStatusResolutionInput(this);
}
}
}
| 295 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystore | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystore/model/CreateKeyOutput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.keystore.model;
import java.util.Objects;
/**
* Outputs for Branch Key creation.
*/
public class CreateKeyOutput {
/**
* A identifier for the created Branch Key.
*/
private final String branchKeyIdentifier;
protected CreateKeyOutput(BuilderImpl builder) {
this.branchKeyIdentifier = builder.branchKeyIdentifier();
}
/**
* @return A identifier for the created Branch Key.
*/
public String branchKeyIdentifier() {
return this.branchKeyIdentifier;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
/**
* @param branchKeyIdentifier A identifier for the created Branch Key.
*/
Builder branchKeyIdentifier(String branchKeyIdentifier);
/**
* @return A identifier for the created Branch Key.
*/
String branchKeyIdentifier();
CreateKeyOutput build();
}
static class BuilderImpl implements Builder {
protected String branchKeyIdentifier;
protected BuilderImpl() {
}
protected BuilderImpl(CreateKeyOutput model) {
this.branchKeyIdentifier = model.branchKeyIdentifier();
}
public Builder branchKeyIdentifier(String branchKeyIdentifier) {
this.branchKeyIdentifier = branchKeyIdentifier;
return this;
}
public String branchKeyIdentifier() {
return this.branchKeyIdentifier;
}
public CreateKeyOutput build() {
if (Objects.isNull(this.branchKeyIdentifier())) {
throw new IllegalArgumentException("Missing value for required field `branchKeyIdentifier`");
}
return new CreateKeyOutput(this);
}
}
}
| 296 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystore | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystore/model/KeyStoreConfig.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.keystore.model;
import java.util.List;
import java.util.Objects;
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
import software.amazon.awssdk.services.kms.KmsClient;
public class KeyStoreConfig {
/**
* The DynamoDB table name that backs this Key Store.
*/
private final String ddbTableName;
/**
* The AWS KMS Key that protects this Key Store.
*/
private final KMSConfiguration kmsConfiguration;
/**
* The logical name for this Key Store, which is cryptographically bound to the keys it holds.
*/
private final String logicalKeyStoreName;
/**
* An identifier for this Key Store.
*/
private final String id;
/**
* The AWS KMS grant tokens that are used when this Key Store calls to AWS KMS.
*/
private final List<String> grantTokens;
/**
* The DynamoDB client this Key Store uses to call Amazon DynamoDB.
*/
private final DynamoDbClient ddbClient;
/**
* The KMS client this Key Store uses to call AWS KMS.
*/
private final KmsClient kmsClient;
protected KeyStoreConfig(BuilderImpl builder) {
this.ddbTableName = builder.ddbTableName();
this.kmsConfiguration = builder.kmsConfiguration();
this.logicalKeyStoreName = builder.logicalKeyStoreName();
this.id = builder.id();
this.grantTokens = builder.grantTokens();
this.ddbClient = builder.ddbClient();
this.kmsClient = builder.kmsClient();
}
/**
* @return The DynamoDB table name that backs this Key Store.
*/
public String ddbTableName() {
return this.ddbTableName;
}
/**
* @return The AWS KMS Key that protects this Key Store.
*/
public KMSConfiguration kmsConfiguration() {
return this.kmsConfiguration;
}
/**
* @return The logical name for this Key Store, which is cryptographically bound to the keys it holds.
*/
public String logicalKeyStoreName() {
return this.logicalKeyStoreName;
}
/**
* @return An identifier for this Key Store.
*/
public String id() {
return this.id;
}
/**
* @return The AWS KMS grant tokens that are used when this Key Store calls to AWS KMS.
*/
public List<String> grantTokens() {
return this.grantTokens;
}
/**
* @return The DynamoDB client this Key Store uses to call Amazon DynamoDB.
*/
public DynamoDbClient ddbClient() {
return this.ddbClient;
}
/**
* @return The KMS client this Key Store uses to call AWS KMS.
*/
public KmsClient kmsClient() {
return this.kmsClient;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
/**
* @param ddbTableName The DynamoDB table name that backs this Key Store.
*/
Builder ddbTableName(String ddbTableName);
/**
* @return The DynamoDB table name that backs this Key Store.
*/
String ddbTableName();
/**
* @param kmsConfiguration The AWS KMS Key that protects this Key Store.
*/
Builder kmsConfiguration(KMSConfiguration kmsConfiguration);
/**
* @return The AWS KMS Key that protects this Key Store.
*/
KMSConfiguration kmsConfiguration();
/**
* @param logicalKeyStoreName The logical name for this Key Store, which is cryptographically bound to the keys it holds.
*/
Builder logicalKeyStoreName(String logicalKeyStoreName);
/**
* @return The logical name for this Key Store, which is cryptographically bound to the keys it holds.
*/
String logicalKeyStoreName();
/**
* @param id An identifier for this Key Store.
*/
Builder id(String id);
/**
* @return An identifier for this Key Store.
*/
String id();
/**
* @param grantTokens The AWS KMS grant tokens that are used when this Key Store calls to AWS KMS.
*/
Builder grantTokens(List<String> grantTokens);
/**
* @return The AWS KMS grant tokens that are used when this Key Store calls to AWS KMS.
*/
List<String> grantTokens();
/**
* @param ddbClient The DynamoDB client this Key Store uses to call Amazon DynamoDB.
*/
Builder ddbClient(DynamoDbClient ddbClient);
/**
* @return The DynamoDB client this Key Store uses to call Amazon DynamoDB.
*/
DynamoDbClient ddbClient();
/**
* @param kmsClient The KMS client this Key Store uses to call AWS KMS.
*/
Builder kmsClient(KmsClient kmsClient);
/**
* @return The KMS client this Key Store uses to call AWS KMS.
*/
KmsClient kmsClient();
KeyStoreConfig build();
}
static class BuilderImpl implements Builder {
protected String ddbTableName;
protected KMSConfiguration kmsConfiguration;
protected String logicalKeyStoreName;
protected String id;
protected List<String> grantTokens;
protected DynamoDbClient ddbClient;
protected KmsClient kmsClient;
protected BuilderImpl() {
}
protected BuilderImpl(KeyStoreConfig model) {
this.ddbTableName = model.ddbTableName();
this.kmsConfiguration = model.kmsConfiguration();
this.logicalKeyStoreName = model.logicalKeyStoreName();
this.id = model.id();
this.grantTokens = model.grantTokens();
this.ddbClient = model.ddbClient();
this.kmsClient = model.kmsClient();
}
public Builder ddbTableName(String ddbTableName) {
this.ddbTableName = ddbTableName;
return this;
}
public String ddbTableName() {
return this.ddbTableName;
}
public Builder kmsConfiguration(KMSConfiguration kmsConfiguration) {
this.kmsConfiguration = kmsConfiguration;
return this;
}
public KMSConfiguration kmsConfiguration() {
return this.kmsConfiguration;
}
public Builder logicalKeyStoreName(String logicalKeyStoreName) {
this.logicalKeyStoreName = logicalKeyStoreName;
return this;
}
public String logicalKeyStoreName() {
return this.logicalKeyStoreName;
}
public Builder id(String id) {
this.id = id;
return this;
}
public String id() {
return this.id;
}
public Builder grantTokens(List<String> grantTokens) {
this.grantTokens = grantTokens;
return this;
}
public List<String> grantTokens() {
return this.grantTokens;
}
public Builder ddbClient(DynamoDbClient ddbClient) {
this.ddbClient = ddbClient;
return this;
}
public DynamoDbClient ddbClient() {
return this.ddbClient;
}
public Builder kmsClient(KmsClient kmsClient) {
this.kmsClient = kmsClient;
return this;
}
public KmsClient kmsClient() {
return this.kmsClient;
}
public KeyStoreConfig build() {
if (Objects.isNull(this.ddbTableName())) {
throw new IllegalArgumentException("Missing value for required field `ddbTableName`");
}
if (Objects.nonNull(this.ddbTableName()) && this.ddbTableName().length() < 3) {
throw new IllegalArgumentException("The size of `ddbTableName` must be greater than or equal to 3");
}
if (Objects.nonNull(this.ddbTableName()) && this.ddbTableName().length() > 255) {
throw new IllegalArgumentException("The size of `ddbTableName` must be less than or equal to 255");
}
if (Objects.isNull(this.kmsConfiguration())) {
throw new IllegalArgumentException("Missing value for required field `kmsConfiguration`");
}
if (Objects.isNull(this.logicalKeyStoreName())) {
throw new IllegalArgumentException("Missing value for required field `logicalKeyStoreName`");
}
return new KeyStoreConfig(this);
}
}
}
| 297 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystore | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystore/model/GetBranchKeyVersionInput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.keystore.model;
import java.util.Objects;
/**
* Inputs for getting a version of a Branch Key.
*/
public class GetBranchKeyVersionInput {
/**
* The identifier for the Branch Key to get a particular version for.
*/
private final String branchKeyIdentifier;
/**
* The version to get.
*/
private final String branchKeyVersion;
protected GetBranchKeyVersionInput(BuilderImpl builder) {
this.branchKeyIdentifier = builder.branchKeyIdentifier();
this.branchKeyVersion = builder.branchKeyVersion();
}
/**
* @return The identifier for the Branch Key to get a particular version for.
*/
public String branchKeyIdentifier() {
return this.branchKeyIdentifier;
}
/**
* @return The version to get.
*/
public String branchKeyVersion() {
return this.branchKeyVersion;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
/**
* @param branchKeyIdentifier The identifier for the Branch Key to get a particular version for.
*/
Builder branchKeyIdentifier(String branchKeyIdentifier);
/**
* @return The identifier for the Branch Key to get a particular version for.
*/
String branchKeyIdentifier();
/**
* @param branchKeyVersion The version to get.
*/
Builder branchKeyVersion(String branchKeyVersion);
/**
* @return The version to get.
*/
String branchKeyVersion();
GetBranchKeyVersionInput build();
}
static class BuilderImpl implements Builder {
protected String branchKeyIdentifier;
protected String branchKeyVersion;
protected BuilderImpl() {
}
protected BuilderImpl(GetBranchKeyVersionInput model) {
this.branchKeyIdentifier = model.branchKeyIdentifier();
this.branchKeyVersion = model.branchKeyVersion();
}
public Builder branchKeyIdentifier(String branchKeyIdentifier) {
this.branchKeyIdentifier = branchKeyIdentifier;
return this;
}
public String branchKeyIdentifier() {
return this.branchKeyIdentifier;
}
public Builder branchKeyVersion(String branchKeyVersion) {
this.branchKeyVersion = branchKeyVersion;
return this;
}
public String branchKeyVersion() {
return this.branchKeyVersion;
}
public GetBranchKeyVersionInput build() {
if (Objects.isNull(this.branchKeyIdentifier())) {
throw new IllegalArgumentException("Missing value for required field `branchKeyIdentifier`");
}
if (Objects.isNull(this.branchKeyVersion())) {
throw new IllegalArgumentException("Missing value for required field `branchKeyVersion`");
}
return new GetBranchKeyVersionInput(this);
}
}
}
| 298 |
0 | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystore | Create_ds/aws-cryptographic-material-providers-library-java/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystore/model/GetActiveBranchKeyOutput.java | // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
package software.amazon.cryptography.keystore.model;
import java.util.Objects;
/**
* Outputs for getting a Branch Key's ACTIVE version.
*/
public class GetActiveBranchKeyOutput {
/**
* The materials for the Branch Key.
*/
private final BranchKeyMaterials branchKeyMaterials;
protected GetActiveBranchKeyOutput(BuilderImpl builder) {
this.branchKeyMaterials = builder.branchKeyMaterials();
}
/**
* @return The materials for the Branch Key.
*/
public BranchKeyMaterials branchKeyMaterials() {
return this.branchKeyMaterials;
}
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public interface Builder {
/**
* @param branchKeyMaterials The materials for the Branch Key.
*/
Builder branchKeyMaterials(BranchKeyMaterials branchKeyMaterials);
/**
* @return The materials for the Branch Key.
*/
BranchKeyMaterials branchKeyMaterials();
GetActiveBranchKeyOutput build();
}
static class BuilderImpl implements Builder {
protected BranchKeyMaterials branchKeyMaterials;
protected BuilderImpl() {
}
protected BuilderImpl(GetActiveBranchKeyOutput model) {
this.branchKeyMaterials = model.branchKeyMaterials();
}
public Builder branchKeyMaterials(BranchKeyMaterials branchKeyMaterials) {
this.branchKeyMaterials = branchKeyMaterials;
return this;
}
public BranchKeyMaterials branchKeyMaterials() {
return this.branchKeyMaterials;
}
public GetActiveBranchKeyOutput build() {
if (Objects.isNull(this.branchKeyMaterials())) {
throw new IllegalArgumentException("Missing value for required field `branchKeyMaterials`");
}
return new GetActiveBranchKeyOutput(this);
}
}
}
| 299 |
Subsets and Splits