List of usage examples for java.security.cert X509Certificate getNotAfter
public abstract Date getNotAfter();
From source file:com.archivas.clienttools.arcutils.utils.net.SSLCertChain.java
public Date getValidNotAfter() { X509Certificate cert = getCertificateList().get(0); return cert.getNotAfter(); }
From source file:com.thoughtworks.go.security.AuthSSLX509TrustManagerFactory.java
private void logKeyStore(KeyStore store) throws KeyStoreException { Enumeration aliases = store.aliases(); while (aliases.hasMoreElements()) { String alias = (String) aliases.nextElement(); LOG.debug("Trusted certificate '" + alias + "':"); Certificate trustedcert = store.getCertificate(alias); if (trustedcert != null && trustedcert instanceof X509Certificate) { X509Certificate cert = (X509Certificate) trustedcert; LOG.trace(" Subject DN: " + cert.getSubjectDN()); LOG.trace(" Signature Algorithm: " + cert.getSigAlgName()); LOG.trace(" Valid from: " + cert.getNotBefore()); LOG.trace(" Valid until: " + cert.getNotAfter()); LOG.trace(" Issuer: " + cert.getIssuerDN()); }//from ww w . ja v a 2 s.c o m } }
From source file:com.zotoh.crypto.CryptoUte.java
/** * @param cert//from ww w . j a v a 2 s .c om * @return */ public static Tuple getCertDesc(Certificate cert) { tstArgIsType("cert", cert, X509Certificate.class); X509Certificate x509 = (X509Certificate) cert; X500Principal issuer = x509.getIssuerX500Principal(); X500Principal subj = x509.getSubjectX500Principal(); Date vs = x509.getNotBefore(); Date ve = x509.getNotAfter(); return new Tuple(subj, issuer, vs, ve); }
From source file:psiprobe.controllers.truststore.TrustStoreController.java
@Override protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { List<Map<String, String>> certificateList = new ArrayList<>(); try {//from www . j a v a 2 s . co m String trustStoreType = System.getProperty("javax.net.ssl.trustStoreType"); KeyStore ks; if (trustStoreType != null) { ks = KeyStore.getInstance(trustStoreType); } else { ks = KeyStore.getInstance("JKS"); } String trustStore = System.getProperty("javax.net.ssl.trustStore"); String trustStorePassword = System.getProperty("javax.net.ssl.trustStorePassword"); if (trustStore != null) { try (FileInputStream fis = new FileInputStream(trustStore)) { ks.load(fis, trustStorePassword != null ? trustStorePassword.toCharArray() : null); } Map<String, String> attributes; for (String alias : Collections.list(ks.aliases())) { attributes = new HashMap<>(); if (ks.getCertificate(alias).getType().equals("X.509")) { X509Certificate cert = (X509Certificate) ks.getCertificate(alias); attributes.put("alias", alias); attributes.put("cn", cert.getSubjectDN().toString()); attributes.put("expirationDate", new SimpleDateFormat("yyyy-MM-dd").format(cert.getNotAfter())); certificateList.add(attributes); } } } } catch (Exception e) { logger.error("There was an exception obtaining truststore: ", e); } ModelAndView mv = new ModelAndView(getViewName()); mv.addObject("certificates", certificateList); return mv; }
From source file:org.openhealthtools.openatna.net.LoggedX509TrustManager.java
/** * @see javax.net.ssl.X509TrustManager#checkServerTrusted(X509Certificate[], String) *///from w w w. j a v a 2 s . c o m public void checkServerTrusted(X509Certificate[] certificates, String authType) throws CertificateException { if (log.isInfoEnabled() && certificates != null) { String certificateChain = "Server Certificate Chain: \n"; for (int c = 0; c < certificates.length; c++) { X509Certificate cert = certificates[c]; certificateChain += "\n Server certificate " + (c + 1) + ":" + "\n Subject DN: " + cert.getSubjectDN() + "\n Signature Algorithm: " + cert.getSigAlgName() + "\n Valid from: " + cert.getNotBefore() + "\n Valid until: " + cert.getNotAfter() + "\n Issuer: " + cert.getIssuerDN(); } log.info(certificateChain); } // This will throw a CertificateException if it is not trusted. try { this.defaultTrustManager.checkServerTrusted(certificates, authType); } catch (CertificateException e) { log.error("Something wrong with the server certificate: (auth type: " + authType + ")", e); throw e; } }
From source file:org.openhealthtools.openatna.net.LoggedX509TrustManager.java
/** * @see javax.net.ssl.X509TrustManager#checkClientTrusted(X509Certificate[], String) *///from ww w.j av a 2s . c o m public void checkClientTrusted(X509Certificate[] certificates, String authType) throws CertificateException { if (log.isInfoEnabled() && certificates != null) { String s = "\n========== checking client certificate chain =========="; for (int c = 0; c < certificates.length; c++) { X509Certificate cert = certificates[c]; s += "\n Client certificate " + (c + 1) + ":"; s += "\n Subject DN: " + cert.getSubjectDN(); s += "\n Signature Algorithm: " + cert.getSigAlgName(); s += "\n Valid from: " + cert.getNotBefore(); s += "\n Valid until: " + cert.getNotAfter(); s += "\n Issuer: " + cert.getIssuerDN(); } s += "\n======================================================="; log.info(s); } // This will throw a CertificateException if it is not trusted. try { this.defaultTrustManager.checkClientTrusted(certificates, authType); } catch (CertificateException e) { log.error("Something wrong with the client certificate (auth type: \" + authType +\")", e); throw e; } }
From source file:psiprobe.controllers.certificates.ListCertificatesController.java
/** * Adds the to store./*ww w .j a v a2s .co m*/ * * @param certs the certs * @param alias the alias * @param x509Cert the x509 cert */ private void addToStore(List<Cert> certs, String alias, X509Certificate x509Cert) { Cert cert = new Cert(); cert.setAlias(alias); cert.setSubjectDistinguishedName(x509Cert.getSubjectDN().toString()); cert.setNotBefore(x509Cert.getNotBefore()); cert.setNotAfter(x509Cert.getNotAfter()); cert.setIssuerDistinguishedName(x509Cert.getIssuerDN().toString()); certs.add(cert); }
From source file:au.edu.monash.merc.capture.util.httpclient.ssl.AuthSSLX509TrustManager.java
/** * @see javax.net.ssl.X509TrustManager#checkClientTrusted(X509Certificate[],String authType) *//*from w w w . j a va 2 s .c o m*/ public void checkClientTrusted(X509Certificate[] certificates, String authType) throws CertificateException { if (LOG.isInfoEnabled() && certificates != null) { for (int c = 0; c < certificates.length; c++) { X509Certificate cert = certificates[c]; LOG.info(" Client certificate " + (c + 1) + ":"); LOG.info(" Subject DN: " + cert.getSubjectDN()); LOG.info(" Signature Algorithm: " + cert.getSigAlgName()); LOG.info(" Valid from: " + cert.getNotBefore()); LOG.info(" Valid until: " + cert.getNotAfter()); LOG.info(" Issuer: " + cert.getIssuerDN()); } } defaultTrustManager.checkClientTrusted(certificates, authType); }
From source file:au.edu.monash.merc.capture.util.httpclient.ssl.AuthSSLX509TrustManager.java
/** * @see javax.net.ssl.X509TrustManager#checkServerTrusted(X509Certificate[],String authType) *///www . j av a 2 s . c o m public void checkServerTrusted(X509Certificate[] certificates, String authType) throws CertificateException { if (LOG.isInfoEnabled() && certificates != null) { for (int c = 0; c < certificates.length; c++) { X509Certificate cert = certificates[c]; LOG.info(" Server certificate " + (c + 1) + ":"); LOG.info(" Subject DN: " + cert.getSubjectDN()); LOG.info(" Signature Algorithm: " + cert.getSigAlgName()); LOG.info(" Valid from: " + cert.getNotBefore()); LOG.info(" Valid until: " + cert.getNotAfter()); LOG.info(" Issuer: " + cert.getIssuerDN()); } } defaultTrustManager.checkServerTrusted(certificates, authType); }
From source file:com.ab.http.AuthSSLX509TrustManager.java
/*** * @see javax.net.ssl.X509TrustManager#checkClientTrusted(X509Certificate[],String * authType)/*from w w w . ja v a2 s.co m*/ */ public void checkClientTrusted(X509Certificate[] certificates, String authType) throws CertificateException { if (certificates != null) { for (int c = 0; c < certificates.length; c++) { X509Certificate cert = certificates[c]; Log.i(TAG, " Client certificate " + (c + 1) + ":"); Log.i(TAG, " Subject DN: " + cert.getSubjectDN()); Log.i(TAG, " Signature Algorithm: " + cert.getSigAlgName()); Log.i(TAG, " Valid from: " + cert.getNotBefore()); Log.i(TAG, " Valid until: " + cert.getNotAfter()); Log.i(TAG, " Issuer: " + cert.getIssuerDN()); } } defaultTrustManager.checkClientTrusted(certificates, authType); }