Skip to content

Commit 579d667

Browse files
committed
fix(sdk): narrow SRT signer exceptions
Signed-off-by: strantalis <strantalis@virtru.com>
1 parent 13796c8 commit 579d667

4 files changed

Lines changed: 9 additions & 5 deletions

File tree

sdk/src/main/java/io/opentdf/platform/sdk/DefaultSrtSigner.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ final class DefaultSrtSigner implements SrtSigner {
1919
}
2020

2121
@Override
22-
public byte[] sign(byte[] input) throws Exception {
23-
return signer.sign(HEADER, input).decode();
22+
public byte[] sign(byte[] input) throws java.security.GeneralSecurityException {
23+
try {
24+
return signer.sign(HEADER, input).decode();
25+
} catch (JOSEException e) {
26+
throw new java.security.GeneralSecurityException("error signing SRT payload", e);
27+
}
2428
}
2529

2630
@Override

sdk/src/main/java/io/opentdf/platform/sdk/KASClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public Base64URL sign(JWSHeader header, byte[] signingInput) throws JOSEExceptio
219219

220220
try {
221221
return Base64URL.encode(srtSigner.sign(signingInput));
222-
} catch (Exception e) {
222+
} catch (java.security.GeneralSecurityException e) {
223223
throw new JOSEException("error signing SRT payload", e);
224224
}
225225
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package io.opentdf.platform.sdk;
22

33
public interface SrtSigner {
4-
byte[] sign(byte[] input) throws Exception;
4+
byte[] sign(byte[] input) throws java.security.GeneralSecurityException;
55

66
String alg();
77
}

sdk/src/test/java/io/opentdf/platform/sdk/KASClientTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public byte[] sign(byte[] input) {
205205
.sign(new JWSHeader.Builder(JWSAlgorithm.RS256).build(), input)
206206
.decode();
207207
} catch (JOSEException e) {
208-
throw new RuntimeException(e);
208+
throw new AssertionError("Signing failed unexpectedly in test", e);
209209
}
210210
}
211211

0 commit comments

Comments
 (0)