Package java.security.cert

Examples of java.security.cert.Certificate.verify()


            assertNotNull("ImplicitlyCA must have null spec", spec);
        } else {
            assertTrue("Public key is not EC", false);
        }
        try {
            cert.verify(ecdsaimplicitlycacacert.getPublicKey());
        } catch (Exception e) {
            assertTrue("Verify failed: " + e.getMessage(), false);
        }
        log.trace("<test17TestBCPKCS10ECDSAWithECDSAImplicitlyCACA()");
    }
View Full Code Here


        // Normal DN order
        assertEquals(CertTools.getSubjectDN(cert), "CN=TESTCVC,C=SE");
        assertEquals("CVC", cert.getType());
        assertEquals(CertTools.getIssuerDN(cert), CertTools.getSubjectDN(cvccacert));
        try {
            cert.verify(cvccacert.getPublicKey());
        } catch (Exception e) {
            assertTrue("Verify failed: " + e.getMessage(), false);
        }
        // FileOutputStream fos = new FileOutputStream("testcert.crt");
        // fos.write(cert.getEncoded());
View Full Code Here

        try {
            // Here we need the CVCA certificate as well to enrich the DV public
            // key with
            PublicKey pkec = cvcdveccert.getPublicKey();
            pkec = KeyTools.getECPublicKeyWithParams(pkec, cvcaeccert.getPublicKey());
            certec.verify(pkec);
        } catch (Exception e) {
            assertTrue("Verify failed: " + e.getMessage(), false);
        }
        cvcert = (CardVerifiableCertificate) certec;
        role = cvcert.getCVCertificate().getCertificateBody().getAuthorizationTemplate().getAuthorizationField().getRole().name();
View Full Code Here

            assertEquals(dsapk.getAlgorithm(), "DSA");
        } else {
            assertTrue("Public key is not DSA", false);
        }
        try {
            cert.verify(rsacacert.getPublicKey());
        } catch (Exception e) {
            assertTrue("Verify failed: " + e.getMessage(), false);
        }
        log.trace("<test24TestBCPKCS10DSAWithRSACA()");
    }
View Full Code Here

            assertEquals(dsapk.getAlgorithm(), "DSA");
        } else {
            assertTrue("Public key is not DSA", false);
        }
        try {
            cert.verify(dsacacert.getPublicKey());
        } catch (Exception e) {
            assertTrue("Verify failed: " + e.getMessage(), false);
        }
        log.trace("<test26TestBCPKCS10DSAWithDSACA()");
    }
View Full Code Here

      Certificate[] cachain = (Certificate[])signSession.getCertificateChain(administrator, caid).toArray(new Certificate[0]);
        // Verify CA-certificate
      Certificate rootcert = cachain[cachain.length - 1];
      if (CertTools.isSelfSigned(rootcert)) {
        try {
          rootcert.verify(rootcert.getPublicKey());
        } catch (GeneralSecurityException se) {
          throw new Exception("RootCA certificate does not verify, issuerDN: "+CertTools.getIssuerDN(rootcert)+", subjectDN: "+CertTools.getSubjectDN(rootcert));
        }
      } else {
        throw new Exception("RootCA certificate not self-signed, issuerDN: "+CertTools.getIssuerDN(rootcert)+", subjectDN: "+CertTools.getSubjectDN(rootcert));
View Full Code Here

        }
        X509Certificate cert = (X509Certificate) incert;
        try {
            // Convert the certificate to a BC certificate. SUN does not handle verifying RSASha256WithMGF1 for example
            Certificate bccert = CertTools.getCertfromByteArray(incert.getEncoded());
            bccert.verify(cert.getPublicKey());
        } catch (Exception e) {
          log.debug("Exception verify POPO: ", e);
          String msg = intres.getLocalizedMessage("signsession.popverificationfailed");
            throw new SignRequestSignatureException(msg);
        }
View Full Code Here

    KeyStore keyStore = KeyStore.getInstance(KEYSTORE_TYPE);
    keyStore.load(new FileInputStream(keyStoreFile), PASSWORD_CHARS);
    Certificate cert = CertUtils.findCert(keyStore);

    cert.verify(cert.getPublicKey()); // throws exception if it can't be verified
  }

  @Test
  public void createPublicSelfSigned() throws Exception {
    CertUtils certUtils = getUtils();
View Full Code Here

      fail("expected not to find private key in keystore");
    } catch (KeyStoreException e) {
      assertTrue(e.getMessage().contains("private key"));
    }
    Certificate cert = CertUtils.findCert(keyStore);
    cert.verify(cert.getPublicKey()); // throws exception if it can't be verified
  }

  @Test
  public void createSigned() throws Exception {
    CertUtils certUtils = getUtils();
View Full Code Here

    KeyStore signedKeyStore = KeyStore.getInstance(KEYSTORE_TYPE);
    signedKeyStore.load(new FileInputStream(signedKeyStoreFile), PASSWORD_CHARS);
    Certificate signedCert = CertUtils.findCert(signedKeyStore);

    try {
      signedCert.verify(signedCert.getPublicKey());
      fail("signed cert should not be able to verify itself");
    } catch (SignatureException e) {
      // expected
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.