You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by co...@apache.org on 2011/01/28 12:47:51 UTC
svn commit: r1064633 - in
/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security:
Init.java utils/resolver/ResourceResolver.java
utils/resolver/ResourceResolverException.java
utils/resolver/ResourceResolverSpi.java
Author: coheigea
Date: Fri Jan 28 11:47:50 2011
New Revision: 1064633
URL: http://svn.apache.org/viewvc?rev=1064633&view=rev
Log:
[SANTUARIO-254,SANTUARIO-256] - Reworked some of the ResourceResolver code.
Modified:
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/Init.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/resolver/ResourceResolver.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/resolver/ResourceResolverException.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/resolver/ResourceResolverSpi.java
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/Init.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/Init.java?rev=1064633&r1=1064632&r2=1064633&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/Init.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/Init.java Fri Jan 28 11:47:50 2011
@@ -289,7 +289,6 @@ public class Init {
if (tag.equals("ResourceResolvers")){
XX_configure_reg_resourceresolver_start = System.currentTimeMillis();
- ResourceResolver.init();
Element[]resolverElem = XMLUtils.selectNodes(el.getFirstChild(),CONF_NS,
"Resolver");
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/resolver/ResourceResolver.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/resolver/ResourceResolver.java?rev=1064633&r1=1064632&r2=1064633&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/resolver/ResourceResolver.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/resolver/ResourceResolver.java Fri Jan 28 11:47:50 2011
@@ -26,173 +26,144 @@ import org.w3c.dom.Attr;
/**
* During reference validation, we have to retrieve resources from somewhere.
* This is done by retrieving a Resolver. The resolver needs two arguments: The
- * URI in which the link to the new resource is defined and the BaseURI of the
- * file/entity in which the URI occurs (the BaseURI is the same as the SystemId.
- *
- * <UL xml:lang="DE" LANG="DE">
- * <LI> Verschiedene Implementierungen k??nnen sich als Resolver registrieren.
- * <LI> Standardm????ig werden erste Implementierungen auf dem XML config file registrirt.
- * <LI> Der Benutzer kann bei Bedarf Implementierungen voranstellen oder anf??gen.
- * <LI> Implementierungen k??nnen mittels Features customized werden ??
- * (z.B. um Proxy-Passworter ??bergeben zu k??nnen).
- * <LI> Jede Implementierung bekommt das URI Attribut und den Base URI
- * ??bergeben und muss antworten, ob sie aufl??sen kann.
- * <LI> Die erste Implementierung, die die Aufgabe erf??llt, f??hrt die Aufl??sung durch.
- * </UL>
+ * URI in which the link to the new resource is defined and the baseURI of the
+ * file/entity in which the URI occurs (the baseURI is the same as the SystemId).
*
* @author $Author$
*/
public class ResourceResolver {
- /** {@link org.apache.commons.logging} logging facility */
- static org.apache.commons.logging.Log log =
+ /** {@link org.apache.commons.logging} logging facility */
+ private static org.apache.commons.logging.Log log =
org.apache.commons.logging.LogFactory.getLog(ResourceResolver.class.getName());
- /** Field _alreadyInitialized */
- static boolean _alreadyInitialized = false;
+ /** these are the system-wide resolvers */
+ private static List<ResourceResolver> resolverVector = new ArrayList<ResourceResolver>(10);
+
+ /** Field transformSpi */
+ protected ResourceResolverSpi resolverSpi = null;
+
+ /**
+ * Constructor ResourceResolver
+ *
+ * @param className
+ * @throws ClassNotFoundException
+ * @throws IllegalAccessException
+ * @throws InstantiationException
+ */
+ private ResourceResolver(String className)
+ throws ClassNotFoundException, IllegalAccessException, InstantiationException {
+ this.resolverSpi =
+ (ResourceResolverSpi) Class.forName(className).newInstance();
+ }
+
+ /**
+ * Constructor ResourceResolver
+ *
+ * @param resourceResolver
+ */
+ public ResourceResolver(ResourceResolverSpi resourceResolver) {
+ this.resolverSpi = resourceResolver;
+ }
+
+ /**
+ * Method getInstance
+ *
+ * @param uri
+ * @param baseURI
+ * @return the instance
+ *
+ * @throws ResourceResolverException
+ */
+ public synchronized static final ResourceResolver getInstance(Attr uri, String baseURI)
+ throws ResourceResolverException {
+ for (int i = 0; i < resolverVector.size(); i++) {
+ ResourceResolver resolver = resolverVector.get(i);
+ ResourceResolver resolverTmp = null;
+
+ if (resolver.resolverSpi.engineIsThreadSafe()) {
+ resolverTmp = resolver;
+ } else {
+ try {
+ resolverTmp =
+ new ResourceResolver(
+ (ResourceResolverSpi)resolver.resolverSpi.getClass().newInstance()
+ );
+ } catch (InstantiationException e) {
+ throw new ResourceResolverException("", e, uri, baseURI);
+ } catch (IllegalAccessException e) {
+ throw new ResourceResolverException("", e, uri, baseURI);
+ }
+ }
- /** these are the system-wide resolvers */
- static List _resolverVector = null;
-
- static boolean allThreadSafeInList=true;
-
- /** Field transformSpi */
- protected ResourceResolverSpi _resolverSpi = null;
-
- /**
- * Constructor ResourceResolver
- *
- * @param className
- * @throws ClassNotFoundException
- * @throws IllegalAccessException
- * @throws InstantiationException
- */
- private ResourceResolver(String className)
- throws ClassNotFoundException, IllegalAccessException,
- InstantiationException {
- this._resolverSpi =
- (ResourceResolverSpi) Class.forName(className).newInstance();
- }
-
- /**
- * Constructor ResourceResolver
- *
- * @param resourceResolver
- */
- public ResourceResolver(ResourceResolverSpi resourceResolver) {
- this._resolverSpi = resourceResolver;
- }
-
-
- /**
- * Method getInstance
- *
- * @param uri
- * @param BaseURI
- * @return the instnace
- *
- * @throws ResourceResolverException
- */
- public static final ResourceResolver getInstance(Attr uri, String BaseURI)
- throws ResourceResolverException {
- int length=ResourceResolver._resolverVector.size();
- for (int i = 0; i < length; i++) {
- ResourceResolver resolver =
- (ResourceResolver) ResourceResolver._resolverVector.get(i);
- ResourceResolver resolverTmp=null;
- try {
- resolverTmp = allThreadSafeInList || resolver._resolverSpi.engineIsThreadSafe() ? resolver :
- new ResourceResolver((ResourceResolverSpi)resolver._resolverSpi.getClass().newInstance());
- } catch (InstantiationException e) {
- throw new ResourceResolverException("",e,uri,BaseURI);
- } catch (IllegalAccessException e) {
- throw new ResourceResolverException("",e,uri,BaseURI);
- }
-
- if (log.isDebugEnabled())
- log.debug("check resolvability by class " + resolver._resolverSpi.getClass().getName());
-
- if ((resolver != null) && resolverTmp.canResolve(uri, BaseURI)) {
- if (i!=0) {
- //update resolver.
- //System.out.println("Swaping");
- List resolverVector=(List)((ArrayList)_resolverVector).clone();
- resolverVector.remove(i);
- resolverVector.add(0,resolver);
- _resolverVector=resolverVector;
- } else {
- //System.out.println("hitting");
- }
-
- return resolverTmp;
- }
- }
-
- Object exArgs[] = { ((uri != null)
- ? uri.getNodeValue()
- : "null"), BaseURI };
-
- throw new ResourceResolverException("utils.resolver.noClass", exArgs,
- uri, BaseURI);
- }
- /**
- * Method getInstance
- *
- * @param uri
- * @param BaseURI
- * @param individualResolvers
- * @return the instance
- *
- * @throws ResourceResolverException
- */
- public static final ResourceResolver getInstance(
- Attr uri, String BaseURI, List individualResolvers)
- throws ResourceResolverException {
- if (log.isDebugEnabled()) {
-
- log.debug("I was asked to create a ResourceResolver and got " + (individualResolvers==null? 0 : individualResolvers.size()) );
- log.debug(" extra resolvers to my existing " + ResourceResolver._resolverVector.size() + " system-wide resolvers");
- }
-
- // first check the individual Resolvers
- int size=0;
- if ((individualResolvers != null) && ((size=individualResolvers.size()) > 0)) {
- for (int i = 0; i < size; i++) {
- ResourceResolver resolver =
- (ResourceResolver) individualResolvers.get(i);
-
- if (resolver != null) {
- String currentClass = resolver._resolverSpi.getClass().getName();
- if (log.isDebugEnabled())
- log.debug("check resolvability by class " + currentClass);
-
- if (resolver.canResolve(uri, BaseURI)) {
- return resolver;
- }
+ if (log.isDebugEnabled()) {
+ log.debug(
+ "check resolvability by class " + resolver.resolverSpi.getClass().getName()
+ );
}
- }
- }
- return getInstance(uri,BaseURI);
- }
+ if ((resolverTmp != null) && resolverTmp.canResolve(uri, baseURI)) {
+ if (i != 0) {
+ // update resolver.
+ resolverVector.remove(i);
+ resolverVector.add(0, resolver);
+ }
- /**
- * The init() function is called by org.apache.xml.security.Init.init()
- */
- public static void init() {
-
- if (!ResourceResolver._alreadyInitialized) {
- ResourceResolver._resolverVector = new ArrayList(10);
- _alreadyInitialized = true;
- }
- }
+ return resolverTmp;
+ }
+ }
+
+ Object exArgs[] = { ((uri != null) ? uri.getNodeValue() : "null"), baseURI };
+
+ throw new ResourceResolverException("utils.resolver.noClass", exArgs, uri, baseURI);
+ }
+
+ /**
+ * Method getInstance
+ *
+ * @param uri
+ * @param baseURI
+ * @param individualResolvers
+ * @return the instance
+ *
+ * @throws ResourceResolverException
+ */
+ public static final ResourceResolver getInstance(
+ Attr uri, String baseURI, List<ResourceResolver> individualResolvers
+ ) throws ResourceResolverException {
+ if (log.isDebugEnabled()) {
+ log.debug(
+ "I was asked to create a ResourceResolver and got "
+ + (individualResolvers == null ? 0 : individualResolvers.size())
+ );
+ }
+
+ // first check the individual Resolvers
+ if (individualResolvers != null) {
+ for (int i = 0; i < individualResolvers.size(); i++) {
+ ResourceResolver resolver = individualResolvers.get(i);
+
+ if (resolver != null) {
+ String currentClass = resolver.resolverSpi.getClass().getName();
+ if (log.isDebugEnabled()) {
+ log.debug("check resolvability by class " + currentClass);
+ }
+
+ if (resolver.canResolve(uri, baseURI)) {
+ return resolver;
+ }
+ }
+ }
+ }
+
+ return getInstance(uri, baseURI);
+ }
/**
* Registers a ResourceResolverSpi class. This method logs a warning if
* the class cannot be registered.
*
- * @param className the name of the ResourceResolverSpi class to be
- * registered
+ * @param className the name of the ResourceResolverSpi class to be registered
*/
public static void register(String className) {
register(className, false);
@@ -202,25 +173,23 @@ public class ResourceResolver {
* Registers a ResourceResolverSpi class at the beginning of the provider
* list. This method logs a warning if the class cannot be registered.
*
- * @param className the name of the ResourceResolverSpi class to be
- * registered
+ * @param className the name of the ResourceResolverSpi class to be registered
*/
public static void registerAtStart(String className) {
register(className, true);
}
- private static void register(String className, boolean start) {
+ private synchronized static void register(String className, boolean start) {
try {
ResourceResolver resolver = new ResourceResolver(className);
if (start) {
- ResourceResolver._resolverVector.add(0, resolver);
- log.debug("registered resolver");
+ resolverVector.add(0, resolver);
} else {
- ResourceResolver._resolverVector.add(resolver);
+ resolverVector.add(resolver);
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("Registered resolver: " + className);
}
- if (!resolver._resolverSpi.engineIsThreadSafe()) {
- allThreadSafeInList=false;
- }
} catch (Exception e) {
log.warn("Error loading resolver " + className +" disabling it");
} catch (NoClassDefFoundError e) {
@@ -228,93 +197,92 @@ public class ResourceResolver {
}
}
- /**
- * Method resolve
- *
- * @param uri
- * @param BaseURI
- * @return the resource
- *
- * @throws ResourceResolverException
- */
- public static XMLSignatureInput resolveStatic(Attr uri, String BaseURI)
- throws ResourceResolverException {
-
- ResourceResolver myResolver = ResourceResolver.getInstance(uri, BaseURI);
-
- return myResolver.resolve(uri, BaseURI);
- }
-
- /**
- * Method resolve
- *
- * @param uri
- * @param BaseURI
- * @return the resource
- *
- * @throws ResourceResolverException
- */
- public XMLSignatureInput resolve(Attr uri, String BaseURI)
- throws ResourceResolverException {
- return this._resolverSpi.engineResolve(uri, BaseURI);
- }
-
- /**
- * Method setProperty
- *
- * @param key
- * @param value
- */
- public void setProperty(String key, String value) {
- this._resolverSpi.engineSetProperty(key, value);
- }
-
- /**
- * Method getProperty
- *
- * @param key
- * @return the value of the property
- */
- public String getProperty(String key) {
- return this._resolverSpi.engineGetProperty(key);
- }
-
- /**
- * Method addProperties
- *
- * @param properties
- */
- public void addProperties(Map properties) {
- this._resolverSpi.engineAddProperies(properties);
- }
-
- /**
- * Method getPropertyKeys
- *
- * @return all property keys.
- */
- public String[] getPropertyKeys() {
- return this._resolverSpi.engineGetPropertyKeys();
- }
-
- /**
- * Method understandsProperty
- *
- * @param propertyToTest
- * @return true if the resolver understands the property
- */
- public boolean understandsProperty(String propertyToTest) {
- return this._resolverSpi.understandsProperty(propertyToTest);
- }
-
- /**
- * Method canResolve
- *
- * @param uri
- * @param BaseURI
- * @return true if it can resolve the uri
- */
- private boolean canResolve(Attr uri, String BaseURI) {
- return this._resolverSpi.engineCanResolve(uri, BaseURI);
- }
+ /**
+ * Method resolveStatic
+ *
+ * @param uri
+ * @param baseURI
+ * @return the resource
+ *
+ * @throws ResourceResolverException
+ */
+ public static XMLSignatureInput resolveStatic(Attr uri, String baseURI)
+ throws ResourceResolverException {
+ ResourceResolver myResolver = ResourceResolver.getInstance(uri, baseURI);
+
+ return myResolver.resolve(uri, baseURI);
+ }
+
+ /**
+ * Method resolve
+ *
+ * @param uri
+ * @param baseURI
+ * @return the resource
+ *
+ * @throws ResourceResolverException
+ */
+ public XMLSignatureInput resolve(Attr uri, String baseURI)
+ throws ResourceResolverException {
+ return this.resolverSpi.engineResolve(uri, baseURI);
+ }
+
+ /**
+ * Method setProperty
+ *
+ * @param key
+ * @param value
+ */
+ public void setProperty(String key, String value) {
+ this.resolverSpi.engineSetProperty(key, value);
+ }
+
+ /**
+ * Method getProperty
+ *
+ * @param key
+ * @return the value of the property
+ */
+ public String getProperty(String key) {
+ return this.resolverSpi.engineGetProperty(key);
+ }
+
+ /**
+ * Method addProperties
+ *
+ * @param properties
+ */
+ public void addProperties(Map<String, String> properties) {
+ this.resolverSpi.engineAddProperies(properties);
+ }
+
+ /**
+ * Method getPropertyKeys
+ *
+ * @return all property keys.
+ */
+ public String[] getPropertyKeys() {
+ return this.resolverSpi.engineGetPropertyKeys();
+ }
+
+ /**
+ * Method understandsProperty
+ *
+ * @param propertyToTest
+ * @return true if the resolver understands the property
+ */
+ public boolean understandsProperty(String propertyToTest) {
+ return this.resolverSpi.understandsProperty(propertyToTest);
+ }
+
+ /**
+ * Method canResolve
+ *
+ * @param uri
+ * @param baseURI
+ * @return true if it can resolve the uri
+ */
+ private boolean canResolve(Attr uri, String baseURI) {
+ return this.resolverSpi.engineCanResolve(uri, baseURI);
+ }
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/resolver/ResourceResolverException.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/resolver/ResourceResolverException.java?rev=1064633&r1=1064632&r2=1064633&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/resolver/ResourceResolverException.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/resolver/ResourceResolverException.java Fri Jan 28 11:47:50 2011
@@ -17,12 +17,9 @@
*/
package org.apache.xml.security.utils.resolver;
-
-
import org.apache.xml.security.exceptions.XMLSecurityException;
import org.w3c.dom.Attr;
-
/**
* This Exception is thrown if something related to the
* {@link org.apache.xml.security.utils.resolver.ResourceResolver} goes wrong.
@@ -31,112 +28,106 @@ import org.w3c.dom.Attr;
*/
public class ResourceResolverException extends XMLSecurityException {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- /**
- * Constructor ResourceResolverException
- *
- * @param _msgID
- * @param uri
- * @param BaseURI
- */
- public ResourceResolverException(String _msgID, Attr uri, String BaseURI) {
-
- super(_msgID);
-
- this._uri = uri;
- this._BaseURI = BaseURI;
- }
-
- /**
- * Constructor ResourceResolverException
- *
- * @param _msgID
- * @param exArgs
- * @param uri
- * @param BaseURI
- */
- public ResourceResolverException(String _msgID, Object exArgs[], Attr uri,
- String BaseURI) {
-
- super(_msgID, exArgs);
-
- this._uri = uri;
- this._BaseURI = BaseURI;
- }
-
- /**
- * Constructor ResourceResolverException
- *
- * @param _msgID
- * @param _originalException
- * @param uri
- * @param BaseURI
- */
- public ResourceResolverException(String _msgID, Exception _originalException,
- Attr uri, String BaseURI) {
-
- super(_msgID, _originalException);
-
- this._uri = uri;
- this._BaseURI = BaseURI;
- }
-
- /**
- * Constructor ResourceResolverException
- *
- * @param _msgID
- * @param exArgs
- * @param _originalException
- * @param uri
- * @param BaseURI
- */
- public ResourceResolverException(String _msgID, Object exArgs[],
- Exception _originalException, Attr uri,
- String BaseURI) {
-
- super(_msgID, exArgs, _originalException);
-
- this._uri = uri;
- this._BaseURI = BaseURI;
- }
-
- //J-
- Attr _uri = null;
- /**
- *
- * @param uri
- */
- public void setURI(Attr uri) {
- this._uri = uri;
- }
-
- /**
- *
- * @return the uri
- */
- public Attr getURI() {
- return this._uri;
- }
-
- String _BaseURI;
-
- /**
- *
- * @param BaseURI
- */
- public void setBaseURI(String BaseURI) {
- this._BaseURI = BaseURI;
- }
-
- /**
- *
- * @return the basUri
- */
- public String getBaseURI() {
- return this._BaseURI;
- }
- //J+
+ private static final long serialVersionUID = 1L;
+
+ private Attr uri = null;
+
+ private String baseURI = null;
+
+ /**
+ * Constructor ResourceResolverException
+ *
+ * @param msgID
+ * @param uri
+ * @param baseURI
+ */
+ public ResourceResolverException(String msgID, Attr uri, String baseURI) {
+ super(msgID);
+
+ this.uri = uri;
+ this.baseURI = baseURI;
+ }
+
+ /**
+ * Constructor ResourceResolverException
+ *
+ * @param msgID
+ * @param exArgs
+ * @param uri
+ * @param baseURI
+ */
+ public ResourceResolverException(String msgID, Object exArgs[], Attr uri,
+ String baseURI) {
+ super(msgID, exArgs);
+
+ this.uri = uri;
+ this.baseURI = baseURI;
+ }
+
+ /**
+ * Constructor ResourceResolverException
+ *
+ * @param msgID
+ * @param originalException
+ * @param uri
+ * @param baseURI
+ */
+ public ResourceResolverException(String msgID, Exception originalException,
+ Attr uri, String baseURI) {
+ super(msgID, originalException);
+
+ this.uri = uri;
+ this.baseURI = baseURI;
+ }
+
+ /**
+ * Constructor ResourceResolverException
+ *
+ * @param msgID
+ * @param exArgs
+ * @param originalException
+ * @param uri
+ * @param baseURI
+ */
+ public ResourceResolverException(String msgID, Object exArgs[],
+ Exception originalException, Attr uri,
+ String baseURI) {
+ super(msgID, exArgs, originalException);
+
+ this.uri = uri;
+ this.baseURI = baseURI;
+ }
+
+ /**
+ *
+ * @param uri
+ */
+ public void setURI(Attr uri) {
+ this.uri = uri;
+ }
+
+ /**
+ *
+ * @return the uri
+ */
+ public Attr getURI() {
+ return this.uri;
+ }
+
+ /**
+ *
+ * @param baseURI
+ */
+ public void setbaseURI(String baseURI) {
+ this.baseURI = baseURI;
+ }
+
+ /**
+ *
+ * @return the baseURI
+ */
+ public String getbaseURI() {
+ return this.baseURI;
+ }
+
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/resolver/ResourceResolverSpi.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/resolver/ResourceResolverSpi.java?rev=1064633&r1=1064632&r2=1064633&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/resolver/ResourceResolverSpi.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/resolver/ResourceResolverSpi.java Fri Jan 28 11:47:50 2011
@@ -1,4 +1,3 @@
-
/*
* Copyright 1999-2004 The Apache Software Foundation.
*
@@ -17,14 +16,12 @@
*/
package org.apache.xml.security.utils.resolver;
-
import java.util.HashMap;
import java.util.Map;
import org.apache.xml.security.signature.XMLSignatureInput;
import org.w3c.dom.Attr;
-
/**
* During reference validation, we have to retrieve resources from somewhere.
*
@@ -32,157 +29,158 @@ import org.w3c.dom.Attr;
*/
public abstract class ResourceResolverSpi {
- /** {@link org.apache.commons.logging} logging facility */
- static org.apache.commons.logging.Log log =
- org.apache.commons.logging.LogFactory.getLog(
- ResourceResolverSpi.class.getName());
-
- /** Field _properties */
- protected java.util.Map _properties = null;
-
- /**
- * This is the workhorse method used to resolve resources.
- *
- * @param uri
- * @param BaseURI
- * @return the resource wrapped arround a XMLSignatureInput
- *
- * @throws ResourceResolverException
- */
- public abstract XMLSignatureInput engineResolve(Attr uri, String BaseURI)
- throws ResourceResolverException;
-
- /**
- * Method engineSetProperty
- *
- * @param key
- * @param value
- */
- public void engineSetProperty(String key, String value) {
- if (_properties==null) {
- _properties=new HashMap();
- }
- this._properties.put(key, value);
- }
-
- /**
- * Method engineGetProperty
- *
- * @param key
- * @return the value of the property
- */
- public String engineGetProperty(String key) {
- if (_properties==null) {
- return null;
- }
- return (String) this._properties.get(key);
- }
-
- /**
- *
- * @param properties
- */
- public void engineAddProperies(Map properties) {
- if (properties!=null) {
- if (_properties==null) {
- _properties=new HashMap();
- }
- this._properties.putAll(properties);
- }
- }
- /**
- * Tells if the implementation does can be reused by several threads safely.
- * It normally means that the implemantation does not have any member, or there is
- * member change betwen engineCanResolve & engineResolve invocations. Or it mantians all
- * member info in ThreadLocal methods.
- */
- public boolean engineIsThreadSafe() {
- return false;
- }
- /**
- * This method helps the {@link ResourceResolver} to decide whether a
- * {@link ResourceResolverSpi} is able to perform the requested action.
- *
- * @param uri
- * @param BaseURI
- * @return true if the engine can resolve the uri
- */
- public abstract boolean engineCanResolve(Attr uri, String BaseURI);
-
- /**
- * Method engineGetPropertyKeys
- *
- * @return the property keys
- */
- public String[] engineGetPropertyKeys() {
- return new String[0];
- }
-
- /**
- * Method understandsProperty
- *
- * @param propertyToTest
- * @return true if understands the property
- */
- public boolean understandsProperty(String propertyToTest) {
-
- String[] understood = this.engineGetPropertyKeys();
-
- if (understood != null) {
- for (int i = 0; i < understood.length; i++) {
- if (understood[i].equals(propertyToTest)) {
- return true;
+ /** {@link org.apache.commons.logging} logging facility */
+ private static org.apache.commons.logging.Log log =
+ org.apache.commons.logging.LogFactory.getLog(ResourceResolverSpi.class.getName());
+
+ /** Field properties */
+ protected java.util.Map<String, String> properties = null;
+
+ /**
+ * This is the workhorse method used to resolve resources.
+ *
+ * @param uri
+ * @param BaseURI
+ * @return the resource wrapped around a XMLSignatureInput
+ *
+ * @throws ResourceResolverException
+ */
+ public abstract XMLSignatureInput engineResolve(Attr uri, String BaseURI)
+ throws ResourceResolverException;
+
+ /**
+ * Method engineSetProperty
+ *
+ * @param key
+ * @param value
+ */
+ public void engineSetProperty(String key, String value) {
+ if (properties == null) {
+ properties = new HashMap<String, String>();
+ }
+ this.properties.put(key, value);
+ }
+
+ /**
+ * Method engineGetProperty
+ *
+ * @param key
+ * @return the value of the property
+ */
+ public String engineGetProperty(String key) {
+ if (properties == null) {
+ return null;
+ }
+ return this.properties.get(key);
+ }
+
+ /**
+ *
+ * @param properties
+ */
+ public void engineAddProperies(Map<String, String> properties) {
+ if (properties != null) {
+ if (properties == null) {
+ properties = new HashMap<String, String>();
+ }
+ this.properties.putAll(properties);
+ }
+ }
+
+ /**
+ * Tells if the implementation does can be reused by several threads safely.
+ * It normally means that the implementation does not have any member, or there is
+ * member change between engineCanResolve & engineResolve invocations. Or it maintains all
+ * member info in ThreadLocal methods.
+ */
+ public boolean engineIsThreadSafe() {
+ return false;
+ }
+
+ /**
+ * This method helps the {@link ResourceResolver} to decide whether a
+ * {@link ResourceResolverSpi} is able to perform the requested action.
+ *
+ * @param uri
+ * @param BaseURI
+ * @return true if the engine can resolve the uri
+ */
+ public abstract boolean engineCanResolve(Attr uri, String BaseURI);
+
+ /**
+ * Method engineGetPropertyKeys
+ *
+ * @return the property keys
+ */
+ public String[] engineGetPropertyKeys() {
+ return new String[0];
+ }
+
+ /**
+ * Method understandsProperty
+ *
+ * @param propertyToTest
+ * @return true if understands the property
+ */
+ public boolean understandsProperty(String propertyToTest) {
+ String[] understood = this.engineGetPropertyKeys();
+
+ if (understood != null) {
+ for (int i = 0; i < understood.length; i++) {
+ if (understood[i].equals(propertyToTest)) {
+ return true;
+ }
}
- }
- }
+ }
- return false;
- }
+ return false;
+ }
- /**
- * Fixes a platform dependent filename to standard URI form.
- *
- * @param str The string to fix.
- *
- * @return Returns the fixed URI string.
- */
- public static String fixURI(String str) {
-
- // handle platform dependent strings
- str = str.replace(java.io.File.separatorChar, '/');
-
- if (str.length() >= 4) {
-
- // str =~ /^\W:\/([^/])/ # to speak perl ;-))
- char ch0 = Character.toUpperCase(str.charAt(0));
- char ch1 = str.charAt(1);
- char ch2 = str.charAt(2);
- char ch3 = str.charAt(3);
- boolean isDosFilename = ((('A' <= ch0) && (ch0 <= 'Z'))
- && (ch1 == ':') && (ch2 == '/')
- && (ch3 != '/'));
-
- if (isDosFilename) {
- if (log.isDebugEnabled())
- log.debug("Found DOS filename: " + str);
- }
- }
-
- // Windows fix
- if (str.length() >= 2) {
- char ch1 = str.charAt(1);
+ /**
+ * Fixes a platform dependent filename to standard URI form.
+ *
+ * @param str The string to fix.
+ *
+ * @return Returns the fixed URI string.
+ */
+ public static String fixURI(String str) {
- if (ch1 == ':') {
+ // handle platform dependent strings
+ str = str.replace(java.io.File.separatorChar, '/');
+
+ if (str.length() >= 4) {
+
+ // str =~ /^\W:\/([^/])/ # to speak perl ;-))
char ch0 = Character.toUpperCase(str.charAt(0));
+ char ch1 = str.charAt(1);
+ char ch2 = str.charAt(2);
+ char ch3 = str.charAt(3);
+ boolean isDosFilename = ((('A' <= ch0) && (ch0 <= 'Z'))
+ && (ch1 == ':') && (ch2 == '/')
+ && (ch3 != '/'));
+
+ if (isDosFilename) {
+ if (log.isDebugEnabled()) {
+ log.debug("Found DOS filename: " + str);
+ }
+ }
+ }
- if (('A' <= ch0) && (ch0 <= 'Z')) {
- str = "/" + str;
+ // Windows fix
+ if (str.length() >= 2) {
+ char ch1 = str.charAt(1);
+
+ if (ch1 == ':') {
+ char ch0 = Character.toUpperCase(str.charAt(0));
+
+ if (('A' <= ch0) && (ch0 <= 'Z')) {
+ str = "/" + str;
+ }
}
- }
- }
+ }
- // done
- return str;
- }
+ // done
+ return str;
+ }
}