1: public class S259 { 2: public Connection connect(Properties props) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException { 3: try { 4: String url = props.getProperty("url"); 5: String id = props.getProperty("id"); 6: String pwd = props.getProperty("passwd" ); 7: 8: //외부 설정 파일에서 패스워드를 가져오며, 패스워드가 값이 있는지 체크하고 있음 9: if (url != null && !"".equals(url) && id != null && !"".equals(id) 10: && pwd != null && !"".equals(pwd)) { 11: KeyGenerator kgen = KeyGenerator.getInstance("Blowfish"); 12: SecretKey skey = kgen.generateKey(); 13: byte[] raw = skey.getEncoded(); 14: SecretKeySpec skeySpec = new SecretKeySpec(raw, "Blowfish"); 15: 16: Cipher cipher = Cipher.getInstance("Blowfish"); 17: cipher.init(Cipher.DECRYPT_MODE, skeySpec); 18: byte[] decrypted_pwd = cipher.doFinal(pwd.getBytes()); 19: pwd = new String(decrypted_pwd); 20: conn = DriverManager.getConnection(url, id, pwd); 21: } 22: } catch (SQLException e) { 23: …