You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by ra...@apache.org on 2005/04/03 10:08:42 UTC
cvs commit: xml-security/src/org/apache/xml/security/utils/resolver/implementations ResolverAnonymous.java ResolverXPointer.java ResolverDirectHTTP.java ResolverLocalFilesystem.java
raul 2005/04/03 00:08:42
Modified: src/org/apache/xml/security/utils/resolver/implementations
ResolverAnonymous.java ResolverXPointer.java
ResolverDirectHTTP.java
ResolverLocalFilesystem.java
Log:
javadoc warning, and minor optimizations
Revision Changes Path
1.9 +3 -8 xml-security/src/org/apache/xml/security/utils/resolver/implementations/ResolverAnonymous.java
Index: ResolverAnonymous.java
===================================================================
RCS file: /home/cvs/xml-security/src/org/apache/xml/security/utils/resolver/implementations/ResolverAnonymous.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ResolverAnonymous.java 24 Sep 2004 20:54:28 -0000 1.8
+++ ResolverAnonymous.java 3 Apr 2005 08:08:42 -0000 1.9
@@ -60,13 +60,8 @@
return this._input;
}
- /**
- * We resolve anonymous (unspecified) URIs
- *
- * @param uri
- * @param BaseURI
- * @return
- *
+ /**
+ * @inheritDoc
*/
public boolean engineCanResolve(Attr uri, String BaseURI) {
if (uri == null) {
1.26 +32 -33 xml-security/src/org/apache/xml/security/utils/resolver/implementations/ResolverXPointer.java
Index: ResolverXPointer.java
===================================================================
RCS file: /home/cvs/xml-security/src/org/apache/xml/security/utils/resolver/implementations/ResolverXPointer.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- ResolverXPointer.java 23 Mar 2005 18:07:08 -0000 1.25
+++ ResolverXPointer.java 3 Apr 2005 08:08:42 -0000 1.26
@@ -19,7 +19,6 @@
import org.apache.xml.security.signature.XMLSignatureInput;
-import org.apache.xml.security.utils.CachedXPathAPIHolder;
import org.apache.xml.security.utils.IdResolver;
import org.apache.xml.security.utils.resolver.ResourceResolverException;
import org.apache.xml.security.utils.resolver.ResourceResolverSpi;
@@ -64,12 +63,12 @@
//CachedXPathAPI cXPathAPI = new CachedXPathAPI();
-
- if (isXPointerSlash(uri)) {
+ String uriStr=uri.getNodeValue();
+ if (isXPointerSlash(uriStr)) {
resultNode = doc;
- } else if (isXPointerId(uri)) {
- String id = getXPointerId(uri);
+ } else if (isXPointerId(uriStr)) {
+ String id = getXPointerId(uriStr);
resultNode =IdResolver.getElementById(doc, id);
// log.debug("Use #xpointer(id('" + id + "')) on element " + selectedElem);
@@ -106,8 +105,8 @@
if (uri == null) {
return false;
}
-
- if (isXPointerSlash(uri) || isXPointerId(uri)) {
+ String uriStr =uri.getNodeValue();
+ if (isXPointerSlash(uriStr) || isXPointerId(uriStr)) {
return true;
}
@@ -120,15 +119,18 @@
* @param uri
* @return true if begins with xpointer
*/
- private static boolean isXPointerSlash(Attr uri) {
+ private static boolean isXPointerSlash(String uri) {
- if (uri.getNodeValue().equals("#xpointer(/)")) {
+ if (uri.equals("#xpointer(/)")) {
return true;
}
return false;
}
+
+ private static final String XP="#xpointer(id(";
+ private static final int XP_LENGTH=XP.length();
/**
* Method isXPointerId
*
@@ -136,25 +138,24 @@
* @return it it has an xpointer id
*
*/
- private static boolean isXPointerId(Attr uri) {
-
- String uriNodeValue = uri.getNodeValue();
+ private static boolean isXPointerId(String uri) {
+
- if (uriNodeValue.startsWith("#xpointer(id(")
- && uriNodeValue.endsWith("))")) {
- String idPlusDelim = uriNodeValue.substring("#xpointer(id(".length(),
- uriNodeValue.length()
- - "))".length());
+ if (uri.startsWith(XP)
+ && uri.endsWith("))")) {
+ String idPlusDelim = uri.substring(XP_LENGTH,
+ uri.length()
+ - 2);
// log.debug("idPlusDelim=" + idPlusDelim);
-
+ int idLen=idPlusDelim.length() -1;
if (((idPlusDelim.charAt(0) == '"') && (idPlusDelim
- .charAt(idPlusDelim.length() - 1) == '"')) || ((idPlusDelim
+ .charAt(idLen) == '"')) || ((idPlusDelim
.charAt(0) == '\'') && (idPlusDelim
- .charAt(idPlusDelim.length() - 1) == '\''))) {
+ .charAt(idLen) == '\''))) {
if (log.isDebugEnabled())
log.debug("Id="
- + idPlusDelim.substring(1, idPlusDelim.length() - 1));
+ + idPlusDelim.substring(1, idLen));
return true;
}
@@ -167,23 +168,21 @@
* Method getXPointerId
*
* @param uri
- * @return
+ * @return xpointerId to search.
*/
- private static String getXPointerId(Attr uri) {
-
- String uriNodeValue = uri.getNodeValue();
+ private static String getXPointerId(String uri) {
- if (uriNodeValue.startsWith("#xpointer(id(")
- && uriNodeValue.endsWith("))")) {
- String idPlusDelim = uriNodeValue.substring("#xpointer(id(".length(),
- uriNodeValue.length()
- - "))".length());
+ if (uri.startsWith(XP)
+ && uri.endsWith("))")) {
+ String idPlusDelim = uri.substring(XP_LENGTH,uri.length()
+ - 2);
+ int idLen=idPlusDelim.length() -1;
if (((idPlusDelim.charAt(0) == '"') && (idPlusDelim
- .charAt(idPlusDelim.length() - 1) == '"')) || ((idPlusDelim
+ .charAt(idLen) == '"')) || ((idPlusDelim
.charAt(0) == '\'') && (idPlusDelim
- .charAt(idPlusDelim.length() - 1) == '\''))) {
- return idPlusDelim.substring(1, idPlusDelim.length() - 1);
+ .charAt(idLen) == '\''))) {
+ return idPlusDelim.substring(1, idLen);
}
}
1.15 +8 -12 xml-security/src/org/apache/xml/security/utils/resolver/implementations/ResolverDirectHTTP.java
Index: ResolverDirectHTTP.java
===================================================================
RCS file: /home/cvs/xml-security/src/org/apache/xml/security/utils/resolver/implementations/ResolverDirectHTTP.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- ResolverDirectHTTP.java 23 Mar 2005 18:07:08 -0000 1.14
+++ ResolverDirectHTTP.java 3 Apr 2005 08:08:42 -0000 1.15
@@ -242,10 +242,9 @@
*
* @param uri
* @param BaseURI
- * @return
+ * @return true if can be resolved
*/
public boolean engineCanResolve(Attr uri, String BaseURI) {
-
if (uri == null) {
log.debug("quick fail, uri == null");
@@ -262,15 +261,14 @@
URI uriNew = null;
- try {
- uriNew = getNewURI(uri.getNodeValue(), BaseURI);
- } catch (URI.MalformedURIException ex) {
- log.debug("", ex);
- }
+ //URI uriNew = new URI(new URI(BaseURI), uri.getNodeValue());
+ if (log.isDebugEnabled())
+ log.debug("I was asked whether I can resolve " + uriNodeValue/*uriNew.toString()*/);
- if ((uriNew != null) && uriNew.getScheme().equals("http")) {
+ if ( uriNodeValue.startsWith("http:") ||
+ BaseURI.startsWith("http:")/*uriNew.getScheme().equals("file")*/) {
if (log.isDebugEnabled())
- log.debug("I state that I can resolve " + uriNew.toString());
+ log.debug("I state that I can resolve " + uriNodeValue/*uriNew.toString()*/);
return true;
}
@@ -282,9 +280,7 @@
}
/**
- * Method engineGetPropertyKeys
- *
- * @return
+ * @inheritDoc
*/
public String[] engineGetPropertyKeys() {
return ResolverDirectHTTP.properties;
1.14 +3 -13 xml-security/src/org/apache/xml/security/utils/resolver/implementations/ResolverLocalFilesystem.java
Index: ResolverLocalFilesystem.java
===================================================================
RCS file: /home/cvs/xml-security/src/org/apache/xml/security/utils/resolver/implementations/ResolverLocalFilesystem.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- ResolverLocalFilesystem.java 3 Apr 2005 07:44:13 -0000 1.13
+++ ResolverLocalFilesystem.java 3 Apr 2005 08:08:42 -0000 1.14
@@ -40,13 +40,7 @@
ResolverLocalFilesystem.class.getName());
/**
- * Method resolve
- *
- * @param uri
- * @param BaseURI
- * @return
- * @throws ResourceResolverException
- * @todo calculate the correct URI from the attribute and the BaseURI
+ * @inheritDoc
*/
public XMLSignatureInput engineResolve(Attr uri, String BaseURI)
throws ResourceResolverException {
@@ -78,7 +72,7 @@
* Method translateUriToFilename
*
* @param uri
- * @return
+ * @return the string of the filename
*/
private static String translateUriToFilename(String uri) {
@@ -113,11 +107,7 @@
}
/**
- * Method engineCanResolve
- *
- * @param uri
- * @param BaseURI
- * @return
+ * @inheritDoc
*/
public boolean engineCanResolve(Attr uri, String BaseURI) {