private Date getDate(String str) throws IllegalCmdParamException { if (str == null) { return null; } final int len = str.length(); try { if (len == 8) { return DateUtil.parseUtcTimeyyyyMMdd(str); } else if (len == 14) { return DateUtil.parseUtcTimeyyyyMMddhhmmss(str); } else { throw new IllegalCmdParamException("invalid time " + str); } } catch (IllegalArgumentException ex) { throw new IllegalCmdParamException("invalid time " + str + ": " + ex.getMessage(), ex); } }
private String format(int index, CertListInfo info) { StringBuilder sb = new StringBuilder(300); sb.append(StringUtil.formatAccount(index, 4)).append(" | "); sb.append(StringUtil.formatText(info.serialNumber().toString(16), 20)).append(" | "); sb.append(DateUtil.toUtcTimeyyyyMMddhhmmss(info.notBefore())).append(" | "); sb.append(DateUtil.toUtcTimeyyyyMMddhhmmss(info.notAfter())).append(" | "); sb.append(info.subject()); return sb.toString(); }
@Override protected Object execute0() throws Exception { CaEntry 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", new File(outFile), cert.getEncoded()); return null; }
@Override protected Object execute0() throws Exception { CrlReason crlReason = CrlReason.forNameOrText(reason); if (!PERMITTED_REASONS.contains(crlReason)) { throw new IllegalCmdParamException("reason " + reason + " is not permitted"); } if (!caManager.getCaNames().contains(caName)) { throw new IllegalCmdParamException("invalid CA name " + caName); } Date revocationDate = null; revocationDate = isNotBlank(revocationDateS) ? DateUtil.parseUtcTimeyyyyMMddhhmmss(revocationDateS) : new Date(); Date invalidityDate = null; if (isNotBlank(invalidityDateS)) { invalidityDate = DateUtil.parseUtcTimeyyyyMMddhhmmss(invalidityDateS); } CertRevocationInfo revInfo = new CertRevocationInfo(crlReason, revocationDate, invalidityDate); boolean bo = caManager.revokeCa(caName, revInfo); output(bo, "revoked", "could not revoke", "CA " + caName); return null; } // method execute0
@Override protected Object execute0() throws Exception { CrlReason crlReason = CrlReason.forNameOrText(reason); if (!CrlReason.PERMITTED_CLIENT_CRLREASONS.contains(crlReason)) { throw new InvalidConfException("reason " + reason + " is not permitted"); } Date invalidityDate = null; if (isNotBlank(invalidityDateS)) { invalidityDate = DateUtil.parseUtcTimeyyyyMMddhhmmss(invalidityDateS); } boolean successful = caManager.revokeCertificate(caName, getSerialNumber(), crlReason, invalidityDate); output(successful, "revoked", "could not revoke", "certificate"); return null; }