Moved ARP config to Classpath.
authorwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Tue, 18 Feb 2003 20:53:31 +0000 (20:53 +0000)
committerwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Tue, 18 Feb 2003 20:53:31 +0000 (20:53 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@472 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

src/edu/internet2/middleware/shibboleth/aa/AAServlet.java
src/edu/internet2/middleware/shibboleth/aa/arp/provider/FileSystemArpRepository.java
webApplication/WEB-INF/classes/conf/arps/arp.site.xml [moved from webApplication/WEB-INF/conf/arps/arp.site.xml with 100% similarity]
webApplication/WEB-INF/classes/conf/origin.properties

index 3f95d45..b16b4a0 100755 (executable)
@@ -153,7 +153,7 @@ public class AAServlet extends HttpServlet {
                Properties defaultProps = new Properties();
                defaultProps.setProperty(
                        "edu.internet2.middleware.shibboleth.aa.arp.provider.FileSystemArpRepository.Path",
-                       getServletContext().getRealPath("/WEB-INF/conf/arps/"));
+                       "/conf/arps/");
                defaultProps.setProperty(
                        "edu.internet2.middleware.shibboleth.aa.arp.ArpRepository.implementation",
                        "edu.internet2.middleware.shibboleth.aa.arp.provider.FileSystemArpRepository");
@@ -172,7 +172,7 @@ public class AAServlet extends HttpServlet {
                Properties properties = new Properties(defaultProps);
                String propertiesFileLocation = getInitParameter("OriginPropertiesFile");
                if (propertiesFileLocation == null) {
-                       propertiesFileLocation = "/WEB-INF/conf/origin.properties";
+                       propertiesFileLocation = "/conf/origin.properties";
                }
                try {
                        log.debug("Loading Configuration from (" + propertiesFileLocation + ").");
index 55392ce..cff05b6 100755 (executable)
@@ -66,6 +66,7 @@ import org.xml.sax.SAXException;
 import edu.internet2.middleware.shibboleth.aa.arp.Arp;
 import edu.internet2.middleware.shibboleth.aa.arp.ArpRepository;
 import edu.internet2.middleware.shibboleth.aa.arp.ArpRepositoryException;
+import edu.internet2.middleware.shibboleth.common.ShibResource;
 
 /**
  * Simple <code>ArpRepository</code> implementation that uses a filesystem for storage.
@@ -82,33 +83,43 @@ public class FileSystemArpRepository extends BaseArpRepository implements ArpRep
 
        public FileSystemArpRepository(Properties props) throws ArpRepositoryException {
                super(props);
-               if (props
-                       .getProperty(
-                               "edu.internet2.middleware.shibboleth.aa.arp.provider.FileSystemArpRepository.Path",
-                               null)
+               if (props.getProperty("edu.internet2.middleware.shibboleth.aa.arp.provider.FileSystemArpRepository.Path", null)
                        == null) {
                        log.error(
                                "Cannot initialize FileSystemArpRepository: attribute (edu.internet2.middleware.shibboleth.aa.arp.provider.FileSystemArpRepository.Path) not specified");
                        throw new ArpRepositoryException("Cannot initialize FileSystemArpRepository");
                }
 
-               File givenPath =
-                       new File(
-                               props.getProperty(
-                                       "edu.internet2.middleware.shibboleth.aa.arp.provider.FileSystemArpRepository.Path"));
-               if (!givenPath.isDirectory()) {
+               try {
+                       File givenPath =
+                               new ShibResource(
+                                       props.getProperty(
+                                               "edu.internet2.middleware.shibboleth.aa.arp.provider.FileSystemArpRepository.Path"),
+                                       this.getClass())
+                                       .getFile();
+
+                       if (!givenPath.isDirectory()) {
+                               log.error(
+                                       "Cannot initialize FileSystemArpRepository: specified path is not a directory: ("
+                                               + givenPath.getPath()
+                                               + ").");
+                               throw new ArpRepositoryException("Cannot initialize FileSystemArpRepository");
+                       }
+
+                       dataStorePath =
+                               props.getProperty("edu.internet2.middleware.shibboleth.aa.arp.provider.FileSystemArpRepository.Path");
+                       if (!dataStorePath.endsWith("/")) {
+                               dataStorePath += "/";
+                       }
+                       log.info("Initializing File System Arp Repository with a root of (" + dataStorePath + ").");
+               } catch (IOException e) {
                        log.error(
-                               "Cannot initialize FileSystemArpRepository: specified path is not a directory: ("
-                                       + givenPath.getPath()
+                               "Cannot initialize FileSystemArpRepository: error accessing path: ("
+                                       + props.getProperty(
+                                               "edu.internet2.middleware.shibboleth.aa.arp.provider.FileSystemArpRepository.Path")
                                        + ").");
                        throw new ArpRepositoryException("Cannot initialize FileSystemArpRepository");
                }
-
-               log.info(
-                       "Initializing File System Arp Repository with a root of (" + givenPath.getAbsolutePath() + ").");
-               dataStorePath =
-                       props.getProperty(
-                               "edu.internet2.middleware.shibboleth.aa.arp.provider.FileSystemArpRepository.Path");
        }
 
        /**
@@ -130,16 +141,15 @@ public class FileSystemArpRepository extends BaseArpRepository implements ArpRep
         */
        protected Element retrieveSiteArpXml() throws IOException, SAXException {
 
-               String fileName = dataStorePath + System.getProperty("file.separator") + siteArpFileName;
+               String fileName = dataStorePath + siteArpFileName;
                log.debug("Attempting to load site ARP from: (" + fileName + ").");
                return retrieveArpXml(fileName);
 
        }
 
-       private Element retrieveArpXml(String fileName)
-               throws FileNotFoundException, SAXException, IOException {
+       private Element retrieveArpXml(String fileName) throws FileNotFoundException, SAXException, IOException {
 
-               File arpFile = new File(fileName);
+               File arpFile = new ShibResource(fileName, this.getClass()).getFile();
                if (!arpFile.exists()) {
                        log.debug("No ARP found.");
                        return null;
@@ -157,7 +167,6 @@ public class FileSystemArpRepository extends BaseArpRepository implements ArpRep
        protected Element retrieveUserArpXml(Principal principal) throws IOException, SAXException {
                String fileName =
                        dataStorePath
-                               + System.getProperty("file.separator")
                                + "arp.user."
                                + principal.getName()
                                + ".xml";
index 42aac73..7559ad4 100755 (executable)
@@ -1,5 +1,5 @@
 #Full Path to ARP repository
-#edu.internet2.middleware.shibboleth.aa.arp.provider.FileSystemArpRepository.Path = /opt/local/tomcat/webapps/shibboleth/WEB-INF/conf/arps/
+edu.internet2.middleware.shibboleth.aa.arp.provider.FileSystemArpRepository.Path = /conf/arps/
 edu.internet2.middleware.shibboleth.aa.arp.ArpRepository.implementation = edu.internet2.middleware.shibboleth.aa.arp.provider.FileSystemArpRepository
 
 edu.internet2.middleware.shibboleth.aa.AAServlet.authorityName = shib2.internet2.edu