Package org.ejbca.cvc

Examples of org.ejbca.cvc.CardVerifiableCertificate.verify()


  private void checkInnerCollision(PublicKey pk, CVCertificate innerreq, String holderref) throws AuthorizationDeniedException {
    // Check to see that the inner signature does not verify using an old certificate (public key)
    // because that means the same keys were used, and that is not allowed according to the EU policy
    CardVerifiableCertificate innercert = new CardVerifiableCertificate(innerreq);
    try {
      innercert.verify(pk);                   
      String msg = intres.getLocalizedMessage("cvc.error.renewsamekeys", holderref);             
      log.info(msg);
      throw new AuthorizationDeniedException(msg);
    } catch (SignatureException e) {
      // It was good if the verification failed
View Full Code Here


        assertEquals(AuthorizationRoleEnum.DV_D, dvcert.getCertificateBody().getAuthorizationTemplate().getAuthorizationField().getRole());
        assertEquals(AuthorizationRoleEnum.CVCA, cvcacert.getCertificateBody().getAuthorizationTemplate().getAuthorizationField().getRole());
        PublicKey cvcapubk = cvcacert.getCertificateBody().getPublicKey();
        PublicKey dvpubk = dvcert.getCertificateBody().getPublicKey();
        dvpubk = KeyTools.getECPublicKeyWithParams(dvpubk, cvcapubk);
        cvcert.verify(dvpubk);
        CardVerifiableCertificate dvjavacert = new CardVerifiableCertificate(dvcert);
        dvjavacert.verify(cvcapubk);

        //
        // Second test that we try to get a new certificate for this user
View Full Code Here

        PublicKey cvcapubk = cvcacert.getCertificateBody().getPublicKey();
        PublicKey dvpubk = dvcert.getCertificateBody().getPublicKey();
        dvpubk = KeyTools.getECPublicKeyWithParams(dvpubk, cvcapubk);
        cvcert.verify(dvpubk);
        CardVerifiableCertificate dvjavacert = new CardVerifiableCertificate(dvcert);
        dvjavacert.verify(cvcapubk);

        //
        // Second test that we try to get a new certificate for this user
        // without outer (renewal) signature. This should fail.
        //
View Full Code Here

        Collection<java.security.cert.Certificate> dvcerts = dvinfo.getCertificateChain();
        assertEquals(2, dvcerts.size());
        CardVerifiableCertificate dvcertactive = (CardVerifiableCertificate)dvcerts.iterator().next();
        obj = CertificateParser.parseCVCObject(dvcertactive.getEncoded());
        // System.out.println(obj.getAsText());
        dvcertactive.verify(cvcakeypair.getPublic());
        // Check to see that is really the same keypair
        String pubk1 = new String(Base64.encode(dvcertactive.getPublicKey().getEncoded(), false));
        String pubk2 = new String(Base64.encode(cert.getCertificateBody().getPublicKey().getEncoded(), false));
        assertTrue(pubk1.compareTo(pubk2) == 0);
        String sequence1 = dvcertactive.getCVCertificate().getCertificateBody().getHolderReference().getSequence();
View Full Code Here

        dvcerts = dvinfo.getCertificateChain();
        assertEquals(2, dvcerts.size());
        dvcertactive = (CardVerifiableCertificate)dvcerts.iterator().next();
        obj = CertificateParser.parseCVCObject(dvcertactive.getEncoded());
        // System.out.println(obj.getAsText());
        dvcertactive.verify(cvcakeypair.getPublic());
        String sequence2 = dvcertactive.getCVCertificate().getCertificateBody().getHolderReference().getSequence();
        int s1 = Integer.parseInt(sequence1);
        int s2 = Integer.parseInt(sequence2);
        assertEquals(s1 + 1, s2); // sequence in new certificate should be old
        // sequence + 1
View Full Code Here

        dvcerts = dvinfo.getCertificateChain();
        assertEquals(2, dvcerts.size());
        dvcertactive = (CardVerifiableCertificate) dvcerts.iterator().next();
        obj = CertificateParser.parseCVCObject(dvcertactive.getEncoded());
        // System.out.println(obj.getAsText());
        dvcertactive.verify(cvcakeypair.getPublic());
        String sequence5 = dvcertactive.getCVCertificate().getCertificateBody().getHolderReference().getSequence();
        assertEquals(sequence3, sequence5); // sequence in new certificate
        // should be same as sequence in
        // request, which was old sequence +
        // 1
View Full Code Here

            CVCAuthenticatedRequest authreq = (CVCAuthenticatedRequest)parsedObject;
            authreq.verify(pk);                     
          } else {
            CVCertificate cert1 = (CVCertificate)parsedObject;
            CardVerifiableCertificate cvcert = new CardVerifiableCertificate(cert1);
            cvcert.verify(pk);                     
          }
          getPrintStream().println("Verification of certificate was successful");
        } catch (Exception e) {
          getPrintStream().println("Verification of certificate failed: "+e.getMessage());
        }
View Full Code Here

        try {
          CardVerifiableCertificate cc = getCardVerifiableCertificate();
          if (cc != null) {
                if (pubKey == null) {
                  cc.verify(cvcert.getCertificateBody().getPublicKey());
                  ret = true; // If we came here verification was successful
                } else {
                    cc.verify(pubKey);
                  ret = true; // If we came here verification was successful
                }           
View Full Code Here

          if (cc != null) {
                if (pubKey == null) {
                  cc.verify(cvcert.getCertificateBody().getPublicKey());
                  ret = true; // If we came here verification was successful
                } else {
                    cc.verify(pubKey);
                  ret = true; // If we came here verification was successful
                }           
          }
        } catch (NoSuchFieldException e) {
            log.error("CVC error!", e);
View Full Code Here

            log.debug("Certificate bytes: "+new String(Base64.encode(cvc.getDEREncoded())));         
        }
       
        CardVerifiableCertificate retCert = new CardVerifiableCertificate(cvc);
        // Verify certificate before returning
        retCert.verify(getCAToken().getPublicKey(SecConst.CAKEYPURPOSE_CERTSIGN));
        if (log.isTraceEnabled()) {
          log.trace("<generateCertificate()");
        }
    return retCert;                                                                                       
  }
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.