Resource loader was not working correctly for files from the classpath.
authorwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Wed, 19 Feb 2003 23:22:17 +0000 (23:22 +0000)
committerwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Wed, 19 Feb 2003 23:22:17 +0000 (23:22 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@484 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

src/edu/internet2/middleware/shibboleth/aa/arp/provider/FileSystemArpRepository.java
src/edu/internet2/middleware/shibboleth/common/ShibResource.java

index fce5b18..adaa308 100755 (executable)
@@ -50,9 +50,7 @@
 package edu.internet2.middleware.shibboleth.aa.arp.provider;
 
 import java.io.File;
-import java.io.FileNotFoundException;
 import java.io.IOException;
-import java.io.InputStream;
 import java.security.Principal;
 import java.util.Properties;
 
@@ -150,21 +148,24 @@ public class FileSystemArpRepository extends BaseArpRepository implements ArpRep
 
        }
 
-       private Element retrieveArpXml(String fileName) throws FileNotFoundException, SAXException, IOException {
+       private Element retrieveArpXml(String fileName) throws SAXException, IOException {
 
-               File arpFile = new ShibResource(fileName, this.getClass()).getFile();
-               if (!arpFile.exists()) {
+               try {
+                       ShibResource resource = new ShibResource(fileName, this.getClass());
+                       if (!resource.getFile().exists()) {
+                               log.debug("No ARP found.");
+                               return null;
+                       }
+
+                       DOMParser parser = new DOMParser();
+                       parser.parse(new InputSource(resource.getInputStream()));
+                       return parser.getDocument().getDocumentElement();
+
+               } catch (ShibResource.ResourceNotAvailableException e) {
                        log.debug("No ARP found.");
                        return null;
                }
-
-               InputStream inStream = new ShibResource(fileName).getInputStream();
-               DOMParser parser = new DOMParser();
-               parser.parse(new InputSource(inStream));
-               inStream.close();
-               return parser.getDocument().getDocumentElement();
        }
-
        /**
         * @see edu.internet2.middleware.shibboleth.aa.arp.provider.BaseArpRepository#retrieveUserArpXml(Principal)
         */
index d122170..6d83cca 100755 (executable)
@@ -56,7 +56,6 @@ import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
-import java.util.Properties;
 
 /**
  * Manages access to shibboleth file-based resources in a consistent fashion.  
@@ -94,7 +93,7 @@ public class ShibResource {
         */
        public File getFile() throws IOException {
                try {
-                       File file = new File(new URI(resource.toString()));
+                       File file = new File(new URI(resource.toString().replaceAll("\\s", "%20")));
                        return file;
                } catch (URISyntaxException e) {
                        throw new ResourceNotAvailableException("File could not be loaded from specified resource: " + e);
@@ -110,7 +109,7 @@ public class ShibResource {
                return resource;
        }
 
-       class ResourceNotAvailableException extends IOException {
+       public class ResourceNotAvailableException extends IOException {
 
                public ResourceNotAvailableException(String message) {
                        super(message);