List of usage examples for java.security NoSuchAlgorithmException getCause
public synchronized Throwable getCause()
From source file:ca.uhn.hl7v2.testpanel.model.conn.AbstractConnection.java
/** * TODO: rename/*from w w w . ja v a 2 s . c om*/ */ public KeyStore getHohSignatureKeystore_() throws KeyStoreException { if (isBlank(getHohSignatureKeystore())) { return null; } if (myHohSignatureKeystore_ != null) { return myHohSignatureKeystore_; } File jksFile = new File(getHohSignatureKeystore()); if (!jksFile.exists() || !jksFile.canRead()) { throw new KeyStoreException("File does not exist or can not be read: " + jksFile.getAbsolutePath()); } char[] password = null; if (isNotBlank(myHohSignatureKeystorePassword)) { password = myHohSignatureKeystorePassword.toCharArray(); } KeyStore keystore; try { keystore = KeystoreUtils.loadKeystore(jksFile, password); } catch (NoSuchAlgorithmException e) { ourLog.error("Failed to load keystore!", e); throw new KeyStoreException("Failed to load keystore: " + e.getMessage()); } catch (CertificateException e) { ourLog.error("Failed to load keystore!", e); throw new KeyStoreException("Failed to load keystore: " + e.getMessage()); } catch (IOException e) { ourLog.error("Failed to load keystore!", e); if (e.getCause() instanceof UnrecoverableKeyException) { throw new KeyStoreException("Keystore password appears to be incorrect"); } throw new KeyStoreException("Failed to load keystore: " + e.getMessage()); } if (this instanceof InboundConnection) { if (!KeystoreUtils.validateKeystoreForSignatureVerifying(keystore)) { throw new KeyStoreException("Keystore contains no keys appropriate for receiving data"); } } else if (this instanceof OutboundConnection) { if (!KeystoreUtils.validateKeystoreForSignatureSigning(keystore)) { throw new KeyStoreException("Keystore contains no keys appropriate for receiving data"); } } myHohSignatureKeystore_ = keystore; return myHohSignatureKeystore_; }