Author: sanka
Date: Tue Nov  7 22:44:35 2006
New Revision: 472407

URL: http://svn.apache.org/viewvc?view=rev&rev=472407
Log:
Added a check whether the argument of PolicyEngine.getPolicy(..)
is actually a policy element.


Modified:
    
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/Constants.java
    
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyEngine.java

Modified: 
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/Constants.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/Constants.java?view=diff&rev=472407&r1=472406&r2=472407
==============================================================================
--- 
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/Constants.java
 (original)
+++ 
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/Constants.java
 Tue Nov  7 22:44:35 2006
@@ -29,7 +29,7 @@
     public static final String ATTR_ID = "Id";
 
     public static final String ATTR_WSP = "wsp";
-    
+
     public static final String ATTR_WSU = "wsu";
 
     public static final String URI_POLICY_NS = 
"http://schemas.xmlsoap.org/ws/2004/09/policy";;
@@ -53,6 +53,9 @@
     public static final short TYPE_POLICYREF = 0x4;
 
     public static final short TYPE_ASSERTION = 0x5;
+
+    public static final QName Q_ELEM_POLICY = new QName(
+            Constants.URI_POLICY_NS, Constants.ELEM_POLICY, 
Constants.ATTR_WSP);
 
     public static final QName Q_ELEM_OPTIONAL_ATTR = new QName(
             Constants.URI_POLICY_NS, "Optional", Constants.ATTR_WSP);

Modified: 
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyEngine.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyEngine.java?view=diff&rev=472407&r1=472406&r2=472407
==============================================================================
--- 
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyEngine.java
 (original)
+++ 
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyEngine.java
 Tue Nov  7 22:44:35 2006
@@ -21,8 +21,6 @@
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.impl.llom.factory.OMXMLBuilderFactory;
 import org.apache.neethi.builders.AssertionBuilder;
-import org.apache.neethi.builders.xml.XmlPrimtiveAssertion;
-
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLInputFactory;
 import java.io.InputStream;
@@ -109,7 +107,10 @@
      * @return
      */
     public static Policy getPolicy(OMElement element) {
-
+        
+        if (! element.getQName().equals(Constants.Q_ELEM_POLICY)) {
+            throw new IllegalArgumentException("Input is not a wsp:Policy 
type");
+        }
         return getPolicyOperator(element);
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to