File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed
main/java/com/mastercard/developer/encryption
test/java/com/mastercard/developer/encryption Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -94,10 +94,10 @@ public JweConfigBuilder withEncryptionKeyFingerprint(String encryptionKeyFingerp
9494 this .encryptionKeyFingerprint = encryptionKeyFingerprint ;
9595 return this ;
9696 }
97-
97+
9898 private void checkParameterValues () {
99- if (decryptionKey == null && encryptionCertificate == null ) {
100- throw new IllegalArgumentException ("You must include at least an encryption certificate or a decryption key" );
99+ if (decryptionKey == null && encryptionCertificate == null && encryptionKey == null ) {
100+ throw new IllegalArgumentException ("You must include at least an encryption key/ certificate or a decryption key" );
101101 }
102102 }
103103}
Original file line number Diff line number Diff line change @@ -31,6 +31,20 @@ public void testBuild_Nominal() throws Exception {
3131 Assert .assertEquals (Collections .singletonMap ("$" , "$" ), config .getEncryptionPaths ());
3232 }
3333
34+ @ Test
35+ public void testBuild_EncryptionKeyNoDecryptionKey () throws Exception {
36+ JweConfig config = JweConfigBuilder .aJweEncryptionConfig ()
37+ .withEncryptionKey (TestUtils .getTestEncryptionCertificate ().getPublicKey ())
38+ .withEncryptionPath ("$" , "$" )
39+ .withEncryptedValueFieldName ("encryptedPayload" )
40+ .build ();
41+ Assert .assertNotNull (config );
42+ Assert .assertEquals (EncryptionConfig .Scheme .JWE , config .getScheme ());
43+ Assert .assertEquals (TestUtils .getTestEncryptionCertificate ().getPublicKey (), config .getEncryptionKey ());
44+ Assert .assertEquals ("encryptedPayload" , config .getEncryptedValueFieldName ());
45+ Assert .assertEquals (Collections .singletonMap ("$" , "$" ), config .getEncryptionPaths ());
46+ }
47+
3448 @ Test
3549 public void testBuild_EncryptionKeyFromCertificate () throws Exception {
3650 EncryptionConfig config = JweConfigBuilder .aJweEncryptionConfig ()
You can’t perform that action at this time.
0 commit comments