You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by gi...@apache.org on 2011/10/11 20:03:15 UTC
svn commit: r1181995 [23/26] - in /webservices/wss4j/branches/swssf: ./
cxf-integration/ cxf-integration/src/main/java/org/swssf/cxfIntegration/
cxf-integration/src/main/java/org/swssf/cxfIntegration/interceptor/
cxf-integration/src/main/java/org/swssf...
Copied: webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/processor/output/AbstractSignatureEndingOutputProcessor.java (from r1179730, webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/impl/processor/output/SignatureEndingOutputProcessor.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/processor/output/AbstractSignatureEndingOutputProcessor.java?p2=webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/processor/output/AbstractSignatureEndingOutputProcessor.java&p1=webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/impl/processor/output/SignatureEndingOutputProcessor.java&r1=1179730&r2=1181995&rev=1181995&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/impl/processor/output/SignatureEndingOutputProcessor.java (original)
+++ webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/processor/output/AbstractSignatureEndingOutputProcessor.java Tue Oct 11 18:03:00 2011
@@ -16,16 +16,14 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.swssf.impl.processor.output;
+package org.swssf.xmlsec.impl.processor.output;
import org.apache.commons.codec.binary.Base64;
-import org.swssf.ext.*;
-import org.swssf.impl.SignaturePartDef;
-import org.swssf.impl.algorithms.SignatureAlgorithm;
-import org.swssf.impl.algorithms.SignatureAlgorithmFactory;
-import org.swssf.impl.util.SignerOutputStream;
-import org.swssf.securityEvent.SecurityEvent;
-import org.swssf.securityEvent.SignatureValueSecurityEvent;
+import org.swssf.xmlsec.ext.*;
+import org.swssf.xmlsec.impl.SignaturePartDef;
+import org.swssf.xmlsec.impl.algorithms.SignatureAlgorithm;
+import org.swssf.xmlsec.impl.algorithms.SignatureAlgorithmFactory;
+import org.swssf.xmlsec.impl.util.SignerOutputStream;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
@@ -42,23 +40,15 @@ import java.util.*;
* @author $Author$
* @version $Revision$ $Date$
*/
-public class SignatureEndingOutputProcessor extends AbstractBufferingOutputProcessor {
+public abstract class AbstractSignatureEndingOutputProcessor extends AbstractBufferingOutputProcessor {
private List<SignaturePartDef> signaturePartDefList;
- public SignatureEndingOutputProcessor(SecurityProperties securityProperties, Constants.Action action, SignatureOutputProcessor signatureOutputProcessor) throws WSSecurityException {
+ public AbstractSignatureEndingOutputProcessor(XMLSecurityProperties securityProperties, XMLSecurityConstants.Action action, AbstractSignatureOutputProcessor signatureOutputProcessor) throws XMLSecurityException {
super(securityProperties, action);
- this.getAfterProcessors().add(SignatureOutputProcessor.class.getName());
- this.getAfterProcessors().add(UsernameTokenOutputProcessor.class.getName());
signaturePartDefList = signatureOutputProcessor.getSignaturePartDefList();
}
- @Override
- public void doFinal(OutputProcessorChain outputProcessorChain) throws XMLStreamException, WSSecurityException {
- setAppendAfterThisTokenId(outputProcessorChain.getSecurityContext().<String>get(Constants.PROP_APPEND_SIGNATURE_ON_THIS_ID));
- super.doFinal(outputProcessorChain);
- }
-
/*
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="Signature-1022834285">
<ds:SignedInfo>
@@ -92,149 +82,150 @@ public class SignatureEndingOutputProces
</ds:Signature>
*/
- protected void processHeaderEvent(OutputProcessorChain outputProcessorChain) throws XMLStreamException, WSSecurityException {
+ @Override
+ public abstract void doFinal(OutputProcessorChain outputProcessorChain) throws XMLStreamException, XMLSecurityException;
+
+ protected void processHeaderEvent(OutputProcessorChain outputProcessorChain) throws XMLStreamException, XMLSecurityException {
OutputProcessorChain subOutputProcessorChain = outputProcessorChain.createSubChain(this);
Map<QName, String> attributes = new HashMap<QName, String>();
- attributes.put(Constants.ATT_NULL_Id, "Signature-" + UUID.randomUUID().toString());
- createStartElementAndOutputAsEvent(subOutputProcessorChain, Constants.TAG_dsig_Signature, attributes);
+ attributes.put(XMLSecurityConstants.ATT_NULL_Id, "Signature-" + UUID.randomUUID().toString());
+ createStartElementAndOutputAsEvent(subOutputProcessorChain, XMLSecurityConstants.TAG_dsig_Signature, attributes);
SignatureAlgorithm signatureAlgorithm;
try {
signatureAlgorithm = SignatureAlgorithmFactory.getInstance().getSignatureAlgorithm(getSecurityProperties().getSignatureAlgorithm());
} catch (NoSuchAlgorithmException e) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_SIGNATURE, e);
+ throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_SIGNATURE, e);
} catch (NoSuchProviderException e) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "noSecProvider", e);
+ throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILURE, "noSecProvider", e);
}
- String tokenId = outputProcessorChain.getSecurityContext().get(Constants.PROP_USE_THIS_TOKEN_ID_FOR_SIGNATURE);
+ String tokenId = outputProcessorChain.getSecurityContext().get(XMLSecurityConstants.PROP_USE_THIS_TOKEN_ID_FOR_SIGNATURE);
if (tokenId == null) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_SIGNATURE);
+ throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_SIGNATURE);
}
SecurityTokenProvider wrappingSecurityTokenProvider = outputProcessorChain.getSecurityContext().getSecurityTokenProvider(tokenId);
if (wrappingSecurityTokenProvider == null) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_SIGNATURE);
+ throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_SIGNATURE);
}
final SecurityToken wrappingSecurityToken = wrappingSecurityTokenProvider.getSecurityToken(null);
if (wrappingSecurityToken == null) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_SIGNATURE);
+ throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_SIGNATURE);
}
signatureAlgorithm.engineInitSign(wrappingSecurityToken.getSecretKey(getSecurityProperties().getSignatureAlgorithm(), null));
- SignedInfoProcessor signedInfoProcessor = new SignedInfoProcessor(getSecurityProperties(), getAction(), signatureAlgorithm);
+ SignedInfoProcessor signedInfoProcessor = newSignedInfoProcessor(signatureAlgorithm);
subOutputProcessorChain.addProcessor(signedInfoProcessor);
- createStartElementAndOutputAsEvent(subOutputProcessorChain, Constants.TAG_dsig_SignedInfo, null);
+ createStartElementAndOutputAsEvent(subOutputProcessorChain, XMLSecurityConstants.TAG_dsig_SignedInfo, null);
attributes = new HashMap<QName, String>();
- attributes.put(Constants.ATT_NULL_Algorithm, getSecurityProperties().getSignatureCanonicalizationAlgorithm());
- createStartElementAndOutputAsEvent(subOutputProcessorChain, Constants.TAG_dsig_CanonicalizationMethod, attributes);
- createEndElementAndOutputAsEvent(subOutputProcessorChain, Constants.TAG_dsig_CanonicalizationMethod);
+ attributes.put(XMLSecurityConstants.ATT_NULL_Algorithm, getSecurityProperties().getSignatureCanonicalizationAlgorithm());
+ createStartElementAndOutputAsEvent(subOutputProcessorChain, XMLSecurityConstants.TAG_dsig_CanonicalizationMethod, attributes);
+ createEndElementAndOutputAsEvent(subOutputProcessorChain, XMLSecurityConstants.TAG_dsig_CanonicalizationMethod);
attributes = new HashMap<QName, String>();
- attributes.put(Constants.ATT_NULL_Algorithm, getSecurityProperties().getSignatureAlgorithm());
- createStartElementAndOutputAsEvent(subOutputProcessorChain, Constants.TAG_dsig_SignatureMethod, attributes);
- createEndElementAndOutputAsEvent(subOutputProcessorChain, Constants.TAG_dsig_SignatureMethod);
+ attributes.put(XMLSecurityConstants.ATT_NULL_Algorithm, getSecurityProperties().getSignatureAlgorithm());
+ createStartElementAndOutputAsEvent(subOutputProcessorChain, XMLSecurityConstants.TAG_dsig_SignatureMethod, attributes);
+ createEndElementAndOutputAsEvent(subOutputProcessorChain, XMLSecurityConstants.TAG_dsig_SignatureMethod);
Iterator<SignaturePartDef> signaturePartDefIterator = signaturePartDefList.iterator();
while (signaturePartDefIterator.hasNext()) {
SignaturePartDef signaturePartDef = signaturePartDefIterator.next();
attributes = new HashMap<QName, String>();
- attributes.put(Constants.ATT_NULL_URI, "#" + signaturePartDef.getSigRefId());
- createStartElementAndOutputAsEvent(subOutputProcessorChain, Constants.TAG_dsig_Reference, attributes);
- createStartElementAndOutputAsEvent(subOutputProcessorChain, Constants.TAG_dsig_Transforms, null);
-
- if (signaturePartDef.getTransformAlgo() != null) {
- attributes = new HashMap<QName, String>();
- attributes.put(Constants.ATT_NULL_Algorithm, signaturePartDef.getTransformAlgo());
- createStartElementAndOutputAsEvent(subOutputProcessorChain, Constants.TAG_dsig_Transform, attributes);
- createStartElementAndOutputAsEvent(subOutputProcessorChain, Constants.TAG_wsse_TransformationParameters, null);
- attributes = new HashMap<QName, String>();
- attributes.put(Constants.ATT_NULL_Algorithm, signaturePartDef.getC14nAlgo());
- createStartElementAndOutputAsEvent(subOutputProcessorChain, Constants.TAG_dsig_CanonicalizationMethod, attributes);
- createEndElementAndOutputAsEvent(subOutputProcessorChain, Constants.TAG_dsig_CanonicalizationMethod);
- createEndElementAndOutputAsEvent(subOutputProcessorChain, Constants.TAG_wsse_TransformationParameters);
- createEndElementAndOutputAsEvent(subOutputProcessorChain, Constants.TAG_dsig_Transform);
- } else {
- attributes = new HashMap<QName, String>();
- attributes.put(Constants.ATT_NULL_Algorithm, signaturePartDef.getC14nAlgo());
- createStartElementAndOutputAsEvent(subOutputProcessorChain, Constants.TAG_dsig_Transform, attributes);
- createEndElementAndOutputAsEvent(subOutputProcessorChain, Constants.TAG_dsig_Transform);
- }
-
- createEndElementAndOutputAsEvent(subOutputProcessorChain, Constants.TAG_dsig_Transforms);
+ attributes.put(XMLSecurityConstants.ATT_NULL_URI, "#" + signaturePartDef.getSigRefId());
+ createStartElementAndOutputAsEvent(subOutputProcessorChain, XMLSecurityConstants.TAG_dsig_Reference, attributes);
+ createStartElementAndOutputAsEvent(subOutputProcessorChain, XMLSecurityConstants.TAG_dsig_Transforms, null);
+ createTransformsStructureForSignature(subOutputProcessorChain, signaturePartDef);
+ createEndElementAndOutputAsEvent(subOutputProcessorChain, XMLSecurityConstants.TAG_dsig_Transforms);
attributes = new HashMap<QName, String>();
- attributes.put(Constants.ATT_NULL_Algorithm, getSecurityProperties().getSignatureDigestAlgorithm());
- createStartElementAndOutputAsEvent(subOutputProcessorChain, Constants.TAG_dsig_DigestMethod, attributes);
- createEndElementAndOutputAsEvent(subOutputProcessorChain, Constants.TAG_dsig_DigestMethod);
- createStartElementAndOutputAsEvent(subOutputProcessorChain, Constants.TAG_dsig_DigestValue, null);
+ attributes.put(XMLSecurityConstants.ATT_NULL_Algorithm, getSecurityProperties().getSignatureDigestAlgorithm());
+ createStartElementAndOutputAsEvent(subOutputProcessorChain, XMLSecurityConstants.TAG_dsig_DigestMethod, attributes);
+ createEndElementAndOutputAsEvent(subOutputProcessorChain, XMLSecurityConstants.TAG_dsig_DigestMethod);
+ createStartElementAndOutputAsEvent(subOutputProcessorChain, XMLSecurityConstants.TAG_dsig_DigestValue, null);
createCharactersAndOutputAsEvent(subOutputProcessorChain, signaturePartDef.getDigestValue());
- createEndElementAndOutputAsEvent(subOutputProcessorChain, Constants.TAG_dsig_DigestValue);
- createEndElementAndOutputAsEvent(subOutputProcessorChain, Constants.TAG_dsig_Reference);
+ createEndElementAndOutputAsEvent(subOutputProcessorChain, XMLSecurityConstants.TAG_dsig_DigestValue);
+ createEndElementAndOutputAsEvent(subOutputProcessorChain, XMLSecurityConstants.TAG_dsig_Reference);
}
- createEndElementAndOutputAsEvent(subOutputProcessorChain, Constants.TAG_dsig_SignedInfo);
+ createEndElementAndOutputAsEvent(subOutputProcessorChain, XMLSecurityConstants.TAG_dsig_SignedInfo);
subOutputProcessorChain.removeProcessor(signedInfoProcessor);
- createStartElementAndOutputAsEvent(subOutputProcessorChain, Constants.TAG_dsig_SignatureValue, null);
+ createStartElementAndOutputAsEvent(subOutputProcessorChain, XMLSecurityConstants.TAG_dsig_SignatureValue, null);
final byte[] signatureValue = signedInfoProcessor.getSignatureValue();
createCharactersAndOutputAsEvent(subOutputProcessorChain, new Base64(76, new byte[]{'\n'}).encodeToString(signatureValue));
- createEndElementAndOutputAsEvent(subOutputProcessorChain, Constants.TAG_dsig_SignatureValue);
+ createEndElementAndOutputAsEvent(subOutputProcessorChain, XMLSecurityConstants.TAG_dsig_SignatureValue);
attributes = new HashMap<QName, String>();
- attributes.put(Constants.ATT_NULL_Id, "KeyId-" + UUID.randomUUID().toString());
- createStartElementAndOutputAsEvent(subOutputProcessorChain, Constants.TAG_dsig_KeyInfo, attributes);
- createSecurityTokenReferenceStructureForSignature(subOutputProcessorChain, wrappingSecurityToken, getSecurityProperties().getSignatureKeyIdentifierType(), getSecurityProperties().isUseSingleCert());
- createEndElementAndOutputAsEvent(subOutputProcessorChain, Constants.TAG_dsig_KeyInfo);
- createEndElementAndOutputAsEvent(subOutputProcessorChain, Constants.TAG_dsig_Signature);
-
- SignatureValueSecurityEvent signatureValueSecurityEvent = new SignatureValueSecurityEvent(SecurityEvent.Event.SignatureValue);
- signatureValueSecurityEvent.setSignatureValue(signatureValue);
- outputProcessorChain.getSecurityContext().registerSecurityEvent(signatureValueSecurityEvent);
+ attributes.put(XMLSecurityConstants.ATT_NULL_Id, "KeyId-" + UUID.randomUUID().toString());
+ createStartElementAndOutputAsEvent(subOutputProcessorChain, XMLSecurityConstants.TAG_dsig_KeyInfo, attributes);
+ createKeyInfoStructureForSignature(subOutputProcessorChain, wrappingSecurityToken, getSecurityProperties().isUseSingleCert());
+ createEndElementAndOutputAsEvent(subOutputProcessorChain, XMLSecurityConstants.TAG_dsig_KeyInfo);
+ createEndElementAndOutputAsEvent(subOutputProcessorChain, XMLSecurityConstants.TAG_dsig_Signature);
}
- class SignedInfoProcessor extends AbstractOutputProcessor {
+ protected SignedInfoProcessor newSignedInfoProcessor(SignatureAlgorithm signatureAlgorithm) throws XMLSecurityException {
+ SignedInfoProcessor signedInfoProcessor = new SignedInfoProcessor(getSecurityProperties(), getAction(), signatureAlgorithm);
+ signedInfoProcessor.getAfterProcessors().add(AbstractSignatureEndingOutputProcessor.class.getName());
+ return signedInfoProcessor;
+ }
+
+ protected abstract void createTransformsStructureForSignature(
+ OutputProcessorChain subOutputProcessorChain,
+ SignaturePartDef signaturePartDef) throws XMLStreamException, XMLSecurityException;
+
+ protected abstract void createKeyInfoStructureForSignature(
+ OutputProcessorChain outputProcessorChain,
+ SecurityToken securityToken,
+ boolean useSingleCertificate) throws XMLStreamException, XMLSecurityException;
+
+
+ public class SignedInfoProcessor extends AbstractOutputProcessor {
private SignerOutputStream signerOutputStream;
private OutputStream bufferedSignerOutputStream;
private Transformer transformer;
+ private byte[] signatureValue = null;
- SignedInfoProcessor(SecurityProperties securityProperties, Constants.Action action, SignatureAlgorithm signatureAlgorithm) throws WSSecurityException {
+ public SignedInfoProcessor(XMLSecurityProperties securityProperties, XMLSecurityConstants.Action action, SignatureAlgorithm signatureAlgorithm) throws XMLSecurityException {
super(securityProperties, action);
- this.getAfterProcessors().add(SignatureEndingOutputProcessor.class.getName());
signerOutputStream = new SignerOutputStream(signatureAlgorithm);
bufferedSignerOutputStream = new BufferedOutputStream(signerOutputStream);
try {
- transformer = Utils.getTransformer(null, this.bufferedSignerOutputStream, getSecurityProperties().getSignatureCanonicalizationAlgorithm());
+ transformer = XMLSecurityUtils.getTransformer(null, this.bufferedSignerOutputStream, getSecurityProperties().getSignatureCanonicalizationAlgorithm());
} catch (NoSuchMethodException e) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_SIGNATURE, e);
+ throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_SIGNATURE, e);
} catch (InstantiationException e) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_SIGNATURE, e);
+ throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_SIGNATURE, e);
} catch (IllegalAccessException e) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_SIGNATURE, e);
+ throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_SIGNATURE, e);
} catch (InvocationTargetException e) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_SIGNATURE, e);
+ throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_SIGNATURE, e);
}
}
- public byte[] getSignatureValue() throws WSSecurityException {
+ public byte[] getSignatureValue() throws XMLSecurityException {
+ if (signatureValue != null) {
+ return signatureValue;
+ }
try {
bufferedSignerOutputStream.close();
- return signerOutputStream.sign();
+ signatureValue = signerOutputStream.sign();
+ return signatureValue;
} catch (IOException e) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_SIGNATURE, e);
+ throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_SIGNATURE, e);
}
}
@Override
- public void processEvent(XMLEvent xmlEvent, OutputProcessorChain outputProcessorChain) throws XMLStreamException, WSSecurityException {
+ public void processEvent(XMLEvent xmlEvent, OutputProcessorChain outputProcessorChain) throws XMLStreamException, XMLSecurityException {
transformer.transform(xmlEvent);
outputProcessorChain.processEvent(xmlEvent);
}
Propchange: webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/processor/output/AbstractSignatureEndingOutputProcessor.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/processor/output/AbstractSignatureOutputProcessor.java (from r1179730, webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/impl/processor/output/SignatureOutputProcessor.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/processor/output/AbstractSignatureOutputProcessor.java?p2=webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/processor/output/AbstractSignatureOutputProcessor.java&p1=webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/impl/processor/output/SignatureOutputProcessor.java&r1=1179730&r2=1181995&rev=1181995&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/impl/processor/output/SignatureOutputProcessor.java (original)
+++ webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/processor/output/AbstractSignatureOutputProcessor.java Tue Oct 11 18:03:00 2011
@@ -16,12 +16,13 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.swssf.impl.processor.output;
+package org.swssf.xmlsec.impl.processor.output;
import org.apache.commons.codec.binary.Base64;
-import org.swssf.config.JCEAlgorithmMapper;
-import org.swssf.ext.*;
-import org.swssf.impl.SignaturePartDef;
+import org.swssf.xmlsec.config.JCEAlgorithmMapper;
+import org.swssf.xmlsec.ext.*;
+import org.swssf.xmlsec.impl.SignaturePartDef;
+import org.swssf.xmlsec.impl.util.DigestOutputStream;
import org.xmlsecurity.ns.configuration.AlgorithmType;
import javax.xml.namespace.QName;
@@ -37,20 +38,22 @@ import java.lang.reflect.InvocationTarge
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
-import java.util.*;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
/**
* @author $Author$
* @version $Revision$ $Date$
*/
-public class SignatureOutputProcessor extends AbstractOutputProcessor {
+public abstract class AbstractSignatureOutputProcessor extends AbstractOutputProcessor {
private List<SecurePart> secureParts;
private List<SignaturePartDef> signaturePartDefList = new LinkedList<SignaturePartDef>();
private InternalSignatureOutputProcessor activeInternalSignatureOutputProcessor = null;
- public SignatureOutputProcessor(SecurityProperties securityProperties, Constants.Action action) throws WSSecurityException {
+ public AbstractSignatureOutputProcessor(XMLSecurityProperties securityProperties, XMLSecurityConstants.Action action) throws XMLSecurityException {
super(securityProperties, action);
secureParts = securityProperties.getSignatureSecureParts();
}
@@ -60,70 +63,10 @@ public class SignatureOutputProcessor ex
}
@Override
- public void processEvent(XMLEvent xmlEvent, OutputProcessorChain outputProcessorChain) throws XMLStreamException, WSSecurityException {
- if (xmlEvent.isStartElement()) {
- StartElement startElement = xmlEvent.asStartElement();
-
- //avoid double signature when child elements matches too
- if (activeInternalSignatureOutputProcessor == null) {
- SecurePart securePart = securePartMatches(startElement, outputProcessorChain);
- if (securePart != null) {
+ public abstract void processEvent(XMLEvent xmlEvent, OutputProcessorChain outputProcessorChain) throws XMLStreamException, XMLSecurityException;
- logger.debug("Matched securePart for signature");
- InternalSignatureOutputProcessor internalSignatureOutputProcessor = null;
- try {
- SignaturePartDef signaturePartDef = new SignaturePartDef();
- if (securePart.getIdToSign() == null) {
- signaturePartDef.setSigRefId("id-" + UUID.randomUUID().toString());
- signaturePartDef.setC14nAlgo(getSecurityProperties().getSignatureCanonicalizationAlgorithm());
-
- boolean found = false;
- List<Attribute> attributeList = new ArrayList<Attribute>();
- @SuppressWarnings("unchecked")
- Iterator<Attribute> attributeIterator = startElement.getAttributes();
- while (attributeIterator.hasNext()) {
- Attribute attribute = attributeIterator.next();
- if (attribute.getName().equals(Constants.ATT_wsu_Id)) {
- signaturePartDef.setSigRefId(attribute.getValue());
- found = true;
- }
- }
- if (!found) {
- attributeList.add(createAttribute(Constants.ATT_wsu_Id, signaturePartDef.getSigRefId()));
- xmlEvent = cloneStartElementEvent(xmlEvent, attributeList);
- }
- } else {
- if (Constants.SOAPMESSAGE_NS10_STRTransform.equals(securePart.getName())) {
- signaturePartDef.setSigRefId(securePart.getIdToReference());
- signaturePartDef.setTransformAlgo(Constants.SOAPMESSAGE_NS10_STRTransform);
- signaturePartDef.setC14nAlgo(Constants.NS_C14N_EXCL);
- } else {
- signaturePartDef.setSigRefId(securePart.getIdToSign());
- signaturePartDef.setC14nAlgo(getSecurityProperties().getSignatureCanonicalizationAlgorithm());
- }
- }
-
- signaturePartDefList.add(signaturePartDef);
- internalSignatureOutputProcessor = new InternalSignatureOutputProcessor(getSecurityProperties(), getAction(), signaturePartDef, startElement.getName());
-
- } catch (NoSuchAlgorithmException e) {
- throw new WSSecurityException(
- WSSecurityException.ErrorCode.UNSUPPORTED_ALGORITHM, "unsupportedKeyTransp",
- e, "No such algorithm: " + getSecurityProperties().getSignatureAlgorithm()
- );
- } catch (NoSuchProviderException e) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "noSecProvider", e);
- }
-
- activeInternalSignatureOutputProcessor = internalSignatureOutputProcessor;
- outputProcessorChain.addProcessor(internalSignatureOutputProcessor);
- }
- }
- }
- outputProcessorChain.processEvent(xmlEvent);
- }
- private SecurePart securePartMatches(StartElement startElement, OutputProcessorChain outputProcessorChain) {
+ protected SecurePart securePartMatches(StartElement startElement, OutputProcessorChain outputProcessorChain) {
SecurePart securePart = securePartMatches(startElement, this.secureParts);
if (securePart != null) {
return securePart;
@@ -135,7 +78,7 @@ public class SignatureOutputProcessor ex
return securePartMatches(startElement, secureParts);
}
- private SecurePart securePartMatches(StartElement startElement, List<SecurePart> secureParts) {
+ protected SecurePart securePartMatches(StartElement startElement, List<SecurePart> secureParts) {
Iterator<SecurePart> securePartIterator = secureParts.iterator();
while (securePartIterator.hasNext()) {
SecurePart securePart = securePartIterator.next();
@@ -151,10 +94,7 @@ public class SignatureOutputProcessor ex
Attribute attribute = attributeIterator.next();
if (attribute != null) {
QName attributeName = attribute.getName();
- if ((attributeName.equals(Constants.ATT_wsu_Id)
- || attributeName.equals(Constants.ATT_NULL_Id)
- || attributeName.equals(Constants.ATT_NULL_ID)
- || attributeName.equals(Constants.ATT_NULL_AssertionID))
+ if ((attributeName.equals(XMLSecurityConstants.ATT_NULL_Id))
&& attribute.getValue().equals(securePart.getIdToSign())) {
return securePart;
}
@@ -165,49 +105,55 @@ public class SignatureOutputProcessor ex
return null;
}
- class InternalSignatureOutputProcessor extends AbstractOutputProcessor {
+ protected InternalSignatureOutputProcessor getActiveInternalSignatureOutputProcessor() {
+ return activeInternalSignatureOutputProcessor;
+ }
+
+ protected void setActiveInternalSignatureOutputProcessor(InternalSignatureOutputProcessor activeInternalSignatureOutputProcessor) {
+ this.activeInternalSignatureOutputProcessor = activeInternalSignatureOutputProcessor;
+ }
+
+ public class InternalSignatureOutputProcessor extends AbstractOutputProcessor {
private SignaturePartDef signaturePartDef;
private QName startElement;
private int elementCounter = 0;
private OutputStream bufferedDigestOutputStream;
- private org.swssf.impl.util.DigestOutputStream digestOutputStream;
+ private DigestOutputStream digestOutputStream;
private Transformer transformer;
- InternalSignatureOutputProcessor(SecurityProperties securityProperties, Constants.Action action, SignaturePartDef signaturePartDef, QName startElement) throws WSSecurityException, NoSuchProviderException, NoSuchAlgorithmException {
+ public InternalSignatureOutputProcessor(XMLSecurityProperties securityProperties, XMLSecurityConstants.Action action, SignaturePartDef signaturePartDef, QName startElement) throws XMLSecurityException, NoSuchProviderException, NoSuchAlgorithmException {
super(securityProperties, action);
- this.getAfterProcessors().add(SignatureOutputProcessor.class.getName());
- this.getBeforeProcessors().add(SignatureEndingOutputProcessor.class.getName());
this.getBeforeProcessors().add(InternalSignatureOutputProcessor.class.getName());
this.signaturePartDef = signaturePartDef;
this.startElement = startElement;
AlgorithmType algorithmID = JCEAlgorithmMapper.getAlgorithmMapping(getSecurityProperties().getSignatureDigestAlgorithm());
MessageDigest messageDigest = MessageDigest.getInstance(algorithmID.getJCEName(), algorithmID.getJCEProvider());
- this.digestOutputStream = new org.swssf.impl.util.DigestOutputStream(messageDigest);
+ this.digestOutputStream = new DigestOutputStream(messageDigest);
this.bufferedDigestOutputStream = new BufferedOutputStream(digestOutputStream);
try {
if (signaturePartDef.getTransformAlgo() != null) {
- Transformer transformer = Utils.getTransformer("#default", this.bufferedDigestOutputStream, signaturePartDef.getC14nAlgo());
- this.transformer = Utils.getTransformer(transformer, null, signaturePartDef.getTransformAlgo());
+ Transformer transformer = XMLSecurityUtils.getTransformer("#default", this.bufferedDigestOutputStream, signaturePartDef.getC14nAlgo());
+ this.transformer = XMLSecurityUtils.getTransformer(transformer, null, signaturePartDef.getTransformAlgo());
} else {
- transformer = Utils.getTransformer(null, this.bufferedDigestOutputStream, signaturePartDef.getC14nAlgo());
+ transformer = XMLSecurityUtils.getTransformer(null, this.bufferedDigestOutputStream, signaturePartDef.getC14nAlgo());
}
} catch (NoSuchMethodException e) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_SIGNATURE, e);
+ throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_SIGNATURE, e);
} catch (InstantiationException e) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_SIGNATURE, e);
+ throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_SIGNATURE, e);
} catch (IllegalAccessException e) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_SIGNATURE, e);
+ throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_SIGNATURE, e);
} catch (InvocationTargetException e) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_SIGNATURE, e);
+ throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_SIGNATURE, e);
}
}
@Override
- public void processEvent(XMLEvent xmlEvent, OutputProcessorChain outputProcessorChain) throws XMLStreamException, WSSecurityException {
+ public void processEvent(XMLEvent xmlEvent, OutputProcessorChain outputProcessorChain) throws XMLStreamException, XMLSecurityException {
transformer.transform(xmlEvent);
@@ -222,7 +168,7 @@ public class SignatureOutputProcessor ex
try {
bufferedDigestOutputStream.close();
} catch (IOException e) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_SIGNATURE, e);
+ throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILED_SIGNATURE, e);
}
String calculatedDigest = new String(Base64.encodeBase64(this.digestOutputStream.getDigestValue()));
logger.debug("Calculated Digest: " + calculatedDigest);
@@ -230,7 +176,7 @@ public class SignatureOutputProcessor ex
outputProcessorChain.removeProcessor(this);
//from now on signature is possible again
- activeInternalSignatureOutputProcessor = null;
+ setActiveInternalSignatureOutputProcessor(null);
xmlEvent = createEndElement(startElement);
}
}
Propchange: webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/processor/output/AbstractSignatureOutputProcessor.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/processor/output/FinalOutputProcessor.java (from r1179730, webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/impl/processor/output/FinalOutputProcessor.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/processor/output/FinalOutputProcessor.java?p2=webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/processor/output/FinalOutputProcessor.java&p1=webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/impl/processor/output/FinalOutputProcessor.java&r1=1179730&r2=1181995&rev=1181995&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/impl/processor/output/FinalOutputProcessor.java (original)
+++ webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/processor/output/FinalOutputProcessor.java Tue Oct 11 18:03:00 2011
@@ -16,9 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.swssf.impl.processor.output;
+package org.swssf.xmlsec.impl.processor.output;
-import org.swssf.ext.*;
+import org.swssf.xmlsec.ext.*;
import javax.xml.stream.XMLEventWriter;
import javax.xml.stream.XMLOutputFactory;
@@ -42,28 +42,28 @@ public class FinalOutputProcessor extend
xmlOutputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, false);
}
- public FinalOutputProcessor(OutputStream outputStream, String encoding, SecurityProperties securityProperties, Constants.Action action) throws WSSecurityException {
+ public FinalOutputProcessor(OutputStream outputStream, String encoding, XMLSecurityProperties securityProperties, XMLSecurityConstants.Action action) throws XMLSecurityException {
super(securityProperties, action);
- setPhase(Constants.Phase.POSTPROCESSING);
+ setPhase(XMLSecurityConstants.Phase.POSTPROCESSING);
try {
xmlEventWriter = xmlOutputFactory.createXMLEventWriter(outputStream, encoding);
} catch (XMLStreamException e) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e);
+ throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILURE, e);
}
}
@Override
- public void processEvent(XMLEvent xmlEvent, OutputProcessorChain outputProcessorChain) throws XMLStreamException, WSSecurityException {
+ public void processEvent(XMLEvent xmlEvent, OutputProcessorChain outputProcessorChain) throws XMLStreamException, XMLSecurityException {
xmlEventWriter.add(xmlEvent);
}
@Override
- public void doFinal(OutputProcessorChain outputProcessorChain) throws WSSecurityException {
+ public void doFinal(OutputProcessorChain outputProcessorChain) throws XMLSecurityException {
try {
xmlEventWriter.flush();
xmlEventWriter.close();
} catch (XMLStreamException e) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e);
+ throw new XMLSecurityException(XMLSecurityException.ErrorCode.FAILURE, e);
}
}
}
Copied: webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/securityToken/SecurityTokenFactory.java (from r1179730, webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/impl/securityToken/SecurityTokenFactory.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/securityToken/SecurityTokenFactory.java?p2=webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/securityToken/SecurityTokenFactory.java&p1=webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/impl/securityToken/SecurityTokenFactory.java&r1=1179730&r2=1181995&rev=1181995&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/impl/securityToken/SecurityTokenFactory.java (original)
+++ webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/securityToken/SecurityTokenFactory.java Tue Oct 11 18:03:00 2011
@@ -16,22 +16,16 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.swssf.impl.securityToken;
+package org.swssf.xmlsec.impl.securityToken;
-import org.apache.commons.codec.binary.Base64;
-import org.oasis_open.docs.wss._2004._01.oasis_200401_wss_wssecurity_secext_1_0.BinarySecurityTokenType;
-import org.oasis_open.docs.wss._2004._01.oasis_200401_wss_wssecurity_secext_1_0.KeyIdentifierType;
-import org.oasis_open.docs.wss._2004._01.oasis_200401_wss_wssecurity_secext_1_0.SecurityTokenReferenceType;
-import org.oasis_open.docs.wss._2004._01.oasis_200401_wss_wssecurity_secext_1_0.UsernameTokenType;
-import org.opensaml.common.SAMLVersion;
-import org.swssf.crypto.Crypto;
-import org.swssf.ext.*;
-import org.swssf.impl.saml.SAMLKeyInfo;
+import org.swssf.xmlsec.config.ConfigurationProperties;
+import org.swssf.xmlsec.crypto.Crypto;
+import org.swssf.xmlsec.ext.SecurityContext;
+import org.swssf.xmlsec.ext.SecurityToken;
+import org.swssf.xmlsec.ext.XMLSecurityException;
import org.w3._2000._09.xmldsig_.KeyInfoType;
import javax.security.auth.callback.CallbackHandler;
-import javax.xml.stream.events.XMLEvent;
-import java.util.Deque;
/**
* Factory to create SecurityToken Objects from keys in XML
@@ -39,125 +33,29 @@ import java.util.Deque;
* @author $Author$
* @version $Revision$ $Date$
*/
-public class SecurityTokenFactory {
+public abstract class SecurityTokenFactory {
- private SecurityTokenFactory() {
- }
-
- public synchronized static SecurityTokenFactory newInstance() throws WSSecurityException {
- return new SecurityTokenFactory();
- }
+ public static SecurityTokenFactory newInstance() throws XMLSecurityException {
- public SecurityToken getSecurityToken(KeyInfoType keyInfoType, Crypto crypto, final CallbackHandler callbackHandler, SecurityContext securityContext, Object processor) throws WSSecurityException {
- if (keyInfoType != null) {
- return getSecurityToken(keyInfoType.getSecurityTokenReferenceType(), crypto, callbackHandler, securityContext, processor);
- } else if (crypto.getDefaultX509Alias() != null) {
- return new X509DefaultSecurityToken(securityContext, crypto, callbackHandler, crypto.getDefaultX509Alias(), crypto.getDefaultX509Alias(), processor);
+ String stf = ConfigurationProperties.getProperty("securityTokenFactory");
+ if (stf == null) {
+ throw new XMLSecurityException(XMLSecurityException.ErrorCode.INVALID_SECURITY, "missingSecurityTokenFactory");
}
- throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY, "noKeyinfo");
- }
- public SecurityToken getSecurityToken(SecurityTokenReferenceType securityTokenReferenceType, Crypto crypto, final CallbackHandler callbackHandler, SecurityContext securityContext, Object processor) throws WSSecurityException {
try {
- if (securityTokenReferenceType == null) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY, "noSecTokRef");
- }
-
- if (securityTokenReferenceType.getX509DataType() != null) {
- return new DelegatingSecurityToken(Constants.KeyIdentifierType.ISSUER_SERIAL, new X509DataSecurityToken(securityContext, crypto, callbackHandler, securityTokenReferenceType.getX509DataType(), securityTokenReferenceType.getId(), processor));
- }
- //todo this is not supported by outputProcessor but can be implemented. We'll have a look at the spec if this is allowed
- else if (securityTokenReferenceType.getKeyIdentifierType() != null) {
- KeyIdentifierType keyIdentifierType = securityTokenReferenceType.getKeyIdentifierType();
-
- String valueType = keyIdentifierType.getValueType();
- String encodingType = keyIdentifierType.getEncodingType();
-
- byte[] binaryContent = null;
- if (Constants.SOAPMESSAGE_NS10_BASE64_ENCODING.equals(encodingType)) {
- binaryContent = Base64.decodeBase64(keyIdentifierType.getValue());
- }
-
- if (Constants.NS_X509_V3_TYPE.equals(valueType)) {
- return new X509_V3SecurityToken(securityContext, crypto, callbackHandler, binaryContent, securityTokenReferenceType.getId(), processor);
- } else if (Constants.NS_X509SubjectKeyIdentifier.equals(valueType)) {
- return new X509SubjectKeyIdentifierSecurityToken(securityContext, crypto, callbackHandler, binaryContent, securityTokenReferenceType.getId(), processor);
- } else if (Constants.NS_THUMBPRINT.equals(valueType)) {
- return new ThumbprintSHA1SecurityToken(securityContext, crypto, callbackHandler, binaryContent, securityTokenReferenceType.getId(), processor);
- } else if (Constants.NS_SAML10_TYPE.equals(valueType) || Constants.NS_SAML20_TYPE.equals(valueType)) {
- SecurityTokenProvider securityTokenProvider = securityContext.getSecurityTokenProvider(keyIdentifierType.getValue());
- if (securityTokenProvider == null) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.SECURITY_TOKEN_UNAVAILABLE, "noToken", keyIdentifierType.getValue());
- }
- return securityTokenProvider.getSecurityToken(crypto);
- }
- } else if (securityTokenReferenceType.getReferenceType() != null) {
-
- String uri = securityTokenReferenceType.getReferenceType().getURI();
- if (uri == null) {
- throw new WSSecurityException("badReferenceURI");
- }
- uri = Utils.dropReferenceMarker(uri);
- //embedded BST:
- if (securityTokenReferenceType.getReferenceType().getBinarySecurityTokenType() != null
- && uri.equals(securityTokenReferenceType.getReferenceType().getBinarySecurityTokenType().getId())) {
- BinarySecurityTokenType binarySecurityTokenType = securityTokenReferenceType.getReferenceType().getBinarySecurityTokenType();
- return new DelegatingSecurityToken(Constants.KeyIdentifierType.BST_EMBEDDED, getSecurityToken(binarySecurityTokenType, securityContext, crypto, callbackHandler, processor));
- } else {//referenced BST:
- //we have to search BST somewhere in the doc. First we will check for a BST already processed and
- //stored in the context. Otherwise we will abort now.
-
- //prevent recursive key reference DOS:
- Integer invokeCount = securityContext.<Integer>get("" + Thread.currentThread().hashCode());
- if (invokeCount == null) {
- invokeCount = 0;
- }
- invokeCount++;
- if (invokeCount == 10) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY_TOKEN);
- }
- securityContext.put("" + Thread.currentThread().hashCode(), invokeCount);
-
- SecurityTokenProvider securityTokenProvider = securityContext.getSecurityTokenProvider(uri);
- if (securityTokenProvider == null) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.SECURITY_TOKEN_UNAVAILABLE, "noToken", uri);
- }
- return new DelegatingSecurityToken(Constants.KeyIdentifierType.BST_DIRECT_REFERENCE, securityTokenProvider.getSecurityToken(crypto));
- }
- }
- throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY, "noKeyinfo");
- } finally {
- securityContext.remove("" + Thread.currentThread().hashCode());
- }
- }
-
- public SecurityToken getSecurityToken(BinarySecurityTokenType binarySecurityTokenType, SecurityContext securityContext, Crypto crypto, CallbackHandler callbackHandler, Object processor) throws WSSecurityException {
-
- //only Base64Encoding is supported
- if (!Constants.SOAPMESSAGE_NS10_BASE64_ENCODING.equals(binarySecurityTokenType.getEncodingType())) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY_TOKEN, "badEncoding", binarySecurityTokenType.getEncodingType());
+ @SuppressWarnings("unchecked")
+ Class<SecurityTokenFactory> securityTokenFactoryClass = (Class<SecurityTokenFactory>) SecurityTokenFactory.class.getClassLoader().loadClass(stf);
+ return securityTokenFactoryClass.newInstance();
+ } catch (ClassNotFoundException e) {
+ throw new XMLSecurityException(XMLSecurityException.ErrorCode.INVALID_SECURITY, "missingSecurityTokenFactory", e);
+ } catch (InstantiationException e) {
+ throw new XMLSecurityException(XMLSecurityException.ErrorCode.INVALID_SECURITY, "missingSecurityTokenFactory", e);
+ } catch (IllegalAccessException e) {
+ throw new XMLSecurityException(XMLSecurityException.ErrorCode.INVALID_SECURITY, "missingSecurityTokenFactory", e);
}
-
- byte[] securityTokenData = Base64.decodeBase64(binarySecurityTokenType.getValue());
-
- if (Constants.NS_X509_V3_TYPE.equals(binarySecurityTokenType.getValueType())) {
- return new X509_V3SecurityToken(securityContext, crypto, callbackHandler, securityTokenData, binarySecurityTokenType.getId(), processor);
- } else if (Constants.NS_X509PKIPathv1.equals(binarySecurityTokenType.getValueType())) {
- return new X509PKIPathv1SecurityToken(securityContext, crypto, callbackHandler, securityTokenData, binarySecurityTokenType.getId(), processor);
- } else {
- throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY_TOKEN, "invalidValueType", binarySecurityTokenType.getValueType());
- }
- }
-
- public SecurityToken getSecurityToken(UsernameTokenType usernameTokenType, SecurityContext securityContext, Object processor) throws WSSecurityException {
- return new UsernameSecurityToken(usernameTokenType, securityContext, usernameTokenType.getId(), processor);
- }
-
- public SecurityToken getSecurityToken(SAMLVersion samlVersion, SAMLKeyInfo samlKeyInfo, SecurityContext securityContext, Crypto crypto, CallbackHandler callbackHandler, String id, Object processor) throws WSSecurityException {
- return new SAMLSecurityToken(samlVersion, samlKeyInfo, securityContext, crypto, callbackHandler, id, processor);
}
- public SecurityToken getSecurityToken(String referencedTokenId, Deque<XMLEvent> xmlEvents, Crypto crypto, CallbackHandler callbackHandler, SecurityContext securityContext, String id, Object processor) throws WSSecurityException {
- return new SecurityTokenReference(securityContext.getSecurityTokenProvider(referencedTokenId).getSecurityToken(crypto), xmlEvents, crypto, callbackHandler, id, processor);
- }
+ public abstract SecurityToken getSecurityToken(KeyInfoType keyInfoType, Crypto crypto,
+ final CallbackHandler callbackHandler,
+ SecurityContext securityContext, Object processor) throws XMLSecurityException;
}
Copied: webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/securityToken/SecurityTokenFactoryImpl.java (from r1179730, webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/impl/securityToken/SecurityTokenFactory.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/securityToken/SecurityTokenFactoryImpl.java?p2=webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/securityToken/SecurityTokenFactoryImpl.java&p1=webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/impl/securityToken/SecurityTokenFactory.java&r1=1179730&r2=1181995&rev=1181995&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/impl/securityToken/SecurityTokenFactory.java (original)
+++ webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/securityToken/SecurityTokenFactoryImpl.java Tue Oct 11 18:03:00 2011
@@ -16,22 +16,15 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.swssf.impl.securityToken;
+package org.swssf.xmlsec.impl.securityToken;
-import org.apache.commons.codec.binary.Base64;
-import org.oasis_open.docs.wss._2004._01.oasis_200401_wss_wssecurity_secext_1_0.BinarySecurityTokenType;
-import org.oasis_open.docs.wss._2004._01.oasis_200401_wss_wssecurity_secext_1_0.KeyIdentifierType;
-import org.oasis_open.docs.wss._2004._01.oasis_200401_wss_wssecurity_secext_1_0.SecurityTokenReferenceType;
-import org.oasis_open.docs.wss._2004._01.oasis_200401_wss_wssecurity_secext_1_0.UsernameTokenType;
-import org.opensaml.common.SAMLVersion;
-import org.swssf.crypto.Crypto;
-import org.swssf.ext.*;
-import org.swssf.impl.saml.SAMLKeyInfo;
+import org.swssf.xmlsec.crypto.Crypto;
+import org.swssf.xmlsec.ext.SecurityContext;
+import org.swssf.xmlsec.ext.SecurityToken;
+import org.swssf.xmlsec.ext.XMLSecurityException;
import org.w3._2000._09.xmldsig_.KeyInfoType;
import javax.security.auth.callback.CallbackHandler;
-import javax.xml.stream.events.XMLEvent;
-import java.util.Deque;
/**
* Factory to create SecurityToken Objects from keys in XML
@@ -39,125 +32,16 @@ import java.util.Deque;
* @author $Author$
* @version $Revision$ $Date$
*/
-public class SecurityTokenFactory {
+public class SecurityTokenFactoryImpl extends SecurityTokenFactory {
- private SecurityTokenFactory() {
+ protected SecurityTokenFactoryImpl() {
}
- public synchronized static SecurityTokenFactory newInstance() throws WSSecurityException {
- return new SecurityTokenFactory();
- }
-
- public SecurityToken getSecurityToken(KeyInfoType keyInfoType, Crypto crypto, final CallbackHandler callbackHandler, SecurityContext securityContext, Object processor) throws WSSecurityException {
- if (keyInfoType != null) {
- return getSecurityToken(keyInfoType.getSecurityTokenReferenceType(), crypto, callbackHandler, securityContext, processor);
- } else if (crypto.getDefaultX509Alias() != null) {
- return new X509DefaultSecurityToken(securityContext, crypto, callbackHandler, crypto.getDefaultX509Alias(), crypto.getDefaultX509Alias(), processor);
- }
- throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY, "noKeyinfo");
- }
-
- public SecurityToken getSecurityToken(SecurityTokenReferenceType securityTokenReferenceType, Crypto crypto, final CallbackHandler callbackHandler, SecurityContext securityContext, Object processor) throws WSSecurityException {
- try {
- if (securityTokenReferenceType == null) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY, "noSecTokRef");
- }
-
- if (securityTokenReferenceType.getX509DataType() != null) {
- return new DelegatingSecurityToken(Constants.KeyIdentifierType.ISSUER_SERIAL, new X509DataSecurityToken(securityContext, crypto, callbackHandler, securityTokenReferenceType.getX509DataType(), securityTokenReferenceType.getId(), processor));
- }
- //todo this is not supported by outputProcessor but can be implemented. We'll have a look at the spec if this is allowed
- else if (securityTokenReferenceType.getKeyIdentifierType() != null) {
- KeyIdentifierType keyIdentifierType = securityTokenReferenceType.getKeyIdentifierType();
-
- String valueType = keyIdentifierType.getValueType();
- String encodingType = keyIdentifierType.getEncodingType();
-
- byte[] binaryContent = null;
- if (Constants.SOAPMESSAGE_NS10_BASE64_ENCODING.equals(encodingType)) {
- binaryContent = Base64.decodeBase64(keyIdentifierType.getValue());
- }
-
- if (Constants.NS_X509_V3_TYPE.equals(valueType)) {
- return new X509_V3SecurityToken(securityContext, crypto, callbackHandler, binaryContent, securityTokenReferenceType.getId(), processor);
- } else if (Constants.NS_X509SubjectKeyIdentifier.equals(valueType)) {
- return new X509SubjectKeyIdentifierSecurityToken(securityContext, crypto, callbackHandler, binaryContent, securityTokenReferenceType.getId(), processor);
- } else if (Constants.NS_THUMBPRINT.equals(valueType)) {
- return new ThumbprintSHA1SecurityToken(securityContext, crypto, callbackHandler, binaryContent, securityTokenReferenceType.getId(), processor);
- } else if (Constants.NS_SAML10_TYPE.equals(valueType) || Constants.NS_SAML20_TYPE.equals(valueType)) {
- SecurityTokenProvider securityTokenProvider = securityContext.getSecurityTokenProvider(keyIdentifierType.getValue());
- if (securityTokenProvider == null) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.SECURITY_TOKEN_UNAVAILABLE, "noToken", keyIdentifierType.getValue());
- }
- return securityTokenProvider.getSecurityToken(crypto);
- }
- } else if (securityTokenReferenceType.getReferenceType() != null) {
-
- String uri = securityTokenReferenceType.getReferenceType().getURI();
- if (uri == null) {
- throw new WSSecurityException("badReferenceURI");
- }
- uri = Utils.dropReferenceMarker(uri);
- //embedded BST:
- if (securityTokenReferenceType.getReferenceType().getBinarySecurityTokenType() != null
- && uri.equals(securityTokenReferenceType.getReferenceType().getBinarySecurityTokenType().getId())) {
- BinarySecurityTokenType binarySecurityTokenType = securityTokenReferenceType.getReferenceType().getBinarySecurityTokenType();
- return new DelegatingSecurityToken(Constants.KeyIdentifierType.BST_EMBEDDED, getSecurityToken(binarySecurityTokenType, securityContext, crypto, callbackHandler, processor));
- } else {//referenced BST:
- //we have to search BST somewhere in the doc. First we will check for a BST already processed and
- //stored in the context. Otherwise we will abort now.
-
- //prevent recursive key reference DOS:
- Integer invokeCount = securityContext.<Integer>get("" + Thread.currentThread().hashCode());
- if (invokeCount == null) {
- invokeCount = 0;
- }
- invokeCount++;
- if (invokeCount == 10) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY_TOKEN);
- }
- securityContext.put("" + Thread.currentThread().hashCode(), invokeCount);
-
- SecurityTokenProvider securityTokenProvider = securityContext.getSecurityTokenProvider(uri);
- if (securityTokenProvider == null) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.SECURITY_TOKEN_UNAVAILABLE, "noToken", uri);
- }
- return new DelegatingSecurityToken(Constants.KeyIdentifierType.BST_DIRECT_REFERENCE, securityTokenProvider.getSecurityToken(crypto));
- }
- }
- throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY, "noKeyinfo");
- } finally {
- securityContext.remove("" + Thread.currentThread().hashCode());
- }
- }
-
- public SecurityToken getSecurityToken(BinarySecurityTokenType binarySecurityTokenType, SecurityContext securityContext, Crypto crypto, CallbackHandler callbackHandler, Object processor) throws WSSecurityException {
-
- //only Base64Encoding is supported
- if (!Constants.SOAPMESSAGE_NS10_BASE64_ENCODING.equals(binarySecurityTokenType.getEncodingType())) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY_TOKEN, "badEncoding", binarySecurityTokenType.getEncodingType());
- }
-
- byte[] securityTokenData = Base64.decodeBase64(binarySecurityTokenType.getValue());
-
- if (Constants.NS_X509_V3_TYPE.equals(binarySecurityTokenType.getValueType())) {
- return new X509_V3SecurityToken(securityContext, crypto, callbackHandler, securityTokenData, binarySecurityTokenType.getId(), processor);
- } else if (Constants.NS_X509PKIPathv1.equals(binarySecurityTokenType.getValueType())) {
- return new X509PKIPathv1SecurityToken(securityContext, crypto, callbackHandler, securityTokenData, binarySecurityTokenType.getId(), processor);
- } else {
- throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY_TOKEN, "invalidValueType", binarySecurityTokenType.getValueType());
- }
- }
-
- public SecurityToken getSecurityToken(UsernameTokenType usernameTokenType, SecurityContext securityContext, Object processor) throws WSSecurityException {
- return new UsernameSecurityToken(usernameTokenType, securityContext, usernameTokenType.getId(), processor);
- }
-
- public SecurityToken getSecurityToken(SAMLVersion samlVersion, SAMLKeyInfo samlKeyInfo, SecurityContext securityContext, Crypto crypto, CallbackHandler callbackHandler, String id, Object processor) throws WSSecurityException {
- return new SAMLSecurityToken(samlVersion, samlKeyInfo, securityContext, crypto, callbackHandler, id, processor);
- }
+ @Override
+ public SecurityToken getSecurityToken(KeyInfoType keyInfoType, Crypto crypto,
+ final CallbackHandler callbackHandler,
+ SecurityContext securityContext, Object processor) throws XMLSecurityException {
- public SecurityToken getSecurityToken(String referencedTokenId, Deque<XMLEvent> xmlEvents, Crypto crypto, CallbackHandler callbackHandler, SecurityContext securityContext, String id, Object processor) throws WSSecurityException {
- return new SecurityTokenReference(securityContext.getSecurityTokenProvider(referencedTokenId).getSecurityToken(crypto), xmlEvents, crypto, callbackHandler, id, processor);
+ throw new XMLSecurityException(XMLSecurityException.ErrorCode.INVALID_SECURITY, "noKeyinfo");
}
}
Modified: webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/Canonicalizer11.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/Canonicalizer11.java?rev=1181995&r1=1179730&r2=1181995&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/Canonicalizer11.java (original)
+++ webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/Canonicalizer11.java Tue Oct 11 18:03:00 2011
@@ -16,10 +16,10 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.swssf.impl.transformer.canonicalizer;
+package org.swssf.xmlsec.impl.transformer.canonicalizer;
-import org.swssf.ext.ComparableAttribute;
-import org.swssf.ext.XMLEventNS;
+import org.swssf.xmlsec.ext.ComparableAttribute;
+import org.swssf.xmlsec.ext.XMLEventNS;
import javax.xml.stream.events.Attribute;
import javax.xml.stream.events.StartElement;
Modified: webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/Canonicalizer11_OmitCommentsTransformer.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/Canonicalizer11_OmitCommentsTransformer.java?rev=1181995&r1=1179730&r2=1181995&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/Canonicalizer11_OmitCommentsTransformer.java (original)
+++ webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/Canonicalizer11_OmitCommentsTransformer.java Tue Oct 11 18:03:00 2011
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.swssf.impl.transformer.canonicalizer;
+package org.swssf.xmlsec.impl.transformer.canonicalizer;
import java.io.OutputStream;
Modified: webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/Canonicalizer11_WithCommentsTransformer.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/Canonicalizer11_WithCommentsTransformer.java?rev=1181995&r1=1179730&r2=1181995&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/Canonicalizer11_WithCommentsTransformer.java (original)
+++ webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/Canonicalizer11_WithCommentsTransformer.java Tue Oct 11 18:03:00 2011
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.swssf.impl.transformer.canonicalizer;
+package org.swssf.xmlsec.impl.transformer.canonicalizer;
import java.io.OutputStream;
Modified: webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/Canonicalizer20010315.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/Canonicalizer20010315.java?rev=1181995&r1=1179730&r2=1181995&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/Canonicalizer20010315.java (original)
+++ webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/Canonicalizer20010315.java Tue Oct 11 18:03:00 2011
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.swssf.impl.transformer.canonicalizer;
+package org.swssf.xmlsec.impl.transformer.canonicalizer;
import java.io.OutputStream;
Modified: webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/Canonicalizer20010315_Excl.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/Canonicalizer20010315_Excl.java?rev=1181995&r1=1179730&r2=1181995&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/Canonicalizer20010315_Excl.java (original)
+++ webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/Canonicalizer20010315_Excl.java Tue Oct 11 18:03:00 2011
@@ -16,11 +16,11 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.swssf.impl.transformer.canonicalizer;
+package org.swssf.xmlsec.impl.transformer.canonicalizer;
-import org.swssf.ext.ComparableAttribute;
-import org.swssf.ext.ComparableNamespace;
-import org.swssf.ext.XMLEventNS;
+import org.swssf.xmlsec.ext.ComparableAttribute;
+import org.swssf.xmlsec.ext.ComparableNamespace;
+import org.swssf.xmlsec.ext.XMLEventNS;
import javax.xml.stream.events.Attribute;
import javax.xml.stream.events.StartElement;
Modified: webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/Canonicalizer20010315_ExclOmitCommentsTransformer.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/Canonicalizer20010315_ExclOmitCommentsTransformer.java?rev=1181995&r1=1179730&r2=1181995&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/Canonicalizer20010315_ExclOmitCommentsTransformer.java (original)
+++ webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/Canonicalizer20010315_ExclOmitCommentsTransformer.java Tue Oct 11 18:03:00 2011
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.swssf.impl.transformer.canonicalizer;
+package org.swssf.xmlsec.impl.transformer.canonicalizer;
import java.io.OutputStream;
Modified: webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/Canonicalizer20010315_ExclWithCommentsTransformer.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/Canonicalizer20010315_ExclWithCommentsTransformer.java?rev=1181995&r1=1179730&r2=1181995&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/Canonicalizer20010315_ExclWithCommentsTransformer.java (original)
+++ webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/Canonicalizer20010315_ExclWithCommentsTransformer.java Tue Oct 11 18:03:00 2011
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.swssf.impl.transformer.canonicalizer;
+package org.swssf.xmlsec.impl.transformer.canonicalizer;
import java.io.OutputStream;
Modified: webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/Canonicalizer20010315_OmitCommentsTransformer.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/Canonicalizer20010315_OmitCommentsTransformer.java?rev=1181995&r1=1179730&r2=1181995&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/Canonicalizer20010315_OmitCommentsTransformer.java (original)
+++ webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/Canonicalizer20010315_OmitCommentsTransformer.java Tue Oct 11 18:03:00 2011
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.swssf.impl.transformer.canonicalizer;
+package org.swssf.xmlsec.impl.transformer.canonicalizer;
import java.io.OutputStream;
Modified: webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/Canonicalizer20010315_WithCommentsTransformer.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/Canonicalizer20010315_WithCommentsTransformer.java?rev=1181995&r1=1179730&r2=1181995&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/Canonicalizer20010315_WithCommentsTransformer.java (original)
+++ webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/Canonicalizer20010315_WithCommentsTransformer.java Tue Oct 11 18:03:00 2011
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.swssf.impl.transformer.canonicalizer;
+package org.swssf.xmlsec.impl.transformer.canonicalizer;
import java.io.OutputStream;
Modified: webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/CanonicalizerBase.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/CanonicalizerBase.java?rev=1181995&r1=1179730&r2=1181995&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/CanonicalizerBase.java (original)
+++ webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/CanonicalizerBase.java Tue Oct 11 18:03:00 2011
@@ -16,9 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.swssf.impl.transformer.canonicalizer;
+package org.swssf.xmlsec.impl.transformer.canonicalizer;
-import org.swssf.ext.*;
+import org.swssf.xmlsec.ext.*;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
@@ -294,20 +294,20 @@ public abstract class CanonicalizerBase
case XMLStreamConstants.END_DOCUMENT:
break;
case XMLStreamConstants.ENTITY_REFERENCE:
- throw new XMLStreamException("illegal event :" + Utils.getXMLEventAsString(xmlEvent));
+ throw new XMLStreamException("illegal event :" + XMLSecurityUtils.getXMLEventAsString(xmlEvent));
case XMLStreamConstants.ATTRIBUTE:
- throw new XMLStreamException("illegal event :" + Utils.getXMLEventAsString(xmlEvent));
+ throw new XMLStreamException("illegal event :" + XMLSecurityUtils.getXMLEventAsString(xmlEvent));
case XMLStreamConstants.DTD:
break;
case XMLStreamConstants.CDATA:
outputTextToWriter(xmlEvent.asCharacters().getData(), this.outputStream);
break;
case XMLStreamConstants.NAMESPACE:
- throw new XMLStreamException("illegal event :" + Utils.getXMLEventAsString(xmlEvent));
+ throw new XMLStreamException("illegal event :" + XMLSecurityUtils.getXMLEventAsString(xmlEvent));
case XMLStreamConstants.NOTATION_DECLARATION:
- throw new XMLStreamException("illegal event :" + Utils.getXMLEventAsString(xmlEvent));
+ throw new XMLStreamException("illegal event :" + XMLSecurityUtils.getXMLEventAsString(xmlEvent));
case XMLStreamConstants.ENTITY_DECLARATION:
- throw new XMLStreamException("illegal event :" + Utils.getXMLEventAsString(xmlEvent));
+ throw new XMLStreamException("illegal event :" + XMLSecurityUtils.getXMLEventAsString(xmlEvent));
}
} catch (IOException e) {
throw new XMLStreamException(e);
Modified: webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/UtfHelpper.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/UtfHelpper.java?rev=1181995&r1=1179730&r2=1181995&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/UtfHelpper.java (original)
+++ webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/transformer/canonicalizer/UtfHelpper.java Tue Oct 11 18:03:00 2011
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.swssf.impl.transformer.canonicalizer;
+package org.swssf.xmlsec.impl.transformer.canonicalizer;
import java.io.IOException;
import java.io.OutputStream;
Modified: webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/util/ConcreteLSInput.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/util/ConcreteLSInput.java?rev=1181995&r1=1179730&r2=1181995&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/util/ConcreteLSInput.java (original)
+++ webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/util/ConcreteLSInput.java Tue Oct 11 18:03:00 2011
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.swssf.impl.util;
+package org.swssf.xmlsec.impl.util;
import org.w3c.dom.ls.LSInput;
Modified: webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/util/DigestOutputStream.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/util/DigestOutputStream.java?rev=1181995&r1=1179730&r2=1181995&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/util/DigestOutputStream.java (original)
+++ webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/util/DigestOutputStream.java Tue Oct 11 18:03:00 2011
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.swssf.impl.util;
+package org.swssf.xmlsec.impl.util;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/util/IVSplittingOutputStream.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/util/IVSplittingOutputStream.java?rev=1181995&r1=1179730&r2=1181995&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/util/IVSplittingOutputStream.java (original)
+++ webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/util/IVSplittingOutputStream.java Tue Oct 11 18:03:00 2011
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.swssf.impl.util;
+package org.swssf.xmlsec.impl.util;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
Modified: webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/util/RFC2253Parser.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/util/RFC2253Parser.java?rev=1181995&r1=1179730&r2=1181995&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/util/RFC2253Parser.java (original)
+++ webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/util/RFC2253Parser.java Tue Oct 11 18:03:00 2011
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.swssf.impl.util;
+package org.swssf.xmlsec.impl.util;
import java.io.IOException;
Modified: webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/util/ReplaceableOuputStream.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/util/ReplaceableOuputStream.java?rev=1181995&r1=1179730&r2=1181995&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/util/ReplaceableOuputStream.java (original)
+++ webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/util/ReplaceableOuputStream.java Tue Oct 11 18:03:00 2011
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.swssf.impl.util;
+package org.swssf.xmlsec.impl.util;
import java.io.FilterOutputStream;
import java.io.IOException;
Modified: webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/util/SignerOutputStream.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/util/SignerOutputStream.java?rev=1181995&r1=1179730&r2=1181995&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/util/SignerOutputStream.java (original)
+++ webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/util/SignerOutputStream.java Tue Oct 11 18:03:00 2011
@@ -16,12 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.swssf.impl.util;
+package org.swssf.xmlsec.impl.util;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.swssf.ext.WSSecurityException;
-import org.swssf.impl.algorithms.SignatureAlgorithm;
+import org.swssf.xmlsec.ext.XMLSecurityException;
+import org.swssf.xmlsec.impl.algorithms.SignatureAlgorithm;
import java.io.OutputStream;
@@ -53,7 +53,7 @@ public class SignerOutputStream extends
if (log.isDebugEnabled()) {
stringBuffer.append(new String(new byte[]{(byte) arg0}));
}
- } catch (WSSecurityException e) {
+ } catch (XMLSecurityException e) {
throw new RuntimeException(e);
}
}
@@ -64,12 +64,12 @@ public class SignerOutputStream extends
if (log.isDebugEnabled()) {
stringBuffer.append(new String(arg0, arg1, arg2));
}
- } catch (WSSecurityException e) {
+ } catch (XMLSecurityException e) {
throw new RuntimeException(e);
}
}
- public boolean verify(byte[] signatureValue) throws WSSecurityException {
+ public boolean verify(byte[] signatureValue) throws XMLSecurityException {
if (log.isDebugEnabled()) {
log.debug("Pre Signed: ");
log.debug(stringBuffer.toString());
@@ -79,7 +79,7 @@ public class SignerOutputStream extends
return signatureAlgorithm.engineVerify(signatureValue);
}
- public byte[] sign() throws WSSecurityException {
+ public byte[] sign() throws XMLSecurityException {
if (log.isDebugEnabled()) {
log.debug("Pre Signed: ");
log.debug(stringBuffer.toString());
Modified: webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/util/TrimmerOutputStream.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/util/TrimmerOutputStream.java?rev=1181995&r1=1179730&r2=1181995&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/util/TrimmerOutputStream.java (original)
+++ webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/util/TrimmerOutputStream.java Tue Oct 11 18:03:00 2011
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.swssf.impl.util;
+package org.swssf.xmlsec.impl.util;
import java.io.FilterOutputStream;
import java.io.IOException;
Modified: webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/w3/_2000/_09/xmldsig_/CanonicalizationMethodType.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/w3/_2000/_09/xmldsig_/CanonicalizationMethodType.java?rev=1181995&r1=1179730&r2=1181995&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/w3/_2000/_09/xmldsig_/CanonicalizationMethodType.java (original)
+++ webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/w3/_2000/_09/xmldsig_/CanonicalizationMethodType.java Tue Oct 11 18:03:00 2011
@@ -18,10 +18,10 @@
*/
package org.w3._2000._09.xmldsig_;
-import org.swssf.ext.Constants;
-import org.swssf.ext.ParseException;
-import org.swssf.ext.Parseable;
-import org.swssf.ext.Utils;
+import org.swssf.xmlsec.ext.ParseException;
+import org.swssf.xmlsec.ext.Parseable;
+import org.swssf.xmlsec.ext.XMLSecurityConstants;
+import org.swssf.xmlsec.ext.XMLSecurityUtils;
import javax.xml.bind.annotation.*;
import javax.xml.stream.XMLStreamConstants;
@@ -73,7 +73,7 @@ public class CanonicalizationMethodType
Iterator<Attribute> attributeIterator = startElement.getAttributes();
while (attributeIterator.hasNext()) {
Attribute attribute = attributeIterator.next();
- if (attribute.getName().equals(Constants.ATT_NULL_Algorithm)) {
+ if (attribute.getName().equals(XMLSecurityConstants.ATT_NULL_Algorithm)) {
this.algorithm = attribute.getValue();
}
}
@@ -92,8 +92,8 @@ public class CanonicalizationMethodType
switch (xmlEvent.getEventType()) {
case XMLStreamConstants.START_ELEMENT:
StartElement startElement = xmlEvent.asStartElement();
- if (startElement.getName().equals(Constants.TAG_c14nExcl_InclusiveNamespaces)) {
- Attribute attribute = startElement.getAttributeByName(Constants.ATT_NULL_PrefixList);
+ if (startElement.getName().equals(XMLSecurityConstants.TAG_c14nExcl_InclusiveNamespaces)) {
+ Attribute attribute = startElement.getAttributeByName(XMLSecurityConstants.ATT_NULL_PrefixList);
if (attribute != null) {
inclusiveNamespaces = attribute.getValue();
}
@@ -121,12 +121,12 @@ public class CanonicalizationMethodType
case XMLStreamConstants.END_ELEMENT:
currentParseable = null;
EndElement endElement = xmlEvent.asEndElement();
- if (endElement.getName().equals(Constants.TAG_dsig_CanonicalizationMethod)) {
+ if (endElement.getName().equals(XMLSecurityConstants.TAG_dsig_CanonicalizationMethod)) {
return true;
}
break;
default:
- throw new ParseException("Unexpected event received " + Utils.getXMLEventAsString(xmlEvent));
+ throw new ParseException("Unexpected event received " + XMLSecurityUtils.getXMLEventAsString(xmlEvent));
}
return false;
}