You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by gi...@apache.org on 2012/10/07 12:02:50 UTC
svn commit: r1395267 [1/3] - in /santuario/xml-security-java/trunk/src:
main/java/org/apache/xml/security/exceptions/
main/java/org/apache/xml/security/resource/
main/java/org/apache/xml/security/stax/config/
main/java/org/apache/xml/security/stax/ext/...
Author: giger
Date: Sun Oct 7 10:02:46 2012
New Revision: 1395267
URL: http://svn.apache.org/viewvc?rev=1395267&view=rev
Log:
SANTUARIO-332 - Exception handling
Modified:
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/exceptions/XMLSecurityException.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/resource/xmlsecurity_de.properties (props changed)
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/resource/xmlsecurity_en.properties (contents, props changed)
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/config/Init.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/config/ResourceResolverMapper.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/config/TransformerAlgorithmMapper.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/AbstractBufferingOutputProcessor.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/AbstractInputProcessor.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/AbstractInputSecurityHeaderHandler.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/AbstractOutputProcessor.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/InputProcessor.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/InputProcessorChain.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/OutboundXMLSec.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/OutputProcessor.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/OutputProcessorChain.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/ProcessorChain.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/ResourceResolver.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/SecurityToken.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/SecurityTokenProvider.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/Transformer.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/XMLSec.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityConfigurationException.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityException.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityHeaderHandler.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityUtils.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/InputProcessorChainImpl.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/OutputProcessorChainImpl.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/SecurityContextImpl.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/XMLSecurityStreamReader.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/XMLSecurityStreamWriter.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/algorithms/HMACSignatureAlgorithm.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/algorithms/PKISignatureAlgorithm.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/algorithms/SignatureAlgorithm.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/algorithms/SignatureAlgorithmFactory.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/input/AbstractDecryptInputProcessor.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/input/AbstractSignatureInputHandler.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/input/AbstractSignatureReferenceVerifyInputProcessor.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/input/LogInputProcessor.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/input/XMLDecryptInputProcessor.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/input/XMLEncryptedKeyInputHandler.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/input/XMLEventReaderInputProcessor.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/input/XMLSecurityInputProcessor.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/input/XMLSignatureInputHandler.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/input/XMLSignatureReferenceVerifyInputProcessor.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/output/AbstractEncryptEndingOutputProcessor.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/output/AbstractEncryptOutputProcessor.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/output/AbstractSignatureEndingOutputProcessor.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/output/AbstractSignatureOutputProcessor.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/output/FinalOutputProcessor.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/output/XMLEncryptOutputProcessor.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/output/XMLSignatureEndingOutputProcessor.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/output/XMLSignatureOutputProcessor.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/resourceResolvers/ResolverFilesystem.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/resourceResolvers/ResolverHttp.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/resourceResolvers/ResolverSameDocument.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/resourceResolvers/ResolverXPointer.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/securityToken/AbstractInboundSecurityToken.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/securityToken/DsaKeyValueSecurityToken.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/securityToken/ECKeyValueSecurityToken.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/securityToken/GenericOutboundSecurityToken.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/securityToken/KeyNameSecurityToken.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/securityToken/OutboundSecurityToken.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/securityToken/RsaKeyValueSecurityToken.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/securityToken/SecurityTokenFactory.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/securityToken/SecurityTokenFactoryImpl.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/securityToken/X509SecurityToken.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/transformer/TransformBase64Decode.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/transformer/TransformIdentity.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/transformer/canonicalizer/CanonicalizerBase.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/util/SignerOutputStream.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/securityEvent/KeyValueTokenSecurityEvent.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/securityEvent/SecurityEventListener.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/I18n.java
santuario/xml-security-java/trunk/src/main/resources/schemas/security-config.xsd
santuario/xml-security-java/trunk/src/main/resources/security-config.xml
santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/InputProcessorChainTest.java
santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/OutputProcessorChainTest.java
santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/UncategorizedTest.java
santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/XMLSecurityStreamReaderTest.java
santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/XMLSecurityStreamWriterTest.java
santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/encryption/DecryptionTest.java
santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/performance/AbstractPerformanceTest.java
santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/signature/AbstractSignatureVerificationTest.java
santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/signature/BaltimoreTest.java
santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/signature/IAIKTest.java
santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/signature/PhaosTest.java
santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/signature/SignatureVerificationTest.java
santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/signature/TestSecurityEventListener.java
santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/signature/UnknownAlgoSignatureTest.java
santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/transformer/TransformBase64DecodeTest.java
santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/transformer/TransformCanonicalizerTest.java
santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/transformer/TransformEnvelopedSignatureTest.java
santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/transformer/TransformIdentityTest.java
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/exceptions/XMLSecurityException.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/exceptions/XMLSecurityException.java?rev=1395267&r1=1395266&r2=1395267&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/exceptions/XMLSecurityException.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/exceptions/XMLSecurityException.java Sun Oct 7 10:02:46 2012
@@ -20,7 +20,6 @@ package org.apache.xml.security.exceptio
import java.text.MessageFormat;
-import org.apache.xml.security.utils.Constants;
import org.apache.xml.security.utils.I18n;
/**
@@ -92,7 +91,7 @@ public class XMLSecurityException extend
* @param msgID
* @param exArgs
*/
- public XMLSecurityException(String msgID, Object exArgs[]) {
+ public XMLSecurityException(String msgID, Object ... exArgs) {
super(MessageFormat.format(I18n.getExceptionMessage(msgID), exArgs));
@@ -106,11 +105,7 @@ public class XMLSecurityException extend
*/
public XMLSecurityException(Exception originalException) {
- super("Missing message ID to locate message string in resource bundle \""
- + Constants.exceptionMessagesResourceBundleBase
- + "\". Original Exception was a "
- + originalException.getClass().getName() + " and message "
- + originalException.getMessage(), originalException);
+ super(originalException.getMessage(), originalException);
}
/**
Propchange: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/resource/xmlsecurity_de.properties
------------------------------------------------------------------------------
--- svn:mime-type (original)
+++ svn:mime-type Sun Oct 7 10:02:46 2012
@@ -1 +1 @@
-application/octet-stream
+text/plain;charset=iso-8859-1
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/resource/xmlsecurity_en.properties
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/resource/xmlsecurity_en.properties?rev=1395267&r1=1395266&r2=1395267&view=diff
==============================================================================
Binary files - no diff available.
Propchange: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/resource/xmlsecurity_en.properties
------------------------------------------------------------------------------
--- svn:mime-type (original)
+++ svn:mime-type Sun Oct 7 10:02:46 2012
@@ -1 +1 @@
-application/octet-stream
+text/plain;charset=iso-8859-1
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/config/Init.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/config/Init.java?rev=1395267&r1=1395266&r2=1395267&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/config/Init.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/config/Init.java Sun Oct 7 10:02:46 2012
@@ -18,8 +18,9 @@
*/
package org.apache.xml.security.stax.config;
+import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.stax.ext.XMLSecurityConfigurationException;
-import org.apache.xml.security.stax.ext.XMLSecurityException;
+import org.apache.xml.security.utils.I18n;
import org.xmlsecurity.ns.configuration.ConfigurationType;
import javax.xml.XMLConstants;
@@ -71,8 +72,12 @@ public class Init {
TransformerAlgorithmMapper.init(configurationTypeJAXBElement.getValue().getTransformAlgorithms());
ResourceResolverMapper.init(configurationTypeJAXBElement.getValue().getResourceResolvers());
+ I18n.init(ConfigurationProperties.getProperty("DefaultLanguageCode"), ConfigurationProperties.getProperty("DefaultCountryCode"));
+
} catch (Exception e) {
- throw new XMLSecurityConfigurationException(XMLSecurityException.ErrorCode.FAILURE, null, e);
+ //kind of chicken-egg problem here
+ I18n.init("en", "US");
+ throw new XMLSecurityConfigurationException(e);
}
initialized = uri;
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/config/ResourceResolverMapper.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/config/ResourceResolverMapper.java?rev=1395267&r1=1395266&r2=1395267&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/config/ResourceResolverMapper.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/config/ResourceResolverMapper.java Sun Oct 7 10:02:46 2012
@@ -18,9 +18,9 @@
*/
package org.apache.xml.security.stax.config;
+import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.stax.ext.ResourceResolver;
import org.apache.xml.security.stax.ext.ResourceResolverLookup;
-import org.apache.xml.security.stax.ext.XMLSecurityException;
import org.apache.xml.security.stax.ext.XMLSecurityUtils;
import org.xmlsecurity.ns.configuration.ResolverType;
import org.xmlsecurity.ns.configuration.ResourceResolversType;
@@ -56,6 +56,6 @@ public class ResourceResolverMapper {
return rr.newInstance(uri, baseURI);
}
}
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_CHECK, "resolver.noClass", uri);
+ throw new XMLSecurityException("utils.resolver.noClass", uri, baseURI);
}
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/config/TransformerAlgorithmMapper.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/config/TransformerAlgorithmMapper.java?rev=1395267&r1=1395266&r2=1395267&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/config/TransformerAlgorithmMapper.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/config/TransformerAlgorithmMapper.java Sun Oct 7 10:02:46 2012
@@ -18,8 +18,8 @@
*/
package org.apache.xml.security.stax.config;
+import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.stax.ext.XMLSecurityConstants;
-import org.apache.xml.security.stax.ext.XMLSecurityException;
import org.apache.xml.security.stax.ext.XMLSecurityUtils;
import org.xmlsecurity.ns.configuration.TransformAlgorithmType;
import org.xmlsecurity.ns.configuration.TransformAlgorithmsType;
@@ -30,7 +30,6 @@ import java.util.Map;
/**
* Mapping between JCE id and xmlsec uri's for algorithms
- * Class lent from apache santuario (xmlsec)
*
* @author $Author$
* @version $Revision$ $Date$
@@ -80,7 +79,7 @@ public class TransformerAlgorithmMapper
clazz = algorithmsClassMapInOut.get(algoURI);
}
if (clazz == null) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILURE, "unknownTransformAlgorithm", algoURI);
+ throw new XMLSecurityException("signature.Transform.UnknownTransform", algoURI);
}
return clazz;
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/AbstractBufferingOutputProcessor.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/AbstractBufferingOutputProcessor.java?rev=1395267&r1=1395266&r2=1395267&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/AbstractBufferingOutputProcessor.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/AbstractBufferingOutputProcessor.java Sun Oct 7 10:02:46 2012
@@ -18,6 +18,7 @@
*/
package org.apache.xml.security.stax.ext;
+import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.stax.ext.stax.XMLSecAttribute;
import org.apache.xml.security.stax.ext.stax.XMLSecEndElement;
import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/AbstractInputProcessor.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/AbstractInputProcessor.java?rev=1395267&r1=1395266&r2=1395267&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/AbstractInputProcessor.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/AbstractInputProcessor.java Sun Oct 7 10:02:46 2012
@@ -18,6 +18,7 @@
*/
package org.apache.xml.security.stax.ext;
+import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
import org.apache.xml.security.stax.ext.stax.XMLSecStartElement;
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/AbstractInputSecurityHeaderHandler.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/AbstractInputSecurityHeaderHandler.java?rev=1395267&r1=1395266&r2=1395267&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/AbstractInputSecurityHeaderHandler.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/AbstractInputSecurityHeaderHandler.java Sun Oct 7 10:02:46 2012
@@ -20,6 +20,7 @@ package org.apache.xml.security.stax.ext
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
import org.apache.xml.security.stax.impl.XMLSecurityEventReader;
@@ -48,7 +49,10 @@ public abstract class AbstractInputSecur
return (T) unmarshaller.unmarshal(new XMLSecurityEventReader(eventDeque, index));
} catch (JAXBException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.INVALID_SECURITY, e);
+ if (e.getCause() != null && e.getCause() instanceof Exception) {
+ throw new XMLSecurityException((Exception)e.getCause());
+ }
+ throw new XMLSecurityException(e);
}
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/AbstractOutputProcessor.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/AbstractOutputProcessor.java?rev=1395267&r1=1395266&r2=1395267&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/AbstractOutputProcessor.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/AbstractOutputProcessor.java Sun Oct 7 10:02:46 2012
@@ -31,6 +31,7 @@ import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.Attribute;
+import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.stax.ext.stax.XMLSecAttribute;
import org.apache.xml.security.stax.ext.stax.XMLSecCharacters;
import org.apache.xml.security.stax.ext.stax.XMLSecEndElement;
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/InputProcessor.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/InputProcessor.java?rev=1395267&r1=1395266&r2=1395267&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/InputProcessor.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/InputProcessor.java Sun Oct 7 10:02:46 2012
@@ -18,6 +18,7 @@
*/
package org.apache.xml.security.stax.ext;
+import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
import javax.xml.stream.XMLStreamException;
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/InputProcessorChain.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/InputProcessorChain.java?rev=1395267&r1=1395266&r2=1395267&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/InputProcessorChain.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/InputProcessorChain.java Sun Oct 7 10:02:46 2012
@@ -18,6 +18,7 @@
*/
package org.apache.xml.security.stax.ext;
+import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
import javax.xml.stream.XMLStreamException;
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/OutboundXMLSec.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/OutboundXMLSec.java?rev=1395267&r1=1395266&r2=1395267&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/OutboundXMLSec.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/OutboundXMLSec.java Sun Oct 7 10:02:46 2012
@@ -28,6 +28,7 @@ import java.util.List;
import javax.crypto.KeyGenerator;
import javax.xml.stream.XMLStreamWriter;
+import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.stax.config.JCEAlgorithmMapper;
import org.apache.xml.security.stax.impl.DocumentContextImpl;
import org.apache.xml.security.stax.impl.OutputProcessorChainImpl;
@@ -159,7 +160,7 @@ public class OutboundXMLSec {
Key key = securityProperties.getSignatureKey();
X509Certificate[] x509Certificates = securityProperties.getSignatureCerts();
if (key instanceof PrivateKey && (x509Certificates == null || x509Certificates.length == 0)) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_SIGNATURE, "noUserCertsFound");
+ throw new XMLSecurityException("stax.signature.publicKeyOrCertificateMissing");
}
final String securityTokenid = IDGenerator.generateID("SIG");
@@ -199,7 +200,7 @@ public class OutboundXMLSec {
Key key = securityProperties.getEncryptionKey();
if (key == null) {
if (transportCert == null && transportKey == null) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_ENCRYPTION, "encryptionKeyMissing");
+ throw new XMLSecurityException("stax.encryption.encryptionKeyMissing");
}
// If none is configured then generate one
String keyAlgorithm =
@@ -208,7 +209,7 @@ public class OutboundXMLSec {
try {
keyGen = KeyGenerator.getInstance(keyAlgorithm);
} catch (NoSuchAlgorithmException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_ENCRYPTION, e);
+ throw new XMLSecurityException(e);
}
//the sun JCE provider expects the real key size for 3DES (112 or 168 bit)
//whereas bouncy castle expects the block size of 128 or 192 bits
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/OutputProcessor.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/OutputProcessor.java?rev=1395267&r1=1395266&r2=1395267&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/OutputProcessor.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/OutputProcessor.java Sun Oct 7 10:02:46 2012
@@ -18,6 +18,7 @@
*/
package org.apache.xml.security.stax.ext;
+import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
import javax.xml.stream.XMLStreamException;
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/OutputProcessorChain.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/OutputProcessorChain.java?rev=1395267&r1=1395266&r2=1395267&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/OutputProcessorChain.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/OutputProcessorChain.java Sun Oct 7 10:02:46 2012
@@ -18,6 +18,7 @@
*/
package org.apache.xml.security.stax.ext;
+import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
import org.apache.xml.security.stax.ext.stax.XMLSecStartElement;
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/ProcessorChain.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/ProcessorChain.java?rev=1395267&r1=1395266&r2=1395267&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/ProcessorChain.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/ProcessorChain.java Sun Oct 7 10:02:46 2012
@@ -18,6 +18,8 @@
*/
package org.apache.xml.security.stax.ext;
+import org.apache.xml.security.exceptions.XMLSecurityException;
+
import javax.xml.stream.XMLStreamException;
/**
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/ResourceResolver.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/ResourceResolver.java?rev=1395267&r1=1395266&r2=1395267&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/ResourceResolver.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/ResourceResolver.java Sun Oct 7 10:02:46 2012
@@ -18,6 +18,7 @@
*/
package org.apache.xml.security.stax.ext;
+import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.stax.ext.stax.XMLSecStartElement;
import java.io.InputStream;
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/SecurityToken.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/SecurityToken.java?rev=1395267&r1=1395266&r2=1395267&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/SecurityToken.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/SecurityToken.java Sun Oct 7 10:02:46 2012
@@ -18,6 +18,7 @@
*/
package org.apache.xml.security.stax.ext;
+import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
import javax.xml.namespace.QName;
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/SecurityTokenProvider.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/SecurityTokenProvider.java?rev=1395267&r1=1395266&r2=1395267&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/SecurityTokenProvider.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/SecurityTokenProvider.java Sun Oct 7 10:02:46 2012
@@ -18,6 +18,8 @@
*/
package org.apache.xml.security.stax.ext;
+import org.apache.xml.security.exceptions.XMLSecurityException;
+
/**
* A SecurityTokenProvider is a object which provides a Token for cryptographic operations
*
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/Transformer.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/Transformer.java?rev=1395267&r1=1395266&r2=1395267&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/Transformer.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/Transformer.java Sun Oct 7 10:02:46 2012
@@ -18,6 +18,7 @@
*/
package org.apache.xml.security.stax.ext;
+import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
import javax.xml.stream.XMLStreamException;
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/XMLSec.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/XMLSec.java?rev=1395267&r1=1395266&r2=1395267&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/XMLSec.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/XMLSec.java Sun Oct 7 10:02:46 2012
@@ -24,6 +24,7 @@ import java.security.interfaces.RSAPriva
import javax.crypto.SecretKey;
+import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.stax.config.Init;
/**
@@ -61,7 +62,7 @@ public class XMLSec {
*/
public static OutboundXMLSec getOutboundXMLSec(XMLSecurityProperties securityProperties) throws XMLSecurityException {
if (securityProperties == null) {
- throw new XMLSecurityConfigurationException(XMLSecurityException.ErrorCode.FAILURE, "missingSecurityProperties");
+ throw new XMLSecurityConfigurationException("stax.missingSecurityProperties");
}
securityProperties = validateAndApplyDefaultsToOutboundSecurityProperties(securityProperties);
@@ -80,7 +81,7 @@ public class XMLSec {
*/
public static InboundXMLSec getInboundWSSec(XMLSecurityProperties securityProperties) throws XMLSecurityException {
if (securityProperties == null) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILURE, "missingSecurityProperties");
+ throw new XMLSecurityConfigurationException("stax.missingSecurityProperties");
}
securityProperties = validateAndApplyDefaultsToInboundSecurityProperties(securityProperties);
@@ -97,7 +98,7 @@ public class XMLSec {
*/
public static XMLSecurityProperties validateAndApplyDefaultsToOutboundSecurityProperties(XMLSecurityProperties securityProperties) throws XMLSecurityConfigurationException {
if (securityProperties.getOutAction() == null) {
- throw new XMLSecurityConfigurationException(XMLSecurityException.ErrorCode.FAILURE, "noOutputAction");
+ throw new XMLSecurityConfigurationException("stax.noOutputAction");
}
for (int i = 0; i < securityProperties.getOutAction().length; i++) {
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityConfigurationException.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityConfigurationException.java?rev=1395267&r1=1395266&r2=1395267&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityConfigurationException.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityConfigurationException.java Sun Oct 7 10:02:46 2012
@@ -18,6 +18,8 @@
*/
package org.apache.xml.security.stax.ext;
+import org.apache.xml.security.exceptions.XMLSecurityException;
+
/**
* Exception when configuration errors are detected
*
@@ -26,31 +28,19 @@ package org.apache.xml.security.stax.ext
*/
public class XMLSecurityConfigurationException extends XMLSecurityException {
- public XMLSecurityConfigurationException(ErrorCode errorCode, String msgId, Object[] args, Throwable exception) {
- super(errorCode, msgId, exception, args);
- }
-
- public XMLSecurityConfigurationException(ErrorCode errorCode, String msgId, Throwable exception) {
- super(errorCode, msgId, exception);
- }
-
- public XMLSecurityConfigurationException(ErrorCode errorCode, String msgId, Object[] args) {
- super(errorCode, msgId, args);
- }
-
- public XMLSecurityConfigurationException(ErrorCode errorCode, String msgId) {
- super(errorCode, msgId);
+ public XMLSecurityConfigurationException(Exception originalException) {
+ super(originalException);
}
- public XMLSecurityConfigurationException(ErrorCode errorCode) {
- super(errorCode);
+ public XMLSecurityConfigurationException(String msgID) {
+ super(msgID);
}
- public XMLSecurityConfigurationException(String errorMessage) {
- super(errorMessage);
+ public XMLSecurityConfigurationException(String msgID, Object... exArgs) {
+ super(msgID, exArgs);
}
- public XMLSecurityConfigurationException(String errorMessage, Throwable t) {
- super(errorMessage, t);
+ public XMLSecurityConfigurationException(String msgID, Exception originalException) {
+ super(msgID, originalException);
}
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityException.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityException.java?rev=1395267&r1=1395266&r2=1395267&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityException.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityException.java Sun Oct 7 10:02:46 2012
@@ -1,166 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.xml.security.stax.ext;
-
-import java.rmi.RemoteException;
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * class lent from apache wss4j
- */
-
-/**
- * Exception class for XML-Security.
- * <p/>
- *
- * @author Davanum Srinivas (dims@yahoo.com).
- */
-public class XMLSecurityException extends RemoteException {
-
- public enum ErrorCode {
- FAILURE,
- UNSUPPORTED_SECURITY_TOKEN,
- UNSUPPORTED_ALGORITHM,
- INVALID_SECURITY,
- INVALID_SECURITY_TOKEN,
- FAILED_AUTHENTICATION,
- FAILED_CHECK,
- SECURITY_TOKEN_UNAVAILABLE,
- MESSAGE_EXPIRED,
- FAILED_ENCRYPTION,
- FAILED_SIGNATURE,
- }
-
- private static final ResourceBundle resources;
-
- static {
- try {
- resources = ResourceBundle.getBundle("messages.errors");
- } catch (MissingResourceException e) {
- throw new RuntimeException(e.getMessage(), e);
- }
- }
-
- /**
- * Constructor.
- * <p/>
- *
- * @param errorCode
- * @param msgId
- * @param exception
- * @param arguments
- */
- public XMLSecurityException(ErrorCode errorCode, String msgId, Throwable exception, Object... arguments) {
- super(getMessage(errorCode, msgId, arguments), exception);
- }
-
- /**
- * Constructor.
- * <p/>
- *
- * @param errorCode
- * @param msgId
- * @param exception
- */
- public XMLSecurityException(ErrorCode errorCode, String msgId, Throwable exception) {
- super(getMessage(errorCode, msgId), exception);
- }
-
- public XMLSecurityException(ErrorCode errorCode, Throwable exception) {
- super(getMessage(errorCode, null), exception);
- }
-
- /**
- * Constructor.
- * <p/>
- *
- * @param errorCode
- * @param msgId
- * @param arguments
- */
- public XMLSecurityException(ErrorCode errorCode, String msgId, Object... arguments) {
- super(getMessage(errorCode, msgId, arguments));
- }
-
- /**
- * Constructor.
- * <p/>
- *
- * @param errorCode
- * @param msgId
- */
- public XMLSecurityException(ErrorCode errorCode, String msgId) {
- this(errorCode, msgId, (Object[]) null);
- }
-
- /**
- * Constructor.
- * <p/>
- *
- * @param errorCode
- */
- public XMLSecurityException(ErrorCode errorCode) {
- this(errorCode, null, (Object[]) null);
- }
-
- /**
- * Constructor.
- * <p/>
- *
- * @param errorMessage
- */
- public XMLSecurityException(String errorMessage) {
- super(errorMessage);
- }
-
- /**
- * Constructor.
- * <p/>
- *
- * @param errorMessage
- */
- public XMLSecurityException(String errorMessage, Throwable t) {
- super(errorMessage, t);
- }
-
- /**
- * get the message from resource bundle.
- * <p/>
- *
- * @param errorCode
- * @param msgId
- * @param arguments
- * @return the message translated from the property (message) file.
- */
- private static String getMessage(ErrorCode errorCode, String msgId, Object... arguments) {
- String msg = null;
- try {
- msg = resources.getString(String.valueOf(errorCode.ordinal()));
- if (msgId != null) {
- return msg += (" (" + MessageFormat.format(resources.getString(msgId), arguments) + ")");
- }
- } catch (MissingResourceException e) {
- throw new RuntimeException("Undefined '" + msgId + "' resource property", e);
- }
- return msg;
- }
-}
\ No newline at end of file
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityHeaderHandler.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityHeaderHandler.java?rev=1395267&r1=1395266&r2=1395267&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityHeaderHandler.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityHeaderHandler.java Sun Oct 7 10:02:46 2012
@@ -18,6 +18,7 @@
*/
package org.apache.xml.security.stax.ext;
+import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
import java.util.Deque;
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityUtils.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityUtils.java?rev=1395267&r1=1395266&r2=1395267&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityUtils.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityUtils.java Sun Oct 7 10:02:46 2012
@@ -19,6 +19,7 @@
package org.apache.xml.security.stax.ext;
import org.apache.commons.codec.binary.Base64;
+import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.keys.content.x509.XMLX509SKI;
import org.apache.xml.security.stax.config.TransformerAlgorithmMapper;
import org.apache.xml.security.stax.ext.stax.XMLSecAttribute;
@@ -27,16 +28,11 @@ import org.apache.xml.security.stax.ext.
import org.apache.xml.security.stax.ext.stax.XMLSecStartElement;
import org.apache.xml.security.stax.impl.algorithms.ECDSAUtils;
-import javax.security.auth.callback.Callback;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.callback.UnsupportedCallbackException;
import javax.xml.bind.JAXBElement;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
-import java.io.IOException;
import java.io.OutputStream;
-import java.lang.reflect.InvocationTargetException;
import java.math.BigInteger;
import java.security.PublicKey;
import java.security.cert.CertificateEncodingException;
@@ -103,61 +99,30 @@ public class XMLSecurityUtils {
}
}
- /**
- * Executes the Callback handling. Typically used to fetch passwords
- *
- * @param callbackHandler
- * @param callback
- * @throws XMLSecurityException if the callback couldn't be executed
- */
- public static void doPasswordCallback(CallbackHandler callbackHandler, Callback callback) throws XMLSecurityException {
- if (callbackHandler == null) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILURE, "noCallback");
- }
- try {
- callbackHandler.handle(new Callback[]{callback});
- } catch (IOException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILURE, e);
- } catch (UnsupportedCallbackException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILURE, e);
- }
- }
-
- /**
- * Try to get the secret key from a CallbackHandler implementation
- *
- * @param callbackHandler a CallbackHandler implementation
- * @return An array of bytes corresponding to the secret key (can be null)
- * @throws XMLSecurityException
- */
- public static void doSecretKeyCallback(CallbackHandler callbackHandler, Callback callback, String id) throws XMLSecurityException {
- if (callbackHandler != null) {
- try {
- callbackHandler.handle(new Callback[]{callback});
- } catch (IOException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILURE, "noPassword", e);
- } catch (UnsupportedCallbackException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILURE, "noPassword", e);
- }
- }
- }
-
public static Class loadClass(String className) throws ClassNotFoundException {
return Thread.currentThread().getContextClassLoader().loadClass(className);
}
//todo transformer factory?
- public static Transformer getTransformer(Object methodParameter1, Object methodParameter2, String algorithm, XMLSecurityConstants.DIRECTION direction)
- throws XMLSecurityException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
+ public static Transformer getTransformer(Object methodParameter1, Object methodParameter2, String algorithm,
+ XMLSecurityConstants.DIRECTION direction) throws XMLSecurityException {
@SuppressWarnings("unchecked")
Class<Transformer> transformerClass = (Class<Transformer>) TransformerAlgorithmMapper.getTransformerClass(algorithm, direction);
- Transformer childTransformer = transformerClass.newInstance();
- if (methodParameter2 != null) {
- childTransformer.setList((List) methodParameter1);
- childTransformer.setOutputStream((OutputStream) methodParameter2);
- } else {
- childTransformer.setTransformer((Transformer) methodParameter1);
+ Transformer childTransformer = null;
+
+ try {
+ childTransformer = transformerClass.newInstance();
+ if (methodParameter2 != null) {
+ childTransformer.setList((List) methodParameter1);
+ childTransformer.setOutputStream((OutputStream) methodParameter2);
+ } else {
+ childTransformer.setTransformer((Transformer) methodParameter1);
+ }
+ } catch (InstantiationException e) {
+ throw new XMLSecurityException(e);
+ } catch (IllegalAccessException e) {
+ throw new XMLSecurityException(e);
}
return childTransformer;
}
@@ -256,19 +221,15 @@ public class XMLSecurityUtils {
X509Certificate[] x509Certificates)
throws XMLSecurityException, XMLStreamException {
// SKI can only be used for a V3 certificate
- if (x509Certificates[0].getVersion() != 3) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_SIGNATURE, "invalidCertForSKI", x509Certificates[0].getVersion());
+ int version = x509Certificates[0].getVersion();
+ if (version != 3) {
+ throw new XMLSecurityException("certificate.noSki.lowVersion", version);
}
abstractOutputProcessor.createStartElementAndOutputAsEvent(outputProcessorChain, XMLSecurityConstants.TAG_dsig_X509Data, true, null);
abstractOutputProcessor.createStartElementAndOutputAsEvent(outputProcessorChain, XMLSecurityConstants.TAG_dsig_X509SKI, false, null);
- byte[] data = null;
- try {
- data = XMLX509SKI.getSKIBytesFromCert(x509Certificates[0]);
- } catch (org.apache.xml.security.exceptions.XMLSecurityException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_SIGNATURE, "invalidCertForSKI", e);
- }
+ byte[] data = XMLX509SKI.getSKIBytesFromCert(x509Certificates[0]);
abstractOutputProcessor.createCharactersAndOutputAsEvent(outputProcessorChain, new Base64(76, new byte[]{'\n'}).encodeToString(data));
abstractOutputProcessor.createEndElementAndOutputAsEvent(outputProcessorChain, XMLSecurityConstants.TAG_dsig_X509SKI);
@@ -287,7 +248,7 @@ public class XMLSecurityUtils {
try {
data = x509Certificates[0].getEncoded();
} catch (CertificateEncodingException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_SIGNATURE, "invalidCertForSKI", e);
+ throw new XMLSecurityException(e);
}
abstractOutputProcessor.createCharactersAndOutputAsEvent(outputProcessorChain, new Base64(76, new byte[]{'\n'}).encodeToString(data));
abstractOutputProcessor.createEndElementAndOutputAsEvent(outputProcessorChain, XMLSecurityConstants.TAG_dsig_X509Certificate);
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/InputProcessorChainImpl.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/InputProcessorChainImpl.java?rev=1395267&r1=1395266&r2=1395267&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/InputProcessorChainImpl.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/InputProcessorChainImpl.java Sun Oct 7 10:02:46 2012
@@ -20,6 +20,7 @@ package org.apache.xml.security.stax.imp
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.stax.ext.*;
import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
@@ -194,7 +195,7 @@ public class InputProcessorChainImpl imp
inputProcessorChain = new InputProcessorChainImpl(securityContext, documentContext.clone(),
inputProcessors.indexOf(inputProcessor) + 1, new ArrayList<InputProcessor>(this.inputProcessors));
} catch (CloneNotSupportedException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILURE, e);
+ throw new XMLSecurityException(e);
}
return inputProcessorChain;
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/OutputProcessorChainImpl.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/OutputProcessorChainImpl.java?rev=1395267&r1=1395266&r2=1395267&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/OutputProcessorChainImpl.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/OutputProcessorChainImpl.java Sun Oct 7 10:02:46 2012
@@ -20,6 +20,7 @@ package org.apache.xml.security.stax.imp
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.stax.ext.*;
import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
import org.apache.xml.security.stax.ext.stax.XMLSecStartElement;
@@ -227,7 +228,7 @@ public class OutputProcessorChainImpl im
outputProcessorChain = new OutputProcessorChainImpl(securityContext, documentContext.clone(),
outputProcessors.indexOf(outputProcessor) + 1, this.outputProcessors);
} catch (CloneNotSupportedException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILURE, e);
+ throw new XMLSecurityException(e);
}
if (parentXMLSecStartElement != null) {
outputProcessorChain.setParentXmlSecStartElement(parentXMLSecStartElement);
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/SecurityContextImpl.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/SecurityContextImpl.java?rev=1395267&r1=1395266&r2=1395267&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/SecurityContextImpl.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/SecurityContextImpl.java Sun Oct 7 10:02:46 2012
@@ -18,10 +18,10 @@
*/
package org.apache.xml.security.stax.impl;
+import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.stax.config.ConfigurationProperties;
import org.apache.xml.security.stax.ext.SecurityContext;
import org.apache.xml.security.stax.ext.SecurityTokenProvider;
-import org.apache.xml.security.stax.ext.XMLSecurityException;
import org.apache.xml.security.stax.securityEvent.AlgorithmSuiteSecurityEvent;
import org.apache.xml.security.stax.securityEvent.SecurityEvent;
import org.apache.xml.security.stax.securityEvent.SecurityEventConstants;
@@ -59,10 +59,7 @@ public class SecurityContextImpl impleme
AlgorithmSuiteSecurityEvent algorithmSuiteSecurityEvent = (AlgorithmSuiteSecurityEvent)securityEvent;
if (algorithmSuiteSecurityEvent.getAlgorithmURI().contains("md5") ||
algorithmSuiteSecurityEvent.getAlgorithmURI().contains("MD5")) {
- throw new XMLSecurityException(
- XMLSecurityException.ErrorCode.INVALID_SECURITY,
- "secureProcessing.AllowMD5Algorithm"
- );
+ throw new XMLSecurityException("secureProcessing.AllowMD5Algorithm");
}
}
for (int i = 0; i < securityEventListeners.size(); i++) {
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/XMLSecurityStreamReader.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/XMLSecurityStreamReader.java?rev=1395267&r1=1395266&r2=1395267&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/XMLSecurityStreamReader.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/XMLSecurityStreamReader.java Sun Oct 7 10:02:46 2012
@@ -18,8 +18,8 @@
*/
package org.apache.xml.security.stax.impl;
+import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.stax.ext.InputProcessorChain;
-import org.apache.xml.security.stax.ext.XMLSecurityException;
import org.apache.xml.security.stax.ext.XMLSecurityProperties;
import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/XMLSecurityStreamWriter.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/XMLSecurityStreamWriter.java?rev=1395267&r1=1395266&r2=1395267&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/XMLSecurityStreamWriter.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/XMLSecurityStreamWriter.java Sun Oct 7 10:02:46 2012
@@ -18,8 +18,8 @@
*/
package org.apache.xml.security.stax.impl;
+import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.stax.ext.OutputProcessorChain;
-import org.apache.xml.security.stax.ext.XMLSecurityException;
import org.apache.xml.security.stax.ext.stax.XMLSecAttribute;
import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
import org.apache.xml.security.stax.ext.stax.XMLSecEventFactory;
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/algorithms/HMACSignatureAlgorithm.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/algorithms/HMACSignatureAlgorithm.java?rev=1395267&r1=1395266&r2=1395267&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/algorithms/HMACSignatureAlgorithm.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/algorithms/HMACSignatureAlgorithm.java Sun Oct 7 10:02:46 2012
@@ -18,7 +18,7 @@
*/
package org.apache.xml.security.stax.impl.algorithms;
-import org.apache.xml.security.stax.ext.XMLSecurityException;
+import org.apache.xml.security.exceptions.XMLSecurityException;
import org.xmlsecurity.ns.configuration.AlgorithmType;
import javax.crypto.Mac;
@@ -57,7 +57,7 @@ public class HMACSignatureAlgorithm impl
try {
mac.init(signingKey);
} catch (InvalidKeyException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_SIGNATURE, e);
+ throw new XMLSecurityException(e);
}
}
@@ -65,7 +65,7 @@ public class HMACSignatureAlgorithm impl
try {
mac.init(signingKey);
} catch (InvalidKeyException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_SIGNATURE, e);
+ throw new XMLSecurityException(e);
}
}
@@ -73,9 +73,9 @@ public class HMACSignatureAlgorithm impl
try {
mac.init(signingKey, algorithmParameterSpec);
} catch (InvalidKeyException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_SIGNATURE, e);
+ throw new XMLSecurityException(e);
} catch (InvalidAlgorithmParameterException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_SIGNATURE, e);
+ throw new XMLSecurityException(e);
}
}
@@ -87,7 +87,7 @@ public class HMACSignatureAlgorithm impl
try {
mac.init(verificationKey);
} catch (InvalidKeyException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_CHECK, e);
+ throw new XMLSecurityException(e);
}
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/algorithms/PKISignatureAlgorithm.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/algorithms/PKISignatureAlgorithm.java?rev=1395267&r1=1395266&r2=1395267&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/algorithms/PKISignatureAlgorithm.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/algorithms/PKISignatureAlgorithm.java Sun Oct 7 10:02:46 2012
@@ -18,7 +18,7 @@
*/
package org.apache.xml.security.stax.impl.algorithms;
-import org.apache.xml.security.stax.ext.XMLSecurityException;
+import org.apache.xml.security.exceptions.XMLSecurityException;
import org.xmlsecurity.ns.configuration.AlgorithmType;
import java.io.IOException;
@@ -47,7 +47,7 @@ public class PKISignatureAlgorithm imple
try {
signature.update(input);
} catch (SignatureException e) {
- throw new XMLSecurityException(e.getMessage(), e);
+ throw new XMLSecurityException(e);
}
}
@@ -55,7 +55,7 @@ public class PKISignatureAlgorithm imple
try {
signature.update(input);
} catch (SignatureException e) {
- throw new XMLSecurityException(e.getMessage(), e);
+ throw new XMLSecurityException(e);
}
}
@@ -63,7 +63,7 @@ public class PKISignatureAlgorithm imple
try {
signature.update(buf, offset, len);
} catch (SignatureException e) {
- throw new XMLSecurityException(e.getMessage(), e);
+ throw new XMLSecurityException(e);
}
}
@@ -71,7 +71,7 @@ public class PKISignatureAlgorithm imple
try {
signature.initSign((PrivateKey) signingKey);
} catch (InvalidKeyException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_SIGNATURE, e);
+ throw new XMLSecurityException(e);
}
}
@@ -79,7 +79,7 @@ public class PKISignatureAlgorithm imple
try {
signature.initSign((PrivateKey) signingKey, secureRandom);
} catch (InvalidKeyException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_SIGNATURE, e);
+ throw new XMLSecurityException(e);
}
}
@@ -87,7 +87,7 @@ public class PKISignatureAlgorithm imple
try {
signature.initSign((PrivateKey) signingKey);
} catch (InvalidKeyException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_SIGNATURE, e);
+ throw new XMLSecurityException(e);
}
}
@@ -101,9 +101,9 @@ public class PKISignatureAlgorithm imple
}
return jcebytes;
} catch (SignatureException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_SIGNATURE, e);
+ throw new XMLSecurityException(e);
} catch (IOException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_SIGNATURE, e);
+ throw new XMLSecurityException(e);
}
}
@@ -111,7 +111,7 @@ public class PKISignatureAlgorithm imple
try {
signature.initVerify((PublicKey) verificationKey);
} catch (InvalidKeyException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_CHECK, e);
+ throw new XMLSecurityException(e);
}
}
@@ -125,9 +125,9 @@ public class PKISignatureAlgorithm imple
}
return this.signature.verify(jcebytes);
} catch (SignatureException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_CHECK, e);
+ throw new XMLSecurityException(e);
} catch (IOException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_CHECK, e);
+ throw new XMLSecurityException(e);
}
}
@@ -135,7 +135,7 @@ public class PKISignatureAlgorithm imple
try {
signature.setParameter(params);
} catch (InvalidAlgorithmParameterException e) {
- throw new XMLSecurityException(e.getMessage(), e);
+ throw new XMLSecurityException(e);
}
}
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/algorithms/SignatureAlgorithm.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/algorithms/SignatureAlgorithm.java?rev=1395267&r1=1395266&r2=1395267&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/algorithms/SignatureAlgorithm.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/algorithms/SignatureAlgorithm.java Sun Oct 7 10:02:46 2012
@@ -18,7 +18,7 @@
*/
package org.apache.xml.security.stax.impl.algorithms;
-import org.apache.xml.security.stax.ext.XMLSecurityException;
+import org.apache.xml.security.exceptions.XMLSecurityException;
import java.security.Key;
import java.security.SecureRandom;
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/algorithms/SignatureAlgorithmFactory.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/algorithms/SignatureAlgorithmFactory.java?rev=1395267&r1=1395266&r2=1395267&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/algorithms/SignatureAlgorithmFactory.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/algorithms/SignatureAlgorithmFactory.java Sun Oct 7 10:02:46 2012
@@ -18,8 +18,8 @@
*/
package org.apache.xml.security.stax.impl.algorithms;
+import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.stax.config.JCEAlgorithmMapper;
-import org.apache.xml.security.stax.ext.XMLSecurityException;
import org.xmlsecurity.ns.configuration.AlgorithmType;
import java.security.NoSuchAlgorithmException;
@@ -46,7 +46,7 @@ public class SignatureAlgorithmFactory {
public SignatureAlgorithm getSignatureAlgorithm(String algoURI) throws XMLSecurityException, NoSuchProviderException, NoSuchAlgorithmException {
AlgorithmType algorithmType = JCEAlgorithmMapper.getAlgorithmMapping(algoURI);
if (algorithmType == null) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.UNSUPPORTED_ALGORITHM, "unknownSignatureAlgorithm", algoURI);
+ throw new XMLSecurityException("algorithms.NoSuchMap", algoURI);
}
String algorithmClass = algorithmType.getAlgorithmClass();
if ("MAC".equalsIgnoreCase(algorithmClass)) {
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/input/AbstractDecryptInputProcessor.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/input/AbstractDecryptInputProcessor.java?rev=1395267&r1=1395266&r2=1395267&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/input/AbstractDecryptInputProcessor.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/input/AbstractDecryptInputProcessor.java Sun Oct 7 10:02:46 2012
@@ -28,6 +28,7 @@ import org.apache.xml.security.binding.x
import org.apache.xml.security.binding.xmlenc.EncryptedKeyType;
import org.apache.xml.security.binding.xmlenc.ReferenceList;
import org.apache.xml.security.binding.xmlenc.ReferenceType;
+import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.stax.config.ConfigurationProperties;
import org.apache.xml.security.stax.config.JCEAlgorithmMapper;
import org.apache.xml.security.stax.config.TransformerAlgorithmMapper;
@@ -103,7 +104,7 @@ public abstract class AbstractDecryptInp
while (referenceTypeIterator.hasNext()) {
ReferenceType referenceType = referenceTypeIterator.next().getValue();
if (referenceType.getURI() == null) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_CHECK);
+ throw new XMLSecurityException("stax.emptyReferenceURI");
}
references.put(XMLSecurityUtils.dropReferenceMarker(referenceType.getURI()), referenceType);
}
@@ -175,7 +176,7 @@ public abstract class AbstractDecryptInp
}
//duplicate id's are forbidden
if (processedReferences.contains(referenceType)) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_CHECK, "duplicateId");
+ throw new XMLSecurityException("signature.Verification.MultipleIDs");
}
processedReferences.add(referenceType);
@@ -245,9 +246,9 @@ public abstract class AbstractDecryptInp
prologInputStream = writeWrapperStartElement(xmlSecStartElement);
epilogInputStream = writeWrapperEndElement();
} catch (UnsupportedEncodingException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILURE, e);
+ throw new XMLSecurityException(e);
} catch (IOException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILURE, e);
+ throw new XMLSecurityException(e);
}
InputStream decryptInputStream = decryptionThread.getPipedInputStream();
@@ -259,7 +260,7 @@ public abstract class AbstractDecryptInp
List<TransformType> transformTypes = transformsType.getTransform();
//to do don't forget to limit the count of transformations if more transformations will be supported!
if (transformTypes.size() > 1) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.INVALID_SECURITY);
+ throw new XMLSecurityException("stax.encryption.Transforms.NotYetImplemented");
}
TransformType transformType = transformTypes.get(0);
@SuppressWarnings("unchecked")
@@ -270,13 +271,13 @@ public abstract class AbstractDecryptInp
Constructor<InputStream> constructor = transformerClass.getConstructor(InputStream.class);
decryptInputStream = constructor.newInstance(decryptInputStream);
} catch (InvocationTargetException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILURE, e);
+ throw new XMLSecurityException(e);
} catch (NoSuchMethodException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILURE, e);
+ throw new XMLSecurityException(e);
} catch (InstantiationException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILURE, e);
+ throw new XMLSecurityException(e);
} catch (IllegalAccessException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILURE, e);
+ throw new XMLSecurityException(e);
}
}
}
@@ -377,10 +378,7 @@ public abstract class AbstractDecryptInp
try {
AlgorithmType symEncAlgo = JCEAlgorithmMapper.getAlgorithmMapping(algorithmURI);
if (symEncAlgo == null) {
- throw new XMLSecurityException(
- XMLSecurityException.ErrorCode.UNSUPPORTED_ALGORITHM, "unsupportedKeyTransp",
- "No such algorithm: " + algorithmURI
- );
+ throw new XMLSecurityException("algorithms.NoSuchMap", algorithmURI);
}
if (symEncAlgo.getJCEProvider() != null) {
symCipher = Cipher.getInstance(symEncAlgo.getJCEName(), symEncAlgo.getJCEProvider());
@@ -389,17 +387,11 @@ public abstract class AbstractDecryptInp
}
//we have to defer the initialization of the cipher until we can extract the IV...
} catch (NoSuchAlgorithmException e) {
- throw new XMLSecurityException(
- XMLSecurityException.ErrorCode.UNSUPPORTED_ALGORITHM, "unsupportedKeyTransp",
- e, "No such algorithm: " + algorithmURI
- );
+ throw new XMLSecurityException(e);
} catch (NoSuchPaddingException e) {
- throw new XMLSecurityException(
- XMLSecurityException.ErrorCode.UNSUPPORTED_ALGORITHM, "unsupportedKeyTransp",
- e, "No such padding: " + algorithmURI
- );
+ throw new XMLSecurityException(e);
} catch (NoSuchProviderException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILURE, "noSecProvider", e);
+ throw new XMLSecurityException(e);
}
return symCipher;
}
@@ -453,7 +445,7 @@ public abstract class AbstractDecryptInp
xmlSecEvents.push(encryptedDataXMLSecEvent);
if (++count >= 50) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.INVALID_SECURITY);
+ throw new XMLSecurityException("stax.xmlStructureSizeExceeded", 50);
}
if (encryptedDataXMLSecEvent.getEventType() == XMLStreamConstants.START_ELEMENT
@@ -485,7 +477,7 @@ public abstract class AbstractDecryptInp
encryptedDataType = encryptedDataTypeJAXBElement.getValue();
} catch (JAXBException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.INVALID_SECURITY, e);
+ throw new XMLSecurityException(e);
}
return encryptedDataType;
}
@@ -539,7 +531,7 @@ public abstract class AbstractDecryptInp
while (refEntryIterator.hasNext()) {
Map.Entry<String, ReferenceType> referenceTypeEntry = refEntryIterator.next();
if (!processedReferences.contains(referenceTypeEntry.getValue())) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_CHECK, "unprocessedEncryptionReferences");
+ throw new XMLSecurityException("stax.encryption.unprocessedReferences");
}
}
}
@@ -610,7 +602,6 @@ public abstract class AbstractDecryptInp
currentXMLStructureDepth++;
if (currentXMLStructureDepth > maximumAllowedXMLStructureDepth) {
throw new XMLSecurityException(
- XMLSecurityException.ErrorCode.INVALID_SECURITY,
"secureProcessing.MaximumAllowedXMLStructureDepth",
maximumAllowedXMLStructureDepth
);
@@ -761,8 +752,10 @@ public abstract class AbstractDecryptInp
outputStreamWriter.write(data, 0, data.length());
break;
default:
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_CHECK,
- "unexpectedXMLEvent", XMLSecurityUtils.getXMLEventAsString(xmlSecEvent));
+ throw new XMLSecurityException(
+ "stax.unexpectedXMLEvent",
+ XMLSecurityUtils.getXMLEventAsString(xmlSecEvent)
+ );
}
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/input/AbstractSignatureInputHandler.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/input/AbstractSignatureInputHandler.java?rev=1395267&r1=1395266&r2=1395267&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/input/AbstractSignatureInputHandler.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/input/AbstractSignatureInputHandler.java Sun Oct 7 10:02:46 2012
@@ -22,6 +22,7 @@ import org.apache.xml.security.binding.e
import org.apache.xml.security.binding.xmldsig.CanonicalizationMethodType;
import org.apache.xml.security.binding.xmldsig.KeyInfoType;
import org.apache.xml.security.binding.xmldsig.SignatureType;
+import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.stax.ext.*;
import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
import org.apache.xml.security.stax.impl.algorithms.SignatureAlgorithm;
@@ -35,12 +36,9 @@ import javax.xml.stream.XMLStreamConstan
import javax.xml.stream.XMLStreamException;
import java.io.IOException;
import java.io.OutputStream;
-import java.lang.reflect.InvocationTargetException;
-import java.security.InvalidKeyException;
import java.security.Key;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
-import java.security.cert.CertificateException;
import java.util.Deque;
import java.util.Iterator;
import java.util.List;
@@ -109,7 +107,7 @@ public abstract class AbstractSignatureI
}
}
} catch (XMLStreamException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_CHECK, e);
+ throw new XMLSecurityException(e);
}
signatureVerifier.doFinal();
return signatureVerifier.getSecurityToken();
@@ -173,17 +171,7 @@ public abstract class AbstractSignatureI
securityToken.verify();
handleSecurityToken(securityToken);
- try {
- createSignatureAlgorithm(securityToken, signatureType);
- } catch (InvalidKeyException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_CHECK, e);
- } catch (NoSuchAlgorithmException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_CHECK, e);
- } catch (NoSuchProviderException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_CHECK, e);
- } catch (CertificateException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_CHECK, e);
- }
+ createSignatureAlgorithm(securityToken, signatureType);
this.securityToken = securityToken;
}
@@ -199,8 +187,7 @@ public abstract class AbstractSignatureI
}
protected void createSignatureAlgorithm(SecurityToken securityToken, SignatureType signatureType)
- throws NoSuchAlgorithmException, NoSuchProviderException, InvalidKeyException,
- CertificateException, XMLSecurityException {
+ throws XMLSecurityException {
Key verifyKey;
final String algorithmURI = signatureType.getSignedInfo().getSignatureMethod().getAlgorithm();
@@ -211,14 +198,14 @@ public abstract class AbstractSignatureI
algorithmURI, XMLSecurityConstants.Sym_Sig, signatureType.getId());
}
- SignatureAlgorithm signatureAlgorithm =
- SignatureAlgorithmFactory.getInstance().getSignatureAlgorithm(
- algorithmURI);
- signatureAlgorithm.engineInitVerify(verifyKey);
- signerOutputStream = new SignerOutputStream(signatureAlgorithm);
- bufferedSignerOutputStream = new UnsynchronizedBufferedOutputStream(signerOutputStream);
-
try {
+ SignatureAlgorithm signatureAlgorithm =
+ SignatureAlgorithmFactory.getInstance().getSignatureAlgorithm(
+ algorithmURI);
+ signatureAlgorithm.engineInitVerify(verifyKey);
+ signerOutputStream = new SignerOutputStream(signatureAlgorithm);
+ bufferedSignerOutputStream = new UnsynchronizedBufferedOutputStream(signerOutputStream);
+
final CanonicalizationMethodType canonicalizationMethodType =
signatureType.getSignedInfo().getCanonicalizationMethod();
InclusiveNamespaces inclusiveNamespacesType =
@@ -234,14 +221,10 @@ public abstract class AbstractSignatureI
this.bufferedSignerOutputStream,
canonicalizationMethodType.getAlgorithm(),
XMLSecurityConstants.DIRECTION.IN);
- } catch (NoSuchMethodException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_CHECK, e);
- } catch (InstantiationException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_CHECK, e);
- } catch (IllegalAccessException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_CHECK, e);
- } catch (InvocationTargetException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_CHECK, e);
+ } catch (NoSuchAlgorithmException e) {
+ throw new XMLSecurityException(e);
+ } catch (NoSuchProviderException e) {
+ throw new XMLSecurityException(e);
}
}
@@ -254,12 +237,12 @@ public abstract class AbstractSignatureI
transformer.doFinal();
bufferedSignerOutputStream.close();
} catch (IOException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_CHECK, e);
+ throw new XMLSecurityException(e);
} catch (XMLStreamException e) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_CHECK, e);
+ throw new XMLSecurityException(e);
}
if (!signerOutputStream.verify(signatureType.getSignatureValue().getValue())) {
- throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_CHECK);
+ throw new XMLSecurityException("errorMessages.InvalidSignatureValueException");
}
}
}