本文整理汇总了Java中java.security.InvalidKeyException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java InvalidKeyException.printStackTrace方法的具体用法?Java InvalidKeyException.printStackTrace怎么用?Java InvalidKeyException.printStackTrace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.security.InvalidKeyException
的用法示例。
在下文中一共展示了InvalidKeyException.printStackTrace方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTheCipherInstance
import java.security.InvalidKeyException; //导入方法依赖的package包/类
/**
* Creates the Cipher Instance.
*/
private static Cipher createTheCipherInstance(int opMode, String transformation, Key key)
{
try
{
Cipher cipher = Cipher.getInstance(transformation);
cipher.init(opMode, key);
return cipher;
}
catch (InvalidKeyException invalidkeyexception)
{
invalidkeyexception.printStackTrace();
}
catch (NoSuchAlgorithmException nosuchalgorithmexception)
{
nosuchalgorithmexception.printStackTrace();
}
catch (NoSuchPaddingException nosuchpaddingexception)
{
nosuchpaddingexception.printStackTrace();
}
LOGGER.error("Cipher creation failed!");
return null;
}
示例2: calculateECKAShS
import java.security.InvalidKeyException; //导入方法依赖的package包/类
/**
* Implement the ECKA algorithm (EG variant) in order to calculate the ShS (shared secret) from the provided
* static and ephemeral keys from the same curve.
* @param privateKey the private key to use for the ShS calculation.
* @param publicKey the public key to use for the ShS calculation.
* @return the calculated shared secret.
*/
public static byte[] calculateECKAShS(PrivateKey privateKey, PublicKey publicKey) {
try {
ECKABasicAgreement basicAgreement = new ECKABasicAgreement();
basicAgreement.init(ECUtil.generatePrivateKeyParameter(privateKey));
return basicAgreement.calculatePoint(ECUtil.generatePublicKeyParameter(publicKey)).getEncoded();
} catch (InvalidKeyException e) {
e.printStackTrace();
}
return null;
}
示例3: mac
import java.security.InvalidKeyException; //导入方法依赖的package包/类
/**
* Mac the passed string using the provided key
*
* @param key
* @param stringToMac
* @return
* @throws NoSuchAlgorithmException
* @throws InvalidKeyException
*/
private byte[] mac(byte[] key, String stringToMac) throws NoSuchAlgorithmException, InvalidKeyException {
try {
Mac m = Mac.getInstance("HmacSHA256");
m.init(new SecretKeySpec(key, "HmacSHA256"));
return m.doFinal(stringToMac.getBytes());
} catch (NoSuchAlgorithmException ex) {
ex.printStackTrace();
throw new NoSuchAlgorithmException(ex.getMessage());
} catch (InvalidKeyException ikx) {
ikx.printStackTrace();
throw new InvalidKeyException(ikx.getMessage());
}
}
示例4: createTheCipherInstance
import java.security.InvalidKeyException; //导入方法依赖的package包/类
private static Cipher createTheCipherInstance(int opMode, String transformation, Key key) {
try {
Cipher cipher = Cipher.getInstance(transformation);
cipher.init(opMode, key);
return cipher;
} catch (InvalidKeyException invalidkeyexception) {
invalidkeyexception.printStackTrace();
} catch (NoSuchAlgorithmException nosuchalgorithmexception) {
nosuchalgorithmexception.printStackTrace();
} catch (NoSuchPaddingException nosuchpaddingexception) {
nosuchpaddingexception.printStackTrace();
}
return null;
}
示例5: cipherInit
import java.security.InvalidKeyException; //导入方法依赖的package包/类
static synchronized void cipherInit(Key key, Mac mac, int opMode, Cipher cipher,
byte[] iv, byte[] ivSeed) throws InvalidAlgorithmParameterException {
try {
cipher.init(opMode, key, newIvSpec(mac, iv, ivSeed));
} catch (InvalidKeyException e) {
e.printStackTrace();
}
}
示例6: readObject
import java.security.InvalidKeyException; //导入方法依赖的package包/类
/**
* 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());
}
}
示例7: readObject
import java.security.InvalidKeyException; //导入方法依赖的package包/类
/**
* 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());
}
}