Package org.apache.xml.security.keys.content

Examples of org.apache.xml.security.keys.content.DEREncodedKeyValue


    public void testECPublicKeyFromKey() throws Exception {
        if (ecKeyControl == null) {
            return;
        }

        DEREncodedKeyValue derEncodedKeyValue = new DEREncodedKeyValue(documentBuilder.newDocument(), ecKeyControl);
        assertEquals(ecKeyControl, derEncodedKeyValue.getPublicKey());
        assertArrayEquals(ecKeyControl.getEncoded(), derEncodedKeyValue.getBytesFromTextChild());
    }
View Full Code Here


        assertArrayEquals(ecKeyControl.getEncoded(), derEncodedKeyValue.getBytesFromTextChild());
    }

    @org.junit.Test
    public void testId() throws Exception {
        DEREncodedKeyValue derEncodedKeyValue = new DEREncodedKeyValue(documentBuilder.newDocument(), rsaKeyControl);
        assertEquals("", derEncodedKeyValue.getId());
        assertNull(derEncodedKeyValue.getElement().getAttributeNodeNS(null, Constants._ATT_ID));

        derEncodedKeyValue.setId(idControl);
        assertEquals(idControl, derEncodedKeyValue.getId());
        assertTrue(derEncodedKeyValue.getElement().getAttributeNodeNS(null, Constants._ATT_ID).isId());

        derEncodedKeyValue.setId(null);
        assertEquals("", derEncodedKeyValue.getId());
        assertNull(derEncodedKeyValue.getElement().getAttributeNodeNS(null, Constants._ATT_ID));
    }
View Full Code Here

        if (!engineCanResolve(element, baseURI, storage)) {
            return null;
        }

        try {
            DEREncodedKeyValue derKeyValue = new DEREncodedKeyValue(element, baseURI);
            return derKeyValue.getPublicKey();
        } catch (XMLSecurityException e) {
            if (log.isDebugEnabled()) {
                log.debug("XMLSecurityException", e);
            }
        }
View Full Code Here

     *
     * @param pk
     * @throws XMLSecurityException
     */
    public void addDEREncodedKeyValue(PublicKey pk) throws XMLSecurityException {
        this.add(new DEREncodedKeyValue(getDocument(), pk));
    }
View Full Code Here

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

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

        if (!engineCanResolve(element, baseURI, storage)) {
            return null;
        }

        try {
            DEREncodedKeyValue derKeyValue = new DEREncodedKeyValue(element, baseURI);
            return derKeyValue.getPublicKey();
        } catch (XMLSecurityException e) {
            if (log.isDebugEnabled()) {
                log.debug("XMLSecurityException", e);
            }
        }
View Full Code Here

    dsaKeyControl = loadPublicKey("dsa.key", "DSA");
  }
 
    @org.junit.Test
    public void testSchema() throws Exception {
      DEREncodedKeyValue derEncodedKeyValue = new DEREncodedKeyValue(documentBuilder.newDocument(), rsaKeyControl);
      Element element = derEncodedKeyValue.getElement();
     
      assertEquals("http://www.w3.org/2009/xmldsig11#", element.getNamespaceURI());
      assertEquals("DEREncodedKeyValue", element.getLocalName());
    }
View Full Code Here

    public void testRSAPublicKeyFromElement() throws Exception {
      Document doc = loadXML("DEREncodedKeyValue-RSA.xml");
      NodeList nl = doc.getElementsByTagNameNS(Constants.SignatureSpec11NS, Constants._TAG_DERENCODEDKEYVALUE);
      Element element = (Element) nl.item(0);
     
      DEREncodedKeyValue derEncodedKeyValue = new DEREncodedKeyValue(element, "");
      assertEquals(rsaKeyControl, derEncodedKeyValue.getPublicKey());
      assertArrayEquals(rsaKeyControl.getEncoded(), derEncodedKeyValue.getBytesFromTextChild());
      assertEquals(idControl, derEncodedKeyValue.getId());
    }
View Full Code Here

    public void testDSAPublicKeyFromElement() throws Exception {
      Document doc = loadXML("DEREncodedKeyValue-DSA.xml");
      NodeList nl = doc.getElementsByTagNameNS(Constants.SignatureSpec11NS, Constants._TAG_DERENCODEDKEYVALUE);
      Element element = (Element) nl.item(0);
     
      DEREncodedKeyValue derEncodedKeyValue = new DEREncodedKeyValue(element, "");
      assertEquals(dsaKeyControl, derEncodedKeyValue.getPublicKey());
      assertArrayEquals(dsaKeyControl.getEncoded(), derEncodedKeyValue.getBytesFromTextChild());
      assertEquals(idControl, derEncodedKeyValue.getId());
    }
View Full Code Here

       
      Document doc = loadXML("DEREncodedKeyValue-EC.xml");
      NodeList nl = doc.getElementsByTagNameNS(Constants.SignatureSpec11NS, Constants._TAG_DERENCODEDKEYVALUE);
      Element element = (Element) nl.item(0);
     
      DEREncodedKeyValue derEncodedKeyValue = new DEREncodedKeyValue(element, "");
      assertEquals(ecKeyControl, derEncodedKeyValue.getPublicKey());
      assertArrayEquals(ecKeyControl.getEncoded(), derEncodedKeyValue.getBytesFromTextChild());
      assertEquals(idControl, derEncodedKeyValue.getId());
    }
View Full Code Here

TOP

Related Classes of org.apache.xml.security.keys.content.DEREncodedKeyValue

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.