Repository: trafodion Updated Branches: refs/heads/master 607e8a7c1 -> 38033e1bc
Print out original exceptions for cert error Project: http://git-wip-us.apache.org/repos/asf/trafodion/repo Commit: http://git-wip-us.apache.org/repos/asf/trafodion/commit/05bf7842 Tree: http://git-wip-us.apache.org/repos/asf/trafodion/tree/05bf7842 Diff: http://git-wip-us.apache.org/repos/asf/trafodion/diff/05bf7842 Branch: refs/heads/master Commit: 05bf784292fb2fb5aa2121b20ec4cdac1d2b9448 Parents: 371b7e5 Author: Kevin Xu <[email protected]> Authored: Thu May 10 15:40:15 2018 +0800 Committer: Kevin Xu <[email protected]> Committed: Thu May 10 15:40:15 2018 +0800 ---------------------------------------------------------------------- .../src/main/java/org/trafodion/jdbc/t4/Certificate.java | 4 ++-- .../src/main/java/org/trafodion/jdbc/t4/Cipher.java | 8 ++++---- .../jdbcT4/src/main/java/org/trafodion/jdbc/t4/Key.java | 8 ++++---- .../main/java/org/trafodion/jdbc/t4/MessageDigest.java | 2 +- .../src/main/java/org/trafodion/jdbc/t4/SecPwd.java | 2 +- .../src/main/java/org/trafodion/jdbc/t4/Security.java | 2 +- .../java/org/trafodion/jdbc/t4/SecurityException.java | 11 +++++++---- 7 files changed, 20 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafodion/blob/05bf7842/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Certificate.java ---------------------------------------------------------------------- diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Certificate.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Certificate.java index eedc663..f96317c 100644 --- a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Certificate.java +++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Certificate.java @@ -68,12 +68,12 @@ public class Certificate } catch (CertificateException cex) { - throw new SecurityException(SecClientMsgKeys.FILE_CORRUPTION, new Object[]{certFile.getName()} ); + throw new SecurityException(cex, SecClientMsgKeys.FILE_CORRUPTION, new Object[]{certFile.getName()} ); } catch (Exception ex) { // This should never happen - throw new SecurityException(SecClientMsgKeys.FILE_NOTFOUND, new Object[]{certFile.getName()} ); + throw new SecurityException(ex, SecClientMsgKeys.FILE_NOTFOUND, new Object[]{certFile.getName()} ); } finally { http://git-wip-us.apache.org/repos/asf/trafodion/blob/05bf7842/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Cipher.java ---------------------------------------------------------------------- diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Cipher.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Cipher.java index 32c0ef9..443239c 100644 --- a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Cipher.java +++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Cipher.java @@ -91,7 +91,7 @@ public class Cipher len = cipherText.length; }catch (Exception ex) { - throw new SecurityException(SecClientMsgKeys.ENCRYPTION_FAILED, null); + throw new SecurityException(ex, SecClientMsgKeys.ENCRYPTION_FAILED, null); } return len; } @@ -108,7 +108,7 @@ public class Cipher return javax.crypto.Cipher.getInstance("AES/CBC/PKCS5Padding"); } catch (Exception ex) { - throw new SecurityException(SecClientMsgKeys.ENCRYPTION_FAILED, null); + throw new SecurityException(ex, SecClientMsgKeys.ENCRYPTION_FAILED, null); } } @@ -145,7 +145,7 @@ public class Cipher } }catch (Exception ex) { - throw new SecurityException(SecClientMsgKeys.DATA_ENCRYPTION_FAILED, null); + throw new SecurityException(ex, SecClientMsgKeys.DATA_ENCRYPTION_FAILED, null); } } @@ -192,7 +192,7 @@ public class Cipher len = plainText.length; }catch (Exception ex) { - throw new SecurityException(SecClientMsgKeys.DECRYPTION_FAILED, null); + throw new SecurityException(ex, SecClientMsgKeys.DECRYPTION_FAILED, null); } } http://git-wip-us.apache.org/repos/asf/trafodion/blob/05bf7842/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Key.java ---------------------------------------------------------------------- diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Key.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Key.java index b143866..3552899 100644 --- a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Key.java +++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Key.java @@ -85,11 +85,11 @@ public class Key { (privKeySpec); }catch (FileNotFoundException fnf) { - throw new SecurityException(SecClientMsgKeys.FILE_NOTFOUND, new Object[]{inFile}); + throw new SecurityException(fnf, SecClientMsgKeys.FILE_NOTFOUND, new Object[]{inFile}); }catch (IOException io) { - throw new SecurityException(SecClientMsgKeys.ERR_OPEN_INPUT_FILE, new Object[]{inFile}); + throw new SecurityException(io, SecClientMsgKeys.ERR_OPEN_INPUT_FILE, new Object[]{inFile}); }catch (Exception e) { - throw new SecurityException(SecClientMsgKeys.ERR_RETRIEVE_KEY_FROM_FILE, new Object[]{inFile}); + throw new SecurityException(e, SecClientMsgKeys.ERR_RETRIEVE_KEY_FROM_FILE, new Object[]{inFile}); }finally { try { if (inStream != null) @@ -124,7 +124,7 @@ public class Key { return skey; }catch (NoSuchAlgorithmException nae) { - throw new SecurityException(SecClientMsgKeys.ERR_CREATE_SYMMETRIC_KEY, null); + throw new SecurityException(nae, SecClientMsgKeys.ERR_CREATE_SYMMETRIC_KEY, null); } } http://git-wip-us.apache.org/repos/asf/trafodion/blob/05bf7842/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/MessageDigest.java ---------------------------------------------------------------------- diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/MessageDigest.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/MessageDigest.java index 4484076..ba24348 100644 --- a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/MessageDigest.java +++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/MessageDigest.java @@ -77,7 +77,7 @@ public class MessageDigest return tmpMd.length; }catch (Exception ex) { - throw new SecurityException(SecClientMsgKeys.HMAC_FAILED, null); + throw new SecurityException(ex, SecClientMsgKeys.HMAC_FAILED, null); } } http://git-wip-us.apache.org/repos/asf/trafodion/blob/05bf7842/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SecPwd.java ---------------------------------------------------------------------- diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SecPwd.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SecPwd.java index 6783c66..aabaa07 100644 --- a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SecPwd.java +++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SecPwd.java @@ -240,7 +240,7 @@ public class SecPwd { outChannel = new FileOutputStream(certFile).getChannel(); outChannel.write(ByteBuffer.wrap(buf)); } catch (Exception e) { - throw new SecurityException(SecClientMsgKeys.ERR_WRITE_CERT_FILE, new Object[]{certFile}); + throw new SecurityException(e, SecClientMsgKeys.ERR_WRITE_CERT_FILE, new Object[]{certFile}); } finally { try { if (outChannel != null) http://git-wip-us.apache.org/repos/asf/trafodion/blob/05bf7842/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Security.java ---------------------------------------------------------------------- diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Security.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Security.java index 1a02021..d1df553 100644 --- a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Security.java +++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Security.java @@ -161,7 +161,7 @@ class Security }catch (SecurityException se) { throw se; }catch (Exception e) { - throw new SecurityException(SecClientMsgKeys.FAILED_BUILDING_PWDKEY, null); + throw new SecurityException(e, SecClientMsgKeys.FAILED_BUILDING_PWDKEY, null); }finally { if (to_digest != null) to_digest = null; http://git-wip-us.apache.org/repos/asf/trafodion/blob/05bf7842/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SecurityException.java ---------------------------------------------------------------------- diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SecurityException.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SecurityException.java index 64d1a3d..e9e8f6d 100644 --- a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SecurityException.java +++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SecurityException.java @@ -31,17 +31,20 @@ public class SecurityException extends SQLException { private static final String SQLState = "38001"; - public SecurityException(String key, Object[] params) + public SecurityException(Exception cex, String key, Object[] params) { // Get the text message from the file secClient.properties. // Parse the message for the error message and error number. - this((SecResourceBundle.obtainMessageText(key, params)).substring(6), + this(cex, (SecResourceBundle.obtainMessageText(key, params)).substring(6), Integer.parseInt((SecResourceBundle.obtainMessageText(key, params)).substring(0, 5))); } - public SecurityException(String errMsg, int errNum) + public SecurityException(Exception cex, String errMsg, int errNum) { - super(errMsg, SQLState, errNum); + super(errMsg, SQLState, errNum, cex); } + public SecurityException(String key, Object[] params) { + this(null, key, params); + } }
