ruchithf    2005/06/13 03:16:04

  Modified:    wss4j/src/org/apache/ws/security/policy/message/token
                        AppliesTo.java
  Log:
  Updating the WS-Trust ...message.token.* stuff
  
  Revision  Changes    Path
  1.3       +58 -6     
ws-fx/wss4j/src/org/apache/ws/security/policy/message/token/AppliesTo.java
  
  Index: AppliesTo.java
  ===================================================================
  RCS file: 
/home/cvs/ws-fx/wss4j/src/org/apache/ws/security/policy/message/token/AppliesTo.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AppliesTo.java    1 Jun 2005 10:54:49 -0000       1.2
  +++ AppliesTo.java    13 Jun 2005 10:16:04 -0000      1.3
  @@ -20,9 +20,12 @@
   
   import org.apache.ws.security.WSSecurityException;
   import org.apache.ws.security.trust.TrustConstants;
  +import org.apache.ws.security.trust.WSTrustException;
   import org.apache.ws.security.trust.message.token.AbstractToken;
   import org.w3c.dom.Document;
   import org.w3c.dom.Element;
  +import org.w3c.dom.Node;
  +import org.w3c.dom.NodeList;
   import org.w3c.dom.Text;
   /**
    * @author Malinda Kaushalye
  @@ -32,20 +35,20 @@
        
        public static final QName TOKEN = new QName(TrustConstants.WSP_NS, 
TrustConstants.APPLIESTO_LN, TrustConstants.WSP_PREFIX);
   
  -     /*
  -      * The WS-Addressing impl is bound to Axis, therefore the 
  +     /**
  +      * The WS-Addressing impl is bound to Apache Axis, therefore the 
         * org.apache.axis.message.addressing.EndpointReference cannot be used 
here
         * since it will bring Axis specific stuff into the common core of 
wss4j 
         */
  -     private Element endpointReferenceElement = null;
  -     private Text addressValueText = null;
  +     private Element endpointReferenceElement;
  +     private Text addressValueText;
   
        /**
         * Constructor for AppliesTo
         * @param elem
         * @throws WSSecurityException
         */
  -     public AppliesTo(Element elem) throws WSSecurityException {     
  +     public AppliesTo(Element elem) throws WSTrustException {        
                super(elem);
        }
        
  @@ -87,7 +90,7 @@
                        return null;
        }
        
  -     public void setAnyElement(Element elem) {
  +     public void addChildElement(Element elem) {
                this.element.appendChild(elem);
        }
        
  @@ -98,4 +101,53 @@
        protected QName getToken() {
                return TOKEN;
        }
  +
  +     /**
  +      * Populates the attribute elements with given elements
  +      * This method will be called with the child elements of the 
<code>wsa:AppliesTo</code>
  +      * @see 
org.apache.ws.security.trust.message.token.AbstractToken#deserializeChildElement(org.w3c.dom.Element)
  +      */
  +     protected void deserializeChildElement(Element elem) throws 
WSTrustException {
  +             if(elem.getNodeName().equals(TrustConstants.WSA_PREFIX + ":" + 
TrustConstants.ENDPOINT_REFERENCE_LN)) {
  +                     NodeList list = elem.getChildNodes();
  +                     for(int i = 0; i < list.getLength(); i++) {
  +                             Node tempNode = list.item(i);
  +                             if(tempNode.getNodeType() == Node.ELEMENT_NODE) 
{ //This MUST be the Address Element
  +                                     NodeList tempNodeList = 
tempNode.getChildNodes();
  +                                     for(int j = 0; j < 
tempNodeList.getLength(); j++) {
  +                                             
if(tempNodeList.item(i).getNodeType() == Node.TEXT_NODE) {//This MUST be the 
Address value
  +                                                     this.addressValueText = 
(Text)tempNodeList.item(0);
  +                                                     
this.endpointReferenceElement = elem;
  +                                                     break;
  +                                             }
  +                                     }
  +                             } else {
  +                                     throw new 
WSTrustException(WSTrustException.INVALID_REQUEST,
  +                                                     
WSTrustException.DESC_EXPECTED_CHILD_ELEM,
  +                                                     new Object[]{ 
  +                                                     
TrustConstants.WSA_PREFIX, TrustConstants.ADDRESS_LN, 
  +                                                     
TrustConstants.WSA_PREFIX, TrustConstants.ENDPOINT_REFERENCE_LN});
  +                             }
  +                     }
  +                     
  +
  +                     
  +             } else {
  +                     //If the Passed elemt is not a wsa:EndpointReference 
element
  +                     throw new 
WSTrustException(WSTrustException.INVALID_REQUEST,
  +                                     
WSTrustException.DESC_EXPECTED_CHILD_ELEM,
  +                                     new Object[]{ 
  +                                     TrustConstants.WSA_PREFIX, 
TrustConstants.ENDPOINT_REFERENCE_LN,
  +                                     TOKEN.getPrefix(), 
TOKEN.getLocalPart()});
  +             }
  +             
  +     }
  +
  +     /* (non-Javadoc)
  +      * @see 
org.apache.ws.security.trust.message.token.AbstractToken#deserializeElementText(org.w3c.dom.Text)
  +      */
  +     protected void setElementTextValue(Text textNode) {
  +             // No processing required here xince everything is handled in 
the 
  +             // deserializeChildElement      
  +     }
   }
  
  
  

Reply via email to