1 2 18 package com.sun.org.apache.xml.internal.security.utils.resolver; 19 20 21 import java.util.Map ; 22 23 import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput; 24 import org.w3c.dom.Attr ; 25 26 27 32 public abstract class ResourceResolverSpi { 33 34 35 static java.util.logging.Logger log = 36 java.util.logging.Logger.getLogger( 37 ResourceResolverSpi.class.getName()); 38 39 40 protected java.util.Map _properties = new java.util.HashMap (10); 41 42 51 public abstract XMLSignatureInput engineResolve(Attr uri, String BaseURI) 52 throws ResourceResolverException; 53 54 60 public void engineSetProperty(String key, String value) { 61 62 java.util.Iterator i = this._properties.keySet().iterator(); 63 64 while (i.hasNext()) { 65 String c = (String ) i.next(); 66 67 if (c.equals(key)) { 68 key = c; 69 70 break; 71 } 72 } 73 74 this._properties.put(key, value); 75 } 76 77 83 public String engineGetProperty(String key) { 84 85 java.util.Iterator i = this._properties.keySet().iterator(); 86 87 while (i.hasNext()) { 88 String c = (String ) i.next(); 89 90 if (c.equals(key)) { 91 key = c; 92 93 break; 94 } 95 } 96 97 return (String ) this._properties.get(key); 98 } 99 100 104 public void engineAddProperies(Map properties) { 105 this._properties.putAll(properties); 106 } 107 108 116 public abstract boolean engineCanResolve(Attr uri, String BaseURI); 117 118 123 public String [] engineGetPropertyKeys() { 124 return new String [0]; 125 } 126 127 133 public boolean understandsProperty(String propertyToTest) { 134 135 String [] understood = this.engineGetPropertyKeys(); 136 137 if (understood != null) { 138 for (int i = 0; i < understood.length; i++) { 139 if (understood[i].equals(propertyToTest)) { 140 return true; 141 } 142 } 143 } 144 145 return false; 146 } 147 148 149 156 public static String fixURI(String str) { 157 158 str = str.replace(java.io.File.separatorChar, '/'); 160 161 if (str.length() >= 4) { 162 163 char ch0 = Character.toUpperCase(str.charAt(0)); 165 char ch1 = str.charAt(1); 166 char ch2 = str.charAt(2); 167 char ch3 = str.charAt(3); 168 boolean isDosFilename = ((('A' <= ch0) && (ch0 <= 'Z')) 169 && (ch1 == ':') && (ch2 == '/') 170 && (ch3 != '/')); 171 172 if (isDosFilename) { 173 if (true) 174 if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Found DOS filename: " + str); 175 } 176 } 177 178 if (str.length() >= 2) { 180 char ch1 = str.charAt(1); 181 182 if (ch1 == ':') { 183 char ch0 = Character.toUpperCase(str.charAt(0)); 184 185 if (('A' <= ch0) && (ch0 <= 'Z')) { 186 str = "/" + str; 187 } 188 } 189 } 190 191 return str; 193 } 194 } 195 | Popular Tags |