Search in sources :

Example 1 with HCEM

use of com.helger.html.hc.html.textlevel.HCEM in project phoss-smp by phax.

the class PageSecureEndpointChangeCertificate method _getCertificateDisplay.

@Nonnull
private static IHCNode _getCertificateDisplay(@Nullable final String sCert, @Nonnull final Locale aDisplayLocale) {
    X509Certificate aEndpointCert = null;
    try {
        aEndpointCert = CertificateHelper.convertStringToCertficate(sCert);
    } catch (final Exception ex) {
    // Ignore
    }
    if (aEndpointCert == null) {
        final int nDisplayLen = 20;
        final String sCertPart = (sCert.length() > nDisplayLen ? sCert.substring(0, 20) + "..." : sCert);
        final HCDiv ret = new HCDiv().addChild("Invalid certificate").addChild(sCert.length() > nDisplayLen ? " starting with: " : ": ");
        if (sCertPart.length() > 0)
            ret.addChild(new HCCode().addChild(sCertPart));
        else
            ret.addChild(new HCEM().addChild("empty"));
        return ret;
    }
    final HCNodeList ret = new HCNodeList();
    ret.addChild(new HCDiv().addChild("Issuer: " + aEndpointCert.getIssuerX500Principal().toString()));
    ret.addChild(new HCDiv().addChild("Subject: " + aEndpointCert.getSubjectX500Principal().toString()));
    final LocalDateTime aNotBefore = PDTFactory.createLocalDateTime(aEndpointCert.getNotBefore());
    ret.addChild(new HCDiv().addChild("Not before: " + PDTToString.getAsString(aNotBefore, aDisplayLocale)));
    final LocalDateTime aNotAfter = PDTFactory.createLocalDateTime(aEndpointCert.getNotAfter());
    ret.addChild(new HCDiv().addChild("Not after: " + PDTToString.getAsString(aNotAfter, aDisplayLocale)));
    return ret;
}
Also used : HCDiv(com.helger.html.hc.html.grouping.HCDiv) LocalDateTime(java.time.LocalDateTime) HCEM(com.helger.html.hc.html.textlevel.HCEM) HCNodeList(com.helger.html.hc.impl.HCNodeList) HCCode(com.helger.html.hc.html.textlevel.HCCode) PDTToString(com.helger.commons.datetime.PDTToString) X509Certificate(java.security.cert.X509Certificate) ISMPEndpoint(com.helger.phoss.smp.domain.serviceinfo.ISMPEndpoint) SMPEndpoint(com.helger.phoss.smp.domain.serviceinfo.SMPEndpoint) Nonnull(javax.annotation.Nonnull)

Aggregations

PDTToString (com.helger.commons.datetime.PDTToString)1 HCDiv (com.helger.html.hc.html.grouping.HCDiv)1 HCCode (com.helger.html.hc.html.textlevel.HCCode)1 HCEM (com.helger.html.hc.html.textlevel.HCEM)1 HCNodeList (com.helger.html.hc.impl.HCNodeList)1 ISMPEndpoint (com.helger.phoss.smp.domain.serviceinfo.ISMPEndpoint)1 SMPEndpoint (com.helger.phoss.smp.domain.serviceinfo.SMPEndpoint)1 X509Certificate (java.security.cert.X509Certificate)1 LocalDateTime (java.time.LocalDateTime)1 Nonnull (javax.annotation.Nonnull)1