@@ -1177,14 +1177,9 @@ private EncryptedData encryptData(
11771177 LOG .debug ("Actual cipher.outputSize = "
11781178 + Integer .toString (encryptedBytes .length ));
11791179 }
1180- } catch (IllegalStateException ise ) {
1181- throw new XMLEncryptionException (ise );
1182- } catch (IllegalBlockSizeException ibse ) {
1183- throw new XMLEncryptionException (ibse );
1184- } catch (BadPaddingException bpe ) {
1185- throw new XMLEncryptionException (bpe );
1186- } catch (UnsupportedEncodingException uee ) {
1187- throw new XMLEncryptionException (uee );
1180+ } catch (IllegalStateException | IllegalBlockSizeException
1181+ | BadPaddingException | UnsupportedEncodingException e ) {
1182+ throw new XMLEncryptionException (e );
11881183 }
11891184
11901185 // Get IV from Cipher Object. If this is null (see BouncyCastle issue BJA-473) then use
@@ -1404,11 +1399,7 @@ public EncryptedKey encryptKey(
14041399 }
14051400 }
14061401 encryptedBytes = c .wrap (key );
1407- } catch (InvalidKeyException ike ) {
1408- throw new XMLEncryptionException (ike );
1409- } catch (IllegalBlockSizeException ibse ) {
1410- throw new XMLEncryptionException (ibse );
1411- } catch (InvalidAlgorithmParameterException e ) {
1402+ } catch (InvalidKeyException | IllegalBlockSizeException | InvalidAlgorithmParameterException e ) {
14121403 throw new XMLEncryptionException (e );
14131404 }
14141405
@@ -1512,11 +1503,7 @@ public Key decryptKey(EncryptedKey encryptedKey, String algorithm)
15121503 c .init (Cipher .UNWRAP_MODE , key , oaepParameters );
15131504 }
15141505 ret = c .unwrap (encryptedBytes , jceKeyAlgorithm , Cipher .SECRET_KEY );
1515- } catch (InvalidKeyException ike ) {
1516- throw new XMLEncryptionException (ike );
1517- } catch (NoSuchAlgorithmException nsae ) {
1518- throw new XMLEncryptionException ( nsae );
1519- } catch (InvalidAlgorithmParameterException e ) {
1506+ } catch (InvalidKeyException | NoSuchAlgorithmException | InvalidAlgorithmParameterException e ) {
15201507 throw new XMLEncryptionException (e );
15211508 }
15221509 LOG .debug ("Decryption of key type {} OK" , algorithm );
@@ -1580,10 +1567,8 @@ private Cipher constructCipher(String algorithm, String digestAlgorithm) throws
15801567 // Check to see if an RSA OAEP MGF-1 with SHA-1 algorithm was requested
15811568 // Some JDKs don't support RSA/ECB/OAEPPadding
15821569 c = constructCipher (algorithm , digestAlgorithm , nsae );
1583- } catch (NoSuchProviderException nspre ) {
1584- throw new XMLEncryptionException (nspre );
1585- } catch (NoSuchPaddingException nspae ) {
1586- throw new XMLEncryptionException (nspae );
1570+ } catch (NoSuchProviderException | NoSuchPaddingException e ) {
1571+ throw new XMLEncryptionException (e );
15871572 }
15881573
15891574 return c ;
@@ -1791,12 +1776,8 @@ public byte[] decryptToByteArray(Element element) throws XMLEncryptionException
17911776 } else {
17921777 c = Cipher .getInstance (jceAlgorithm , requestedJCEProvider );
17931778 }
1794- } catch (NoSuchAlgorithmException nsae ) {
1795- throw new XMLEncryptionException (nsae );
1796- } catch (NoSuchProviderException nspre ) {
1797- throw new XMLEncryptionException (nspre );
1798- } catch (NoSuchPaddingException nspae ) {
1799- throw new XMLEncryptionException (nspae );
1779+ } catch (NoSuchAlgorithmException | NoSuchProviderException | NoSuchPaddingException e ) {
1780+ throw new XMLEncryptionException (e );
18001781 }
18011782
18021783 int ivLen = JCEMapper .getIVLengthFromURI (encMethodAlgorithm ) / 8 ;
@@ -1817,18 +1798,14 @@ public byte[] decryptToByteArray(Element element) throws XMLEncryptionException
18171798
18181799 try {
18191800 c .init (cipherMode , key , paramSpec );
1820- } catch (InvalidKeyException ike ) {
1821- throw new XMLEncryptionException (ike );
1822- } catch (InvalidAlgorithmParameterException iape ) {
1823- throw new XMLEncryptionException (iape );
1801+ } catch (InvalidKeyException | InvalidAlgorithmParameterException e ) {
1802+ throw new XMLEncryptionException (e );
18241803 }
18251804
18261805 try {
18271806 return c .doFinal (encryptedBytes , ivLen , encryptedBytes .length - ivLen );
1828- } catch (IllegalBlockSizeException ibse ) {
1829- throw new XMLEncryptionException (ibse );
1830- } catch (BadPaddingException bpe ) {
1831- throw new XMLEncryptionException (bpe );
1807+ } catch (IllegalBlockSizeException | BadPaddingException e ) {
1808+ throw new XMLEncryptionException (e );
18321809 }
18331810 }
18341811
@@ -2209,12 +2186,8 @@ CipherReference newCipherReference(Element element) throws XMLEncryptionExceptio
22092186 LOG .debug ("Creating a DSIG based Transforms element" );
22102187 try {
22112188 result .setTransforms (new TransformsImpl (transformsElement ));
2212- } catch (XMLSignatureException xse ) {
2213- throw new XMLEncryptionException (xse );
2214- } catch (InvalidTransformException ite ) {
2215- throw new XMLEncryptionException (ite );
2216- } catch (XMLSecurityException xse ) {
2217- throw new XMLEncryptionException (xse );
2189+ } catch (XMLSecurityException e ) {
2190+ throw new XMLEncryptionException (e );
22182191 }
22192192 }
22202193
@@ -2554,7 +2527,7 @@ public AgreementMethodImpl(String algorithm) {
25542527 tmpAlgorithm = new URI (algorithm );
25552528 } catch (URISyntaxException ex ) {
25562529 throw (IllegalArgumentException )
2557- new IllegalArgumentException ().initCause (ex );
2530+ new IllegalArgumentException ().initCause (ex );
25582531 }
25592532 algorithmURI = tmpAlgorithm .toString ();
25602533 }
@@ -2970,7 +2943,7 @@ public void setType(String type) {
29702943 tmpType = new URI (type );
29712944 } catch (URISyntaxException ex ) {
29722945 throw (IllegalArgumentException )
2973- new IllegalArgumentException ().initCause (ex );
2946+ new IllegalArgumentException ().initCause (ex );
29742947 }
29752948 this .type = tmpType .toString ();
29762949 }
@@ -3012,7 +2985,7 @@ public void setEncoding(String encoding) {
30122985 tmpEncoding = new URI (encoding );
30132986 } catch (URISyntaxException ex ) {
30142987 throw (IllegalArgumentException )
3015- new IllegalArgumentException ().initCause (ex );
2988+ new IllegalArgumentException ().initCause (ex );
30162989 }
30172990 this .encoding = tmpEncoding .toString ();
30182991 }
@@ -3093,7 +3066,7 @@ public EncryptionMethodImpl(String algorithm) {
30933066 tmpAlgorithm = new URI (algorithm );
30943067 } catch (URISyntaxException ex ) {
30953068 throw (IllegalArgumentException )
3096- new IllegalArgumentException ().initCause (ex );
3069+ new IllegalArgumentException ().initCause (ex );
30973070 }
30983071 this .algorithm = tmpAlgorithm .toString ();
30993072 encryptionMethodInformation = new LinkedList <>();
@@ -3300,7 +3273,7 @@ public void setTarget(String target) {
33003273 tmpTarget = new URI (target );
33013274 } catch (URISyntaxException ex ) {
33023275 throw (IllegalArgumentException )
3303- new IllegalArgumentException ().initCause (ex );
3276+ new IllegalArgumentException ().initCause (ex );
33043277 }
33053278 this .target = tmpTarget .toString ();
33063279 }
0 commit comments