Package com.sun.org.apache.xml.internal.security.keys.content.x509

Examples of com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509Digest


     *
     * @param x509CertificateDigestBytes
     * @param algorithmURI
     */
    public void addDigest(byte[] x509CertificateDigestBytes, String algorithmURI) {
        this.add(new XMLX509Digest(getDocument(), x509CertificateDigestBytes, algorithmURI));
    }
View Full Code Here


        Element e =
            XMLUtils.selectDs11Node(
                getFirstChild(), Constants._TAG_X509DIGEST, i);

        if (e != null) {
            return new XMLX509Digest(e, this.baseURI);
        }
        return null;
    }
View Full Code Here

     * @throws XMLSecurityException
     */
    private X509Certificate resolveCertificate(Element element, String baseURI, StorageResolver storage)
        throws XMLSecurityException {

        XMLX509Digest x509Digests[] = null;

        Element x509childNodes[] = XMLUtils.selectDs11Nodes(element.getFirstChild(), Constants._TAG_X509DIGEST);

        if (x509childNodes == null || x509childNodes.length <= 0) {
            return null;
        }

        try {        
            checkStorage(storage);

            x509Digests = new XMLX509Digest[x509childNodes.length];

            for (int i = 0; i < x509childNodes.length; i++) {
                x509Digests[i] = new XMLX509Digest(x509childNodes[i], baseURI);
            }

            Iterator<Certificate> storageIterator = storage.getIterator();
            while (storageIterator.hasNext()) {
                X509Certificate cert = (X509Certificate) storageIterator.next();

                for (int i = 0; i < x509Digests.length; i++) {
                    XMLX509Digest keyInfoDigest = x509Digests[i];
                    byte[] certDigestBytes = XMLX509Digest.getDigestBytesFromCert(cert, keyInfoDigest.getAlgorithm());

                    if (Arrays.equals(keyInfoDigest.getDigestBytes(), certDigestBytes)) {
                        if (log.isDebugEnabled()) {
                            log.debug("Found certificate with: " + cert.getSubjectX500Principal().getName());
                        }
                        return cert;
                    }
View Full Code Here

     * @param algorithmURI
     * @throws XMLSecurityException
     */
    public void addDigest(X509Certificate x509certificate, String algorithmURI)
        throws XMLSecurityException {
        this.add(new XMLX509Digest(getDocument(), x509certificate, algorithmURI));
    }
View Full Code Here

     *
     * @param x509CertificateDigestByes
     * @param algorithmURI
     */
    public void addDigest(byte[] x509certificateDigestBytes, String algorithmURI) {
        this.add(new XMLX509Digest(getDocument(), x509certificateDigestBytes, algorithmURI));
    }
View Full Code Here

        Element e =
            XMLUtils.selectDs11Node(
                getFirstChild(), Constants._TAG_X509DIGEST, i);

        if (e != null) {
            return new XMLX509Digest(e, this.baseURI);
        }
        return null;
    }
View Full Code Here

     * @throws XMLSecurityException
     */
    private X509Certificate resolveCertificate(Element element, String baseURI, StorageResolver storage)
        throws XMLSecurityException {

        XMLX509Digest x509Digests[] = null;

        Element x509childNodes[] = XMLUtils.selectDs11Nodes(element.getFirstChild(), Constants._TAG_X509DIGEST);

        if (x509childNodes == null || x509childNodes.length <= 0) {
            return null;
        }

        try {        
            checkStorage(storage);

            x509Digests = new XMLX509Digest[x509childNodes.length];

            for (int i = 0; i < x509childNodes.length; i++) {
                x509Digests[i] = new XMLX509Digest(x509childNodes[i], baseURI);
            }

            Iterator<Certificate> storageIterator = storage.getIterator();
            while (storageIterator.hasNext()) {
                X509Certificate cert = (X509Certificate) storageIterator.next();

                for (int i = 0; i < x509Digests.length; i++) {
                    XMLX509Digest keyInfoDigest = x509Digests[i];
                    byte[] certDigestBytes = XMLX509Digest.getDigestBytesFromCert(cert, keyInfoDigest.getAlgorithm());

                    if (Arrays.equals(keyInfoDigest.getDigestBytes(), certDigestBytes)) {
                        if (log.isDebugEnabled()) {
                            log.debug("Found certificate with: " + cert.getSubjectX500Principal().getName());
                        }
                        return cert;
                    }
View Full Code Here

      }
    }
   
  @org.junit.Test
  public void testSchema() throws Exception {
    XMLX509Digest x509Digest = new XMLX509Digest(documentBuilder.newDocument(), digestControl, algorithmURIControl);
      Element element = x509Digest.getElement();
     
      assertEquals("http://www.w3.org/2009/xmldsig11#", element.getNamespaceURI());
      assertEquals("X509Digest", element.getLocalName());
  }
View Full Code Here

  public void testDigestFromElement() throws Exception {
      Document doc = loadXML("X509Digest.xml");
      NodeList nl = doc.getElementsByTagNameNS(Constants.SignatureSpec11NS, Constants._TAG_X509DIGEST);
      Element element = (Element) nl.item(0);
     
    XMLX509Digest x509Digest = new XMLX509Digest(element, "");
      assertEquals(algorithmURIControl, x509Digest.getAlgorithm());
      assertArrayEquals(digestControl, x509Digest.getDigestBytes());
  }
View Full Code Here

      assertArrayEquals(digestControl, x509Digest.getDigestBytes());
  }

  @org.junit.Test
  public void testDigestOnConstructionWithCert() throws Exception {
    XMLX509Digest x509Digest = new XMLX509Digest(documentBuilder.newDocument(), certControl, algorithmURIControl);
      assertEquals(algorithmURIControl, x509Digest.getAlgorithm());
      assertArrayEquals(digestControl, x509Digest.getDigestBytes());
  }
View Full Code Here

TOP

Related Classes of com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509Digest

Copyright © 2018 www.massapicom. 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.