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 di...@apache.org on 2005/07/12 21:56:21 UTC

cvs commit: ws-wss4j/src/org/apache/ws/security/handler WSHandlerConstants.java

dims        2005/07/12 12:56:21

  Modified:    src/org/apache/ws/security/message/token Timestamp.java
                        UsernameToken.java
               src/org/apache/ws/security WSConstants.java WSSConfig.java
                        WSSecurityEngine.java
               src/org/apache/ws/axis/security WSDoAllSender.java
               src/org/apache/ws/security/handler WSHandlerConstants.java
  Log:
  Fix for WSS-4 - To be able to configure WSS completely in configuration of handlers (wsdd-files)
  
  Revision  Changes    Path
  1.10      +1 -1      ws-wss4j/src/org/apache/ws/security/message/token/Timestamp.java
  
  Index: Timestamp.java
  ===================================================================
  RCS file: /home/cvs/ws-wss4j/src/org/apache/ws/security/message/token/Timestamp.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Timestamp.java	12 Jul 2005 19:14:23 -0000	1.9
  +++ Timestamp.java	12 Jul 2005 19:56:20 -0000	1.10
  @@ -120,7 +120,7 @@
                   WSConstants.WSU_PREFIX);
   
           DateFormat zulu = null;
  -        if (WSConstants.TIMESTAMP_WITH_MS) {
  +        if (wssConfig.isPrecisionInMilliSeconds()) {
           	zulu = new XmlSchemaDateFormat();
           }
           else {
  
  
  
  1.18      +1 -1      ws-wss4j/src/org/apache/ws/security/message/token/UsernameToken.java
  
  Index: UsernameToken.java
  ===================================================================
  RCS file: /home/cvs/ws-wss4j/src/org/apache/ws/security/message/token/UsernameToken.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- UsernameToken.java	12 Jul 2005 19:14:23 -0000	1.17
  +++ UsernameToken.java	12 Jul 2005 19:56:20 -0000	1.18
  @@ -188,7 +188,7 @@
               return;
           }
           DateFormat zulu = null;
  -        if (WSConstants.TIMESTAMP_WITH_MS) {
  +        if (wssConfig.isPrecisionInMilliSeconds()) {
           	zulu = new XmlSchemaDateFormat();
           }
           else {
  
  
  
  1.30      +0 -7      ws-wss4j/src/org/apache/ws/security/WSConstants.java
  
  Index: WSConstants.java
  ===================================================================
  RCS file: /home/cvs/ws-wss4j/src/org/apache/ws/security/WSConstants.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- WSConstants.java	12 Jul 2005 19:14:23 -0000	1.29
  +++ WSConstants.java	12 Jul 2005 19:56:21 -0000	1.30
  @@ -51,13 +51,6 @@
        * @param specs instructs WSS4J on which standard to follow
        */
       public static final int COMPLIANCE_MODE = OASIS_1_0;
  -    /**
  -     * Set the timestamp precision mode.
  -     * If set to <code>true</code> then use timestamps with milliseconds,
  -     * otherwise omit the millisconds. As per XML Date/Time specification
  -     * the defualt is to include the milliseconds.
  -     */
  -    public static final boolean TIMESTAMP_WITH_MS = true;
   
       /*
        * All the various string and keywords required.
  
  
  
  1.5       +26 -0     ws-wss4j/src/org/apache/ws/security/WSSConfig.java
  
  Index: WSSConfig.java
  ===================================================================
  RCS file: /home/cvs/ws-wss4j/src/org/apache/ws/security/WSSConfig.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- WSSConfig.java	10 Mar 2005 18:52:08 -0000	1.4
  +++ WSSConfig.java	12 Jul 2005 19:56:21 -0000	1.5
  @@ -47,6 +47,14 @@
       public static final int TIMESTAMP_IN_HEADER_ELEMENT = 2;
       protected int timestampLocation = TIMESTAMP_IN_SECURITY_ELEMENT;
   
  +    /**
  +     * Set the timestamp precision mode.
  +     * If set to <code>true</code> then use timestamps with milliseconds,
  +     * otherwise omit the millisconds. As per XML Date/Time specification
  +     * the defualt is to include the milliseconds.
  +     */
  +    protected boolean precisionInMilliSeconds = true;
  +
       protected WSSConfig() {
       }
   
  @@ -224,4 +232,22 @@
       public void setWsiBSPCompliant(boolean wsiBSPCompliant) {
           this.wsiBSPCompliant = wsiBSPCompliant;
       }
  +
  +    /**
  +     * Checks if we need to use milliseconds in timestamps
  +     *
  +     * @return
  +     */
  +    public boolean isPrecisionInMilliSeconds() {
  +        return precisionInMilliSeconds;
  +    }
  +
  +    /**
  +     * Set the precision in milliseconds
  +     *
  +     * @param wsiBSPCompliant
  +     */
  +    public void setPrecisionInMilliSeconds(boolean precisionInMilliSeconds) {
  +        this.precisionInMilliSeconds = precisionInMilliSeconds;
  +    }
   }
  
  
  
  1.46      +6 -0      ws-wss4j/src/org/apache/ws/security/WSSecurityEngine.java
  
  Index: WSSecurityEngine.java
  ===================================================================
  RCS file: /home/cvs/ws-wss4j/src/org/apache/ws/security/WSSecurityEngine.java,v
  retrieving revision 1.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- WSSecurityEngine.java	5 Jun 2005 18:46:21 -0000	1.45
  +++ WSSecurityEngine.java	12 Jul 2005 19:56:21 -0000	1.46
  @@ -1448,4 +1448,10 @@
           return decryptedBytes;
       }
   
  +    /**
  +     * Should the timestamps have millisecond precision
  +     */
  +    public void setPrecisionInMilliSeconds(boolean precisionInMilliSeconds) {
  +        wssConfig.setPrecisionInMilliSeconds(precisionInMilliSeconds);
  +    }
   }
  
  
  
  1.33      +24 -0     ws-wss4j/src/org/apache/ws/axis/security/WSDoAllSender.java
  
  Index: WSDoAllSender.java
  ===================================================================
  RCS file: /home/cvs/ws-wss4j/src/org/apache/ws/axis/security/WSDoAllSender.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- WSDoAllSender.java	21 May 2005 20:40:39 -0000	1.32
  +++ WSDoAllSender.java	12 Jul 2005 19:56:21 -0000	1.33
  @@ -182,6 +182,8 @@
   
   			boolean mu = decodeMustUnderstand(reqData);
   
  +            secEngine.setPrecisionInMilliSeconds(decodeTimestampPrecision(reqData));
  +
   			if ((reqData.actor = (String) getOption(WSHandlerConstants.ACTOR)) == null) {
   				reqData.actor = (String) reqData.msgContext
   						.getProperty(WSHandlerConstants.ACTOR);
  @@ -812,6 +814,28 @@
           return mu;
       }
   
  +    private boolean decodeTimestampPrecision(RequestData reqData) throws AxisFault {
  +        boolean precisionInMilliSeconds = true;
  +        String value = null;
  +        if ((value =
  +                (String) getOption(WSHandlerConstants.TIMESTAMP_PRECISION))
  +                == null) {
  +            value =
  +                    (String) reqData.msgContext.getProperty(WSHandlerConstants.TIMESTAMP_PRECISION);
  +        }
  +        if (value != null) {
  +            if (value.equals("0") || value.equals("false")) {
  +                precisionInMilliSeconds = false;
  +            } else if (
  +                    value.equals("1") || value.equals("true")) {
  +                precisionInMilliSeconds = true;
  +            } else {
  +                throw new AxisFault("WSDoAllSender: illegal precisionInMilliSeconds parameter");
  +            }
  +        }
  +        return precisionInMilliSeconds;
  +    }
  +
       /**
        * Get a password to construct a UsernameToken or sign a message.
        * <p/>
  
  
  
  1.5       +4 -0      ws-wss4j/src/org/apache/ws/security/handler/WSHandlerConstants.java
  
  Index: WSHandlerConstants.java
  ===================================================================
  RCS file: /home/cvs/ws-wss4j/src/org/apache/ws/security/handler/WSHandlerConstants.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- WSHandlerConstants.java	24 Jun 2005 11:27:38 -0000	1.4
  +++ WSHandlerConstants.java	12 Jul 2005 19:56:21 -0000	1.5
  @@ -1297,6 +1297,10 @@
       public static final String TTL_TIMESTAMP = "timeToLive";
   
   
  +    /**
  +     * Should timestamps have precision in milliseconds
  +     */
  +    public static final String TIMESTAMP_PRECISION = "precisionInMilliseconds";
   
       /**
   
  
  
  

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