5
5
import javax .crypto .NoSuchPaddingException ;
6
6
import java .security .InvalidKeyException ;
7
7
import java .security .NoSuchAlgorithmException ;
8
+ import java .security .spec .InvalidKeySpecException ;
8
9
import java .util .UUID ;
9
10
10
11
public class TossCertSessionGenerator {
11
- private final static String version = "v1_0.0.10 " ;
12
+ private final static String version = "v1_0.0.11 " ;
12
13
private final static String publicKey = "MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAoVdxG0Qi9pip46Jw9ImSlPVD8+L2mM47ey6EZna7D7utgNdh8Tzkjrm1Yl4h6kPJrhdWvMIJGS51+6dh041IXcJEoUquNblUEqAUXBYwQM8PdfnS12SjlvZrP4q6whBE7IV1SEIBJP0gSK5/8Iu+uld2ctJiU4p8uswL2bCPGWdvVPltxAg6hfAG/ImRUKPRewQsFhkFvqIDCpO6aeaR10q6wwENZltlJeeRnl02VWSneRmPqqypqCxz0Y+yWCYtsA+ngfZmwRMaFkXcWjaWnvSqqV33OAsrQkvuBHWoEEkvQ0P08+h9Fy2+FhY9TeuukQ2CVFz5YyOhp25QtWyQI+IaDKk+hLxJ1APR0c3tmV0ANEIjO6HhJIdu2KQKtgFppvqSrZp2OKtI8EZgVbWuho50xvlaPGzWoMi9HSCb+8ARamlOpesxHH3O0cTRUnft2Zk1FHQb2Pidb2z5onMEnzP2xpTqAIVQyb6nMac9tof5NFxwR/c4pmci+1n8GFJIFN18j2XGad1mNyio/R8LabqnzNwJC6VPnZJz5/pDUIk9yKNOY0KJe64SRiL0a4SNMohtyj6QlA/3SGxaEXb8UHpophv4G9wN1CgfyUamsRqp8zo5qDxBvlaIlfkqJvYPkltj7/23FHDjPi8q8UkSiAeu7IV5FTfB5KsiN8+sGSMCAwEAAQ==" ;
13
14
14
15
private final RSACipher rsaCipher ;
@@ -20,8 +21,10 @@ public TossCertSessionGenerator() {
20
21
public TossCertSessionGenerator (String publicKeyString ) {
21
22
try {
22
23
this .rsaCipher = new RSACipher (publicKeyString );
23
- } catch (Exception e ) {
24
- throw new RuntimeException (e );
24
+ } catch (NoSuchAlgorithmException e ) {
25
+ throw new RuntimeException (e .getCause ());
26
+ } catch (InvalidKeySpecException e ) {
27
+ throw new RuntimeException (e .getCause ());
25
28
}
26
29
}
27
30
@@ -53,8 +56,16 @@ private TossCertSession generate(AESAlgorithm algorithm, int keyLength, int ivLe
53
56
}
54
57
String encryptedSessionKey = buildEncryptSessionKeyPart (algorithm , secretKey , iv );
55
58
return new TossCertSession (version , id , algorithm , secretKey , iv , encryptedSessionKey );
56
- } catch (Exception e ) {
57
- throw new RuntimeException (e );
59
+ } catch (NoSuchPaddingException e ) {
60
+ throw new RuntimeException (e .getCause ());
61
+ } catch (IllegalBlockSizeException e ) {
62
+ throw new RuntimeException (e .getCause ());
63
+ } catch (NoSuchAlgorithmException e ) {
64
+ throw new RuntimeException (e .getCause ());
65
+ } catch (BadPaddingException e ) {
66
+ throw new RuntimeException (e .getCause ());
67
+ } catch (InvalidKeyException e ) {
68
+ throw new RuntimeException (e .getCause ());
58
69
}
59
70
}
60
71
@@ -66,8 +77,16 @@ public TossCertSession deserialize(String serializedSessionKey) {
66
77
String iv = fields [4 ];
67
78
String encryptedSessionKey = buildEncryptSessionKeyPart (algorithm , secretKey , iv );
68
79
return new TossCertSession (fields [0 ], fields [1 ], algorithm , secretKey , iv , encryptedSessionKey );
69
- } catch (Exception e ) {
70
- throw new RuntimeException (e );
80
+ } catch (NoSuchPaddingException e ) {
81
+ throw new RuntimeException (e .getCause ());
82
+ } catch (IllegalBlockSizeException e ) {
83
+ throw new RuntimeException (e .getCause ());
84
+ } catch (NoSuchAlgorithmException e ) {
85
+ throw new RuntimeException (e .getCause ());
86
+ } catch (BadPaddingException e ) {
87
+ throw new RuntimeException (e .getCause ());
88
+ } catch (InvalidKeyException e ) {
89
+ throw new RuntimeException (e .getCause ());
71
90
}
72
91
}
73
92
0 commit comments