Package org.apache.xml.security.encryption

Examples of org.apache.xml.security.encryption.XMLCipher.encryptKey()


      {
         String keyWrapAlgo = getXMLEncryptionURLForKeyUnwrap(pubKeyAlg, keySize);
         keyCipher = XMLCipher.getInstance(keyWrapAlgo);
           
         keyCipher.init(XMLCipher.WRAP_MODE, keyUsedToEncryptSecretKey);
         return keyCipher.encryptKey(document, keyToBeEncrypted);
      }
      catch (XMLEncryptionException e)
      {
        throw new ProcessingException(e);
      }
View Full Code Here


      try
      {
         cipher = XMLCipher.getInstance(wrapAlgorithm);
         cipher.init(XMLCipher.WRAP_MODE, token.getCert().getPublicKey());
         key = cipher.encryptKey(document, secretKey);
      }
      catch (XMLSecurityException e)
      {
         throw new WSSecurityException("Error encrypting key: " + e.getMessage(), e);
      }
View Full Code Here

        RSAPrivateKey privKey = (RSAPrivateKey) keyFactory.generatePrivate(privKeySpec);

        // Encrypt the data encryption key with the key encryption key
        XMLCipher keyCipher = XMLCipher.getInstance(XMLCipher.RSA_v1dot5);
        keyCipher.init(XMLCipher.WRAP_MODE, pubKey);
        EncryptedKey encryptedKey = keyCipher.encryptKey(document, dataEncryptKey);
       
        String keyName = "testResolvePrivateKey";
        KeyInfo kekInfo = new KeyInfo(document);
        kekInfo.addKeyName(keyName);
        encryptedKey.setKeyInfo(kekInfo);
View Full Code Here

      try
      {
         cipher = XMLCipher.getInstance(wrapAlgorithm);
         cipher.init(XMLCipher.WRAP_MODE, token.getCert().getPublicKey());
         key = cipher.encryptKey(document, secretKey);
      }
      catch (XMLSecurityException e)
      {
         throw new WSSecurityException("Error encrypting key: " + e.getMessage(), e);
      }
View Full Code Here

      try
      {
         cipher = XMLCipher.getInstance(wrapAlgorithm);
         cipher.init(XMLCipher.WRAP_MODE, token.getCert().getPublicKey());
         key = cipher.encryptKey(document, secretKey);
      }
      catch (XMLSecurityException e)
      {
         throw new WSSecurityException("Error encrypting key: " + e.getMessage(), e);
      }
View Full Code Here

      try
      {
         cipher = XMLCipher.getInstance(wrapAlgorithm);
         cipher.init(XMLCipher.WRAP_MODE, token.getCert().getPublicKey());
         key = cipher.encryptKey(document, secretKey);
      }
      catch (XMLSecurityException e)
      {
         throw new WSSecurityException("Error encrypting key: " + e.getMessage(), e);
      }
View Full Code Here

/*     */     org.apache.xml.security.encryption.EncryptedKey key;
/*     */     try
/*     */     {
/* 157 */       cipher = XMLCipher.getInstance("http://www.w3.org/2001/04/xmlenc#rsa-1_5");
/* 158 */       cipher.init(3, this.token.getCert().getPublicKey());
/* 159 */       key = cipher.encryptKey(this.document, this.secretKey);
/*     */     }
/*     */     catch (XMLSecurityException e)
/*     */     {
/* 163 */       throw new WSSecurityException("Error encrypting key: " + e.getMessage(), e);
/*     */     }
View Full Code Here

        XMLCipher xmlCipher = XMLCipher.getInstance(dalg);
        xmlCipher.init(XMLCipher.ENCRYPT_MODE, dek);
        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);
        }
View Full Code Here

        if (wrappingCert != null) {
            XMLCipher newCipher = XMLCipher.getInstance(keyTransportAlgorithm);
            newCipher.init(XMLCipher.WRAP_MODE, wrappingCert.getPublicKey());

            EncryptedKey encryptedKey = newCipher.encryptKey(document, encryptingKey);
            // Create a KeyInfo for the EncryptedKey
            KeyInfo encryptedKeyKeyInfo = encryptedKey.getKeyInfo();
            if (encryptedKeyKeyInfo == null) {
                encryptedKeyKeyInfo = new KeyInfo(document);
                encryptedKeyKeyInfo.getElement().setAttributeNS(
View Full Code Here

        try {
            String keyWrapAlgo = getXMLEncryptionURLForKeyUnwrap(pubKeyAlg, keySize);
            keyCipher = XMLCipher.getInstance(keyWrapAlgo);

            keyCipher.init(XMLCipher.WRAP_MODE, keyUsedToEncryptSecretKey);
            return keyCipher.encryptKey(document, keyToBeEncrypted);
        } catch (XMLEncryptionException e) {
            throw logger.processingError(e);
        }
    }
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.