I can certainly optimize this code, do ONE check for startsWith("javax") before doing all the other checks. But if we change to use the JAX-RPC properties in place of our own, then we'll go down the full verification path anyway.
I don't think you're being paranoid. I think JAX-RPC is being paranoid. We assume the user is a good user and will give us good data. JAX-RPC assumes the user is evil (or at least foolish) and that the runtime must be evil/fool-proof. So what do we do? Treat the properties purely as a Properties object and flout JAX-RPC? Or do the checks and bow to JAX-RPC? Russell Butek [EMAIL PROTECTED] Glen Daniels <[EMAIL PROTECTED]> on 02/06/2002 09:53:15 AM Please respond to [EMAIL PROTECTED] To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]> cc: Subject: RE: cvs commit: xml-axis/java/src/org/apache/axis/utils resources .properties Hm. I'm getting very concerned about performance as more and more string compares on strings like "javax.xml.rpc..." need to be done during critical-path code. Am I being paranoid about this? --G > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, February 06, 2002 10:17 AM > To: [EMAIL PROTECTED] > Subject: cvs commit: xml-axis/java/src/org/apache/axis/utils > resources.properties > > > butek 02/02/06 07:17:17 > > Modified: java/src/org/apache/axis/client Call.java Stub.java > java/src/org/apache/axis/utils resources.properties > Log: > We now verify the standard JAX-RPC properties in both Call > and Stub objects. > > ToDo: replace the AXIS properties with JAX-RPC properties. > For example: > MessageContext.USERID="user.id" should be replaced by > Call..USERNAME_PROPERTY="javax.xml.rpc.security.auth.username". > > Question: we can set maintain session to true via the AXIS > way - setMaintainSession - > or via the JAX-RPC way - setProperty("...session.maintain", > true). Do we want to keep > setMaintainSession as a convenience method? Or do we want > to remove it? > > Revision Changes Path > 1.68 +101 -7 > xml-axis/java/src/org/apache/axis/client/Call.java > > Index: Call.java > =================================================================== > RCS file: > /home/cvs/xml-axis/java/src/org/apache/axis/client/Call.java,v > retrieving revision 1.67 > retrieving revision 1.68 > diff -u -r1.67 -r1.68 > --- Call.java 5 Feb 2002 19:37:48 -0000 1.67 > +++ Call.java 6 Feb 2002 15:17:17 -0000 1.68 > @@ -170,6 +170,22 @@ > public static final String TRANSPORT_NAME = > "transport_name" ; > public static final String TRANSPORT_PROPERTY= > "java.protocol.handler.pkgs"; > > + // Constants for the standard properties > + public static final String USERNAME_PROPERTY = > + "javax.xml.rpc.security.auth.username"; > + public static final String PASSWORD_PROPERTY = > + "javax.xml.rpc.security.auth.password"; > + public static final String SESSION_PROPERTY = > + "javax.xml.rpc.http.session.maintain"; > + public static final String OPERATION_STYLE_PROPERTY = > + "javax.xml.rpc.soap.operation.style"; > + public static final String SOAPACTION_USE_PROPERTY = > + "javax.xml.rpc.soap.http.soapaction.use"; > + public static final String SOAPACTION_URI_PROPERTY = > + "javax.xml.rpc.soap.http.soapaction.uri"; > + public static final String NAMESPACE_URI_PROPERTY = > + "javax.xml.rpc.encodingstyle.namespace.uri"; > + > /** > * A Hashtable mapping protocols (Strings) to > Transports (classes) > */ > @@ -635,14 +651,92 @@ > * @param value Value of the property > */ > public void setProperty(String name, Object value) { > - if (name == null || value == null) return; > - > - if ( name.equals(TRANSPORT_NAME) ) { > + if (name == null || value == null) { > + return; > + // Is this right? Shouldn't we throw an > exception like: throw new IllegalArgumentException(); > + } > + else if (name.equals(USERNAME_PROPERTY)) { > + if (!(value instanceof String)) { > + throw new IllegalArgumentException( > + JavaUtils.getMessage("badProp00", > new String[] { > + name, "java.lang.String", > value.getClass().getName()})); > + } > + } > + else if (name.equals(PASSWORD_PROPERTY)) { > + if (!(value instanceof String)) { > + throw new IllegalArgumentException( > + JavaUtils.getMessage("badProp00", > new String[] { > + name, "java.lang.String", > value.getClass().getName()})); > + } > + } > + else if (name.equals(SESSION_PROPERTY)) { > + if (!(value instanceof Boolean)) { > + throw new IllegalArgumentException( > + JavaUtils.getMessage("badProp00", > new String[] > + {name, > + "java.lang.Boolean", > + value.getClass().getName()})); > + } > + } > + else if (name.equals(OPERATION_STYLE_PROPERTY)) { > + if (!(value instanceof String)) { > + throw new IllegalArgumentException( > + JavaUtils.getMessage("badProp00", > new String[] { > + name, "java.lang.String", > value.getClass().getName()})); > + } > + String style = (String) value; > + if (!style.equals("rpc") && > !style.equals("document")) { > + throw new IllegalArgumentException( > + JavaUtils.getMessage("badProp01", > new String[] { > + name, "\"rpc\", \"document\"", style})); > + } > + } > + else if (name.equals(SOAPACTION_USE_PROPERTY)) { > + if (!(value instanceof Boolean)) { > + throw new IllegalArgumentException( > + JavaUtils.getMessage("badProp00", > new String[] > + {name, > + "java.lang.Boolean", > + value.getClass().getName()})); > + } > + } > + else if (name.equals(SOAPACTION_URI_PROPERTY)) { > + if (!(value instanceof String)) { > + throw new IllegalArgumentException( > + JavaUtils.getMessage("badProp00", > new String[] > + {name, > + "java.lang.String", > + value.getClass().getName()})); > + } > + Boolean useSOAP = > + (Boolean) > myProperties.get(SOAPACTION_USE_PROPERTY); > + if (useSOAP == null || !useSOAP.booleanValue()) { > + throw new IllegalArgumentException( > + JavaUtils.getMessage("badProp02", > new String[] > + {name, SOAPACTION_USE_PROPERTY, "true"})); > + } > + } > + else if (name.equals(NAMESPACE_URI_PROPERTY)) { > + if (!(value instanceof String)) { > + throw new IllegalArgumentException( > + JavaUtils.getMessage("badProp00", > new String[] > + {name, > + "java.lang.String", > + value.getClass().getName()})); > + } > + } > + else if ( name.equals(TRANSPORT_NAME) ) { > + if (!(value instanceof String)) { > + throw new IllegalArgumentException( > + JavaUtils.getMessage("badProp00", > new String[] { > + name, "java.lang.String", > value.getClass().getName()})); > + } > transportName = (String) value ; > - if ( transport != null ) > - transport.setTransportName( (String) value ); > - return ; > - } > + if (transport != null) > + transport.setTransportName((String) value); > + return; > + } > + > if (myProperties == null) > myProperties = new Hashtable(); > myProperties.put(name, value); > > > > 1.2 +41 -6 > xml-axis/java/src/org/apache/axis/client/Stub.java > > Index: Stub.java > =================================================================== > RCS file: > /home/cvs/xml-axis/java/src/org/apache/axis/client/Stub.java,v > retrieving revision 1.1 > retrieving revision 1.2 > diff -u -r1.1 -r1.2 > --- Stub.java 28 Jan 2002 20:50:14 -0000 1.1 > +++ Stub.java 6 Feb 2002 15:17:17 -0000 1.2 > @@ -65,6 +65,8 @@ > > import org.apache.axis.AxisFault; > > +import org.apache.axis.utils.JavaUtils; > + > /** > * This class is the base for all generated stubs. > */ > @@ -72,12 +74,11 @@ > public abstract class Stub implements javax.xml.rpc.Stub { > > // Constants for the standard properties > - public static final String USERNAME_PROPERTY = > - "javax.xml.rpc.security.auth.username"; > - public static final String PASSWORD_PROPERTY = > - "javax.xml.rpc.security.auth.password"; > + public static final String USERNAME_PROPERTY = > Call.USERNAME_PROPERTY; > + public static final String PASSWORD_PROPERTY = > Call.PASSWORD_PROPERTY; > public static final String ADDRESS_PROPERTY = > "javax.xml.rpc.service.endpoint.address"; > + public static final String SESSION_PROPERTY = > Call.SESSION_PROPERTY; > > protected Service service = null; > > @@ -108,8 +109,29 @@ > * @param value - Value of the property > */ > public void _setProperty(String name, Object value) { > - cachedProperties.put(name, value); > - if (name.equals(ADDRESS_PROPERTY)) { > + if (name == null || value == null) { > + throw new IllegalArgumentException(); > + } > + else if (name.equals(USERNAME_PROPERTY)) { > + if (!(value instanceof String)) { > + throw new IllegalArgumentException( > + JavaUtils.getMessage("badProp00", > new String[] { > + name, "java.lang.String", > value.getClass().getName()})); > + } > + } > + else if (name.equals(PASSWORD_PROPERTY)) { > + if (!(value instanceof String)) { > + throw new IllegalArgumentException( > + JavaUtils.getMessage("badProp00", > new String[] { > + name, "java.lang.String", > value.getClass().getName()})); > + } > + } > + else if (name.equals(ADDRESS_PROPERTY)) { > + if (!(value instanceof String)) { > + throw new IllegalArgumentException( > + JavaUtils.getMessage("badProp00", > new String[] { > + name, "java.lang.String", > value.getClass().getName()})); > + } > try { > cachedEndpoint = new URL ((String) value); > } > @@ -117,6 +139,18 @@ > throw new > IllegalArgumentException(mue.getMessage()); > } > } > + else if (name.equals(SESSION_PROPERTY)) { > + if (!(value instanceof Boolean)) { > + throw new IllegalArgumentException( > + JavaUtils.getMessage("badProp00", > new String[] > + {name, > + "java.lang.Boolean", > + value.getClass().getName()})); > + } > + maintainSessionSet = true; > + maintainSession = ((Boolean) value).booleanValue(); > + } > + cachedProperties.put(name, value); > } // _setProperty > > /** > @@ -143,5 +177,6 @@ > public void setMaintainSession(boolean session) { > maintainSessionSet = true; > maintainSession = session; > + cachedProperties.put(SESSION_PROPERTY, new > Boolean(session)); > } // setmaintainSession > } > > > > 1.49 +4 -0 > xml-axis/java/src/org/apache/axis/utils/resources.properties > > Index: resources.properties > =================================================================== > RCS file: > /home/cvs/xml-axis/java/src/org/apache/axis/utils/resources.pr > operties,v > retrieving revision 1.48 > retrieving revision 1.49 > diff -u -r1.48 -r1.49 > --- resources.properties 1 Feb 2002 22:46:13 -0000 1.48 > +++ resources.properties 6 Feb 2002 15:17:17 -0000 1.49 > @@ -631,3 +631,7 @@ > axisVersion=Apache Axis version: #axisVersion# > builtOn=Built on #today# > > ############################################################## > ############### > + > +badProp00=Bad property. The value for {0} should be of > type {1}, but it is of type {2}. > +badProp01=Bad property. {0} should be {1}; but it is {2}. > +badProp02=Cannot set {0} property when {1} property is not {2}. > > > >