• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java JCEMapper类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.sun.org.apache.xml.internal.security.algorithms.JCEMapper的典型用法代码示例。如果您正苦于以下问题:Java JCEMapper类的具体用法?Java JCEMapper怎么用?Java JCEMapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JCEMapper类属于com.sun.org.apache.xml.internal.security.algorithms包,在下文中一共展示了JCEMapper类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: IntegrityHmac

import com.sun.org.apache.xml.internal.security.algorithms.JCEMapper; //导入依赖的package包/类
/**
 * Method IntegrityHmacSHA1das
 *
 * @throws XMLSignatureException
 */
public IntegrityHmac() throws XMLSignatureException {

   String algorithmID = JCEMapper.translateURItoJCEID(this.engineGetURI());
   if (log.isLoggable(java.util.logging.Level.FINE))
     log.log(java.util.logging.Level.FINE, "Created IntegrityHmacSHA1 using " + algorithmID);

   try {
      this._macAlgorithm = Mac.getInstance(algorithmID);
   } catch (java.security.NoSuchAlgorithmException ex) {
      Object[] exArgs = { algorithmID,
                          ex.getLocalizedMessage() };

      throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
   }
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:21,代码来源:IntegrityHmac.java


示例2: constructCipher

import com.sun.org.apache.xml.internal.security.algorithms.JCEMapper; //导入依赖的package包/类
/**
 * Construct a Cipher object
 */
private Cipher constructCipher(String algorithm, String digestAlgorithm) throws XMLEncryptionException {
    String jceAlgorithm = JCEMapper.translateURItoJCEID(algorithm);
    if (log.isLoggable(java.util.logging.Level.FINE)) {
        log.log(java.util.logging.Level.FINE, "JCE Algorithm = " + jceAlgorithm);
    }

    Cipher c;
    try {
        if (requestedJCEProvider == null) {
            c = Cipher.getInstance(jceAlgorithm);
        } else {
            c = Cipher.getInstance(jceAlgorithm, requestedJCEProvider);
        }
    } catch (NoSuchAlgorithmException nsae) {
        // Check to see if an RSA OAEP MGF-1 with SHA-1 algorithm was requested
        // Some JDKs don't support RSA/ECB/OAEPPadding
        if (XMLCipher.RSA_OAEP.equals(algorithm)
            && (digestAlgorithm == null
                || MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA1.equals(digestAlgorithm))) {
            try {
                if (requestedJCEProvider == null) {
                    c = Cipher.getInstance("RSA/ECB/OAEPWithSHA1AndMGF1Padding");
                } else {
                    c = Cipher.getInstance("RSA/ECB/OAEPWithSHA1AndMGF1Padding", requestedJCEProvider);
                }
            } catch (Exception ex) {
                throw new XMLEncryptionException("empty", ex);
            }
        } else {
            throw new XMLEncryptionException("empty", nsae);
        }
    } catch (NoSuchProviderException nspre) {
        throw new XMLEncryptionException("empty", nspre);
    } catch (NoSuchPaddingException nspae) {
        throw new XMLEncryptionException("empty", nspae);
    }

    return c;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:43,代码来源:XMLCipher.java


示例3: IntegrityHmac

import com.sun.org.apache.xml.internal.security.algorithms.JCEMapper; //导入依赖的package包/类
/**
 * Method IntegrityHmac
 *
 * @throws XMLSignatureException
 */
public IntegrityHmac() throws XMLSignatureException {
    String algorithmID = JCEMapper.translateURItoJCEID(this.engineGetURI());
    if (log.isLoggable(java.util.logging.Level.FINE)) {
        log.log(java.util.logging.Level.FINE, "Created IntegrityHmacSHA1 using " + algorithmID);
    }

    try {
        this.macAlgorithm = Mac.getInstance(algorithmID);
    } catch (java.security.NoSuchAlgorithmException ex) {
        Object[] exArgs = { algorithmID, ex.getLocalizedMessage() };

        throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:IntegrityHmac.java


示例4: getInstance

import com.sun.org.apache.xml.internal.security.algorithms.JCEMapper; //导入依赖的package包/类
public static XMLCipher getInstance(String transformation,Cipher cipher) throws XMLEncryptionException {
    // sanity checks
    logger.log(java.util.logging.Level.FINE, "Getting XMLCipher...");
    if (null == transformation)
        logger.log(java.util.logging.Level.SEVERE, "Transformation unexpectedly null...");
    if(!isValidEncryptionAlgorithm(transformation))
        logger.log(java.util.logging.Level.WARNING, "Algorithm non-standard, expected one of " + ENC_ALGORITHMS);

    XMLCipher instance = new XMLCipher();

    instance._algorithm = transformation;
    instance._key = null;
    instance._kek = null;


    /* Create a canonicaliser - used when serialising DOM to octets
     * prior to encryption (and for the reverse) */

    try {
        instance._canon = Canonicalizer.getInstance
                (Canonicalizer.ALGO_ID_C14N_WITH_COMMENTS);

    } catch (InvalidCanonicalizerException ice) {
        throw new XMLEncryptionException("empty", ice);
    }

    String jceAlgorithm = JCEMapper.translateURItoJCEID(transformation);

    try {
        instance._contextCipher = cipher;
        //Cipher.getInstance(jceAlgorithm);
        logger.log(java.util.logging.Level.FINE, "cihper.algoritm = " +
                instance._contextCipher.getAlgorithm());
    }catch(Exception ex) {
        throw new XMLEncryptionException("empty", ex);
    }

    return (instance);
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:40,代码来源:XMLCipher.java


示例5: dynamicInit

import com.sun.org.apache.xml.internal.security.algorithms.JCEMapper; //导入依赖的package包/类
/**
 * Dynamically initialise the library by registering the default algorithms/implementations
 */
private static void dynamicInit() {
    //
    // Load the Resource Bundle - the default is the English resource bundle.
    // To load another resource bundle, call I18n.init(...) before calling this
    // method.
    //
    I18n.init("en", "US");

    if (log.isLoggable(java.util.logging.Level.FINE)) {
        log.log(java.util.logging.Level.FINE, "Registering default algorithms");
    }
    try {
        AccessController.doPrivileged(new PrivilegedExceptionAction<Void>(){
            @Override public Void run() throws XMLSecurityException {
                //
                // Bind the default prefixes
                //
                ElementProxy.registerDefaultPrefixes();

                //
                // Set the default Transforms
                //
                Transform.registerDefaultAlgorithms();

                //
                // Set the default signature algorithms
                //
                SignatureAlgorithm.registerDefaultAlgorithms();

                //
                // Set the default JCE algorithms
                //
                JCEMapper.registerDefaultAlgorithms();

                //
                // Set the default c14n algorithms
                //
                Canonicalizer.registerDefaultAlgorithms();

                //
                // Register the default resolvers
                //
                ResourceResolver.registerDefaultResolvers();

                //
                // Register the default key resolvers
                //
                KeyResolver.registerDefaultResolvers();

                return null;
            }
       });
    } catch (PrivilegedActionException ex) {
        XMLSecurityException xse = (XMLSecurityException)ex.getException();
        log.log(java.util.logging.Level.SEVERE, xse.getMessage(), xse);
        xse.printStackTrace();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:62,代码来源:Init.java


示例6: getProviderInstance

import com.sun.org.apache.xml.internal.security.algorithms.JCEMapper; //导入依赖的package包/类
/**
 * Returns an <code>XMLCipher</code> that implements the specified
 * transformation and operates on the specified context document.
 *
 * @param transformation the name of the transformation, e.g.,
 *   <code>XMLCipher.TRIPLEDES</code> which is shorthand for
 *   &quot;http://www.w3.org/2001/04/xmlenc#tripledes-cbc&quot;
 * @param provider the JCE provider that supplies the transformation
 * @return the XMLCipher
 * @throws XMLEncryptionException
 */

public static XMLCipher getProviderInstance(String transformation, String provider)
        throws XMLEncryptionException {
    // sanity checks
    logger.log(java.util.logging.Level.FINE, "Getting XMLCipher...");
    if (null == transformation)
        logger.log(java.util.logging.Level.SEVERE, "Transformation unexpectedly null...");
    if(null == provider)
        logger.log(java.util.logging.Level.SEVERE, "Provider unexpectedly null..");
    if("" == provider)
        logger.log(java.util.logging.Level.SEVERE, "Provider's value unexpectedly not specified...");
    if(!isValidEncryptionAlgorithm(transformation))
        logger.log(java.util.logging.Level.WARNING, "Algorithm non-standard, expected one of " + ENC_ALGORITHMS);

            XMLCipher instance = new XMLCipher();

    instance._algorithm = transformation;
            instance._requestedJCEProvider = provider;
            instance._key = null;
            instance._kek = null;

            /* Create a canonicaliser - used when serialising DOM to octets
             * prior to encryption (and for the reverse) */

            try {
                    instance._canon = Canonicalizer.getInstance
                            (Canonicalizer.ALGO_ID_C14N_WITH_COMMENTS);
            } catch (InvalidCanonicalizerException ice) {
                    throw new XMLEncryptionException("empty", ice);
            }

    try {
                    String jceAlgorithm =
                            JCEMapper.translateURItoJCEID(transformation);

        instance._contextCipher = Cipher.getInstance(jceAlgorithm, provider);

        logger.log(java.util.logging.Level.FINE, "cipher._algorithm = " +
            instance._contextCipher.getAlgorithm());
        logger.log(java.util.logging.Level.FINE, "provider.name = " + provider);
    } catch (NoSuchAlgorithmException nsae) {
        throw new XMLEncryptionException("empty", nsae);
    } catch (NoSuchProviderException nspre) {
        throw new XMLEncryptionException("empty", nspre);
    } catch (NoSuchPaddingException nspe) {
        throw new XMLEncryptionException("empty", nspe);
    }

    return (instance);
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:62,代码来源:XMLCipher.java


示例7: dynamicInit

import com.sun.org.apache.xml.internal.security.algorithms.JCEMapper; //导入依赖的package包/类
/**
 * Dynamically initialise the library by registering the default algorithms/implementations
 */
private static void dynamicInit() {
    //
    // Load the Resource Bundle - the default is the English resource bundle.
    // To load another resource bundle, call I18n.init(...) before calling this
    // method.
    //
    I18n.init("en", "US");

    if (log.isLoggable(java.util.logging.Level.FINE)) {
        log.log(java.util.logging.Level.FINE, "Registering default algorithms");
    }
    try {
        //
        // Bind the default prefixes
        //
        ElementProxy.registerDefaultPrefixes();

        //
        // Set the default Transforms
        //
        Transform.registerDefaultAlgorithms();

        //
        // Set the default signature algorithms
        //
        SignatureAlgorithm.registerDefaultAlgorithms();

        //
        // Set the default JCE algorithms
        //
        JCEMapper.registerDefaultAlgorithms();

        //
        // Set the default c14n algorithms
        //
        Canonicalizer.registerDefaultAlgorithms();

        //
        // Register the default resolvers
        //
        ResourceResolver.registerDefaultResolvers();

        //
        // Register the default key resolvers
        //
        KeyResolver.registerDefaultResolvers();
    } catch (Exception ex) {
        log.log(java.util.logging.Level.SEVERE, ex.getMessage(), ex);
        ex.printStackTrace();
    }
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:55,代码来源:Init.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java StringUtility类代码示例发布时间:2022-05-21
下一篇:
Java Picture类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap