Author: werner
Date: Tue Aug 30 13:23:39 2005
New Revision: 264848
URL: http://svn.apache.org/viewcvs?rev=264848&view=rev
Log:
Yet another clean up of the common handler code. TimeToLive decoding and some
other
decoding was combined.
Modified:
webservices/wss4j/trunk/src/org/apache/ws/axis/security/WSDoAllReceiver.java
webservices/wss4j/trunk/src/org/apache/ws/axis/security/WSDoAllSender.java
webservices/wss4j/trunk/src/org/apache/ws/security/WSSecurityEngine.java
webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSHandler.java
webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSS4JHandler.java
Modified:
webservices/wss4j/trunk/src/org/apache/ws/axis/security/WSDoAllReceiver.java
URL:
http://svn.apache.org/viewcvs/webservices/wss4j/trunk/src/org/apache/ws/axis/security/WSDoAllReceiver.java?rev=264848&r1=264847&r2=264848&view=diff
==============================================================================
---
webservices/wss4j/trunk/src/org/apache/ws/axis/security/WSDoAllReceiver.java
(original)
+++
webservices/wss4j/trunk/src/org/apache/ws/axis/security/WSDoAllReceiver.java
Tue Aug 30 13:23:39 2005
@@ -282,24 +282,7 @@
Timestamp timestamp = actionResult.getTimestamp();
if (timestamp != null) {
- String ttl = null;
- if ((ttl = (String)
getOption(WSHandlerConstants.TTL_TIMESTAMP)) == null) {
- ttl = (String) msgContext
- .getProperty(WSHandlerConstants.TTL_TIMESTAMP);
- }
- int ttl_i = 0;
- if (ttl != null) {
- try {
- ttl_i = Integer.parseInt(ttl);
- } catch (NumberFormatException e) {
- ttl_i = reqData.getTimeToLive();
- }
- }
- if (ttl_i <= 0) {
- ttl_i = reqData.getTimeToLive();
- }
-
- if (!verifyTimestamp(timestamp, reqData.getTimeToLive())) {
+ if (!verifyTimestamp(timestamp,
decodeTimeToLive(reqData))) {
throw new AxisFault(
"WSDoAllReceiver: The timestamp could not be
validated");
}
Modified:
webservices/wss4j/trunk/src/org/apache/ws/axis/security/WSDoAllSender.java
URL:
http://svn.apache.org/viewcvs/webservices/wss4j/trunk/src/org/apache/ws/axis/security/WSDoAllSender.java?rev=264848&r1=264847&r2=264848&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/axis/security/WSDoAllSender.java
(original)
+++ webservices/wss4j/trunk/src/org/apache/ws/axis/security/WSDoAllSender.java
Tue Aug 30 13:23:39 2005
@@ -82,17 +82,6 @@
return;
}
- boolean mu = decodeMustUnderstand(reqData);
-
-
secEngine.setPrecisionInMilliSeconds(decodeTimestampPrecision(reqData));
-
- String actor = null;
- if ((actor = (String) getOption(WSHandlerConstants.ACTOR)) ==
null) {
- actor = (String)
- getProperty(reqData.getMsgContext(),
WSHandlerConstants.ACTOR);
- }
- reqData.setActor(actor);
-
/*
* For every action we need a username, so get this now. The
* username defined in the deployment descriptor takes
precedence.
@@ -124,7 +113,7 @@
}
if (doDebug) {
log.debug("Action: " + doAction);
- log.debug("Actor: " + reqData.getActor() + ", mu: " + mu);
+ log.debug("Actor: " + reqData.getActor());
}
/*
* Now get the SOAP part from the request message and convert it
@@ -161,7 +150,7 @@
+ e);
}
}
- doSenderAction(doAction, mu, doc, reqData, actions);
+ doSenderAction(doAction, doc, reqData, actions);
/*
* If required convert the resulting document into a message
first.
Modified:
webservices/wss4j/trunk/src/org/apache/ws/security/WSSecurityEngine.java
URL:
http://svn.apache.org/viewcvs/webservices/wss4j/trunk/src/org/apache/ws/security/WSSecurityEngine.java?rev=264848&r1=264847&r2=264848&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/WSSecurityEngine.java
(original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/WSSecurityEngine.java
Tue Aug 30 13:23:39 2005
@@ -80,7 +80,7 @@
* <p/>
*
* @author Davanum Srinivas ([EMAIL PROTECTED]).
- * @author Werner Dittmann ([EMAIL PROTECTED]).
+ * @author Werner Dittmann ([EMAIL PROTECTED]).
*/
public class WSSecurityEngine {
private static final String VALUE_TYPE = "ValueType";
Modified:
webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSHandler.java
URL:
http://svn.apache.org/viewcvs/webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSHandler.java?rev=264848&r1=264847&r2=264848&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSHandler.java
(original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSHandler.java
Tue Aug 30 13:23:39 2005
@@ -66,17 +66,26 @@
*
*
* @param doAction a set defining the actions to do
- * @param mu if true set the musetUnderstand flag to true in the
SOAP
- * request
* @param doc the request as DOM document
* @param reqData a data storage to pass values around bewteen methods
* @param actions a vector holding the actions to do in the order defined
in
* the deployment file or property
* @throws WSSecurityException
*/
- protected void doSenderAction(int doAction, boolean mu, Document doc,
+ protected void doSenderAction(int doAction, Document doc,
RequestData reqData, Vector actions) throws
WSSecurityException {
+ boolean mu = decodeMustUnderstand(reqData);
+
+
secEngine.setPrecisionInMilliSeconds(decodeTimestampPrecision(reqData));
+
+ String actor = null;
+ if ((actor = (String) getOption(WSHandlerConstants.ACTOR)) == null) {
+ actor = (String)
+ getProperty(reqData.getMsgContext(),
WSHandlerConstants.ACTOR);
+ }
+ reqData.setActor(actor);
+
reqData.setSoapConstants(WSSecurityUtil.getSOAPConstants(doc
.getDocumentElement()));
/*
@@ -364,28 +373,10 @@
}
protected void performTSAction(int actionToDo, boolean mu, Document doc,
RequestData reqData) throws WSSecurityException {
- String ttl = null;
- if ((ttl =
- (String) getOption(WSHandlerConstants.TTL_TIMESTAMP))
- == null) {
- ttl =
- (String) getProperty(reqData.getMsgContext(),
WSHandlerConstants.TTL_TIMESTAMP);
- }
- int ttl_i = 0;
- if (ttl != null) {
- try {
- ttl_i = Integer.parseInt(ttl);
- } catch (NumberFormatException e) {
- ttl_i = reqData.getTimeToLive();
- }
- }
- if (ttl_i <= 0) {
- ttl_i = reqData.getTimeToLive();
- }
WSAddTimestamp timeStampBuilder =
new WSAddTimestamp(reqData.getActor(), mu);
// add the Timestamp to the SOAP Enevelope
- timeStampBuilder.build(doc, ttl_i);
+ timeStampBuilder.build(doc, decodeTimeToLive(reqData));
}
/**
@@ -589,6 +580,28 @@
return mu;
}
+ protected int decodeTimeToLive(RequestData reqData) {
+ String ttl = null;
+ if ((ttl =
+ (String) getOption(WSHandlerConstants.TTL_TIMESTAMP))
+ == null) {
+ ttl =
+ (String) getProperty(reqData.getMsgContext(),
WSHandlerConstants.TTL_TIMESTAMP);
+ }
+ int ttl_i = 0;
+ if (ttl != null) {
+ try {
+ ttl_i = Integer.parseInt(ttl);
+ } catch (NumberFormatException e) {
+ ttl_i = reqData.getTimeToLive();
+ }
+ }
+ if (ttl_i <= 0) {
+ ttl_i = reqData.getTimeToLive();
+ }
+ return ttl_i;
+ }
+
protected boolean decodeTimestampPrecision(RequestData reqData) throws
WSSecurityException {
boolean precisionInMilliSeconds = true;
String value = null;
Modified:
webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSS4JHandler.java
URL:
http://svn.apache.org/viewcvs/webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSS4JHandler.java?rev=264848&r1=264847&r2=264848&view=diff
==============================================================================
---
webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSS4JHandler.java
(original)
+++
webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSS4JHandler.java
Tue Aug 30 13:23:39 2005
@@ -21,7 +21,6 @@
import org.apache.commons.logging.LogFactory;
import org.apache.ws.security.SOAPConstants;
import org.apache.ws.security.WSConstants;
-import org.apache.ws.security.WSSecurityEngine;
import org.apache.ws.security.WSSecurityEngineResult;
import org.apache.ws.security.WSSecurityException;
import org.apache.ws.security.message.token.Timestamp;
@@ -63,7 +62,7 @@
public class WSS4JHandler extends WSHandler implements Handler {
private HandlerInfo handlerInfo;
static Log log = LogFactory.getLog(WSS4JHandler.class.getName());
- static final WSSecurityEngine secEngine = new WSSecurityEngine();
+// static final WSSecurityEngine secEngine = new WSSecurityEngine();
private boolean doDebug = false;
@@ -191,15 +190,7 @@
if (doAction == WSConstants.NO_SECURITY) {
return true;
}
-
- boolean mu = decodeMustUnderstand(reqData);
-
- String actor;
- if ((actor = (String) getOption(WSHandlerConstants.ACTOR)) == null) {
- actor = (String) mc.getProperty(WSHandlerConstants.ACTOR);
- }
- reqData.setActor(actor);
-
+
/*
* For every action we need a username, so get this now. The username
* defined in the deployment descriptor takes precedence.
@@ -226,7 +217,7 @@
}
if (doDebug) {
log.debug("Action: " + doAction);
- log.debug("Actor: " + reqData.getActor() + ", mu: " + mu);
+ log.debug("Actor: " + reqData.getActor());
}
/*
* Now get the SOAP part from the request message and convert it into a
@@ -264,7 +255,7 @@
log.debug("WSS4JHandler: orginal SOAP request: ");
log.debug(org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(doc));
}
- doSenderAction(doAction, mu, doc, reqData, actions);
+ doSenderAction(doAction, doc, reqData, actions);
/*
* If required convert the resulting document into a message first. The
@@ -490,26 +481,7 @@
Timestamp timestamp = actionResult.getTimestamp();
if (timestamp != null) {
- String ttl = null;
- if ((ttl =
- (String) getOption(WSHandlerConstants.TTL_TIMESTAMP))
- == null) {
- ttl =
- (String)
mc.getProperty(WSHandlerConstants.TTL_TIMESTAMP);
- }
- int ttl_i = 0;
- if (ttl != null) {
- try {
- ttl_i = Integer.parseInt(ttl);
- } catch (NumberFormatException e) {
- ttl_i = reqData.getTimeToLive();
- }
- }
- if (ttl_i <= 0) {
- ttl_i = reqData.getTimeToLive();
- }
-
- if (!verifyTimestamp(timestamp, reqData.getTimeToLive())) {
+ if (!verifyTimestamp(timestamp, decodeTimeToLive(reqData))) {
throw new JAXRPCException("WSS4JHandler: The timestamp
could not be validated");
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]