public byte[] readContent() throws IOException { if (binary != null) { return binary; } return IoUtil.read(file); }
public byte[] readContent() throws IOException { if (binary != null) { return binary; } return IoUtil.read(file); }
public String readContent() throws IOException { if (value != null) { return value; } return new String(IoUtil.read(file), "UTF-8"); }
public String readContent() throws IOException { if (value != null) { return value; } return new String(IoUtil.read(file), "UTF-8"); }
private static byte[] getBinary(String fileName, Map<String, String> properties, String baseDir) throws IOException { fileName = expandConf(fileName, properties); InputStream is = Files.newInputStream(Paths.get(resolveFilePath(fileName, baseDir))); return IoUtil.read(is); }
protected String value(FileOrValueType fileOrValue) throws IOException { if (fileOrValue == null) { return null; } if (fileOrValue.getValue() != null) { return fileOrValue.getValue(); } File file = new File(baseDir, fileOrValue.getFile()); return new String(IoUtil.read(file), "UTF-8"); }
public static X509Certificate parseCert(InputStream certStream) throws IOException, CertificateException { Args.notNull(certStream, "certStream"); return parseCert(IoUtil.read(certStream)); }
protected String readContent(FileOrValue fileOrValue) throws IOException { if (fileOrValue == null) { return null; } if (fileOrValue.getValue() != null) { return fileOrValue.getValue(); } File file = new File(baseDir, fileOrValue.getFile()); return new String(IoUtil.read(file), "UTF-8"); }
public static org.bouncycastle.asn1.x509.Certificate parseBcCert(InputStream certStream) throws IOException, CertificateException { Args.notNull(certStream, "certStream"); return parseBcCert(IoUtil.read(certStream)); }
public static CertificationRequest parseCsr(InputStream csrStream) throws IOException { Args.notNull(csrStream, "csrStream"); return parseCsr(IoUtil.read(csrStream)); }
private X509Cert readCertificate(byte[] keyId) throws CertificateException, IOException { byte[] encoded = IoUtil.read(new File(certDir, hex(keyId) + VALUE_FILE_SUFFIX)); X509Certificate cert = X509Util.parseCert(encoded); return new X509Cert(cert, encoded); }
protected byte[] binary(FileOrBinaryType fileOrValue) throws IOException { if (fileOrValue == null) { return null; } if (fileOrValue.getBinary() != null) { return fileOrValue.getBinary(); } File file = new File(baseDir, fileOrValue.getFile()); return IoUtil.read(file); }
protected byte[] readContent(FileOrBinary fileOrBinary) throws IOException { if (fileOrBinary == null) { return null; } if (fileOrBinary.getBinary() != null) { return fileOrBinary.getBinary(); } File file = new File(baseDir, fileOrBinary.getFile()); return IoUtil.read(file); }
@Override protected Object execute0() throws Exception { String msg = "configuration to file " + confFile; try { InputStream is = caManager.exportConf(caNames); save(new File(confFile), IoUtil.read(is)); println("exported " + msg); return null; } catch (CaMgmtException ex) { throw new CmdFailure("could not export " + msg + ", error: " + ex.getMessage(), ex); } }
@Override protected Object execute0() throws Exception { if (type == null && conf == null && confFile == null) { throw new IllegalCmdParamException("nothing to update"); } if (conf == null && confFile != null) { conf = new String(IoUtil.read(confFile)); } String msg = "certificate profile " + name; try { caManager.changeCertprofile(name, type, conf); println("updated " + msg); return null; } catch (CaMgmtException ex) { throw new CmdFailure("could not update " + msg + ", error: " + ex.getMessage(), ex); } }
@Override protected Object execute0() throws Exception { CertificationRequest csr = X509Util.parseCsr(IoUtil.read(csrFile)); String sigAlgo = AlgorithmUtil.getSignatureAlgoName(csr.getSignatureAlgorithm()); boolean bo = securityFactory.verifyPopo(csr, null); String txt = bo ? "valid" : "invalid"; println("The POP is " + txt + " (signature algorithm " + sigAlgo + ")."); return null; }
@Override protected Object execute0() throws Exception { if (conf == null && confFile != null) { conf = new String(IoUtil.read(confFile)); } MgmtEntry.Certprofile entry = new MgmtEntry.Certprofile(new NameId(null, name), type, conf); String msg = "certificate profile " + name; try { caManager.addCertprofile(entry); println("added " + msg); return null; } catch (CaMgmtException ex) { throw new CmdFailure("could not add " + msg + ", error: " + ex.getMessage(), ex); } }
@Override protected Object execute0() throws Exception { if (conf == null && confFile != null) { conf = new String(IoUtil.read(confFile)); } MgmtEntry.Publisher entry = new MgmtEntry.Publisher(new NameId(null, name), type, conf); String msg = "publisher " + name; try { caManager.addPublisher(entry); println("added " + msg); return null; } catch (CaMgmtException ex) { throw new CmdFailure("could not add " + msg + ", error: " + ex.getMessage(), ex); } }
@Override protected Object execute0() throws Exception { MgmtEntry.Ca caEntry = getCaEntry(); byte[] csr = IoUtil.read(csrFile); BigInteger serialNumber = null; if (serialS != null) { serialNumber = toBigInt(serialS); } X509Certificate rootcaCert = caManager.generateRootCa(caEntry, rootcaProfile, csr, serialNumber); if (rootcaCertOutFile != null) { saveVerbose("saved root certificate to file", rootcaCertOutFile, encodeCert(rootcaCert.getEncoded(), outform)); } println("generated root CA " + caEntry.getIdent().getName()); return null; }
@Override protected Object execute0() throws Exception { MgmtEntry.Ca ca = caManager.getCa(caName); if (ca == null) { throw new CmdFailure("CA " + caName + " not available"); } Date notBefore = StringUtil.isNotBlank(notBeforeS) ? DateUtil.parseUtcTimeyyyyMMddhhmmss(notBeforeS) : null; Date notAfter = StringUtil.isNotBlank(notAfterS) ? DateUtil.parseUtcTimeyyyyMMddhhmmss(notAfterS) : null; byte[] encodedCsr = IoUtil.read(csrFile); X509Certificate cert = caManager.generateCertificate(caName, profileName, encodedCsr, notBefore, notAfter); saveVerbose("saved certificate to file", outFile, encodeCert(cert.getEncoded(), outform)); return null; }