Package org.apache.xml.security.keys

Examples of org.apache.xml.security.keys.KeyInfo


        if (includeki && kek != null && dek != null) {
          XMLCipher keyCipher = XMLCipher.getInstance(kalg);
          keyCipher.init(XMLCipher.WRAP_MODE, kek);
          enckey = keyCipher.encryptKey(dom, dek);
          EncryptedData encdata = xmlCipher.getEncryptedData();
          KeyInfo keyInfo = new KeyInfo(dom);
          keyInfo.add(enckey);
          encdata.setKeyInfo(keyInfo);
        }
        dom = xmlCipher.doFinal(dom, dom.getDocumentElement(), false);
        return domToFom(dom, options);
      } catch (Exception e) {
View Full Code Here


            if (signedElement.hasAttributeNS(null, "Id")) {
                signedElement.setIdAttributeNS(null, "Id", true);
            }
           
            // See also WSS4J SAMLUtil.getCredentialFromKeyInfo
            KeyInfo keyInfo = signature.getKeyInfo();
           
            X509Certificate cert = keyInfo.getX509Certificate();
            if (cert != null) {
                valid = signature.checkSignatureValue(cert);
            } else {
                PublicKey pk = keyInfo.getPublicKey();
                if (pk != null) {
                    valid = signature.checkSignatureValue(pk);
                }
            }
           
            // validate trust
            new TrustValidator().validateTrust(crypto, cert, keyInfo.getPublicKey());
           
            if (valid && persistSignature) {
                message.setContent(XMLSignature.class, signature);
                message.setContent(Element.class, signedElement);
            }
View Full Code Here

    private void embedKeyInfoInEncryptedData(Document document, XMLCipher keyCipher, XMLCipher xmlCipher, Key dataEncryptionkey)
        throws XMLEncryptionException {

        EncryptedKey encryptedKey = keyCipher.encryptKey(document, dataEncryptionkey, mgfAlgorithm, null);
        KeyInfo keyInfo = new KeyInfo(document);
        keyInfo.add(encryptedKey);   
        EncryptedData encryptedDataElement = xmlCipher.getEncryptedData();
        encryptedDataElement.setKeyInfo(keyInfo);
    }
View Full Code Here

    private void embedKeyInfoInEncryptedData(Document document, XMLCipher keyCipher, XMLCipher xmlCipher, Key dataEncryptionkey)
        throws XMLEncryptionException {

        EncryptedKey encryptedKey = keyCipher.encryptKey(document, dataEncryptionkey);
        KeyInfo keyInfo = new KeyInfo(document);
        keyInfo.add(encryptedKey);   
        EncryptedData encryptedDataElement = xmlCipher.getEncryptedData();
        encryptedDataElement.setKeyInfo(keyInfo);
    }
View Full Code Here

        // If it exists use it, but it's not mandatory
        if (keyInfoElem != null &&
            keyInfoElem.getNamespaceURI().equals(Constants.SignatureSpecNS) &&
            keyInfoElem.getLocalName().equals(Constants._TAG_KEYINFO)) {
            this._keyInfo = new KeyInfo(keyInfoElem, BaseURI);
        }

        this._state = MODE_VERIFY;
    }
View Full Code Here

        // check to see if we are signing and if we have to create a keyinfo
        if (this._state == MODE_SIGN && this._keyInfo == null) {

            // create the KeyInfo
            this._keyInfo = new KeyInfo(this._doc);

            // get the Element from KeyInfo
            Element keyInfoElement = this._keyInfo.getElement();
            Element firstObject = XMLUtils.selectDsNode
                (this._constructionElement.getFirstChild(),
View Full Code Here

    private void embedKeyInfoInEncryptedData(Document document, XMLCipher keyCipher, XMLCipher xmlCipher, Key dataEncryptionkey)
        throws XMLEncryptionException {

        EncryptedKey encryptedKey = keyCipher.encryptKey(document, dataEncryptionkey, mgfAlgorithm, null);
        KeyInfo keyInfo = new KeyInfo(document);
        keyInfo.add(encryptedKey);   
        EncryptedData encryptedDataElement = xmlCipher.getEncryptedData();
        encryptedDataElement.setKeyInfo(keyInfo);
    }
View Full Code Here

            default :
                throw new WSSecurityException(WSSecurityException.FAILURE,
                        "unsupportedKeyId");
        }
        KeyInfo keyInfo = new KeyInfo(doc);
        keyInfo.addUnknownElement(secToken.getElement());
        WSSecurityUtil.appendChildElement(doc, xencEncryptedKey, keyInfo.getElement());

        Element xencCipherValue = WSEncryptBody.createCipherValue(doc, xencEncryptedKey);
        xencCipherValue.appendChild(keyText);
        //    createDataRefList(doc, xencEncryptedKey, encDataRefs);
        log.debug("Encryption complete.");
View Full Code Here

        }

        sig.addResourceResolver(EnvelopeIdResolver.getInstance());

        X509Certificate[] certs = null;
        KeyInfo info = sig.getKeyInfo();
        byte[] secretKey = null;
        UsernameToken ut = null;
        DerivedKeyToken dkt = null;

        if (info != null) {
            Node node = WSSecurityUtil.getDirectChild(info.getElement(),
                    SecurityTokenReference.SECURITY_TOKEN_REFERENCE,
                    WSConstants.WSSE_NS);
            if (node == null) {
                throw new WSSecurityException(
                        WSSecurityException.INVALID_SECURITY,
View Full Code Here

                        "invalidSAMLsecurity",
                        new Object[] { "for SAML Signature (Key Holder)" });
            }
            Element e = samlSubj.getKeyInfo();
            try {
                KeyInfo ki = new KeyInfo(e, null);

                if (ki.containsX509Data()) {
                    X509Data data = ki.itemX509Data(0);
                    XMLX509Certificate certElem = null;
                    if (data != null && data.containsCertificate()) {
                        certElem = data.itemCertificate(0);
                    }
                    if (certElem != null) {
View Full Code Here

TOP

Related Classes of org.apache.xml.security.keys.KeyInfo

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.