List of usage examples for java.security.cert X509Certificate getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:org.texai.x509.X509Utils.java
/** Makes a canonical X.509 certificate by serializing it to bytes and reconsituting it. This ensures * that all issuer and subject names have no space following the commas. /*w ww . ja v a2 s .co m*/ * @param x509Certificate the input certificate * @return the canonical certificate */ public static X509Certificate makeCanonicalX509Certificate(final X509Certificate x509Certificate) { //Preconditions assert x509Certificate != null : "x509Certificate must not be null"; X509Certificate canonicalX509Certificate; try { final byte[] certificateBytes = x509Certificate.getEncoded(); final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(certificateBytes); canonicalX509Certificate = readX509Certificate(byteArrayInputStream); } catch (CertificateException | NoSuchProviderException ex) { throw new TexaiException(ex); } LOGGER.debug("x509Certificate (" + x509Certificate.getClass().getName() + ")...\n" + x509Certificate + "\ncanonicalX509Certificate(" + canonicalX509Certificate.getClass().getName() + ")...\n" + canonicalX509Certificate); //Postconditions assert canonicalX509Certificate.equals( x509Certificate) : "canonicalX509Certificate must equal x509Certificate,\ncanonicalX509Certificate...\n" + canonicalX509Certificate + "\nx509Certificate...\n" + x509Certificate; return canonicalX509Certificate; }
From source file:test.unit.be.fedict.trust.MemoryCertificateRepositoryTest.java
@Test public void trustPointFoundByDifferentCryptoProvider() throws Exception { // setup//from w w w . j a va 2 s. c o m DateTime notBefore = new DateTime(); DateTime notAfter = notBefore.plusMonths(1); KeyPair keyPair = TrustTestUtils.generateKeyPair(); X509Certificate trustPoint = TrustTestUtils.generateSelfSignedCertificate(keyPair, "CN=Test", notBefore, notAfter); LOG.debug("trust point certificate impl class: " + trustPoint.getClass().getName()); MemoryCertificateRepository testedInstance = new MemoryCertificateRepository(); testedInstance.addTrustPoint(trustPoint); CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509", new BouncyCastleProvider()); X509Certificate certificate = (X509Certificate) certificateFactory .generateCertificate(new ByteArrayInputStream(trustPoint.getEncoded())); LOG.debug("certificate impl class: " + certificate.getClass().getName()); // operate assertFalse(certificate.getClass().equals(trustPoint.getClass())); assertTrue(testedInstance.isTrustPoint(certificate)); }