You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fx-dev@ws.apache.org by we...@apache.org on 2005/09/06 21:05:04 UTC
svn commit: r279068 - in
/webservices/wss4j/trunk/src/org/apache/ws/security: WSEncryptionPart.java
message/WSAddSignatureConfirmation.java message/WSSignEnvelope.java
Author: werner
Date: Tue Sep 6 12:04:58 2005
New Revision: 279068
URL: http://svn.apache.org/viewcvs?rev=279068&view=rev
Log: (empty)
Added:
webservices/wss4j/trunk/src/org/apache/ws/security/message/WSAddSignatureConfirmation.java
Modified:
webservices/wss4j/trunk/src/org/apache/ws/security/WSEncryptionPart.java
webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSignEnvelope.java
Modified: webservices/wss4j/trunk/src/org/apache/ws/security/WSEncryptionPart.java
URL: http://svn.apache.org/viewcvs/webservices/wss4j/trunk/src/org/apache/ws/security/WSEncryptionPart.java?rev=279068&r1=279067&r2=279068&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/WSEncryptionPart.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/WSEncryptionPart.java Tue Sep 6 12:04:58 2005
@@ -25,13 +25,20 @@
private String name;
private String namespace;
private String encModifier;
+ private String id;
public WSEncryptionPart(String nm, String nmspace, String encMod) {
name = nm;
namespace = nmspace;
encModifier = encMod;
+ id = null;
}
+ public WSEncryptionPart(String id) {
+ this.id = id;
+ name = namespace = encModifier = null;
+ }
+
/**
* @return the local name of the element to encrypt.
*/
@@ -51,5 +58,12 @@
*/
public String getEncModifier() {
return encModifier;
+ }
+
+ /**
+ * @return Returns the id.
+ */
+ public String getId() {
+ return id;
}
}
Added: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSAddSignatureConfirmation.java
URL: http://svn.apache.org/viewcvs/webservices/wss4j/trunk/src/org/apache/ws/security/message/WSAddSignatureConfirmation.java?rev=279068&view=auto
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/WSAddSignatureConfirmation.java (added)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/WSAddSignatureConfirmation.java Tue Sep 6 12:04:58 2005
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2003-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.ws.security.message;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.security.message.token.SignatureConfirmation;
+import org.apache.ws.security.util.WSSecurityUtil;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * Builds a WS SignatureConfirmation and inserts it into the SOAP Envelope.
+ *
+ * @author Werner Dittmann (Werner.Dittmann@t-online.de).
+ */
+
+public class WSAddSignatureConfirmation extends WSBaseMessage {
+ private static Log log = LogFactory.getLog(WSAddSignatureConfirmation.class
+ .getName());
+
+ private SignatureConfirmation sc = null;
+
+ private String id = null;
+
+ /**
+ * Constructor.
+ */
+ public WSAddSignatureConfirmation() {
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param actor
+ * the name of the actor of the <code>wsse:Security</code>
+ * header
+ */
+ public WSAddSignatureConfirmation(String actor) {
+ super(actor);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param actor
+ * The name of the actor of the <code>wsse:Security</code>
+ * header
+ * @param mu
+ * Set <code>mustUnderstand</code> to true or false
+ */
+ public WSAddSignatureConfirmation(String actor, boolean mu) {
+ super(actor, mu);
+ }
+
+ /**
+ * Adds a new <code>SignatureConfirmation</code> to a soap envelope.
+ *
+ * A complete <code>SignatureConfirmation</code> is constructed and added
+ * to the <code>wsse:Security</code> header.
+ *
+ * @param doc
+ * The SOAP enevlope as W3C document
+ * @param sigVal
+ * the Signature value. This will be the content of the "Value"
+ * attribute.
+ * @return Document with SignatureConfirmation added
+ */
+ public Document build(Document doc, byte[] sigVal) {
+ log.debug("Begin add signature confirmation...");
+ Element securityHeader = insertSecurityHeader(doc);
+ sc = new SignatureConfirmation(doc, sigVal);
+ if (id != null) {
+ sc.setID(id);
+ }
+ WSSecurityUtil.prependChildElement(doc, securityHeader,
+ sc.getElement(), true);
+ sc = null;
+ return doc;
+ }
+
+ /**
+ * Set the wsu:Id value of the SignatureConfirmation
+ *
+ * @param id
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ * Get the wsu:Id value of the SignatureConfirmation
+ *
+ * @return Returns the wsu:id value
+ */
+ public String getId() {
+ return id;
+ }
+}
\ No newline at end of file
Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSignEnvelope.java
URL: http://svn.apache.org/viewcvs/webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSignEnvelope.java?rev=279068&r1=279067&r2=279068&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSignEnvelope.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSignEnvelope.java Tue Sep 6 12:04:58 2005
@@ -331,9 +331,12 @@
for (int part = 0; part < parts.size(); part++) {
WSEncryptionPart encPart = (WSEncryptionPart) parts.get(part);
+
+ String idToSign = encPart.getId();
+
String elemName = encPart.getName();
String nmSpace = encPart.getNamespace();
-
+
/*
* Set up the elements to sign. There are two resevered element
* names: "Token" and "STRTransform" "Token": Setup the Signature to
@@ -344,7 +347,20 @@
*
*/
try {
- if (elemName.equals("Token")) {
+ if (idToSign != null) {
+ Element toSignById = WSSecurityUtil.getElementByWsuId(doc, "#"+idToSign);
+ transforms = new Transforms(doc);
+ transforms
+ .addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
+ if (wssConfig.isWsiBSPCompliant()) {
+ transforms.item(0).getElement().appendChild(
+ new InclusiveNamespaces(doc,
+ getInclusivePrefixes(toSignById))
+ .getElement());
+ }
+ sig.addDocument("#" + idToSign, transforms);
+ }
+ else if (elemName.equals("Token")) {
transforms = new Transforms(doc);
transforms
.addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
---------------------------------------------------------------------
To unsubscribe, e-mail: wss4j-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: wss4j-dev-help@ws.apache.org