8295405: Add cause in a couple of IllegalArgumentException and InvalidParameterException shown by sun/security/pkcs11 tests
Reviewed-by: mdoerr, mullan
This commit is contained in:
parent
fd668dc44f
commit
d5d34241e2
src
java.base/share/classes/sun/security/tools/keytool
jdk.crypto.cryptoki/share/classes/sun/security/pkcs11
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -160,7 +160,7 @@ public final class CertAndKeyGen {
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException(e.getMessage());
|
||||
throw new IllegalArgumentException(e.getMessage(), e);
|
||||
}
|
||||
generateInternal();
|
||||
}
|
||||
@ -176,7 +176,7 @@ public final class CertAndKeyGen {
|
||||
keyGen.initialize(keyBits, prng);
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException(e.getMessage());
|
||||
throw new IllegalArgumentException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
generateInternal();
|
||||
@ -349,7 +349,7 @@ public final class CertAndKeyGen {
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new CertificateEncodingException("getSelfCert: " +
|
||||
e.getMessage());
|
||||
e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -358,7 +358,7 @@ final class Config {
|
||||
try {
|
||||
return PropertyExpander.expand(s);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e.getMessage());
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -396,6 +396,10 @@ final class Config {
|
||||
return new ConfigurationException(msg + ", line " + st.lineno());
|
||||
}
|
||||
|
||||
private ConfigurationException excLine(String msg, Throwable e) {
|
||||
return new ConfigurationException(msg + ", line " + st.lineno(), e);
|
||||
}
|
||||
|
||||
private void parse() throws IOException {
|
||||
while (true) {
|
||||
int token = nextToken();
|
||||
@ -817,7 +821,7 @@ final class Config {
|
||||
try {
|
||||
return Functions.getMechanismId(mech);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw excLine("Unknown mechanism: " + mech);
|
||||
throw excLine("Unknown mechanism: " + mech, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -977,7 +981,7 @@ final class Config {
|
||||
try {
|
||||
return Functions.getObjectClassId(name);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw excLine("Unknown object class " + name);
|
||||
throw excLine("Unknown object class " + name, e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -989,7 +993,7 @@ final class Config {
|
||||
try {
|
||||
return Functions.getKeyId(name);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw excLine("Unknown key algorithm " + name);
|
||||
throw excLine("Unknown key algorithm " + name, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1001,7 +1005,7 @@ final class Config {
|
||||
try {
|
||||
return Functions.getAttributeId(name);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw excLine("Unknown attribute name " + name);
|
||||
throw excLine("Unknown attribute name " + name, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1061,4 +1065,8 @@ class ConfigurationException extends IOException {
|
||||
ConfigurationException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
ConfigurationException(String msg, Throwable e) {
|
||||
super(msg, e);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -140,7 +140,7 @@ final class P11AEADCipher extends CipherSpi {
|
||||
try {
|
||||
engineSetPadding(algoParts[2]);
|
||||
} catch (NoSuchPaddingException e) {
|
||||
throw new NoSuchAlgorithmException();
|
||||
throw new NoSuchAlgorithmException(e);
|
||||
}
|
||||
} else if (algoParts[0].equals("ChaCha20-Poly1305")) {
|
||||
fixedKeySize = 32;
|
||||
|
@ -151,7 +151,7 @@ final class P11KeyPairGenerator extends KeyPairGeneratorSpi {
|
||||
try {
|
||||
checkKeySize(keySize, null);
|
||||
} catch (InvalidAlgorithmParameterException e) {
|
||||
throw new InvalidParameterException(e.getMessage());
|
||||
throw (InvalidParameterException) new InvalidParameterException(e.getMessage()).initCause(e);
|
||||
}
|
||||
this.params = null;
|
||||
if (algorithm.equals("EC")) {
|
||||
|
@ -1332,7 +1332,7 @@ final class P11KeyStore extends KeyStoreSpi {
|
||||
RSAKeyFactory.checkKeyLengths(keyLength, null,
|
||||
-1, Integer.MAX_VALUE);
|
||||
} catch (InvalidKeyException e) {
|
||||
throw new KeyStoreException(e.getMessage());
|
||||
throw new KeyStoreException(e.getMessage(), e);
|
||||
}
|
||||
|
||||
return P11Key.privateKey(session,
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -445,7 +445,7 @@ final class P11Signature extends SignatureSpi {
|
||||
padding = RSAPadding.getInstance
|
||||
(RSAPadding.PAD_BLOCKTYPE_1, (len + 7) >> 3);
|
||||
} catch (InvalidAlgorithmParameterException iape) {
|
||||
throw new InvalidKeyException(iape.getMessage());
|
||||
throw new InvalidKeyException(iape.getMessage(), iape);
|
||||
}
|
||||
int maxDataSize = padding.getMaxDataSize();
|
||||
int encodedLength = switch (algorithm) {
|
||||
@ -809,7 +809,7 @@ final class P11Signature extends SignatureSpi {
|
||||
DerValue result = new DerValue(DerValue.tag_Sequence,
|
||||
outseq.toByteArray());
|
||||
return result.toByteArray();
|
||||
} catch (java.io.IOException e) {
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Internal error", e);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user