当前位置: 首页>>代码示例>>Java>>正文


Java XMLCipher.setKEK方法代码示例

本文整理汇总了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);
}
 
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:23,代码来源:SignatureEncryptionTest.java

示例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);
}
 
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:23,代码来源:SymmetricEncryptionCreationTest.java

示例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");
}
 
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:33,代码来源:Decrypter.java


注:本文中的org.apache.xml.security.encryption.XMLCipher.setKEK方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。