Skip to content

Commit 139d32e

Browse files
lavaleritexastony
andauthored
feat: Add Java Interceptor (#31)
Co-authored-by: texastony <[email protected]>
1 parent 0f203a4 commit 139d32e

File tree

137 files changed

+10467
-274
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+10467
-274
lines changed

.github/workflows/ci_test_java.yml

+4-18
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This workflow performs tests in .NET.
1+
# This workflow performs tests in Java.
22
name: Library Java tests
33

44
on:
@@ -15,6 +15,7 @@ jobs:
1515
StructuredEncryption,
1616
DynamoDbItemEncryptor,
1717
DynamoDbEncryptionMiddlewareInternal,
18+
DynamoDbEncryption,
1819
]
1920
java-version: [ 8, 11, 16, 17 ]
2021
os: [
@@ -33,9 +34,8 @@ jobs:
3334
uses: aws-actions/configure-aws-credentials@v1
3435
with:
3536
aws-region: us-west-2
36-
# TODO: This role was manually created.
37-
role-to-assume: arn:aws:iam::370957321024:role/DDBEC-Dafny-Private-CA-Read
38-
role-session-name: JavaDDBECDafnyTests
37+
role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-DDBEC-Dafny-Role-us-west-2
38+
role-session-name: DDBEC-Dafny-Java-Tests
3939

4040
- uses: actions/checkout@v3
4141

@@ -78,20 +78,6 @@ jobs:
7878
distribution: 'corretto'
7979
java-version: ${{ matrix.java-version }}
8080

81-
# Java DafnyRuntime is not published to maven,
82-
# so manually download a nightly build for 3.10.0 and grab it from there.
83-
- name: Locally Cache Java DafnyRuntime
84-
run: |
85-
wget https://github.com/dafny-lang/dafny/releases/download/nightly/dafny-nightly-2022-12-02-edab6cc-x64-osx-10.14.2.zip
86-
unzip dafny-nightly-2022-12-02-edab6cc-x64-osx-10.14.2.zip
87-
mvn install:install-file \
88-
-Dfile=dafny/DafnyRuntime.jar \
89-
-DgroupId=dafny.lang \
90-
-DartifactId=DafnyRuntime \
91-
-Dversion=3.10.0 \
92-
-DgeneratePom=true \
93-
-Dpackaging=jar
94-
9581
- name: Build ${{ matrix.library }} implementation
9682
shell: bash
9783
working-directory: ./${{ matrix.library }}

.github/workflows/ci_test_net.yml

+7
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ jobs:
5959
working-directory: ./${{ matrix.library }}
6060
run: make setup_net
6161

62+
- name: Configure AWS Credentials
63+
uses: aws-actions/configure-aws-credentials@v1
64+
with:
65+
aws-region: us-west-2
66+
role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-DDBEC-Dafny-Role-us-west-2
67+
role-session-name: DDBEC-Dafny-Net-Tests
68+
6269
- name: Compile ${{ matrix.library }} implementation
6370
shell: bash
6471
working-directory: ./${{ matrix.library }}

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
.idea/*
2+
**/.idea/*
3+
**/*.iml
24
.vscode/*
35
*.sln?*
46
**/.DS_Store

DynamoDbEncryption/Makefile

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
5+
DEPS_DIR:=$(ROOT_DIR)/../private-aws-encryption-sdk-dafny-staging
6+
7+
build_java_dependencies:
8+
$(MAKE) -C $(DEPS_DIR)/StandardLibrary mvn_local_deploy
9+
$(MAKE) -C $(DEPS_DIR)/AwsCryptographyPrimitives mvn_local_deploy
10+
$(MAKE) -C $(DEPS_DIR)/ComAmazonawsKms mvn_local_deploy
11+
$(MAKE) -C $(DEPS_DIR)/ComAmazonawsDynamodb mvn_local_deploy
12+
$(MAKE) -C $(DEPS_DIR)/AwsCryptographicMaterialProviders mvn_local_deploy
13+
$(MAKE) -C $(ROOT_DIR)/../StructuredEncryption mvn_local_deploy
14+
$(MAKE) -C $(ROOT_DIR)/../DynamoDbItemEncryptor mvn_local_deploy
15+
$(MAKE) -C $(ROOT_DIR)/../DynamoDbEncryptionMiddlewareInternal mvn_local_deploy
16+
17+
build_java: build_java_dependencies
18+
gradle -p runtimes/java build
19+
20+
mvn_local_deploy:
21+
gradle -p runtimes/java publishToMavenLocal
22+
23+
test_java:
24+
gradle -p runtimes/java test
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#
2+
# https://help.github.com/articles/dealing-with-line-endings/
3+
#
4+
# Linux start script should use lf
5+
/gradlew text eol=lf
6+
7+
# These are Windows script files and should use crlf
8+
*.bat text eol=crlf
9+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Ignore Gradle project-specific cache directory
2+
.gradle
3+
4+
# JetBrains
5+
.idea/*
6+
*.iml
7+
8+
# Ignore Gradle build output directory
9+
build
10+
11+
# Mac OS X
12+
.DS_Store
13+
14+
# Dafny Generated Java
15+
src/main/dafny-generated/
16+
src/test/dafny-generated/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
import java.net.URI
2+
import javax.annotation.Nullable
3+
4+
plugins {
5+
`java`
6+
`java-library`
7+
`maven-publish`
8+
}
9+
10+
group = "software.amazon.cryptography"
11+
version = "1.0-SNAPSHOT"
12+
description = "AwsCryptographyDynamoDbEncryption"
13+
14+
java {
15+
toolchain.languageVersion.set(JavaLanguageVersion.of(8))
16+
sourceSets["main"].java {
17+
srcDir("src/main/java")
18+
}
19+
sourceSets["test"].java {
20+
srcDir("src/test")
21+
}
22+
}
23+
24+
var caUrl: URI? = null
25+
@Nullable
26+
val caUrlStr: String? = System.getenv("CODEARTIFACT_URL_JAVA_CONVERSION")
27+
if (!caUrlStr.isNullOrBlank()) {
28+
caUrl = URI.create(caUrlStr)
29+
}
30+
31+
var caPassword: String? = null
32+
@Nullable
33+
val caPasswordString: String? = System.getenv("CODEARTIFACT_AUTH_TOKEN")
34+
if (!caPasswordString.isNullOrBlank()) {
35+
caPassword = caPasswordString
36+
}
37+
38+
repositories {
39+
mavenCentral()
40+
mavenLocal()
41+
if (caUrl != null && caPassword != null) {
42+
maven {
43+
name = "CodeArtifact"
44+
url = caUrl!!
45+
credentials {
46+
username = "aws"
47+
password = caPassword!!
48+
}
49+
}
50+
}
51+
}
52+
53+
dependencies {
54+
implementation("dafny.lang:DafnyRuntime:3.10.0")
55+
implementation("software.amazon.dafny:conversion:1.0-SNAPSHOT")
56+
implementation("software.amazon.cryptography:StandardLibrary:1.0-SNAPSHOT")
57+
implementation("software.amazon.cryptography:AwsCryptographyPrimitives:1.0-SNAPSHOT")
58+
implementation("software.amazon.cryptography:AwsCryptographyDynamoDbItemEncryptor:1.0-SNAPSHOT")
59+
implementation("software.amazon.cryptography:AwsCryptographyDynamoDbEncryptionMiddlewareInternal:1.0-SNAPSHOT")
60+
implementation("software.amazon.cryptography:AwsCryptographyStructuredEncryption:1.0-SNAPSHOT")
61+
implementation("software.amazon.cryptography:AwsCryptographicMaterialProviders:1.0-SNAPSHOT")
62+
implementation("software.amazon.cryptography:ComAmazonawsDynamodb:1.0-SNAPSHOT")
63+
implementation("software.amazon.cryptography:ComAmazonawsKms:1.0-SNAPSHOT")
64+
implementation("com.amazonaws:aws-java-sdk:1.12.347")
65+
implementation(platform("software.amazon.awssdk:bom:2.19.1"))
66+
implementation("software.amazon.awssdk:dynamodb")
67+
implementation("software.amazon.awssdk:dynamodb-enhanced")
68+
implementation("software.amazon.awssdk:kms")
69+
implementation("software.amazon.awssdk:core:2.19.1")
70+
implementation("com.amazonaws:aws-dynamodb-encryption-java:2.0.3")
71+
72+
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1")
73+
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1")
74+
}
75+
76+
tasks.test {
77+
useJUnitPlatform()
78+
}
79+
80+
publishing {
81+
publications.create<MavenPublication>("maven") {
82+
groupId = "software.amazon.cryptography"
83+
artifactId = "AwsCryptographyDynamoDbEncryption"
84+
from(components["java"])
85+
}
86+
repositories { mavenLocal() }
87+
}
88+
89+
tasks.withType<JavaCompile>() {
90+
options.encoding = "UTF-8"
91+
}
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
4+
networkTimeout=10000
5+
zipStoreBase=GRADLE_USER_HOME
6+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)