Skip to content

Commit 496f937

Browse files
Merge pull request #47 from shilpat55/main
Adding method for specifying the kid
2 parents 6736f06 + f725668 commit 496f937

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/main/java/com/mastercard/developer/encryption/JweConfigBuilder.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ public JweConfigBuilder withEncryptedValueFieldName(String encryptedValueFieldNa
7474
return this;
7575
}
7676

77+
public JweConfigBuilder withEncryptionKeyFingerprint(String encryptionKeyFingerprint) {
78+
this.encryptionKeyFingerprint = encryptionKeyFingerprint;
79+
return this;
80+
}
81+
7782
private void checkParameterValues() {
7883
if (decryptionKey == null && encryptionCertificate == null) {
7984
throw new IllegalArgumentException("You must include at least an encryption certificate or a decryption key");

src/test/java/com/mastercard/developer/encryption/JweConfigBuilderTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,14 @@ public void testBuild_ShouldThrowIllegalArgumentException_WhenNotDefiniteEncrypt
9696
.withEncryptionCertificate(TestUtils.getTestEncryptionCertificate())
9797
.build();
9898
}
99+
100+
@Test
101+
public void testBuild_ShouldNotComputeCertificateKeyFingerprint_WhenFingerprintSet() throws Exception {
102+
EncryptionConfig config = JweConfigBuilder.aJweEncryptionConfig()
103+
.withEncryptionCertificate(TestUtils.getTestEncryptionCertificate())
104+
.withDecryptionKey(TestUtils.getTestDecryptionKey())
105+
.withEncryptionKeyFingerprint("2f4lvi26vJWzkzAIaiR2G0YsJAQ=")
106+
.build();
107+
Assert.assertEquals("2f4lvi26vJWzkzAIaiR2G0YsJAQ=", config.getEncryptionKeyFingerprint());
108+
}
99109
}

0 commit comments

Comments
 (0)