public static PrivateKey fromPKCS8PEM(Reader reader) throws IOException { return fromPKCS8PEM(PEMFormatUtil.readerToString(reader)); }
protected PrivateKey checkPrivateKey() throws IOException { String privateKeyFileName = getCfgValue(ClientXMLTags.PRIVATE_KEY); if (trivial(privateKeyFileName)) { throw new MyConfigurationException("Error: There is no private key specified."); } File privateKeyFile = new File(privateKeyFileName); if (!privateKeyFile.exists()) { throw new MyConfigurationException("Error: The specified private key file \"" + privateKeyFileName + "\" does not exist"); } if (!privateKeyFile.isFile()) { throw new MyConfigurationException("Error: The specified private key file \"" + privateKeyFileName + "\" is not actually a file"); } if (!privateKeyFile.canRead()) { throw new MyConfigurationException("Error: The specified private key file \"" + privateKeyFileName + "\" is not readable. Check the permissions."); } return KeyUtil.fromPKCS8PEM(new FileReader(privateKeyFile)); }
@Override public Asset fromMap(ConversionMap<String, Object> map, Asset asset) { super.fromMap(map, asset); asset.setUsername(map.getString(getAR().username())); try { String rawCert = map.getString(getAR().certificates()); if (rawCert != null && 0 < rawCert.length()) { asset.setCertificates(CertUtil.fromX509PEM(rawCert)); } } catch (CertificateException e) { throw new GeneralException("Error: could not create certificate", e); } String temp = map.getString(getAR().privateKey()); if(temp != null){ asset.setPrivateKey(KeyUtil.fromPKCS8PEM(temp)); } asset.setRedirect(map.getURI(getAR().redirect())); asset.setCreationTime(map.getDate(getAR().creationTime())); asset.setToken(map.getIdentifier(getAR().token())); String rawCertReq = map.getString(getAR().certReq()); if(rawCertReq != null){ asset.setCertReq(CertUtil.fromStringToCertReq(rawCertReq)); } return asset; }