You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by co...@apache.org on 2015/02/18 12:50:41 UTC
svn commit: r1660601 - in
/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax:
./ ext/ impl/processor/input/ impl/processor/output/ impl/securityToken/
Author: coheigea
Date: Wed Feb 18 11:50:41 2015
New Revision: 1660601
URL: http://svn.apache.org/r1660601
Log:
Multi catch refactoring
Modified:
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/ConfigurationConverter.java
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/WSSec.java
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/ext/WSSUtils.java
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/input/DecryptInputProcessor.java
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/input/SecurityHeaderInputProcessor.java
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/EncryptOutputProcessor.java
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/EncryptedKeyOutputProcessor.java
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/WSSSignatureOutputProcessor.java
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/ExternalSecurityTokenImpl.java
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/KerberosClientSecurityToken.java
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/KerberosServiceSecurityTokenImpl.java
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/SamlSecurityTokenImpl.java
Modified: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/ConfigurationConverter.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/ConfigurationConverter.java?rev=1660601&r1=1660600&r2=1660601&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/ConfigurationConverter.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/ConfigurationConverter.java Wed Feb 18 11:50:41 2015
@@ -37,7 +37,6 @@ import org.apache.wss4j.common.crypto.Ja
import org.apache.wss4j.common.crypto.PasswordEncryptor;
import org.apache.wss4j.common.ext.WSSecurityException;
import org.apache.wss4j.common.util.Loader;
-import org.apache.wss4j.stax.ext.WSSConfigurationException;
import org.apache.wss4j.stax.ext.WSSConstants;
import org.apache.wss4j.stax.ext.WSSConstants.UsernameTokenPasswordType;
import org.apache.wss4j.stax.ext.WSSSecurityProperties;
@@ -297,8 +296,6 @@ public final class ConfigurationConverte
crypto = properties.getEncryptionCrypto();
}
return crypto.getDefaultX509Identifier();
- } catch (WSSConfigurationException e) {
- LOG.debug(e.getMessage(), e);
} catch (WSSecurityException e) {
LOG.debug(e.getMessage(), e);
}
Modified: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/WSSec.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/WSSec.java?rev=1660601&r1=1660600&r2=1660601&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/WSSec.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/WSSec.java Wed Feb 18 11:50:41 2015
@@ -74,13 +74,8 @@ public class WSSec {
Schema schema = WSSUtils.loadWSSecuritySchemas();
WSSConstants.setJaxbSchemas(schema);
- } catch (XMLSecurityException e) {
- throw new RuntimeException(e.getMessage(), e);
- } catch (JAXBException e) {
- throw new RuntimeException(e.getMessage(), e);
- } catch (SAXException e) {
- throw new RuntimeException(e.getMessage(), e);
- } catch (URISyntaxException e) {
+ } catch (XMLSecurityException | JAXBException
+ | SAXException | URISyntaxException e) {
throw new RuntimeException(e.getMessage(), e);
}
}
Modified: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/ext/WSSUtils.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/ext/WSSUtils.java?rev=1660601&r1=1660600&r2=1660601&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/ext/WSSUtils.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/ext/WSSUtils.java Wed Feb 18 11:50:41 2015
@@ -85,9 +85,7 @@ public class WSSUtils extends XMLSecurit
}
try {
callbackHandler.handle(new Callback[]{callback});
- } catch (IOException e) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e);
- } catch (UnsupportedCallbackException e) {
+ } catch (IOException | UnsupportedCallbackException e) {
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e);
}
}
@@ -104,9 +102,7 @@ public class WSSUtils extends XMLSecurit
if (callbackHandler != null) {
try {
callbackHandler.handle(new Callback[]{callback});
- } catch (IOException e) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "noPassword", e);
- } catch (UnsupportedCallbackException e) {
+ } catch (IOException | UnsupportedCallbackException e) {
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "noPassword", e);
}
}
@@ -280,9 +276,7 @@ public class WSSUtils extends XMLSecurit
CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509", "BC");
List<X509Certificate> certificates = Arrays.asList(x509Certificates);
abstractOutputProcessor.createCharactersAndOutputAsEvent(outputProcessorChain, new Base64(76, new byte[]{'\n'}).encodeToString(certificateFactory.generateCertPath(certificates).getEncoded()));
- } catch (CertificateException e) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e);
- } catch (NoSuchProviderException e) {
+ } catch (CertificateException | NoSuchProviderException e) {
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e);
}
}
@@ -338,9 +332,7 @@ public class WSSUtils extends XMLSecurit
MessageDigest sha = MessageDigest.getInstance("SHA-1");
byte[] data = sha.digest(x509Certificates[0].getEncoded());
abstractOutputProcessor.createCharactersAndOutputAsEvent(outputProcessorChain, new Base64(76, new byte[]{'\n'}).encodeToString(data));
- } catch (CertificateEncodingException e) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e);
- } catch (NoSuchAlgorithmException e) {
+ } catch (CertificateEncodingException | NoSuchAlgorithmException e) {
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e);
}
abstractOutputProcessor.createEndElementAndOutputAsEvent(outputProcessorChain, WSSConstants.TAG_wsse_KeyIdentifier);
Modified: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/input/DecryptInputProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/input/DecryptInputProcessor.java?rev=1660601&r1=1660600&r2=1660601&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/input/DecryptInputProcessor.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/input/DecryptInputProcessor.java Wed Feb 18 11:50:41 2015
@@ -141,13 +141,8 @@ public class DecryptInputProcessor exten
inputStream = new LimitingInputStream(
constructor.newInstance(inputStream),
maximumAllowedDecompressedBytes);
- } catch (InvocationTargetException e) {
- throw new XMLSecurityException(e);
- } catch (NoSuchMethodException e) {
- throw new XMLSecurityException(e);
- } catch (InstantiationException e) {
- throw new XMLSecurityException(e);
- } catch (IllegalAccessException e) {
+ } catch (InvocationTargetException | NoSuchMethodException
+ | InstantiationException | IllegalAccessException e) {
throw new XMLSecurityException(e);
}
}
Modified: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/input/SecurityHeaderInputProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/input/SecurityHeaderInputProcessor.java?rev=1660601&r1=1660600&r2=1660601&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/input/SecurityHeaderInputProcessor.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/input/SecurityHeaderInputProcessor.java Wed Feb 18 11:50:41 2015
@@ -216,9 +216,7 @@ public class SecurityHeaderInputProcesso
try {
XMLSecurityHeaderHandler xmlSecurityHeaderHandler = clazz.newInstance();
xmlSecurityHeaderHandler.handle(inputProcessorChain, securityProperties, eventQueue, index);
- } catch (InstantiationException e) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY, e);
- } catch (IllegalAccessException e) {
+ } catch (InstantiationException | IllegalAccessException e) {
throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY, e);
} catch (WSSecurityException e) {
throw e;
Modified: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/EncryptOutputProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/EncryptOutputProcessor.java?rev=1660601&r1=1660600&r2=1660601&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/EncryptOutputProcessor.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/EncryptOutputProcessor.java Wed Feb 18 11:50:41 2015
@@ -319,13 +319,8 @@ public class EncryptOutputProcessor exte
try {
Constructor<OutputStream> constructor = transformerClass.getConstructor(OutputStream.class);
outputStream = constructor.newInstance(outputStream);
- } catch (InvocationTargetException e) {
- throw new XMLSecurityException(e);
- } catch (NoSuchMethodException e) {
- throw new XMLSecurityException(e);
- } catch (InstantiationException e) {
- throw new XMLSecurityException(e);
- } catch (IllegalAccessException e) {
+ } catch (InvocationTargetException | NoSuchMethodException
+ | InstantiationException | IllegalAccessException e) {
throw new XMLSecurityException(e);
}
}
Modified: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/EncryptedKeyOutputProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/EncryptedKeyOutputProcessor.java?rev=1660601&r1=1660600&r2=1660601&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/EncryptedKeyOutputProcessor.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/EncryptedKeyOutputProcessor.java Wed Feb 18 11:50:41 2015
@@ -326,24 +326,16 @@ public class EncryptedKeyOutputProcessor
callback.setKey(encryptedEphemeralKey);
try {
((WSSSecurityProperties)getSecurityProperties()).getCallbackHandler().handle(new Callback[]{callback});
- } catch (IOException e) { // NOPMD
- // Do nothing
- } catch (UnsupportedCallbackException e) { // NOPMD
+ } catch (IOException | UnsupportedCallbackException e) { // NOPMD
// Do nothing
}
}
createCharactersAndOutputAsEvent(subOutputProcessorChain, new Base64(76, new byte[]{'\n'}).encodeToString(encryptedEphemeralKey));
- } catch (NoSuchPaddingException e) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e);
- } catch (NoSuchAlgorithmException e) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e);
- } catch (InvalidKeyException e) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e);
- } catch (IllegalBlockSizeException e) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e);
- } catch (InvalidAlgorithmParameterException e) {
+ } catch (NoSuchPaddingException | NoSuchAlgorithmException
+ | InvalidKeyException | IllegalBlockSizeException
+ | InvalidAlgorithmParameterException e) {
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e);
}
Modified: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/WSSSignatureOutputProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/WSSSignatureOutputProcessor.java?rev=1660601&r1=1660600&r2=1660601&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/WSSSignatureOutputProcessor.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/WSSSignatureOutputProcessor.java Wed Feb 18 11:50:41 2015
@@ -212,9 +212,7 @@ public class WSSSignatureOutputProcessor
//reset the inputStream to be able to reuse it
inputStream.reset();
- } catch (IOException e) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_SIGNATURE, e);
- } catch (XMLStreamException e) {
+ } catch (IOException | XMLStreamException e) {
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_SIGNATURE, e);
}
Modified: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/ExternalSecurityTokenImpl.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/ExternalSecurityTokenImpl.java?rev=1660601&r1=1660600&r2=1660601&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/ExternalSecurityTokenImpl.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/ExternalSecurityTokenImpl.java Wed Feb 18 11:50:41 2015
@@ -53,11 +53,10 @@ public class ExternalSecurityTokenImpl e
new WSPasswordCallback(id, WSPasswordCallback.CUSTOM_TOKEN);
try {
securityProperties.getCallbackHandler().handle(new Callback[]{pwcb});
- } catch (IOException e) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "noPassword", e);
- } catch (UnsupportedCallbackException e) {
+ } catch (IOException | UnsupportedCallbackException e) {
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "noPassword", e);
}
+
this.tokenElement = pwcb.getCustomToken();
this.key = pwcb.getKey();
}
Modified: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/KerberosClientSecurityToken.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/KerberosClientSecurityToken.java?rev=1660601&r1=1660600&r2=1660601&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/KerberosClientSecurityToken.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/KerberosClientSecurityToken.java Wed Feb 18 11:50:41 2015
@@ -117,11 +117,7 @@ public class KerberosClientSecurityToken
);
}
}
- } catch (LoginException e) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e);
- } catch (UnsupportedCallbackException e) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e);
- } catch (IOException e) {
+ } catch (LoginException | UnsupportedCallbackException | IOException e) {
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e);
}
}
Modified: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/KerberosServiceSecurityTokenImpl.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/KerberosServiceSecurityTokenImpl.java?rev=1660601&r1=1660600&r2=1660601&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/KerberosServiceSecurityTokenImpl.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/KerberosServiceSecurityTokenImpl.java Wed Feb 18 11:50:41 2015
@@ -140,11 +140,7 @@ public class KerberosServiceSecurityToke
kerberosTokenDecoder.setSubject(subject);
return kerberosTokenDecoder;
}
- } catch (LoginException e) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e);
- } catch (UnsupportedCallbackException e) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e);
- } catch (IOException e) {
+ } catch (LoginException | UnsupportedCallbackException | IOException e) {
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e);
}
}
Modified: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/SamlSecurityTokenImpl.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/SamlSecurityTokenImpl.java?rev=1660601&r1=1660600&r2=1660601&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/SamlSecurityTokenImpl.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/SamlSecurityTokenImpl.java Wed Feb 18 11:50:41 2015
@@ -76,11 +76,10 @@ public class SamlSecurityTokenImpl exten
new WSPasswordCallback(id, WSPasswordCallback.CUSTOM_TOKEN);
try {
securityProperties.getCallbackHandler().handle(new Callback[]{pwcb});
- } catch (IOException e) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "noPassword", e);
- } catch (UnsupportedCallbackException e) {
+ } catch (IOException | UnsupportedCallbackException e) {
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "noPassword", e);
}
+
Element assertionElem = pwcb.getCustomToken();
if (assertionElem != null && "Assertion".equals(assertionElem.getLocalName())
&& (WSSConstants.NS_SAML.equals(assertionElem.getNamespaceURI())