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

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

源代码1 项目: signature   文件: ITSUtils.java
/**
 * create by: iizvv
 * description: 获取Token
 * create time: 2019-06-29 15:14
 *

 * @return 请求头
 */
static Map getToken(String p8, String iss, String kid) {
    String s = p8.
            replace("-----BEGIN PRIVATE KEY-----", "").
            replace("-----END PRIVATE KEY-----", "");
    byte[] encodeKey = Base64.decode(s);
    String token = null;
    try {
        token = Jwts.builder().
                setHeaderParam(JwsHeader.ALGORITHM, "ES256").
                setHeaderParam(JwsHeader.KEY_ID,kid).
                setHeaderParam(JwsHeader.TYPE, "JWT").

                setIssuer(iss).
                claim("exp", System.currentTimeMillis()/1000 +  60 * 10).
                setAudience("appstoreconnect-v1").
                signWith(SignatureAlgorithm.ES256, new ECPrivateKeyImpl(encodeKey)).
                compact();
    } catch (InvalidKeyException e) {
        e.printStackTrace();
    }
    Map map = new HashMap();
    map.put("Content-Type", "application/json");
    map.put("Authorization", "Bearer " + token);
    return map;
}
 
源代码2 项目: Bytecoder   文件: PKCS8Key.java
/**
 * Serialization read ... PKCS#8 keys serialize as
 * themselves, and they're parsed when they get read back.
 */
@java.io.Serial
private void readObject (ObjectInputStream stream)
throws IOException {

    try {
        decode(stream);

    } catch (InvalidKeyException e) {
        e.printStackTrace();
        throw new IOException("deserialized key is invalid: " +
                              e.getMessage());
    }
}
 
源代码3 项目: GOAi   文件: CommonUtil.java
/**
 * hmac HmacSHA256
 *
 * @param message 信息
 * @param secret  秘钥
 * @return 加密结果
 */
public static String hmacSha256(String message, String secret) {
    Exception exception = null;
    try {
        Mac mac = Mac.getInstance("HmacSHA256");
        SecretKeySpec secretKeySpec = new SecretKeySpec(secret.getBytes(), "HmacSHA256");
        mac.init(secretKeySpec);
        return HexUtil.hexEncode(mac.doFinal(message.getBytes()), false);
    } catch (NoSuchAlgorithmException ignored) {
    } catch (InvalidKeyException e) {
        e.printStackTrace();
        exception = e;
    }
    throw new ExchangeException("hmacSha256 error.", exception);
}
 
源代码4 项目: VyAPI   文件: ContactAdapter.java
@Override
public void onBindViewHolder(@NonNull ContactHolder holder, final int position) {
    Contact currentContact = contacts.get(position);
    holder.tvName.setText(currentContact.getFname() + " " + currentContact.getLname());
    holder.tvWebsite.setText(currentContact.getWebsite());

    holder.tvName.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            index = position;
            notifyDataSetChanged();
        }
    });

    if(index == position){
        HomeFragment.selected_id = currentContact.getId();
        HomeFragment.selected_fname = currentContact.getFname();
        HomeFragment.selected_lname = currentContact.getLname();
        try {
            HomeFragment.selected_phonenumber = CreateContactFragment.decrypt(currentContact.getPhonenumber());
            HomeFragment.selected_email = CreateContactFragment.decrypt(currentContact.getEmail());
        } catch (InvalidKeyException e) {
            e.printStackTrace();
        }
        HomeFragment.selected_website = currentContact.getWebsite();
        HomeFragment.selected_location = currentContact.getLocation();

        holder.tvName.setTextColor(Color.parseColor("#0033cc"));
    }else {
        holder.tvName.setTextColor(Color.parseColor("#000000"));
    }
}
 
源代码5 项目: jdk8u-jdk   文件: PKCS8Key.java
/**
 * Serialization read ... PKCS#8 keys serialize as
 * themselves, and they're parsed when they get read back.
 */
private void readObject (ObjectInputStream stream)
throws IOException {

    try {
        decode(stream);

    } catch (InvalidKeyException e) {
        e.printStackTrace();
        throw new IOException("deserialized key is invalid: " +
                              e.getMessage());
    }
}
 
源代码6 项目: dragonwell8_jdk   文件: PKCS8Key.java
/**
 * Serialization read ... PKCS#8 keys serialize as
 * themselves, and they're parsed when they get read back.
 */
private void readObject (ObjectInputStream stream)
throws IOException {

    try {
        decode(stream);

    } catch (InvalidKeyException e) {
        e.printStackTrace();
        throw new IOException("deserialized key is invalid: " +
                              e.getMessage());
    }
}
 
源代码7 项目: openjdk-jdk9   文件: X509Key.java
/**
 * Serialization read ... X.509 keys serialize as
 * themselves, and they're parsed when they get read back.
 */
private void readObject(ObjectInputStream stream) throws IOException {
    try {
        decode(stream);
    } catch (InvalidKeyException e) {
        e.printStackTrace();
        throw new IOException("deserialized key is invalid: " +
                              e.getMessage());
    }
}
 
源代码8 项目: TencentKona-8   文件: PKCS8Key.java
/**
 * Serialization read ... PKCS#8 keys serialize as
 * themselves, and they're parsed when they get read back.
 */
private void readObject (ObjectInputStream stream)
throws IOException {

    try {
        decode(stream);

    } catch (InvalidKeyException e) {
        e.printStackTrace();
        throw new IOException("deserialized key is invalid: " +
                              e.getMessage());
    }
}
 
源代码9 项目: jdk8u60   文件: X509Key.java
/**
 * Serialization read ... X.509 keys serialize as
 * themselves, and they're parsed when they get read back.
 */
private void readObject(ObjectInputStream stream) throws IOException {
    try {
        decode(stream);
    } catch (InvalidKeyException e) {
        e.printStackTrace();
        throw new IOException("deserialized key is invalid: " +
                              e.getMessage());
    }
}
 
源代码10 项目: jdk8u60   文件: PKCS8Key.java
/**
 * Serialization read ... PKCS#8 keys serialize as
 * themselves, and they're parsed when they get read back.
 */
private void readObject (ObjectInputStream stream)
throws IOException {

    try {
        decode(stream);

    } catch (InvalidKeyException e) {
        e.printStackTrace();
        throw new IOException("deserialized key is invalid: " +
                              e.getMessage());
    }
}
 
源代码11 项目: openjdk-jdk9   文件: PKCS8Key.java
/**
 * Serialization read ... PKCS#8 keys serialize as
 * themselves, and they're parsed when they get read back.
 */
private void readObject (ObjectInputStream stream)
throws IOException {

    try {
        decode(stream);

    } catch (InvalidKeyException e) {
        e.printStackTrace();
        throw new IOException("deserialized key is invalid: " +
                              e.getMessage());
    }
}
 
源代码12 项目: bumblebench   文件: HMACBench.java
protected long doBatch(long numBytes) throws InterruptedException {
    long numIterations = java.lang.Math.round((double)numBytes/data.length);
    try{
        for (long i = 0; i < numIterations; i++) {
            mac.init(key);
            byte[] result = mac.doFinal(data);
        }
    } catch (InvalidKeyException e){
        e.printStackTrace();
    }
    return numIterations*data.length;
}
 
源代码13 项目: julongchain   文件: RsaImpl.java
/**
 * 获取ASN.1 格式公钥编码
 * @param n     N
 * @param e     E
 * @return 公钥编码
 * @throws CspException
 */
private static byte[] getPublicDer(BigInteger n, BigInteger e) throws CspException{
    try {
        RSAPublicKeyImpl rsapublickeyimpl = new RSAPublicKeyImpl(n, e);
        return rsapublickeyimpl.getEncoded();
    }catch( InvalidKeyException ex){
        ex.printStackTrace();
        String err = String.format("[JC_PKCS]:InvalidKeyException ErrMessage: %s", ex.getMessage());
        setLoggerErr(err, 0);
        throw new CspException(err, ex.getCause());
    }
}
 
源代码14 项目: BlockchainWallet-Crypto   文件: HmacSha512.java
private static Mac initialize(final byte[] byteKey) {
    final Mac hmacSha512 = getInstance(HMAC_SHA512);
    final SecretKeySpec keySpec = new SecretKeySpec(byteKey, HMAC_SHA512);
    try {
        hmacSha512.init(keySpec);
    } catch (InvalidKeyException e) {
        e.printStackTrace();
    }
    return hmacSha512;
}
 
源代码15 项目: openjdk-jdk8u   文件: X509Key.java
/**
 * Serialization read ... X.509 keys serialize as
 * themselves, and they're parsed when they get read back.
 */
private void readObject(ObjectInputStream stream) throws IOException {
    try {
        decode(stream);
    } catch (InvalidKeyException e) {
        e.printStackTrace();
        throw new IOException("deserialized key is invalid: " +
                              e.getMessage());
    }
}
 
源代码16 项目: openjdk-jdk8u   文件: PKCS8Key.java
/**
 * Serialization read ... PKCS#8 keys serialize as
 * themselves, and they're parsed when they get read back.
 */
private void readObject (ObjectInputStream stream)
throws IOException {

    try {
        decode(stream);

    } catch (InvalidKeyException e) {
        e.printStackTrace();
        throw new IOException("deserialized key is invalid: " +
                              e.getMessage());
    }
}
 
源代码17 项目: mts   文件: PluggableParameterOperatorBinary.java
private static byte[][] deriveSRTPKeys(Cipher AEScipher, long index, long keyDerivationRate, byte[] masterSalt, byte[] masterKey) throws UnsupportedEncodingException
{
	byte[] iv = new byte[16];
	byte[] encKey = new byte[16];
	byte[] authKey = new byte[20];
	byte[] saltKey = new byte[14];
	byte[][] ret = new byte[3][];
	long label = 0;

    // compute the session encryption key
    computeIv(iv, label, index, keyDerivationRate, masterSalt);
    SecretKey encryptionKey = new SecretKeySpec(masterKey, 0, 16, "AES");
    
    try 
    {
        AEScipher.init(Cipher.ENCRYPT_MODE, encryptionKey);
    } 
    catch (InvalidKeyException e1) 
    {
        e1.printStackTrace();
    }
    
    getCipherStream(AEScipher, encKey, 16, iv);
    
    label = 0x01;
    computeIv(iv, label, index, keyDerivationRate, masterSalt);
    getCipherStream(AEScipher, authKey, 20, iv);

    label = 0x02;
    computeIv(iv, label, index, keyDerivationRate, masterSalt);
    getCipherStream(AEScipher, saltKey, 14, iv);       
    ret[0] = encKey;
    ret[1] = authKey;
    ret[2] = saltKey;
    return ret;
}
 
源代码18 项目: openjdk-jdk8u-backup   文件: X509Key.java
/**
 * Serialization read ... X.509 keys serialize as
 * themselves, and they're parsed when they get read back.
 */
private void readObject(ObjectInputStream stream) throws IOException {
    try {
        decode(stream);
    } catch (InvalidKeyException e) {
        e.printStackTrace();
        throw new IOException("deserialized key is invalid: " +
                              e.getMessage());
    }
}
 
源代码19 项目: openjdk-jdk8u-backup   文件: PKCS8Key.java
/**
 * Serialization read ... PKCS#8 keys serialize as
 * themselves, and they're parsed when they get read back.
 */
private void readObject (ObjectInputStream stream)
throws IOException {

    try {
        decode(stream);

    } catch (InvalidKeyException e) {
        e.printStackTrace();
        throw new IOException("deserialized key is invalid: " +
                              e.getMessage());
    }
}
 
源代码20 项目: Bytecoder   文件: X509Key.java
/**
 * Serialization read ... X.509 keys serialize as
 * themselves, and they're parsed when they get read back.
 */
@java.io.Serial
private void readObject(ObjectInputStream stream) throws IOException {
    try {
        decode(stream);
    } catch (InvalidKeyException e) {
        e.printStackTrace();
        throw new IOException("deserialized key is invalid: " +
                              e.getMessage());
    }
}