1
0
mirror of synced 2026-05-22 13:23:17 +00:00

Update exception variable names

Consistently use `ex` for caught exception and `cause` for Exception
constructor arguments.

Issue gh-8945
This commit is contained in:
Phillip Webb
2020-07-28 23:53:30 -07:00
committed by Rob Winch
parent e9130489a6
commit 8d80166aaf
194 changed files with 635 additions and 633 deletions
@@ -119,8 +119,8 @@ public class OpenSamlInitializationService {
try {
InitializationService.initialize();
}
catch (Exception e) {
throw new Saml2Exception(e);
catch (Exception ex) {
throw new Saml2Exception(ex);
}
BasicParserPool parserPool = new BasicParserPool();
@@ -139,8 +139,8 @@ public class OpenSamlInitializationService {
try {
parserPool.initialize();
}
catch (Exception e) {
throw new Saml2Exception(e);
catch (Exception ex) {
throw new Saml2Exception(ex);
}
XMLObjectProviderRegistrySupport.setParserPool(parserPool);
@@ -282,11 +282,11 @@ public final class OpenSamlAuthenticationProvider implements AuthenticationProvi
process(token, response);
return this.authenticationConverter.apply(token).convert(response);
}
catch (Saml2AuthenticationException e) {
throw e;
catch (Saml2AuthenticationException ex) {
throw ex;
}
catch (Exception e) {
throw authException(Saml2ErrorCodes.INTERNAL_VALIDATION_ERROR, e.getMessage(), e);
catch (Exception ex) {
throw authException(Saml2ErrorCodes.INTERNAL_VALIDATION_ERROR, ex.getMessage(), ex);
}
}
@@ -309,8 +309,8 @@ public final class OpenSamlAuthenticationProvider implements AuthenticationProvi
Element element = document.getDocumentElement();
return (Response) this.responseUnmarshaller.unmarshall(element);
}
catch (Exception e) {
throw authException(Saml2ErrorCodes.MALFORMED_RESPONSE_DATA, e.getMessage(), e);
catch (Exception ex) {
throw authException(Saml2ErrorCodes.MALFORMED_RESPONSE_DATA, ex.getMessage(), ex);
}
}
@@ -371,10 +371,10 @@ public final class OpenSamlAuthenticationProvider implements AuthenticationProvi
try {
profileValidator.validate(response.getSignature());
}
catch (Exception e) {
catch (Exception ex) {
validationExceptions.put(Saml2ErrorCodes.INVALID_SIGNATURE,
authException(Saml2ErrorCodes.INVALID_SIGNATURE,
"Invalid signature for SAML Response [" + response.getID() + "]: ", e));
"Invalid signature for SAML Response [" + response.getID() + "]: ", ex));
}
try {
@@ -389,10 +389,10 @@ public final class OpenSamlAuthenticationProvider implements AuthenticationProvi
"Invalid signature for SAML Response [" + response.getID() + "]"));
}
}
catch (Exception e) {
catch (Exception ex) {
validationExceptions.put(Saml2ErrorCodes.INVALID_SIGNATURE,
authException(Saml2ErrorCodes.INVALID_SIGNATURE,
"Invalid signature for SAML Response [" + response.getID() + "]: ", e));
"Invalid signature for SAML Response [" + response.getID() + "]: ", ex));
}
}
@@ -421,8 +421,8 @@ public final class OpenSamlAuthenticationProvider implements AuthenticationProvi
Assertion assertion = decrypter.decrypt(encryptedAssertion);
assertions.add(assertion);
}
catch (DecryptionException e) {
throw authException(Saml2ErrorCodes.DECRYPTION_ERROR, e.getMessage(), e);
catch (DecryptionException ex) {
throw authException(Saml2ErrorCodes.DECRYPTION_ERROR, ex.getMessage(), ex);
}
}
response.getAssertions().addAll(assertions);
@@ -457,11 +457,11 @@ public final class OpenSamlAuthenticationProvider implements AuthenticationProvi
authException(Saml2ErrorCodes.INVALID_ASSERTION, message));
}
}
catch (Exception e) {
catch (Exception ex) {
String message = String.format("Invalid assertion [%s] for SAML response [%s]: %s", assertion.getID(),
((Response) assertion.getParent()).getID(), e.getMessage());
((Response) assertion.getParent()).getID(), ex.getMessage());
validationExceptions.put(Saml2ErrorCodes.INVALID_ASSERTION,
authException(Saml2ErrorCodes.INVALID_ASSERTION, message, e));
authException(Saml2ErrorCodes.INVALID_ASSERTION, message, ex));
}
}
@@ -494,8 +494,8 @@ public final class OpenSamlAuthenticationProvider implements AuthenticationProvi
assertion.getSubject().setNameID(nameId);
return nameId;
}
catch (DecryptionException e) {
throw authException(Saml2ErrorCodes.DECRYPTION_ERROR, e.getMessage(), e);
catch (DecryptionException ex) {
throw authException(Saml2ErrorCodes.DECRYPTION_ERROR, ex.getMessage(), ex);
}
}
@@ -549,8 +549,8 @@ public final class OpenSamlAuthenticationProvider implements AuthenticationProvi
Element element = marshaller.marshall(xsAny);
return SerializeSupport.nodeToString(element);
}
catch (MarshallingException e) {
throw new Saml2Exception(e);
catch (MarshallingException ex) {
throw new Saml2Exception(ex);
}
}
return xsAny.getTextContent();
@@ -242,8 +242,8 @@ public class OpenSamlAuthenticationRequestFactory implements Saml2Authentication
SignatureSupport.signObject(authnRequest, parameters);
return authnRequest;
}
catch (MarshallingException | SignatureException | SecurityException e) {
throw new Saml2Exception(e);
catch (MarshallingException | SignatureException | SecurityException ex) {
throw new Saml2Exception(ex);
}
}
@@ -280,8 +280,8 @@ public class OpenSamlAuthenticationRequestFactory implements Saml2Authentication
result.put("Signature", b64Signature);
return result;
}
catch (SecurityException e) {
throw new Saml2Exception(e);
catch (SecurityException ex) {
throw new Saml2Exception(ex);
}
}
@@ -290,8 +290,8 @@ public class OpenSamlAuthenticationRequestFactory implements Saml2Authentication
Element element = this.marshaller.marshall(authnRequest);
return SerializeSupport.nodeToString(element);
}
catch (MarshallingException e) {
throw new Saml2Exception(e);
catch (MarshallingException ex) {
throw new Saml2Exception(ex);
}
}
@@ -51,8 +51,8 @@ final class Saml2Utils {
deflater.finish();
return b.toByteArray();
}
catch (IOException e) {
throw new Saml2Exception("Unable to deflate string", e);
catch (IOException ex) {
throw new Saml2Exception("Unable to deflate string", ex);
}
}
@@ -64,8 +64,8 @@ final class Saml2Utils {
iout.finish();
return new String(out.toByteArray(), StandardCharsets.UTF_8);
}
catch (IOException e) {
throw new Saml2Exception("Unable to inflate string", e);
catch (IOException ex) {
throw new Saml2Exception("Unable to inflate string", ex);
}
}
@@ -111,7 +111,7 @@ public final class OpenSamlMetadataResolver implements Saml2MetadataResolver {
try {
x509Certificate.setValue(new String(Base64.getEncoder().encode(certificate.getEncoded())));
}
catch (CertificateEncodingException e) {
catch (CertificateEncodingException ex) {
throw new Saml2Exception("Cannot encode certificate " + certificate.toString());
}
@@ -145,8 +145,8 @@ public final class OpenSamlMetadataResolver implements Saml2MetadataResolver {
Element element = this.entityDescriptorMarshaller.marshall(entityDescriptor);
return SerializeSupport.prettyPrintXML(element);
}
catch (Exception e) {
throw new Saml2Exception(e);
catch (Exception ex) {
throw new Saml2Exception(ex);
}
}
@@ -187,8 +187,8 @@ public class OpenSamlRelyingPartyRegistrationBuilderHttpMessageConverter
try {
return KeyInfoSupport.getCertificates(keyDescriptor.getKeyInfo());
}
catch (CertificateException e) {
throw new Saml2Exception(e);
catch (CertificateException ex) {
throw new Saml2Exception(ex);
}
}
@@ -198,8 +198,8 @@ public class OpenSamlRelyingPartyRegistrationBuilderHttpMessageConverter
Element element = document.getDocumentElement();
return (EntityDescriptor) this.unmarshaller.unmarshall(element);
}
catch (Exception e) {
throw new Saml2Exception(e);
catch (Exception ex) {
throw new Saml2Exception(ex);
}
}
@@ -60,11 +60,11 @@ public final class RelyingPartyRegistrations {
try {
return rest.getForObject(metadataLocation, RelyingPartyRegistration.Builder.class);
}
catch (RestClientException e) {
if (e.getCause() instanceof Saml2Exception) {
throw (Saml2Exception) e.getCause();
catch (RestClientException ex) {
if (ex.getCause() instanceof Saml2Exception) {
throw (Saml2Exception) ex.getCause();
}
throw new Saml2Exception(e);
throw new Saml2Exception(ex);
}
}
@@ -99,8 +99,8 @@ public final class Saml2AuthenticationTokenConverter implements AuthenticationCo
iout.finish();
return new String(out.toByteArray(), StandardCharsets.UTF_8);
}
catch (IOException e) {
throw new Saml2Exception("Unable to inflate string", e);
catch (IOException ex) {
throw new Saml2Exception("Unable to inflate string", ex);
}
}
@@ -48,8 +48,8 @@ public final class Saml2Utils {
deflater.finish();
return b.toByteArray();
}
catch (IOException e) {
throw new Saml2Exception("Unable to deflate string", e);
catch (IOException ex) {
throw new Saml2Exception("Unable to deflate string", ex);
}
}
@@ -61,8 +61,8 @@ public final class Saml2Utils {
iout.finish();
return new String(out.toByteArray(), StandardCharsets.UTF_8);
}
catch (IOException e) {
throw new Saml2Exception("Unable to inflate string", e);
catch (IOException ex) {
throw new Saml2Exception("Unable to inflate string", ex);
}
}
@@ -61,8 +61,8 @@ public final class TestSaml2X509Credentials {
try {
return (X509Certificate) CertificateFactory.getInstance("X.509").generateCertificate(certBytes);
}
catch (CertificateException e) {
throw new Saml2Exception(e);
catch (CertificateException ex) {
throw new Saml2Exception(ex);
}
}
@@ -70,8 +70,8 @@ public final class TestSaml2X509Credentials {
try {
return KeySupport.decodePrivateKey(key.getBytes(StandardCharsets.UTF_8), new char[0]);
}
catch (KeyException e) {
throw new Saml2Exception(e);
catch (KeyException ex) {
throw new Saml2Exception(ex);
}
}
@@ -61,8 +61,8 @@ public final class TestSaml2X509Credentials {
try {
return (X509Certificate) CertificateFactory.getInstance("X.509").generateCertificate(certBytes);
}
catch (CertificateException e) {
throw new Saml2Exception(e);
catch (CertificateException ex) {
throw new Saml2Exception(ex);
}
}
@@ -70,8 +70,8 @@ public final class TestSaml2X509Credentials {
try {
return KeySupport.decodePrivateKey(key.getBytes(StandardCharsets.UTF_8), new char[0]);
}
catch (KeyException e) {
throw new Saml2Exception(e);
catch (KeyException ex) {
throw new Saml2Exception(ex);
}
}
@@ -436,8 +436,8 @@ public class OpenSamlAuthenticationProviderTests {
Element element = marshaller.marshall(object);
return SerializeSupport.nodeToString(element);
}
catch (MarshallingException e) {
throw new Saml2Exception(e);
catch (MarshallingException ex) {
throw new Saml2Exception(ex);
}
}
@@ -226,8 +226,8 @@ public class OpenSamlAuthenticationRequestFactoryTests {
Element element = document.getDocumentElement();
return (AuthnRequest) this.unmarshaller.unmarshall(element);
}
catch (Exception e) {
throw new Saml2Exception(e);
catch (Exception ex) {
throw new Saml2Exception(ex);
}
}
@@ -210,8 +210,8 @@ final class TestOpenSamlObjects {
try {
SignatureSupport.signObject(signable, parameters);
}
catch (MarshallingException | SignatureException | SecurityException e) {
throw new Saml2Exception(e);
catch (MarshallingException | SignatureException | SecurityException ex) {
throw new Saml2Exception(ex);
}
return signable;
@@ -228,8 +228,8 @@ final class TestOpenSamlObjects {
try {
SignatureSupport.signObject(signable, parameters);
}
catch (MarshallingException | SignatureException | SecurityException e) {
throw new Saml2Exception(e);
catch (MarshallingException | SignatureException | SecurityException ex) {
throw new Saml2Exception(ex);
}
return signable;
@@ -241,8 +241,8 @@ final class TestOpenSamlObjects {
try {
return encrypter.encrypt(assertion);
}
catch (EncryptionException e) {
throw new Saml2Exception("Unable to encrypt assertion.", e);
catch (EncryptionException ex) {
throw new Saml2Exception("Unable to encrypt assertion.", ex);
}
}
@@ -253,8 +253,8 @@ final class TestOpenSamlObjects {
try {
return encrypter.encrypt(assertion);
}
catch (EncryptionException e) {
throw new Saml2Exception("Unable to encrypt assertion.", e);
catch (EncryptionException ex) {
throw new Saml2Exception("Unable to encrypt assertion.", ex);
}
}
@@ -264,8 +264,8 @@ final class TestOpenSamlObjects {
try {
return encrypter.encrypt(nameId);
}
catch (EncryptionException e) {
throw new Saml2Exception("Unable to encrypt nameID.", e);
catch (EncryptionException ex) {
throw new Saml2Exception("Unable to encrypt nameID.", ex);
}
}
@@ -276,8 +276,8 @@ final class TestOpenSamlObjects {
try {
return encrypter.encrypt(nameId);
}
catch (EncryptionException e) {
throw new Saml2Exception("Unable to encrypt nameID.", e);
catch (EncryptionException ex) {
throw new Saml2Exception("Unable to encrypt nameID.", ex);
}
}
@@ -130,8 +130,8 @@ public class OpenSamlRelyingPartyRegistrationBuilderHttpMessageConverterTests {
InputStream certificate = new ByteArrayInputStream(Base64.getDecoder().decode(data.getBytes()));
return (X509Certificate) CertificateFactory.getInstance("X.509").generateCertificate(certificate);
}
catch (Exception e) {
throw new IllegalArgumentException(e);
catch (Exception ex) {
throw new IllegalArgumentException(ex);
}
}
@@ -92,9 +92,9 @@ public class Saml2WebSsoAuthenticationFilterTests {
this.filter.attemptAuthentication(this.request, this.response);
failBecauseExceptionWasNotThrown(Saml2AuthenticationException.class);
}
catch (Exception e) {
assertThat(e).isInstanceOf(Saml2AuthenticationException.class);
assertThat(e.getMessage()).isEqualTo("No relying party registration found");
catch (Exception ex) {
assertThat(ex).isInstanceOf(Saml2AuthenticationException.class);
assertThat(ex.getMessage()).isEqualTo("No relying party registration found");
}
}