Package org.apache.xml.security.keys

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


            // encrypt
            cipher = XMLCipher.getInstance(XMLCipher.AES_128);
            cipher.init(XMLCipher.ENCRYPT_MODE, key);
      EncryptedData builder = cipher.getEncryptedData();

      KeyInfo builderKeyInfo = builder.getKeyInfo();
      if (builderKeyInfo == null) {
        builderKeyInfo = new KeyInfo(d);
        builder.setKeyInfo(builderKeyInfo);
      }

      builderKeyInfo.add(encryptedKey);

            ed = cipher.doFinal(d, e);

            //decrypt
      key = null;
View Full Code Here


            // encrypt
            cipher = XMLCipher.getInstance(XMLCipher.AES_256);
            cipher.init(XMLCipher.ENCRYPT_MODE, key);
      EncryptedData builder = cipher.getEncryptedData();

      KeyInfo builderKeyInfo = builder.getKeyInfo();
      if (builderKeyInfo == null) {
        builderKeyInfo = new KeyInfo(d);
        builder.setKeyInfo(builderKeyInfo);
      }

      builderKeyInfo.add(encryptedKey);

            ed = cipher.doFinal(d, e);
            log.debug("Encrypted document");
            log.debug(toString(ed));
View Full Code Here

            // encrypt
            cipher = XMLCipher.getInstance(XMLCipher.AES_192);
            cipher.init(XMLCipher.ENCRYPT_MODE, key);
      EncryptedData builder = cipher.getEncryptedData();

      KeyInfo builderKeyInfo = builder.getKeyInfo();
      if (builderKeyInfo == null) {
        builderKeyInfo = new KeyInfo(d);
        builder.setKeyInfo(builderKeyInfo);
      }

      builderKeyInfo.add(encryptedKey);

            ed = cipher.doFinal(d, e);

            //decrypt
      key = null;
View Full Code Here

            X509Certificate cert = null;
            PublicKey publicKey = null;
           
           
            // See also WSS4J SAMLUtil.getCredentialFromKeyInfo
            KeyInfo keyInfo = signature.getKeyInfo();
           
            if (keyInfo != null) {
                cert = keyInfo.getX509Certificate();
                if (cert != null) {
                    valid = signature.checkSignatureValue(cert);
                } else {
                    publicKey = keyInfo.getPublicKey();
                    if (publicKey != null) {
                        valid = signature.checkSignatureValue(publicKey);
                    }
                }
            } else if (!keyInfoMustBeAvailable) {
View Full Code Here

      Element e = XMLUtils.getDirectChild(this._constructionElement,
                                          Constants._TAG_KEYINFO,
                                          Constants.SignatureSpecNS);

      if (e != null) {
         return new KeyInfo(e, this._baseURI);
      } else {
         return null;
      }
   }
View Full Code Here

            "00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f"));
      Key contentKey = em.createSecretKeyFromBytes(
         org.apache.xml.security.utils.HexDump.hexStringToByteArray(
            "00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f"));
      byte ciphertext[] = em.wrap(contentKey, wrapKey);
      KeyInfo ki = new KeyInfo(doc);

      ki.add(new org.apache.xml.security.keys.content.KeyName(doc,
              "Christian Geuer-Pollmann"));

      EncryptedKey ed = new EncryptedKey(doc, em, ki,
                                         new CipherData(doc, ciphertext), null,
                                         null, "Christian Geuer-Pollmann", "",
View Full Code Here

      Element e = XMLUtils.getDirectChild(this._constructionElement,
                                          Constants._TAG_KEYINFO,
                                          Constants.SignatureSpecNS);

      if (e != null) {
         return new KeyInfo(e, this._baseURI);
      } else {
         return null;
      }
   }
View Full Code Here

      }

      Key cek;

      {
         KeyInfo ki = new KeyInfo(doc);

         ki.add(new org.apache.xml.security.keys.content.KeyName(doc,
                 "Christian Geuer-Pollmann"));

         EncryptedData ed =
            new EncryptedData(doc,
                              EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES128,
View Full Code Here

        boolean valid = false;
        Reference ref = null;
        try {
            XMLSignature signature = new XMLSignature(signatureElement, "");   
            // 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);
                }
            }
            // is this call redundant given that signature.checkSignatureValue uses References ?
            ref = getReference(signature);
            Element signedElement = validateReference(root, ref);
           
            // validate trust
            new TrustValidator().validateTrust(crypto, cert, keyInfo.getPublicKey());
           
            if (persistSignature) {
                message.setContent(XMLSignature.class, signature);
                message.setContent(Element.class, signedElement);
            }
View Full Code Here

      Element keyInfoElem =XMLUtils.selectDsNode(this._constructionElement.getFirstChild(),
                               Constants._TAG_KEYINFO,0);

      // If it exists use it, but it's not mandatory
      if (keyInfoElem != null) {
         this._keyInfo = new KeyInfo(keyInfoElem, BaseURI);
      }
   }
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.