/** * This method reads a private key file and returns a {@link PrivateKey} * * @param privateKeyLocation the location of the private key file * @return the created {@link PrivateKey} */ private PrivateKey createPrivateKey(String privateKeyLocation) { PrivateKey privateKey = null; try { FileInputStream fisPrivateKey = new FileInputStream(privateKeyLocation); privateKey = KeySupport.decodePrivateKey( StringSupport.inputStreamToString(fisPrivateKey, null).getBytes(), null); fisPrivateKey.close(); } catch (Exception e) { return null; } return privateKey; }
/** * This method reads a certificate file and returns a {@link X509Certificate} * * @param certLocation the location of the certificate file * @return the created {@link X509Certificate} */ private X509Certificate createCertificate(String certLocation) { X509Certificate cert = null; try { FileInputStream fisCertificate = new FileInputStream(certLocation); cert = X509Support.decodeCertificate( StringSupport.inputStreamToString(fisCertificate, null).getBytes()); fisCertificate.close(); } catch (Exception e) { return null; } return cert; }
/** * This method reads a private key file and returns a {@link PrivateKey} * * @param privateKeyLocation the location of the private key file * @return the created {@link PrivateKey} */ private PrivateKey getPrivateKey(String privateKeyLocation) { PrivateKey privateKey = null; try { FileInputStream fisPrivateKey = new FileInputStream(privateKeyLocation); privateKey = KeySupport.decodePrivateKey( StringSupport.inputStreamToString(fisPrivateKey, null).getBytes(), null); fisPrivateKey.close(); } catch (Exception e) { log.debug("{} Couldnt create the PrivateKey: {}", getLogPrefix(), e); return null; } return privateKey; }
/** * This method reads a certificate file and returns a {@link X509Certificate} * * @param certLocation the location of the certificate file * @return the created {@link X509Certificate} */ private X509Certificate getCertificate(String certLocation) { X509Certificate cert = null; try { FileInputStream fisCertificate = new FileInputStream(certLocation); cert = X509Support.decodeCertificate( StringSupport.inputStreamToString(fisCertificate, null).getBytes()); fisCertificate.close(); } catch (Exception e) { log.debug("{} Couldnt create the X509Certificate: {}", getLogPrefix(), e); return null; } return cert; }