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


Java InvalidKeyException.initCause方法代码示例

本文整理汇总了Java中java.security.InvalidKeyException.initCause方法的典型用法代码示例。如果您正苦于以下问题:Java InvalidKeyException.initCause方法的具体用法?Java InvalidKeyException.initCause怎么用?Java InvalidKeyException.initCause使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.security.InvalidKeyException的用法示例。


在下文中一共展示了InvalidKeyException.initCause方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: DSAPrivateKey

import java.security.InvalidKeyException; //导入方法依赖的package包/类
/**
 * Make a DSA private key out of a private key and three parameters.
 */
public DSAPrivateKey(BigInteger x, BigInteger p,
                     BigInteger q, BigInteger g)
throws InvalidKeyException {
    this.x = x;
    algid = new AlgIdDSA(p, q, g);

    try {
        key = new DerValue(DerValue.tag_Integer,
                           x.toByteArray()).toByteArray();
        encode();
    } catch (IOException e) {
        InvalidKeyException ike = new InvalidKeyException(
            "could not DER encode x: " + e.getMessage());
        ike.initCause(e);
        throw ike;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:DSAPrivateKey.java

示例2: parseKeyBits

import java.security.InvalidKeyException; //导入方法依赖的package包/类
protected void parseKeyBits() throws InvalidKeyException {
    try {
        DerInputStream in = new DerInputStream(key);
        x = in.getBigInteger();
    } catch (IOException e) {
        InvalidKeyException ike = new InvalidKeyException(e.getMessage());
        ike.initCause(e);
        throw ike;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:DSAPrivateKey.java

示例3: parseKeyBits

import java.security.InvalidKeyException; //导入方法依赖的package包/类
private void parseKeyBits() throws InvalidKeyException {
    try {
        DerInputStream in = new DerInputStream(this.key);
        this.x = in.getBigInteger();
    } catch (IOException e) {
        InvalidKeyException ike = new InvalidKeyException(
            "Error parsing key encoding: " + e.getMessage());
        ike.initCause(e);
        throw ike;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:12,代码来源:DHPrivateKey.java

示例4: engineTranslateKey

import java.security.InvalidKeyException; //导入方法依赖的package包/类
/**
 * Translates a <code>SecretKey</code> object, whose provider may be
 * unknown or potentially untrusted, into a corresponding
 * <code>SecretKey</code> object of this key factory.
 *
 * @param key the key whose provider is unknown or untrusted
 *
 * @return the translated key
 *
 * @exception InvalidKeyException if the given key cannot be processed by
 * this key factory.
 */
protected SecretKey engineTranslateKey(SecretKey key)
    throws InvalidKeyException {
    if ((key != null) &&
        (key.getAlgorithm().equalsIgnoreCase("PBKDF2WithHmacSHA1")) &&
        (key.getFormat().equalsIgnoreCase("RAW"))) {

        // Check if key originates from this factory
        if (key instanceof com.sun.crypto.provider.PBKDF2KeyImpl) {
            return key;
        }
        // Check if key implements the PBEKey
        if (key instanceof javax.crypto.interfaces.PBEKey) {
            javax.crypto.interfaces.PBEKey pKey =
                (javax.crypto.interfaces.PBEKey) key;
            try {
                PBEKeySpec spec =
                    new PBEKeySpec(pKey.getPassword(),
                                   pKey.getSalt(),
                                   pKey.getIterationCount(),
                                   pKey.getEncoded().length*8);
                return new PBKDF2KeyImpl(spec, "HmacSHA1");
            } catch (InvalidKeySpecException re) {
                InvalidKeyException ike = new InvalidKeyException
                    ("Invalid key component(s)");
                ike.initCause(re);
                throw ike;
            }
        }
    }
    throw new InvalidKeyException("Invalid key format/algorithm");
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:44,代码来源:PBKDF2HmacSHA1Factory.java

示例5: engineTranslateKey

import java.security.InvalidKeyException; //导入方法依赖的package包/类
/**
 * Translates a <code>SecretKey</code> object, whose provider may be
 * unknown or potentially untrusted, into a corresponding
 * <code>SecretKey</code> object of this key factory.
 *
 * @param key the key whose provider is unknown or untrusted
 *
 * @return the translated key
 *
 * @exception InvalidKeyException if the given key cannot be processed by
 * this key factory.
 */
protected SecretKey engineTranslateKey(SecretKey key)
    throws InvalidKeyException {
    if ((key != null) &&
        (key.getAlgorithm().equalsIgnoreCase("PBKDF2With" + prfAlgo)) &&
        (key.getFormat().equalsIgnoreCase("RAW"))) {

        // Check if key originates from this factory
        if (key instanceof com.sun.crypto.provider.PBKDF2KeyImpl) {
            return key;
        }
        // Check if key implements the PBEKey
        if (key instanceof javax.crypto.interfaces.PBEKey) {
            javax.crypto.interfaces.PBEKey pKey =
                (javax.crypto.interfaces.PBEKey) key;
            try {
                PBEKeySpec spec =
                    new PBEKeySpec(pKey.getPassword(),
                                   pKey.getSalt(),
                                   pKey.getIterationCount(),
                                   pKey.getEncoded().length*8);
                return new PBKDF2KeyImpl(spec, prfAlgo);
            } catch (InvalidKeySpecException re) {
                InvalidKeyException ike = new InvalidKeyException
                    ("Invalid key component(s)");
                ike.initCause(re);
                throw ike;
            }
        }
    }
    throw new InvalidKeyException("Invalid key format/algorithm");
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:44,代码来源:PBKDF2Core.java


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