Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ public HyperwalletEncryption(JWEAlgorithm encryptionAlgorithm, JWSAlgorithm sign

public String encrypt(String body) throws JOSEException, IOException, ParseException {

JWK clientPrivateKey = getKeyByAlgorithm(loadKeySet(clientPrivateKeySetLocation), signAlgorithm);
JWK hyperwalletPublicKey = getKeyByAlgorithm(loadKeySet(hyperwalletKeySetLocation), encryptionAlgorithm);
JWK clientPrivateKey = getKeyByAlgorithm(loadClientPrivateKeySet(), signAlgorithm);
JWK hyperwalletPublicKey = getKeyByAlgorithm(loadHyperwalletKeySet(), encryptionAlgorithm);
JWSSigner jwsSigner = getJWSSigner(clientPrivateKey);
JWEEncrypter jweEncrypter = getJWEEncrypter(hyperwalletPublicKey);

Expand All @@ -132,8 +132,8 @@ public String encrypt(String body) throws JOSEException, IOException, ParseExcep

public String decrypt(String body) throws ParseException, IOException, JOSEException {

JWK privateKeyToDecrypt = getKeyByAlgorithm(loadKeySet(clientPrivateKeySetLocation), encryptionAlgorithm);
JWK publicKeyToSign = getKeyByAlgorithm(loadKeySet(hyperwalletKeySetLocation), signAlgorithm);
JWK privateKeyToDecrypt = getKeyByAlgorithm(loadClientPrivateKeySet(), encryptionAlgorithm);
JWK publicKeyToSign = getKeyByAlgorithm(loadHyperwalletKeySet(), signAlgorithm);
JWEDecrypter jweDecrypter = getJWEDecrypter(privateKeyToDecrypt);
JWSVerifier jwsVerifier = getJWSVerifier(publicKeyToSign);

Expand All @@ -148,6 +148,20 @@ public String decrypt(String body) throws ParseException, IOException, JOSEExcep
return jwsObject.getPayload().toString();
}

/**
* Allows clients to implement a custom loading of their private JWK set.
*/
protected JWKSet loadClientPrivateKeySet() throws IOException, ParseException {
return loadKeySet(clientPrivateKeySetLocation);
}

/**
* Allows clients to implement a custom loading of Hyperwallet public JWK set.
*/
protected JWKSet loadHyperwalletKeySet() throws IOException, ParseException {
return loadKeySet(hyperwalletKeySetLocation);
}

public void verifySignatureExpirationDate(Object signatureExpirationDate) {
if (signatureExpirationDate == null) {
throw new HyperwalletException("exp JWS header param was null");
Expand Down Expand Up @@ -389,4 +403,4 @@ public HyperwalletEncryption build() {
return hyperwalletEncryption;
}
}
}
}