本文整理汇总了Java中org.apache.xml.security.encryption.XMLCipher.setKEK方法的典型用法代码示例。如果您正苦于以下问题:Java XMLCipher.setKEK方法的具体用法?Java XMLCipher.setKEK怎么用?Java XMLCipher.setKEK使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.xml.security.encryption.XMLCipher
的用法示例。
在下文中一共展示了XMLCipher.setKEK方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: decryptUsingDOM
import org.apache.xml.security.encryption.XMLCipher; //导入方法依赖的package包/类
/**
* Decrypt the document using DOM API and run some tests on the decrypted Document.
*/
private Document decryptUsingDOM(
String algorithm,
SecretKey secretKey,
Key wrappingKey,
Document document
) throws Exception {
XMLCipher cipher = XMLCipher.getInstance(algorithm);
cipher.init(XMLCipher.DECRYPT_MODE, secretKey);
if (wrappingKey != null) {
cipher.setKEK(wrappingKey);
}
NodeList nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
Element ee = (Element) nodeList.item(0);
return cipher.doFinal(document, ee);
}
示例2: decryptUsingDOM
import org.apache.xml.security.encryption.XMLCipher; //导入方法依赖的package包/类
/**
* Decrypt the document using DOM API and run some tests on the decrypted Document.
*/
private Document decryptUsingDOM(
String algorithm,
SecretKey secretKey,
Key wrappingKey,
Document document
) throws Exception {
XMLCipher cipher = XMLCipher.getInstance(algorithm);
cipher.init(XMLCipher.DECRYPT_MODE, secretKey);
if (wrappingKey != null) {
cipher.setKEK(wrappingKey);
}
NodeList nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
Element ee = (Element)nodeList.item(0);
return cipher.doFinal(document, ee);
}
示例3: main
import org.apache.xml.security.encryption.XMLCipher; //导入方法依赖的package包/类
public static void main(String unused[]) throws Exception {
Document document = loadEncryptionDocument();
Element encryptedDataElement =
(Element) document.getElementsByTagNameNS(
EncryptionConstants.EncryptionSpecNS,
EncryptionConstants._TAG_ENCRYPTEDDATA).item(0);
/*
* Load the key to be used for decrypting the xml data
* encryption key.
*/
Key kek = loadKeyEncryptionKey();
String providerName = "BC";
XMLCipher xmlCipher =
XMLCipher.getInstance();
/*
* The key to be used for decrypting xml data would be obtained
* from the keyinfo of the EncrypteData using the kek.
*/
xmlCipher.init(XMLCipher.DECRYPT_MODE, null);
xmlCipher.setKEK(kek);
/*
* The following doFinal call replaces the encrypted data with
* decrypted contents in the document.
*/
xmlCipher.doFinal(document, encryptedDataElement);
outputDocToFile(document, "build/decryptedInfo.xml");
}