Skip to content

Commit

Permalink
Issue #322: Move AwsKeyManager to its own module
Browse files Browse the repository at this point in the history
  • Loading branch information
ALRubinger committed Jun 27, 2024
1 parent 281aeb7 commit de62fa2
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 15 deletions.
6 changes: 6 additions & 0 deletions credentials/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@
and therefore are within the remit of this module to self-define
if desired.
-->
<dependency>
<groupId>xyz.block</groupId>
<artifactId>web5-keymanager-aws</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ktor</groupId>
<artifactId>ktor-client-mock-jvm</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import org.junit.jupiter.api.assertDoesNotThrow
import web5.sdk.common.Convert
import web5.sdk.common.Json
import web5.sdk.crypto.AlgorithmId
import web5.sdk.crypto.AwsKeyManager
import web5.sdk.crypto.InMemoryKeyManager
import web5.sdk.crypto.Jwa
import web5.sdk.dids.did.BearerDid
Expand All @@ -18,21 +17,20 @@ import web5.sdk.dids.didcore.Purpose
import web5.sdk.jose.jws.JwsHeader
import web5.sdk.jose.jwt.Jwt
import web5.sdk.jose.jwt.JwtClaimsSet
import web5.sdk.keymanager.aws.AwsKeyManager
import web5.sdk.dids.methods.dht.CreateDidDhtOptions
import web5.sdk.dids.methods.dht.DidDht
import web5.sdk.dids.methods.jwk.DidJwk
import web5.sdk.dids.methods.key.DidKey
import web5.sdk.testing.TestVectors
import java.io.File
import java.net.URI
import java.security.SignatureException
import java.util.Calendar
import kotlin.test.Ignore
import kotlin.test.assertContains
import kotlin.test.assertEquals
import kotlin.test.assertFails
import kotlin.test.assertNotNull
import kotlin.test.assertNull

data class StreetCredibility(val localRespect: String, val legit: Boolean)
class VerifiableCredentialTest {
Expand Down
11 changes: 7 additions & 4 deletions crypto/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@
<groupId>com.nimbusds</groupId>
<artifactId>nimbus-jose-jwt</artifactId>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-kms</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-kotlin</artifactId>
Expand All @@ -67,6 +63,13 @@
<artifactId>bcpkix-jdk15to18</artifactId>
</dependency>

<!-- Test Dependencies -->
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

<!-- Build Configuration -->
Expand Down
5 changes: 4 additions & 1 deletion dids/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@
<groupId>io.ktor</groupId>
<artifactId>ktor-serialization-jackson-jvm</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
</dependency>

<!--
Test dependencies may declare direct versions; they are not exported
Expand All @@ -100,7 +104,6 @@
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.16.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
5 changes: 5 additions & 0 deletions distribution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@
<artifactId>web5-jose</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>xyz.block</groupId>
<artifactId>web5-keymanager-aws</artifactId>
<version>${project.version}</version>
</dependency>

<!-- External -->

Expand Down
56 changes: 56 additions & 0 deletions keymanager-aws/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<!-- Parent -->
<parent>
<groupId>xyz.block</groupId>
<artifactId>web5-parent</artifactId>
<version>0.0.0-main-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<!-- Model Version -->
<modelVersion>4.0.0</modelVersion>

<!-- Artifact Configuration -->
<artifactId>web5-keymanager-aws</artifactId>
<name>Web5 AWS KeyManager Implementation</name>
<description>AWS Implementation of KeyManager</description>


<!-- Properties -->
<properties>

<!-- Versioning -->

</properties>

<!-- Dependencies -->
<dependencies>

<!-- Internal Dependencies -->
<dependency>
<groupId>xyz.block</groupId>
<artifactId>web5-crypto</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>xyz.block</groupId>
<artifactId>web5-testing</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

<!-- External -->
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-kms</artifactId>
</dependency>

</dependencies>

<!-- Build Configuration -->
<build>

</build>
</project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package web5.sdk.crypto
package web5.sdk.keymanager.aws

import com.amazonaws.services.kms.AWSKMS
import com.amazonaws.services.kms.AWSKMSClientBuilder
Expand All @@ -19,6 +19,11 @@ import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo
import org.bouncycastle.crypto.ExtendedDigest
import org.bouncycastle.crypto.digests.SHA256Digest
import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter
import web5.sdk.crypto.AlgorithmId
import web5.sdk.crypto.Jwa
import web5.sdk.crypto.JwaCurve
import web5.sdk.crypto.KeyGenOptions
import web5.sdk.crypto.KeyManager
import web5.sdk.crypto.jwk.Jwk
import java.nio.ByteBuffer
import java.security.PublicKey
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package web5.sdk.crypto
package web5.sdk.keymanager.aws

import com.amazonaws.AmazonServiceException
import com.amazonaws.auth.AWSStaticCredentialsProvider
Expand All @@ -7,6 +7,9 @@ import com.amazonaws.services.kms.AWSKMSClient
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import web5.sdk.crypto.AlgorithmId
import web5.sdk.crypto.Crypto
import web5.sdk.crypto.Jwa
import kotlin.test.assertEquals
import kotlin.test.assertTrue

Expand Down Expand Up @@ -45,11 +48,11 @@ class AwsKeyManagerTest {
val signature = awsKeyManager.sign(alias, signingInput)

//Verify the signature with BouncyCastle via Crypto
Crypto.verify(
publicKey = awsKeyManager.getPublicKey(alias),
signedPayload = signingInput,
signature = signature
)
Crypto.verify(
publicKey = awsKeyManager.getPublicKey(alias),
signedPayload = signingInput,
signature = signature
)
}

@Test
Expand Down
13 changes: 13 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<module>dids</module>
<module>distribution</module>
<module>jose</module>
<module>keymanager-aws</module>
<module>testing</module>
</modules>

Expand Down Expand Up @@ -103,10 +104,12 @@
<version.com.networknt>1.0.87</version.com.networknt>
<version.com.nfeld.jsonpathkt>2.0.1</version.com.nfeld.jsonpathkt>
<version.com.squareup.okhttp3>4.12.0</version.com.squareup.okhttp3>
<version.commons.codec>1.17.0</version.commons.codec>
<version.dnsjava>3.5.2</version.dnsjava>
<version.io.github.erdtman>1.1</version.io.github.erdtman>
<version.io.github.oshai>6.0.2</version.io.github.oshai>
<version.io.ktor>2.3.7</version.io.ktor>
<version.org.apache.httpcomponents.httpcore>4.4.16</version.org.apache.httpcomponents.httpcore>
<version.org.bouncycastle>1.78</version.org.bouncycastle>
<version.org.junit.jupiter>5.10.1</version.org.junit.jupiter>

Expand Down Expand Up @@ -174,6 +177,11 @@
<artifactId>okhttp-dnsoverhttps</artifactId>
<version>${version.com.squareup.okhttp3}</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>${version.commons.codec}</version>
</dependency>
<dependency>
<groupId>dnsjava</groupId>
<artifactId>dnsjava</artifactId>
Expand Down Expand Up @@ -225,6 +233,11 @@
<artifactId>ktor-serialization-kotlinx-json-jvm</artifactId>
<version>${version.io.ktor}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>${version.org.apache.httpcomponents.httpcore}</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
Expand Down

0 comments on commit de62fa2

Please sign in to comment.