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;
}
Aggregations