Skip to content

Commit 71dfa31

Browse files
kaiferroot
authored and
root
committed
RELEASE
1 parent cf501a2 commit 71dfa31

File tree

4 files changed

+56
-13
lines changed

4 files changed

+56
-13
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ JAVA 1.8버전 사용자들을 위한 세션키 발급 및 개인정보 암복
66

77
예시)
88
```
9-
<version>0.0.10</version>
9+
<version>0.0.11</version>
1010
```
1111

1212
pom.xml 을 사용하시면 아래와 같이 추가해주세요.

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins {
66
}
77

88
group 'com.github.toss'
9-
version '0.0.10'
9+
version '0.0.11'
1010

1111
sourceCompatibility = JavaVersion.VERSION_1_6
1212
targetCompatibility = JavaVersion.VERSION_1_6

src/main/java/im/toss/cert/sdk/TossCertSession.java

+28-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package im.toss.cert.sdk;
22

3+
import javax.crypto.BadPaddingException;
4+
import javax.crypto.IllegalBlockSizeException;
5+
import javax.crypto.NoSuchPaddingException;
6+
import java.security.InvalidAlgorithmParameterException;
37
import java.security.InvalidKeyException;
48
import java.security.NoSuchAlgorithmException;
59

@@ -42,8 +46,18 @@ public String encrypt(String plainText) {
4246
String encrypted = aesCipher.encrypt(plainText);
4347
String hash = calculateHash(plainText);
4448
return addMeta(StringUtils.join(separator, new String[]{encrypted, hash}));
45-
} catch (Exception e) {
46-
throw new RuntimeException(e);
49+
} catch (InvalidAlgorithmParameterException e) {
50+
throw new RuntimeException(e.getCause());
51+
} catch (NoSuchPaddingException e) {
52+
throw new RuntimeException(e.getCause());
53+
} catch (IllegalBlockSizeException e) {
54+
throw new RuntimeException(e.getCause());
55+
} catch (NoSuchAlgorithmException e) {
56+
throw new RuntimeException(e.getCause());
57+
} catch (BadPaddingException e) {
58+
throw new RuntimeException(e.getCause());
59+
} catch (InvalidKeyException e) {
60+
throw new RuntimeException(e.getCause());
4761
}
4862
}
4963

@@ -62,8 +76,18 @@ public String decrypt(String encryptedText) {
6276
String plainText = aesCipher.decrypt(items[2]);
6377
verify(plainText, items);
6478
return plainText;
65-
} catch (Exception e) {
66-
throw new RuntimeException(e);
79+
} catch (InvalidAlgorithmParameterException e) {
80+
throw new RuntimeException(e.getCause());
81+
} catch (NoSuchPaddingException e) {
82+
throw new RuntimeException(e.getCause());
83+
} catch (IllegalBlockSizeException e) {
84+
throw new RuntimeException(e.getCause());
85+
} catch (NoSuchAlgorithmException e) {
86+
throw new RuntimeException(e.getCause());
87+
} catch (BadPaddingException e) {
88+
throw new RuntimeException(e.getCause());
89+
} catch (InvalidKeyException e) {
90+
throw new RuntimeException(e.getCause());
6791
}
6892
}
6993

src/main/java/im/toss/cert/sdk/TossCertSessionGenerator.java

+26-7
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
import javax.crypto.NoSuchPaddingException;
66
import java.security.InvalidKeyException;
77
import java.security.NoSuchAlgorithmException;
8+
import java.security.spec.InvalidKeySpecException;
89
import java.util.UUID;
910

1011
public class TossCertSessionGenerator {
11-
private final static String version = "v1_0.0.10";
12+
private final static String version = "v1_0.0.11";
1213
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==";
1314

1415
private final RSACipher rsaCipher;
@@ -20,8 +21,10 @@ public TossCertSessionGenerator() {
2021
public TossCertSessionGenerator(String publicKeyString) {
2122
try {
2223
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());
2528
}
2629
}
2730

@@ -53,8 +56,16 @@ private TossCertSession generate(AESAlgorithm algorithm, int keyLength, int ivLe
5356
}
5457
String encryptedSessionKey = buildEncryptSessionKeyPart(algorithm, secretKey, iv);
5558
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());
5869
}
5970
}
6071

@@ -66,8 +77,16 @@ public TossCertSession deserialize(String serializedSessionKey) {
6677
String iv = fields[4];
6778
String encryptedSessionKey = buildEncryptSessionKeyPart(algorithm, secretKey, iv);
6879
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());
7190
}
7291
}
7392

0 commit comments

Comments
 (0)