mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
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
7 changed files with 24 additions and 16 deletions
|
@ -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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -160,7 +160,7 @@ public final class CertAndKeyGen {
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new IllegalArgumentException(e.getMessage());
|
throw new IllegalArgumentException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
generateInternal();
|
generateInternal();
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@ public final class CertAndKeyGen {
|
||||||
keyGen.initialize(keyBits, prng);
|
keyGen.initialize(keyBits, prng);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new IllegalArgumentException(e.getMessage());
|
throw new IllegalArgumentException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
generateInternal();
|
generateInternal();
|
||||||
|
@ -349,7 +349,7 @@ public final class CertAndKeyGen {
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new CertificateEncodingException("getSelfCert: " +
|
throw new CertificateEncodingException("getSelfCert: " +
|
||||||
e.getMessage());
|
e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -358,7 +358,7 @@ final class Config {
|
||||||
try {
|
try {
|
||||||
return PropertyExpander.expand(s);
|
return PropertyExpander.expand(s);
|
||||||
} catch (Exception e) {
|
} 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());
|
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 {
|
private void parse() throws IOException {
|
||||||
while (true) {
|
while (true) {
|
||||||
int token = nextToken();
|
int token = nextToken();
|
||||||
|
@ -817,7 +821,7 @@ final class Config {
|
||||||
try {
|
try {
|
||||||
return Functions.getMechanismId(mech);
|
return Functions.getMechanismId(mech);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
throw excLine("Unknown mechanism: " + mech);
|
throw excLine("Unknown mechanism: " + mech, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -977,7 +981,7 @@ final class Config {
|
||||||
try {
|
try {
|
||||||
return Functions.getObjectClassId(name);
|
return Functions.getObjectClassId(name);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
throw excLine("Unknown object class " + name);
|
throw excLine("Unknown object class " + name, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -989,7 +993,7 @@ final class Config {
|
||||||
try {
|
try {
|
||||||
return Functions.getKeyId(name);
|
return Functions.getKeyId(name);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
throw excLine("Unknown key algorithm " + name);
|
throw excLine("Unknown key algorithm " + name, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1001,7 +1005,7 @@ final class Config {
|
||||||
try {
|
try {
|
||||||
return Functions.getAttributeId(name);
|
return Functions.getAttributeId(name);
|
||||||
} catch (IllegalArgumentException e) {
|
} 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) {
|
ConfigurationException(String msg) {
|
||||||
super(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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -140,7 +140,7 @@ final class P11AEADCipher extends CipherSpi {
|
||||||
try {
|
try {
|
||||||
engineSetPadding(algoParts[2]);
|
engineSetPadding(algoParts[2]);
|
||||||
} catch (NoSuchPaddingException e) {
|
} catch (NoSuchPaddingException e) {
|
||||||
throw new NoSuchAlgorithmException();
|
throw new NoSuchAlgorithmException(e);
|
||||||
}
|
}
|
||||||
} else if (algoParts[0].equals("ChaCha20-Poly1305")) {
|
} else if (algoParts[0].equals("ChaCha20-Poly1305")) {
|
||||||
fixedKeySize = 32;
|
fixedKeySize = 32;
|
||||||
|
|
|
@ -151,7 +151,7 @@ final class P11KeyPairGenerator extends KeyPairGeneratorSpi {
|
||||||
try {
|
try {
|
||||||
checkKeySize(keySize, null);
|
checkKeySize(keySize, null);
|
||||||
} catch (InvalidAlgorithmParameterException e) {
|
} catch (InvalidAlgorithmParameterException e) {
|
||||||
throw new InvalidParameterException(e.getMessage());
|
throw (InvalidParameterException) new InvalidParameterException(e.getMessage()).initCause(e);
|
||||||
}
|
}
|
||||||
this.params = null;
|
this.params = null;
|
||||||
if (algorithm.equals("EC")) {
|
if (algorithm.equals("EC")) {
|
||||||
|
|
|
@ -1332,7 +1332,7 @@ final class P11KeyStore extends KeyStoreSpi {
|
||||||
RSAKeyFactory.checkKeyLengths(keyLength, null,
|
RSAKeyFactory.checkKeyLengths(keyLength, null,
|
||||||
-1, Integer.MAX_VALUE);
|
-1, Integer.MAX_VALUE);
|
||||||
} catch (InvalidKeyException e) {
|
} catch (InvalidKeyException e) {
|
||||||
throw new KeyStoreException(e.getMessage());
|
throw new KeyStoreException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return P11Key.privateKey(session,
|
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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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
|
padding = RSAPadding.getInstance
|
||||||
(RSAPadding.PAD_BLOCKTYPE_1, (len + 7) >> 3);
|
(RSAPadding.PAD_BLOCKTYPE_1, (len + 7) >> 3);
|
||||||
} catch (InvalidAlgorithmParameterException iape) {
|
} catch (InvalidAlgorithmParameterException iape) {
|
||||||
throw new InvalidKeyException(iape.getMessage());
|
throw new InvalidKeyException(iape.getMessage(), iape);
|
||||||
}
|
}
|
||||||
int maxDataSize = padding.getMaxDataSize();
|
int maxDataSize = padding.getMaxDataSize();
|
||||||
int encodedLength = switch (algorithm) {
|
int encodedLength = switch (algorithm) {
|
||||||
|
@ -809,7 +809,7 @@ final class P11Signature extends SignatureSpi {
|
||||||
DerValue result = new DerValue(DerValue.tag_Sequence,
|
DerValue result = new DerValue(DerValue.tag_Sequence,
|
||||||
outseq.toByteArray());
|
outseq.toByteArray());
|
||||||
return result.toByteArray();
|
return result.toByteArray();
|
||||||
} catch (java.io.IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException("Internal error", e);
|
throw new RuntimeException("Internal error", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue