java.security.InvalidKeyException#initCause ( )源码实例Demo

下面列出了java.security.InvalidKeyException#initCause ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: TencentKona-8   文件: DSAPrivateKey.java
/**
 * 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;
    }
}
 
源代码2 项目: jdk8u-jdk   文件: DSAPrivateKey.java
/**
 * 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;
    }
}
 
源代码3 项目: jdk8u60   文件: DSAPrivateKey.java
/**
 * 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;
    }
}
 
源代码4 项目: Bytecoder   文件: DSAPrivateKey.java
/**
 * 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;
    }
}
 
源代码5 项目: Bytecoder   文件: PBKDF2Core.java
/**
 * 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");
}
 
源代码6 项目: openjdk-jdk9   文件: PBKDF2Core.java
/**
 * 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");
}
 
源代码7 项目: dragonwell8_jdk   文件: DHPrivateKey.java
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;
    }
}
 
源代码8 项目: dragonwell8_jdk   文件: PBKDF2HmacSHA1Factory.java
/**
 * 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");
}
 
源代码9 项目: openjdk-jdk9   文件: PBKDF2HmacSHA1Factory.java
/**
 * 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");
}
 
源代码10 项目: openjdk-jdk9   文件: DSAPrivateKey.java
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;
    }
}
 
源代码11 项目: jdk8u-jdk   文件: DSAPrivateKey.java
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;
    }
}
 
源代码12 项目: TencentKona-8   文件: PBKDF2Core.java
/**
 * 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");
}
 
源代码13 项目: openjdk-jdk8u-backup   文件: PBKDF2Core.java
/**
 * 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");
}
 
源代码14 项目: openjdk-jdk8u-backup   文件: DHPrivateKey.java
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;
    }
}
 
源代码15 项目: jdk8u-jdk   文件: PBKDF2Core.java
/**
 * 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");
}
 
源代码16 项目: jdk8u60   文件: PBKDF2Core.java
/**
 * 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");
}
 
源代码17 项目: jdk8u-jdk   文件: DHPrivateKey.java
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;
    }
}
 
源代码18 项目: jdk8u-jdk   文件: PBKDF2HmacSHA1Factory.java
/**
 * 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");
}
 
源代码19 项目: openjdk-jdk8u   文件: DHPrivateKey.java
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;
    }
}
 
源代码20 项目: openjdk-jdk8u   文件: PBKDF2HmacSHA1Factory.java
/**
 * 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");
}