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 2006/03/06 14:51:40 UTC

svn commit: r383540 - in /webservices/wss4j/trunk/src/org/apache/ws/security: message/WSSecBase.java message/WSSecHeader.java message/WSSecTimestamp.java saml/SAMLUtil.java saml/WSSecSignatureSAML.java

Author: werner
Date: Mon Mar  6 05:51:39 2006
New Revision: 383540

URL: http://svn.apache.org/viewcvs?rev=383540&view=rev
Log:
Some code cleanup, no new functions.

Modified:
    webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecBase.java
    webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecHeader.java
    webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecTimestamp.java
    webservices/wss4j/trunk/src/org/apache/ws/security/saml/SAMLUtil.java
    webservices/wss4j/trunk/src/org/apache/ws/security/saml/WSSecSignatureSAML.java

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecBase.java
URL: http://svn.apache.org/viewcvs/webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecBase.java?rev=383540&r1=383539&r2=383540&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecBase.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecBase.java Mon Mar  6 05:51:39 2006
@@ -47,8 +47,6 @@
 
 	protected Vector parts = null;
 
-	protected int timeToLive = 300; // time between Created and Expires
-
 	protected boolean doDebug = false;
 
 	protected WSSConfig wssConfig = WSSConfig.getDefaultWSConfig();
@@ -57,18 +55,6 @@
 	 * Constructor.
 	 */
 	public WSSecBase() {
-	}
-
-	/**
-	 * Set the time to live. This is the time difference in seconds between the
-	 * <code>Created</code> and the <code>Expires</code> in
-	 * <code>Timestamp</code>. <p/>
-	 * 
-	 * @param ttl
-	 *            The time to live in second
-	 */
-	public void setTimeToLive(int ttl) {
-		timeToLive = ttl;
 	}
 
 	/**

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecHeader.java
URL: http://svn.apache.org/viewcvs/webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecHeader.java?rev=383540&r1=383539&r2=383540&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecHeader.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecHeader.java Mon Mar  6 05:51:39 2006
@@ -32,136 +32,126 @@
 /**
  * This class implements WS Security header.
  * 
- * It provides to setup a Security header with a specified actor and
- * mustunderstand flag.
+ * Setup a Security header with a specified actor and mustunderstand flag.
  * 
  * <p/>
  * 
- * Use the to set or overwrite the default values for actor and mustunderstand.
- * The defaults are: empty <code>actor</code> and <code>mustunderstand</code>
- * is true.
+ * The defaults for actor and mustunderstand are: empty <code>actor</code> and
+ * <code>mustunderstand</code> is true.
  * 
  * @author Werner Dittmann (Werner.Dittmann@apache.org)
  */
 public class WSSecHeader {
-	private static Log log = LogFactory.getLog(WSSecHeader.class.getName());
+    private static Log log = LogFactory.getLog(WSSecHeader.class.getName());
 
-	protected String actor = null;
+    protected String actor = null;
 
-	protected boolean mustunderstand = true;
+    protected boolean mustunderstand = true;
 
-	protected boolean doDebug = false;
+    protected boolean doDebug = false;
 
-	protected WSSConfig wssConfig = WSSConfig.getDefaultWSConfig();
-
-	private Element securityHeader = null;
-
-	/**
-	 * Constructor.
-	 */
-	public WSSecHeader() {
-	}
-
-	/**
-	 * Constructor. <p/>
-	 * 
-	 * @param actor
-	 *            The actor name of the <code>wsse:Security</code> header
-	 */
-	public WSSecHeader(String actor) {
-		this(actor, true);
-	}
-
-	/**
-	 * Constructor. <p/>
-	 * 
-	 * @param actor
-	 *            The actor name of the <code>wsse:Security</code> header
-	 * @param mu
-	 *            Set <code>mustUnderstand</code> to true or false
-	 */
-	public WSSecHeader(String actor, boolean mu) {
-		setActor(actor);
-		setMustUnderstand(mu);
-	}
-
-	/**
-	 * set actor name. <p/>
-	 * 
-	 * @param act
-	 *            The actor name of the <code>wsse:Security</code> header
-	 */
-	public void setActor(String act) {
-		actor = act;
-	}
-
-	/**
-	 * Set the <code>mustUnderstand</code> flag for the
-	 * <code>wsse:Security</code> header
-	 * 
-	 * @param mu
-	 *            Set <code>mustUnderstand</code> to true or false
-	 */
-	public void setMustUnderstand(boolean mu) {
-		mustunderstand = mu;
-	}
-
-	/**
-	 * Get the security header element of this instance.
-	 * 
-	 * @return The security header element.
-	 */
-	public Element getSecurityHeader() {
-		return securityHeader;
-	}
-
-	/**
-	 * @param wsConfig
-	 *            The wsConfig to set.
-	 */
-	public void setWsConfig(WSSConfig wsConfig) {
-		this.wssConfig = wsConfig;
-	}
-
-	/**
-	 * Creates a security header and inserts it as child into the SOAP Envelope.
-	 * <p/> Check if a WS Security header block for an actor is already
-	 * available in the document. If a header block is found return it,
-	 * otherwise a new wsse:Security header block is created and the attributes
-	 * set
-	 * 
-	 * @param doc
-	 *            A SOAP envelope as <code>Document</code>
-	 * @return A <code>wsse:Security</code> element
-	 */
-	public Element insertSecurityHeader(Document doc) {
-
-		/*
-		 * If there is already a security header in this instance just return it
-		 */
-		if (securityHeader != null) {
-			return securityHeader;
-		}
-		SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(doc
-				.getDocumentElement());
-
-		securityHeader = WSSecurityUtil.findWsseSecurityHeaderBlock(doc, doc
-				.getDocumentElement(), actor, true);
-
-		String soapPrefix = WSSecurityUtil.getPrefixNS(soapConstants
-				.getEnvelopeURI(), securityHeader);
-		if (actor != null && actor.length() > 0) {
-			securityHeader.setAttributeNS(soapConstants.getEnvelopeURI(),
-					soapPrefix
-							+ ":"
-							+ soapConstants.getRoleAttributeQName()
-									.getLocalPart(), actor);
-		}
-		if (mustunderstand) {
-			securityHeader.setAttributeNS(soapConstants.getEnvelopeURI(),
-					soapPrefix + ":" + WSConstants.ATTR_MUST_UNDERSTAND,
-					soapConstants.getMustunderstand());
-		}
-		return securityHeader;
-	}
+    private Element securityHeader = null;
+
+    /**
+     * Constructor.
+     */
+    public WSSecHeader() {
+    }
+
+    /**
+     * Constructor.
+     * 
+     * @param actor
+     *            The actor name of the <code>wsse:Security</code> header
+     */
+    public WSSecHeader(String actor) {
+        this(actor, true);
+    }
+
+    /**
+     * Constructor.
+     * 
+     * @param actor
+     *            The actor name of the <code>wsse:Security</code> header
+     * @param mu
+     *            Set <code>mustUnderstand</code> to true or false
+     */
+    public WSSecHeader(String act, boolean mu) {
+        actor = act;
+        mustunderstand = mu;
+    }
+
+    /**
+     * set actor name.
+     * 
+     * @param act
+     *            The actor name of the <code>wsse:Security</code> header
+     */
+    public void setActor(String act) {
+        actor = act;
+    }
+
+    /**
+     * Set the <code>mustUnderstand</code> flag for the
+     * <code>wsse:Security</code> header.
+     * 
+     * @param mu
+     *            Set <code>mustUnderstand</code> to true or false
+     */
+    public void setMustUnderstand(boolean mu) {
+        mustunderstand = mu;
+    }
+
+    /**
+     * Get the security header element of this instance.
+     * 
+     * @return The security header element.
+     */
+    public Element getSecurityHeader() {
+        return securityHeader;
+    }
+
+    /**
+     * Creates a security header and inserts it as child into the SOAP Envelope.
+     * 
+     * <p/>
+     * 
+     * Check if a WS Security header block for an actor is already available in
+     * the document. If a header block is found return it, otherwise a new
+     * wsse:Security header block is created and the attributes set
+     * 
+     * @param doc
+     *            A SOAP envelope as <code>Document</code>
+     * @return A <code>wsse:Security</code> element
+     */
+    public Element insertSecurityHeader(Document doc) {
+
+        /*
+         * If there is already a security header in this instance just return it
+         */
+        if (securityHeader != null) {
+            return securityHeader;
+        }
+        SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(doc
+                .getDocumentElement());
+
+        securityHeader = WSSecurityUtil.findWsseSecurityHeaderBlock(doc, doc
+                .getDocumentElement(), actor, true);
+
+        String soapPrefix = WSSecurityUtil.getPrefixNS(soapConstants
+                .getEnvelopeURI(), securityHeader);
+        if (actor != null && actor.length() > 0) {
+            securityHeader.setAttributeNS(soapConstants.getEnvelopeURI(),
+                    soapPrefix
+                            + ":"
+                            + soapConstants.getRoleAttributeQName()
+                                    .getLocalPart(), actor);
+        }
+        if (mustunderstand) {
+            securityHeader.setAttributeNS(soapConstants.getEnvelopeURI(),
+                    soapPrefix + ":" + WSConstants.ATTR_MUST_UNDERSTAND,
+                    soapConstants.getMustunderstand());
+        }
+        return securityHeader;
+    }
 }

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecTimestamp.java
URL: http://svn.apache.org/viewcvs/webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecTimestamp.java?rev=383540&r1=383539&r2=383540&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecTimestamp.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecTimestamp.java Mon Mar  6 05:51:39 2006
@@ -38,45 +38,60 @@
 
     private Document document = null;
 
+    private int timeToLive = 300; // time between Created and Expires
+
     /**
      * Constructor.
      */
     public WSSecTimestamp() {
     }
 
-	/**
-	 * Creates a Timestamp element.
-	 * 
-	 * The method prepares and initializes a WSSec Timestamp structure after the
-	 * relevant information was set. Before calling <code>prepare()</code> the
-	 * parameter such as <code>timeToLive</code> can be set if the deafult
-	 * value is not suitable.
-	 * 
-	 * @param doc
-	 *            The SOAP enevlope as W3C document
-	 */
-	public void prepare(Document doc) {
-		document = doc;
-        ts = new Timestamp(wssConfig.isPrecisionInMilliSeconds(), doc, timeToLive);
-		String tsId = "Timestamp-" + ts.hashCode();
-		ts.setID(tsId);
-	}
-
-	/**
-	 * Prepends the Timestamp element to the elements already in the
-	 * Security header.
-	 * 
-	 * The method can be called any time after <code>prepare()</code>.
-	 * This allows to insert the Timestamp element at any position in the
-	 * Security header.
-	 * 
-	 * @param secHeader
-	 *            The security header that holds the Signature element.
-	 */
-	public void prependToHeader(WSSecHeader secHeader) {
-		WSSecurityUtil.prependChildElement(document, secHeader
-				.getSecurityHeader(), ts.getElement(), false);
-	}
+    /**
+     * Set the time to live. This is the time difference in seconds between the
+     * <code>Created</code> and the <code>Expires</code> in
+     * <code>Timestamp</code>. <p/>
+     * 
+     * @param ttl
+     *            The time to live in second
+     */
+    public void setTimeToLive(int ttl) {
+        timeToLive = ttl;
+    }
+
+    /**
+     * Creates a Timestamp element.
+     * 
+     * The method prepares and initializes a WSSec Timestamp structure after the
+     * relevant information was set. Before calling <code>prepare()</code> the
+     * parameter such as <code>timeToLive</code> can be set if the deafult
+     * value is not suitable.
+     * 
+     * @param doc
+     *            The SOAP enevlope as W3C document
+     */
+    public void prepare(Document doc) {
+        document = doc;
+        ts = new Timestamp(wssConfig.isPrecisionInMilliSeconds(), doc,
+                timeToLive);
+        String tsId = "Timestamp-" + ts.hashCode();
+        ts.setID(tsId);
+    }
+
+    /**
+     * Prepends the Timestamp element to the elements already in the Security
+     * header.
+     * 
+     * The method can be called any time after <code>prepare()</code>. This
+     * allows to insert the Timestamp element at any position in the Security
+     * header.
+     * 
+     * @param secHeader
+     *            The security header that holds the Signature element.
+     */
+    public void prependToHeader(WSSecHeader secHeader) {
+        WSSecurityUtil.prependChildElement(document, secHeader
+                .getSecurityHeader(), ts.getElement(), false);
+    }
 
     /**
      * Adds a new <code>Timestamp</code> to a soap envelope.
@@ -94,24 +109,24 @@
     public Document build(Document doc, WSSecHeader secHeader) {
         log.debug("Begin add timestamp...");
 
-		prepare(doc);
-		prependToHeader(secHeader);
+        prepare(doc);
+        prependToHeader(secHeader);
 
-		return doc;
+        return doc;
     }
 
-	/**
-	 * Get the id generated during <code>prepare()</code>.
-	 * 
-	 * Returns the the value of wsu:Id attribute of this Timestamp. 
-	 * 
-	 * @return Return the wsu:Id of this token or null if <code>prepareToken()</code>
-	 * was not called before.
-	 */
+    /**
+     * Get the id generated during <code>prepare()</code>.
+     * 
+     * Returns the the value of wsu:Id attribute of this Timestamp.
+     * 
+     * @return Return the wsu:Id of this token or null if
+     *         <code>prepareToken()</code> was not called before.
+     */
     public String getId() {
-    	if (ts == null) {
-    		return null;
-    	}
+        if (ts == null) {
+            return null;
+        }
         return ts.getID();
     }
 }

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/saml/SAMLUtil.java
URL: http://svn.apache.org/viewcvs/webservices/wss4j/trunk/src/org/apache/ws/security/saml/SAMLUtil.java?rev=383540&r1=383539&r2=383540&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/saml/SAMLUtil.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/saml/SAMLUtil.java Mon Mar  6 05:51:39 2006
@@ -1,7 +1,6 @@
 package org.apache.ws.security.saml;
 
 import org.w3c.dom.Element;
-import org.apache.ws.security.components.crypto.Crypto;
 import org.apache.ws.security.WSSecurityException;
 import org.apache.ws.security.util.WSSecurityUtil;
 import org.apache.xml.security.keys.KeyInfo;

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/saml/WSSecSignatureSAML.java
URL: http://svn.apache.org/viewcvs/webservices/wss4j/trunk/src/org/apache/ws/security/saml/WSSecSignatureSAML.java?rev=383540&r1=383539&r2=383540&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/saml/WSSecSignatureSAML.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/saml/WSSecSignatureSAML.java Mon Mar  6 05:51:39 2006
@@ -12,7 +12,6 @@
 import org.apache.ws.security.message.EnvelopeIdResolver;
 import org.apache.ws.security.message.WSSecHeader;
 import org.apache.ws.security.message.WSSecSignature;
-import org.apache.ws.security.message.token.BinarySecurity;
 import org.apache.ws.security.message.token.Reference;
 import org.apache.ws.security.message.token.SecurityTokenReference;
 import org.apache.ws.security.message.token.X509Security;



---------------------------------------------------------------------
To unsubscribe, e-mail: wss4j-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: wss4j-dev-help@ws.apache.org