protected String toUtcTimeyyyyMMddhhmmssZ(Date date) { return DateUtil.toUtcTimeyyyyMMddhhmmss(date) + "Z"; }
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); } }
@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; }
final long epoch = DateUtil.parseUtcTimeyyyyMMdd("20100101").getTime(); UniqueIdGenerator idGen = new UniqueIdGenerator(epoch, shardId);
@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); String msg = "CA " + caName; try { caManager.revokeCa(caName, revInfo); println("revoked " + msg); return null; } catch (CaMgmtException ex) { throw new CmdFailure("could not revoke " + msg + ", error: " + ex.getMessage(), ex); } } // method execute0
private String format(int index, CertListInfo info) { return StringUtil.concat(StringUtil.formatAccount(index, 4), " | ", StringUtil.formatText(info.getSerialNumber().toString(16), 20), " | ", DateUtil.toUtcTimeyyyyMMddhhmmss(info.getNotBefore()), " | ", DateUtil.toUtcTimeyyyyMMddhhmmss(info.getNotAfter()), " | ", info.getSubject()); }
@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); } BigInteger serialNo = getSerialNumber(); String msg = "certificate (serial number = 0x" + serialNo.toString(16) + ")"; try { caManager.revokeCertificate(caName, serialNo, crlReason, invalidityDate); println("revoked " + msg); return null; } catch (CaMgmtException ex) { throw new CmdFailure("could not revoke " + msg + ", error: " + ex.getMessage(), ex); } }
private PKIMessage buildPkiMessage(CsrEnrollCertRequest csr, Date notBefore, Date notAfter) { CmpUtf8Pairs utf8Pairs = new CmpUtf8Pairs(CmpUtf8Pairs.KEY_CERTPROFILE, csr.getCertprofile()); if (notBefore != null) { utf8Pairs.putUtf8Pair(CmpUtf8Pairs.KEY_NOTBEFORE, DateUtil.toUtcTimeyyyyMMddhhmmss(notBefore)); } if (notAfter != null) { utf8Pairs.putUtf8Pair(CmpUtf8Pairs.KEY_NOTAFTER, DateUtil.toUtcTimeyyyyMMddhhmmss(notAfter)); } PKIHeader header = buildPkiHeader(implicitConfirm, null, utf8Pairs); PKIBody body = new PKIBody(PKIBody.TYPE_P10_CERT_REQ, csr.getCsr()); return new PKIMessage(header, body); }
notBefore = DateUtil.parseUtcTimeyyyyMMddhhmmss(str); notAfter = DateUtil.parseUtcTimeyyyyMMddhhmmss(str);
if (invalidityTime != null) { event.addEventData(CaAuditConstants.NAME_invalidity_time, DateUtil.toUtcTimeyyyyMMddhhmmss(invalidityTime));
: DateUtil.parseUtcTimeyyyyMMddhhmmss(strNotBefore); : DateUtil.parseUtcTimeyyyyMMddhhmmss(strNotAfter); RestAPIConstants.PARAM_invalidity_time); if (StringUtil.isNotBlank(strInvalidityTime)) { invalidityTime = DateUtil.parseUtcTimeyyyyMMddhhmmss(strInvalidityTime);
} else { event.addEventData(CaAuditConstants.NAME_next_update, DateUtil.toUtcTimeyyyyMMddhhmmss(nextUpdate)); if (nextUpdate.getTime() - thisUpdate.getTime() < 10 * 60 * MS_PER_SECOND) {
event.addEventData(CaAuditConstants.NAME_certprofile, gct.certprofile.getIdent().getName()); event.addEventData(CaAuditConstants.NAME_not_before, DateUtil.toUtcTimeyyyyMMddhhmmss(gct.grantedNotBefore)); event.addEventData(CaAuditConstants.NAME_not_after, DateUtil.toUtcTimeyyyyMMddhhmmss(gct.grantedNotAfter));