public CertificateManager(Certificate cert) { this.cert = cert; String type = cert.getType(); if (type.equals(CERTIFICATE_TYPE_NAME) && cert instanceof X509Certificate) { x509cert = (X509Certificate) cert; } }
private List<String> names(List<Certificate> certificates) { ArrayList<String> strings = new ArrayList<>(); for (Certificate cert : certificates) { if (cert instanceof X509Certificate) { strings.add(String.valueOf(((X509Certificate) cert).getSubjectDN())); } else { strings.add(cert.getType()); } } return strings; } }
public String generateText() { StringBuilder str = new StringBuilder(); String type = cert.getType(); if (type.equals(CERTIFICATE_TYPE_NAME)) { str.append(generateTextForX509()); } else { str.append(cert.toString()); } return str.toString(); }
private List<String> names(List<Certificate> certificates) { ArrayList<String> strings = new ArrayList<>(); for (Certificate cert : certificates) { if (cert instanceof X509Certificate) { strings.add(String.valueOf(((X509Certificate) cert).getSubjectDN())); } else { strings.add(cert.getType()); } } return strings; } }
/** * Returns an alternate object to be serialized. * * @return the object to serialize. * @throws ObjectStreamException * if the creation of the alternate object fails. */ protected Object writeReplace() throws ObjectStreamException { try { return new CertificateRep(getType(), getEncoded()); } catch (CertificateEncodingException e) { throw new NotSerializableException("Could not create serialization object: " + e); } }
String s = chain[0].getType(); if (!(chain[0].getPublicKey().getAlgorithm()).equals(privateKey.getAlgorithm())) { throw new IllegalArgumentException("Algorithm of private key does not match " if (!s.equals(chain[i].getType())) { throw new IllegalArgumentException("Certificates from the given chain have " + "different types");
Certificate certificate = trustStore.getCertificate(alias); if (!(certificate instanceof X509Certificate)) { log.debug("Skipping non-X509Certificate in KeyStore. Certificate type: {}", certificate.getType()); continue;
try { KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType()); keystore.load(new FileInputStream("keystoreLocation"), "keystorePassword".toCharArray()); Enumeration<String> aliases = keystore.aliases(); while(aliases.hasMoreElements()){ String alias = aliases.nextElement(); if(keystore.getCertificate(alias).getType().equals("X.509")){ System.out.println(alias + " expires " + ((X509Certificate) keystore.getCertificate(alias)).getNotAfter()); } } } catch (Exception e) { e.printStackTrace(); }
/** * Tries to prepare an {@link Authentication} using the given certificate. * * @param cert The certificate to use. * @return The authentication instance created with the certificate or null if the certificate type is unsupported. */ @Nullable protected Authentication fromCertificate(final Certificate cert) { if (cert instanceof X509Certificate) { log.debug("Found X509 certificate"); return new X509CertificateAuthentication((X509Certificate) cert); } else { log.debug("Unsupported certificate type: {}", cert.getType()); return null; } }
for (String alias : Collections.list(ks.aliases())) { attributes = new HashMap<>(); if ("X.509".equals(ks.getCertificate(alias).getType())) { X509Certificate cert = (X509Certificate) ks.getCertificate(alias);
if (certificate != null && "X.509".equals(certificate.getType()))
@Override public X509Certificate decode(InputStream inputStream) throws CertificateException { CertificateFactory cf = CertificateFactory.getInstance("X.509"); Certificate certificate = cf.generateCertificate(inputStream); if (certificate instanceof X509Certificate) { return (X509Certificate) certificate; } throw new CertificateException( String.format("%s certificate format is not supported, Only X.509 certificate is supported", certificate.getType())); } };
private X509Certificate certificateIn(KeyStore.PrivateKeyEntry certEntry) { if (certEntry == null) { return null; } Certificate myCertificate = certEntry.getCertificate(); if (myCertificate instanceof X509Certificate) { //if( "X.509".equals(myCertificate.getType()) ) { return (X509Certificate) myCertificate; } throw new IllegalArgumentException("Certificate is not X509: " + myCertificate.getType()); //PublicKey myPublicKey = pkEntry.getCertificate().getPublicKey(); //return new RsaCredential(myPrivateKey, myPublicKey); }
private X509Certificate certificateIn(KeyStore.TrustedCertificateEntry certEntry) { if (certEntry == null) { return null; } Certificate myCertificate = certEntry.getTrustedCertificate(); if (myCertificate instanceof X509Certificate) { //if( "X.509".equals(myCertificate.getType()) ) { return (X509Certificate) myCertificate; } throw new IllegalArgumentException("Certificate is not X509: " + myCertificate.getType()); //PublicKey myPublicKey = pkEntry.getCertificate().getPublicKey(); //return new RsaCredential(myPrivateKey, myPublicKey); }
private X509Certificate certificateIn(KeyStore.TrustedCertificateEntry certEntry) { if( certEntry == null ) { return null; } Certificate myCertificate = certEntry.getTrustedCertificate(); if( myCertificate instanceof X509Certificate ) { //if( "X.509".equals(myCertificate.getType()) ) { return (X509Certificate)myCertificate; } throw new IllegalArgumentException("Certificate is not X509: "+myCertificate.getType()); //PublicKey myPublicKey = pkEntry.getCertificate().getPublicKey(); //return new RsaCredential(myPrivateKey, myPublicKey); }
private X509Certificate certificateIn(KeyStore.PrivateKeyEntry certEntry) { if( certEntry == null ) { return null; } Certificate myCertificate = certEntry.getCertificate(); if( myCertificate instanceof X509Certificate ) { //if( "X.509".equals(myCertificate.getType()) ) { return (X509Certificate)myCertificate; } throw new IllegalArgumentException("Certificate is not X509: "+myCertificate.getType()); //PublicKey myPublicKey = pkEntry.getCertificate().getPublicKey(); //return new RsaCredential(myPrivateKey, myPublicKey); }
/** * Returns an alternate object to be serialized. * * @return the object to serialize. * @throws ObjectStreamException * if the creation of the alternate object fails. */ protected Object writeReplace() throws ObjectStreamException { try { return new CertificateRep(getType(), getEncoded()); } catch (CertificateEncodingException e) { throw new NotSerializableException("Could not create serialization object: " + e); } }
/** * Returns an alternate object to be serialized. * * @return the object to serialize. * @throws ObjectStreamException * if the creation of the alternate object fails. */ protected Object writeReplace() throws ObjectStreamException { try { return new CertificateRep(getType(), getEncoded()); } catch (CertificateEncodingException e) { throw new NotSerializableException("Could not create serialization object: " + e); } }
/** * Returns an alternate object to be serialized. * * @return the object to serialize. * @throws ObjectStreamException * if the creation of the alternate object fails. */ protected Object writeReplace() throws ObjectStreamException { try { return new CertificateRep(getType(), getEncoded()); } catch (CertificateEncodingException e) { throw new NotSerializableException("Could not create serialization object: " + e); } }
final PemObject pemObject = new PemObject(intermediateCert.getType(), intermediateCert.getEncoded()); final StringWriter textWriter = new StringWriter(); try (final PemWriter pemWriter = new PemWriter(textWriter);) {