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 2004/04/07 07:56:17 UTC
cvs commit: ws-fx/wss4j/src/org/apache/ws/security/message WSBaseMessage.java
werner 2004/04/06 22:56:17
Modified: wss4j/src/org/apache/ws/security WSConstants.java
WSSecurityEngine.java
wss4j/src/org/apache/ws/security/message WSBaseMessage.java
Log:
Small fix to detect the Timestamp element.
Revision Changes Path
1.13 +1 -0 ws-fx/wss4j/src/org/apache/ws/security/WSConstants.java
Index: WSConstants.java
===================================================================
RCS file: /home/cvs/ws-fx/wss4j/src/org/apache/ws/security/WSConstants.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- WSConstants.java 28 Mar 2004 17:48:39 -0000 1.12
+++ WSConstants.java 7 Apr 2004 05:56:17 -0000 1.13
@@ -45,6 +45,7 @@
public static final String XML_NS = "http://www.w3.org/XML/1998/namespace";
public static final String USERNAME_TOKEN_LN = "UsernameToken";
public static final String BINARY_TOKEN_LN = "BinarySecurityToken";
+ public static final String TIMESTAMP_TOKEN_LN = "Timestamp";
public static final String USERNAME_LN = "Username";
public static final String PASSWORD_LN = "Password";
public static final String PASSWORD_TYPE_ATTR = "Type";
1.19 +1 -1 ws-fx/wss4j/src/org/apache/ws/security/WSSecurityEngine.java
Index: WSSecurityEngine.java
===================================================================
RCS file: /home/cvs/ws-fx/wss4j/src/org/apache/ws/security/WSSecurityEngine.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- WSSecurityEngine.java 1 Apr 2004 19:22:36 -0000 1.18
+++ WSSecurityEngine.java 7 Apr 2004 05:56:17 -0000 1.19
@@ -108,7 +108,7 @@
/**
* <code>wsu:Timestamp</code> as defined by OASIS WS Security specification,
*/
- protected static final QName TIMESTAMP = new QName(WSConstants.WSU_NS, "wsu:Timestamp");
+ protected static final QName TIMESTAMP = new QName(WSConstants.WSU_NS, WSConstants.TIMESTAMP_TOKEN_LN);
static {
1.5 +38 -18 ws-fx/wss4j/src/org/apache/ws/security/message/WSBaseMessage.java
Index: WSBaseMessage.java
===================================================================
RCS file: /home/cvs/ws-fx/wss4j/src/org/apache/ws/security/message/WSBaseMessage.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- WSBaseMessage.java 14 Mar 2004 10:44:38 -0000 1.4
+++ WSBaseMessage.java 7 Apr 2004 05:56:17 -0000 1.5
@@ -46,8 +46,8 @@
protected String password = null;
protected int keyIdentifierType = WSConstants.ISSUER_SERIAL;
protected Vector parts = null;
- protected int timeToLive = 300; // time between Created and Expires
-
+ protected int timeToLive = 300; // time between Created and Expires
+
protected boolean doDebug = false;
/**
@@ -163,7 +163,8 @@
* @throws Exception
*/
protected String setBodyID(Document doc) throws Exception {
- SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(doc.getDocumentElement());
+ SOAPConstants soapConstants =
+ WSSecurityUtil.getSOAPConstants(doc.getDocumentElement());
Element bodyElement =
(Element) WSSecurityUtil.getDirectChild(
doc.getFirstChild(),
@@ -174,7 +175,7 @@
}
return setWsuId(bodyElement);
}
-
+
protected String setWsuId(Element bodyElement) {
String id = bodyElement.getAttributeNS(WSConstants.WSU_NS, "Id");
if ((id == null) || (id.length() == 0)) {
@@ -215,20 +216,22 @@
* @return A <code>wsse:Security</code> element
*/
protected Element insertSecurityHeader(Document doc, boolean timestamp) {
- SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(doc.getDocumentElement());
+ SOAPConstants soapConstants =
+ WSSecurityUtil.getSOAPConstants(doc.getDocumentElement());
// lookup a security header block that matches actor
Element securityHeader =
WSSecurityUtil.getSecurityHeader(doc, actor, soapConstants);
- if (securityHeader == null) { // create if nothing found
+ if (securityHeader == null) { // create if nothing found
securityHeader =
WSSecurityUtil.findWsseSecurityHeaderBlock(
doc,
doc.getDocumentElement(),
true);
-
+
String soapPrefix =
- WSSecurityUtil.getPrefix(soapConstants.getEnvelopeURI(),
- securityHeader);
+ WSSecurityUtil.getPrefix(
+ soapConstants.getEnvelopeURI(),
+ securityHeader);
if (actor != null && actor.length() > 0) {
// Check for SOAP 1.2 here and use "role" instead of "actor"
securityHeader.setAttributeNS(
@@ -245,10 +248,19 @@
soapConstants.getMustunderstand());
}
if (timestamp) {
- Element elementTime = doc.createElementNS(WSConstants.WSU_NS, "wsu:Timestamp");
- WSSecurityUtil.setNamespace(elementTime, WSConstants.WSU_NS, WSConstants.WSU_PREFIX);
+ Element elementTime =
+ doc.createElementNS(
+ WSConstants.WSU_NS,
+ WSConstants.WSU_PREFIX
+ + ":"
+ + WSConstants.TIMESTAMP_TOKEN_LN);
+ WSSecurityUtil.setNamespace(
+ elementTime,
+ WSConstants.WSU_NS,
+ WSConstants.WSU_PREFIX);
- SimpleDateFormat zulu = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
+ SimpleDateFormat zulu =
+ new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
zulu.setTimeZone(TimeZone.getTimeZone("GMT"));
Calendar rightNow = Calendar.getInstance();
@@ -256,19 +268,27 @@
doc.createElementNS(
WSConstants.WSU_NS,
WSConstants.WSU_PREFIX + ":" + WSConstants.CREATED_LN);
- WSSecurityUtil.setNamespace(elementCreated, WSConstants.WSU_NS, WSConstants.WSU_PREFIX);
- elementCreated.appendChild(doc.createTextNode(zulu.format(rightNow.getTime())));
-
+ WSSecurityUtil.setNamespace(
+ elementCreated,
+ WSConstants.WSU_NS,
+ WSConstants.WSU_PREFIX);
+ elementCreated.appendChild(
+ doc.createTextNode(zulu.format(rightNow.getTime())));
+
long currentTime = rightNow.getTimeInMillis();
currentTime += timeToLive * 1000;
rightNow.setTimeInMillis(currentTime);
-
+
Element elementExpires =
doc.createElementNS(
WSConstants.WSU_NS,
WSConstants.WSU_PREFIX + ":" + WSConstants.EXPIRES_LN);
- WSSecurityUtil.setNamespace(elementExpires, WSConstants.WSU_NS, WSConstants.WSU_PREFIX);
- elementExpires.appendChild(doc.createTextNode(zulu.format(rightNow.getTime())));
+ WSSecurityUtil.setNamespace(
+ elementExpires,
+ WSConstants.WSU_NS,
+ WSConstants.WSU_PREFIX);
+ elementExpires.appendChild(
+ doc.createTextNode(zulu.format(rightNow.getTime())));
elementTime.appendChild(elementCreated);
elementTime.appendChild(elementExpires);