Cleanup of the interfaces to the Arp Repository.
authorwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Tue, 17 Sep 2002 04:14:06 +0000 (04:14 +0000)
committerwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Tue, 17 Sep 2002 04:14:06 +0000 (04:14 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@301 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

src/edu/internet2/middleware/shibboleth/aa/AAResponder.java
src/edu/internet2/middleware/shibboleth/aa/AAServlet.java
src/edu/internet2/middleware/shibboleth/aa/ArpRepository.java
src/edu/internet2/middleware/shibboleth/aa/ArpRepositoryException.java [moved from src/edu/internet2/middleware/shibboleth/aa/ArpFactory.java with 75% similarity]
src/edu/internet2/middleware/shibboleth/aa/ArpRepositoryFactory.java [new file with mode: 0755]
src/edu/internet2/middleware/shibboleth/aa/FileArpRepository.java [moved from src/edu/internet2/middleware/shibboleth/aa/ArpFileFactory.java with 56% similarity]
src/edu/internet2/middleware/shibboleth/aa/arpUtil/ArpUtil.java
webApplication/WEB-INF/conf/arps/admin [moved from webApplication/arps/admin with 100% similarity, mode: 0755]
webApplication/WEB-INF/web.xml

index 041a180..e510e03 100755 (executable)
@@ -74,19 +74,26 @@ import org.apache.log4j.Logger;
 
 public class AAResponder{
 
-    ArpFactory arpFactory;
+    ArpRepository arpFactory;
     Arp adminArp;
     DirContext ctx;
     String domain;
     private static Logger log = Logger.getLogger(AAResponder.class.getName());    
 
-    public AAResponder(ArpFactory arpFactory, DirContext ctx, String domain)
+    public AAResponder(ArpRepository arpFactory, DirContext ctx, String domain)
        throws AAException{
 
        this.arpFactory = arpFactory;
-       adminArp = arpFactory.getInstance("admin", true);
-       if(adminArp.isNew())
-           throw new AAException("Admin Arp not found in "+arpFactory);
+       try {
+               adminArp = arpFactory.lookupArp("admin", true);
+       } catch (ArpRepositoryException e) {
+               log.error("Error while searching Arp Repository (" + arpFactory + ") : " + e.getMessage());
+           throw new AAException("Unable to load admin ARP.");
+       }
+       if(adminArp ==  null) {
+               log.error("Admin ARP not found in Arp Repository (" + arpFactory + ").");
+           throw new AAException("Unable to load admin ARP.");
+       }
        this.ctx = ctx;
        this.domain = domain;
     }
@@ -144,53 +151,63 @@ public class AAResponder{
     }
 
 
-    private Set getCombinedReleaseSet(Arp admin, String sharName, String url, String userName)
-       throws AAException {
-       
-       Set adminSet;
-       Set userSet;
-
-
-       Arp userArp = arpFactory.getInstance(userName, false);  
-       if(userArp.isNew()){
-           // no user ARP just use the admin
-           // only go throu and drop the exclude ones
-           adminSet = getReleaseSet(adminArp, sharName, url, adminArp);
-           Iterator it = adminSet.iterator();
-           while(it.hasNext()){
-               ArpAttribute attr = (ArpAttribute)it.next();
-               if(attr.mustExclude())
-                   adminSet.remove(attr);
-           }
-           return adminSet;
-       }
+       private Set getCombinedReleaseSet(Arp admin, String sharName, String url, String userName)
+               throws AAException {
 
-       adminSet = getReleaseSet(adminArp, sharName, url, adminArp);
-       userSet = getReleaseSet(userArp, sharName, url, adminArp);
-       // combine the two
-       Iterator it = adminSet.iterator();
-       while(it.hasNext()){
-           ArpAttribute aAttr = (ArpAttribute)it.next();
-           if(aAttr.mustExclude()){
-               userSet.remove(aAttr);  // ok if not there
-               adminSet.remove(aAttr);
-           }
-           if(userSet.contains(aAttr)){
-               // in both. Combine filters
-               ArpFilter f = combineFilters(aAttr, getAttr(userSet, aAttr));
-               log.info("Combining filters: "+
-                                  aAttr.getFilter()+ " AND "+
-                                  getAttr(userSet, aAttr).getFilter()+
-                                  " = " + f);
-               if(f != null)
-                   aAttr.setFilter(f, true); // force it
-               userSet.remove(aAttr);
-           }
-       }
-       adminSet.addAll(userSet);
-       return adminSet;
+               try {
+                       Set adminSet;
+                       Set userSet;
+                       Arp userArp;
+
+                       userArp = arpFactory.lookupArp(userName, false);
+
+                       if (userArp == null) {
+                               // no user ARP just use the admin
+                               // only go throu and drop the exclude ones
+                               adminSet = getReleaseSet(adminArp, sharName, url, adminArp);
+                               Iterator it = adminSet.iterator();
+                               while (it.hasNext()) {
+                                       ArpAttribute attr = (ArpAttribute) it.next();
+                                       if (attr.mustExclude())
+                                               adminSet.remove(attr);
+                               }
+                               return adminSet;
+                       }
+
+                       adminSet = getReleaseSet(adminArp, sharName, url, adminArp);
+                       userSet = getReleaseSet(userArp, sharName, url, adminArp);
+                       // combine the two
+                       Iterator it = adminSet.iterator();
+                       while (it.hasNext()) {
+                               ArpAttribute aAttr = (ArpAttribute) it.next();
+                               if (aAttr.mustExclude()) {
+                                       userSet.remove(aAttr); // ok if not there
+                                       adminSet.remove(aAttr);
+                               }
+                               if (userSet.contains(aAttr)) {
+                                       // in both. Combine filters
+                                       ArpFilter f = combineFilters(aAttr, getAttr(userSet, aAttr));
+                                       log.info(
+                                               "Combining filters: "
+                                                       + aAttr.getFilter()
+                                                       + " AND "
+                                                       + getAttr(userSet, aAttr).getFilter()
+                                                       + " = "
+                                                       + f);
+                                       if (f != null)
+                                               aAttr.setFilter(f, true); // force it
+                                       userSet.remove(aAttr);
+                               }
+                       }
+                       adminSet.addAll(userSet);
+                       return adminSet;
+
+               } catch (ArpRepositoryException e) {
+                       log.error("Error while searching Arp Repository (" + arpFactory + ") : " + e.getMessage());
+                       throw new AAException("Unable to load user ARP.");
+               }
 
-    }              
+       }                   
                    
 
     private Set getReleaseSet(Arp arp, String sharName, String url, Arp admin)
index 52c897e..9c34304 100755 (executable)
@@ -82,7 +82,7 @@ public class AAServlet extends HttpServlet {
     String ctxFactory;
     AAResponder responder;
     HandleRepositoryFactory hrf;
-    ArpFactory arpFactory;
+    ArpRepository arpFactory;
     private static Logger log = Logger.getLogger(AAServlet.class.getName());    
     
     public void init()
@@ -102,19 +102,21 @@ public class AAServlet extends HttpServlet {
             // build a properties object to be handed to ArpFactories
             // include all parameters :-(
             Enumeration en = getInitParameterNames();
-            Properties props = new Properties();
+            Properties defaultProps = new Properties();
+            defaultProps.setProperty("edu.internet2.middleware.shibboleth.aa.FileArpRepository.Path", getServletContext().getRealPath("/WEB-INF/conf/arps"));
+            Properties props = new Properties(defaultProps);
             while(en.hasMoreElements()){
                 String key = (String)en.nextElement();
                 String val = getInitParameter(key);
                 props.setProperty(key, val);
             }
-            props.setProperty("arpFactoryRealPath",
-                              getServletContext().getRealPath("/"));
 
             arpFactoryMethod = getInitParameter("arpFactoryMethod");
-
+                       if (arpFactoryMethod == null) {
+                               arpFactoryMethod = "edu.internet2.middleware.shibboleth.aa.FileArpRepository";  
+                       }
    
-            arpFactory = ArpRepository.getInstance(arpFactoryMethod, props);
+            arpFactory = ArpRepositoryFactory.getInstance(arpFactoryMethod, props);
 
            log.info("Using "+ctxFactory+" as directory for attributes.");
 
index 13b3875..022caed 100755 (executable)
 package edu.internet2.middleware.shibboleth.aa;
 
 /**
- *  Attribute Authority & Release Policy
- *  Factory for generating ARP managers/factories.
+ *  Defines interaction with an ARP storage/retrieval mechanism.
  *
- * @author     Parviz Dousti (dousti@cmu.edu)
- * @created    June, 2002
+ * @author Parviz Dousti (dousti@cmu.edu)
+ * @author Walter Hoehn (wassa@columbia.edu)
  */
-import java.util.*;
-import java.lang.reflect.*;
 
+public interface ArpRepository {
 
-public class ArpRepository{
+       /**
+        * Searches the repository for the named ARP.
+        * @return an instance of <code>Arp</code> or null
+        *  if the ARP is not found in the repository 
+        */
 
-    /**
-     * This is a class to allow implementation of different 
-     * repositories for ARPs. e.g. File system, SQL database, or LDAP
-     * It returns an implementation based on the given class name.  
-     * It passes a Properties object with all configured key-value pairs 
-     * Each implementation can extract their own configuration values
-     * from Properties.
-     */
+       public Arp lookupArp(String arpName, boolean isDefault) throws ArpRepositoryException ;
 
-    public static ArpFactory getInstance(String implementor, Properties props)
-        throws AAException{
+       /**
+        * If an ARP is found in the repository that matches the results of getName(), 
+        * it is replaced with the specified ARP.  If not, the specified ARP is added to the repository
+        */
 
-        try{
-            Class implementorClass = Class.forName(implementor);
-            Class[] params = new Class[1];
-            params[0] = Class.forName("java.util.Properties");
-            Constructor implementorConstructor = implementorClass.getConstructor(params);
-            Object[] args = new Object[1];
-            args[0] = props;
-            return (ArpFactory) implementorConstructor.newInstance(args);
+       public void update(Arp arp) throws ArpRepositoryException;
+
+       /**
+        * Removes the specified ARP from the repository if it exists
+        */
+
+       public void remove(Arp arp) throws ArpRepositoryException;
 
-        }catch(ClassNotFoundException cnfe){
-            throw new AAException("Failed to instantiate an ArpFactory: "+cnfe);
-        }catch(InstantiationException ie){
-            throw new AAException("Failed to instantiate an ArpFactory: "+ie);
-        }catch(IllegalAccessException iae){
-            throw new AAException("Failed to instantiate an ArpFactory: "+iae);
-        }catch(NoSuchMethodException nsme){
-            throw new AAException("Failed to instantiate an ArpFactory: "+nsme);
-        }catch(InvocationTargetException ite){
-            throw new AAException("Failed to instantiate an ArpFactory: "+ite);
-        }
-    }
 }
  */
 
 package edu.internet2.middleware.shibboleth.aa;
-
 /**
- *  Attribute Authority & Release Policy
- *  Common interface for all ARP repositories.
- *
- * @author     Parviz Dousti (dousti@cmu.edu)
- * @created    June, 2002
+ * Indicates an error occurred while manipulating an Arp Repository
+ * 
+ * @author Walter Hoehn (wassa@columbia.edu)
  */
 
-
-public interface ArpFactory{
-
-
-    /**
-     * Returns an Arp instance. It tries to retrieve the Arp from a repository
-     * If not found then creates a new emplty Arp.  
-     * Arp can be check by its isNew() to see how it was generated
-     */
-
-    public Arp getInstance(String arpName, boolean isDefault)
-       throws AAException;
-
-    
-    /**
-     * Writes the given ARP back to the repository.
-     */
-
-    public void write(Arp arp) throws AAException;
-
-    /**
-     * Rereads the ARP if the version on storage is newer
-     * than the one in memory.
-     */
-
-    public Arp reread(Arp arp) throws AAException;
-
-    /**
-     * Permanently removes the given ARP from the repository
-     */
-
-    public void remove(Arp arp) throws AAException;
+class ArpRepositoryException extends Exception {
+       
+       ArpRepositoryException(String message) {
+               super(message); 
+       }       
 
 }
-
diff --git a/src/edu/internet2/middleware/shibboleth/aa/ArpRepositoryFactory.java b/src/edu/internet2/middleware/shibboleth/aa/ArpRepositoryFactory.java
new file mode 100755 (executable)
index 0000000..2b5c766
--- /dev/null
@@ -0,0 +1,89 @@
+/* 
+ * The Shibboleth License, Version 1. 
+ * Copyright (c) 2002 
+ * University Corporation for Advanced Internet Development, Inc. 
+ * All rights reserved
+ * 
+ * 
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * Redistributions of source code must retain the above copyright notice, this 
+ * list of conditions and the following disclaimer.
+ * 
+ * Redistributions in binary form must reproduce the above copyright notice, 
+ * this list of conditions and the following disclaimer in the documentation 
+ * and/or other materials provided with the distribution, if any, must include 
+ * the following acknowledgment: "This product includes software developed by 
+ * the University Corporation for Advanced Internet Development 
+ * <http://www.ucaid.edu>Internet2 Project. Alternately, this acknowledegement 
+ * may appear in the software itself, if and wherever such third-party 
+ * acknowledgments normally appear.
+ * 
+ * Neither the name of Shibboleth nor the names of its contributors, nor 
+ * Internet2, nor the University Corporation for Advanced Internet Development, 
+ * Inc., nor UCAID may be used to endorse or promote products derived from this 
+ * software without specific prior written permission. For written permission, 
+ * please contact shibboleth@shibboleth.org
+ * 
+ * Products derived from this software may not be called Shibboleth, Internet2, 
+ * UCAID, or the University Corporation for Advanced Internet Development, nor 
+ * may Shibboleth appear in their name, without prior written permission of the 
+ * University Corporation for Advanced Internet Development.
+ * 
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
+ * AND WITH ALL FAULTS. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 
+ * PARTICULAR PURPOSE, AND NON-INFRINGEMENT ARE DISCLAIMED AND THE ENTIRE RISK 
+ * OF SATISFACTORY QUALITY, PERFORMANCE, ACCURACY, AND EFFORT IS WITH LICENSEE. 
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER, CONTRIBUTORS OR THE UNIVERSITY 
+ * CORPORATION FOR ADVANCED INTERNET DEVELOPMENT, INC. BE LIABLE FOR ANY DIRECT, 
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package edu.internet2.middleware.shibboleth.aa;
+
+import java.lang.reflect.Constructor;
+import java.util.Properties;
+
+import org.apache.log4j.Logger;
+
+/**
+ * Factory for generating instances of <code>ArpRepository</code>.  Configuration
+ * is delegated to the Arp Repository.  Runtime options are passed to conrecte constructors
+ * via a <code>Properties</code> object.
+ *
+ * @author     Parviz Dousti (dousti@cmu.edu)
+ * @created    June, 2002
+ */
+
+public class ArpRepositoryFactory {
+
+       private static Logger log = Logger.getLogger(AAServlet.class.getName());
+
+       public static ArpRepository getInstance(String repositoryClassName, Properties props)
+               throws AAException {
+
+               try {
+                       Class implementorClass = Class.forName(repositoryClassName);
+                       Class[] params = new Class[1];
+                       params[0] = Class.forName("java.util.Properties");
+                       Constructor implementorConstructor = implementorClass.getConstructor(params);
+                       Object[] args = new Object[1];
+                       args[0] = props;
+                       log.debug("Initializing Arp Repository of type (" + implementorClass.getName() + ").");
+                       return (ArpRepository) implementorConstructor.newInstance(args);
+
+               } catch (Exception e) {
+                       log.error("Failed to instantiate an Arp Repository: " + e.getMessage());
+                       throw new AAException("Failed to instantiate an Arp Repository.");
+
+               }
+       }
+}
@@ -72,113 +72,91 @@ import org.apache.log4j.Logger;
  * @created    June, 2002
  */
 
-public class ArpFileFactory implements ArpFactory {
-
-       static String dataStore;
-       private static Logger log = Logger.getLogger(ArpFileFactory.class.getName());
-       public ArpFileFactory(Properties props) {
-               String pathData = props.getProperty("arpFactoryData");
-               if (pathData == null) {
-                       String realPath = props.getProperty("arpFactoryRealPath");
-                       realPath += "arps";
-                       log.debug("shib dir = " + realPath);
-                       pathData = realPath;
+public class FileArpRepository implements ArpRepository {
+
+       private String dataStorePath;
+       private static Logger log = Logger.getLogger(FileArpRepository.class.getName());
+       public FileArpRepository(Properties props) throws ArpRepositoryException {
+               
+               if (props.getProperty("edu.internet2.middleware.shibboleth.aa.FileArpRepository.Path", null) == null) {
+                       log.error("Cannot initialize FileArpRepository: attribute (edu.internet2.middleware.shibboleth.aa.FileArpRepository.Path) not specified");
+                       throw new ArpRepositoryException("Cannot initialize FileArpRepository");
+               }
+               
+               File givenPath = new File(props.getProperty("edu.internet2.middleware.shibboleth.aa.FileArpRepository.Path"));
+               if (!givenPath.isDirectory()) {
+                       log.error("Cannot initialize FileArpRepository: specified path is not a directory.");
+                       throw new ArpRepositoryException("Cannot initialize FileArpRepository");                
                }
-               dataStore = pathData;
+               
+               log.info("Initializing File Arp Repository with a root of (" + givenPath.getAbsolutePath() + ").");
+               dataStorePath = props.getProperty("edu.internet2.middleware.shibboleth.aa.FileArpRepository.Path");
        }
 
-       /**
-        * returns an Arp instance. It tries to retrieve the Arp from file system
-        * If not found then creates a new emplty Arp.  
-        * Arp can be check by its isNew() to see how it was generated
-        */
-
-       public Arp getInstance(String arpName, boolean isAdmin) throws AAException {
+       public Arp lookupArp(String arpName, boolean isAdmin) throws ArpRepositoryException {
                try {
 
-                       String fileName = dataStore + System.getProperty("file.separator") + arpName;
-                       log.info("AA: Looking for ARP " + fileName);
+                       String fileName = dataStorePath + System.getProperty("file.separator") + arpName;
+                       log.info("Searching for ARP " + arpName);
+                       log.debug("Looking at : " + fileName);
+                       
+                       File arpFile = new File(fileName);
+                       if (!arpFile.exists()) {
+                               return null;    
+                       }
 
                        FileInputStream f = new FileInputStream(fileName);
                        ObjectInput s = new ObjectInputStream(f);
                        Arp arp = (Arp) s.readObject();
-                       if (!arpName.equals(arp.getName()))
-                               throw new AAException("Wrong ARP name.  ARP maybe renamed in datastore. ");
+                       if (!arpName.equals(arp.getName())) {
+                               log.warn("Unexpected ARP name: expected - (" + arpName + ") actual - (" + arp.getName() + ")");
+                       }
                        arp.setNew(false);
                        arp.setLastRead(new Date());
                        log.info("AA: Found and using ARP " + arpName);
                        return arp;
-
-               } catch (FileNotFoundException e) {
-                       // check the IO error to make sure "file not found"
-                       log.info("AA: Got File Not Found for " + arpName + " in " + dataStore);
-                       try {
-                               Arp arp = new Arp(arpName, isAdmin);
-                               arp.setNew(true);
-                               arp.setLastRead(new Date());
-                               return arp;
-                       } catch (NotOwnerException noe) {
-                               throw new AAException("Cannot create an ARP. Not owner.");
-                       }
-
-               } catch (IOException fe) {
-                       throw new AAException("Reading ARP failed: " + fe);
-               } catch (ClassNotFoundException ce) {
-                       throw new AAException("ARP retrival failed: " + ce);
-               } catch (Exception oe) {
-                       throw new AAException(oe.toString());
+               } catch (FileNotFoundException fnfe) {
+                       log.error("Unable to read ARP storage: " + fnfe.getMessage());
+                       throw new ArpRepositoryException("Unable to read ARP storage.");                        
+               } catch (IOException ioe) {
+                       log.error("Unable to unmarshall ARP from file: " + ioe.getMessage());
+                       throw new ArpRepositoryException("Unable to unmarshall ARP.");  
+               } catch (ClassNotFoundException cnfe) {
+                       log.error("Serious Problem! Unable to unmarhsall ARP because (Arp) class not found: " + cnfe.getMessage());
+                       throw new ArpRepositoryException("Unable to unmarshall ARP.");  
                }
        }
 
-       public void write(Arp arp) throws AAException {
-               // XXX do we need to check any permissions?
+       public void update(Arp arp) throws ArpRepositoryException {
+
                try {
-                       String fileName = dataStore + System.getProperty("file.separator") + arp.getName();
+                       String fileName = dataStorePath + System.getProperty("file.separator") + arp.getName();
                        FileOutputStream f = new FileOutputStream(fileName);
                        ObjectOutput s = new ObjectOutputStream(f);
-                       arp.setNew(false);
                        s.writeObject(arp);
                        s.flush();
-               } catch (IOException e) {
-                       throw new AAException("IO Problem:" + e);
-               }
-       }
-
-       /**
-        * Reread the arp from file system if the copy on disk
-        * is newer than the copy in memory.
-        */
-
-       public Arp reread(Arp arp) throws AAException {
-               String fileName = dataStore + System.getProperty("file.separator") + arp.getName();
-               File file = new File(fileName);
-               if (file == null)
-                       throw new AAException("Arp not found on disk while trying to re-read. :" + arp);
-               Date timeStamp = new Date(file.lastModified());
-               log.info(
-                       "AA: Check ARP's freshness: in memory ("
-                               + arp.getLastRead()
-                               + ") vs on disk ("
-                               + timeStamp
-                               + ")");
-               if (timeStamp.after(arp.getLastRead())) {
-                       log.info("AA: ARP has been modified on disk. Re-read " + arp.getName());
-                       return getInstance(arp.getName(), arp.isAdmin());
+                       arp.setNew(false);
+               } catch (FileNotFoundException e) {
+                       log.error("Unable to write ARP to file:" + e.getMessage());
+                       throw new ArpRepositoryException("Unable to update ARP.");
+               } catch (IOException ioe) {
+                       log.error("Error serializing ARP:" + ioe.getMessage());
+                       throw new ArpRepositoryException("Unable to update ARP.");
                }
-               return arp; // return the old one.
        }
 
-       public void remove(Arp arp) throws AAException {
+       public void remove(Arp arp) throws ArpRepositoryException {
                try {
-                       String fileName = dataStore + System.getProperty("file.separator") + arp.getName();
-                       File f = new File(fileName);
-                       f.delete();
-               } catch (Exception e) {
-                       throw new AAException("IO Problem:" + e);
+               String fileName = dataStorePath + System.getProperty("file.separator") + arp.getName();
+               File f = new File(fileName);
+               f.delete();
+               } catch (SecurityException e) {
+                       log.error("Cannot write ARP with current Security Manager configuration" + e.getMessage());
+                       throw new ArpRepositoryException("Unable to remove ARP.");
                }
        }
 
        public String toString() {
-               return "ArpFileFactory:dir=" + dataStore;
+               return "FileArpRepository:dir=" + dataStorePath;
        }
 }
index 5a60d87..0d3383b 100755 (executable)
@@ -70,7 +70,7 @@ class ArpUtil{
 
     private static Logger log = Logger.getLogger(ArpUtil.class.getName());
     static Principal user;
-    static ArpFactory arpFactory;
+    static ArpRepository arpFactory;
     static String listUsage = "\tArpUtil list <arp name> [-acls] [-dir <ldap url> <user id>]";
     static String addUsage = "\tArpUtil add <arp name> [-admin] <shar name> [-default] <url> [-title comment] <attribute name> [-exclude] [-filter [!]<val1> [!]<val2> ...]";    
     static String removeUsage = "\tArpUtil remove <arp name> [<shar name> [<url> [<attribute name>]]]";
@@ -79,7 +79,9 @@ class ArpUtil{
 
     public static void main(String [] args)throws AAException{
 
-       arpFactory = ArpRepository.getInstance("file",  System.getProperty("arp.dir"));
+       Properties props = new Properties();
+       props.setProperty("arpFactoryRealpath", System.getProperty("arp.dir"));
+       arpFactory = ArpRepositoryFactory.getInstance("edu.internet2.middleware.shibboleth.aa.FileArpRepository", props);
 
        PropertyConfigurator.configure(System.getProperty("log.config"));
        
@@ -136,7 +138,7 @@ class ArpUtil{
                }
            }
 
-           Arp arp = arpFactory.getInstance(arpName, false);
+           Arp arp = arpFactory.lookupArp(arpName, false);
            if(arp.isNew() == true){
                System.out.println("Arp not Found: "+arpName);
            }
@@ -250,7 +252,7 @@ class ArpUtil{
           
 
        try{
-           Arp arp = arpFactory.getInstance(arpName, isAdmin);
+           Arp arp = arpFactory.lookupArp(arpName, isAdmin);
            ArpShar s = arp.getShar(sharName);
 
            if(s == null)
@@ -280,7 +282,7 @@ class ArpUtil{
            r.addAnAttribute(a);
            s.addAResource(r);
            arp.addAShar(s);
-           arpFactory.write(arp);
+           arpFactory.update(arp);
        }catch(AAPermissionException pe){
            System.out.println("Permission denied: "+pe);
        }catch(Exception e){
@@ -316,7 +318,7 @@ class ArpUtil{
        }
 
        try{
-           Arp arp = arpFactory.getInstance(arpName, false/* does not matter here */);
+           Arp arp = arpFactory.lookupArp(arpName, false/* does not matter here */);
            if(arp.isNew()){
                System.out.println("ARP not found: "+arp);
                return;
@@ -334,7 +336,7 @@ class ArpUtil{
            if(resourceName == null){
                // remove the whole shar
                arp.removeAShar(sharName);
-               arpFactory.write(arp);
+               arpFactory.update(arp);
                return;
            }
            ArpResource r = s.getResource(resourceName);
@@ -345,7 +347,7 @@ class ArpUtil{
            if(attrName == null){
                // remove the whole resource
                s.removeAResource(resourceName);
-               arpFactory.write(arp);
+               arpFactory.update(arp);
                return;
            }
            ArpAttribute a = r.getAttribute(attrName);
@@ -354,7 +356,7 @@ class ArpUtil{
                return;
            }
            r.removeAnAttribute(attrName);
-           arpFactory.write(arp);
+           arpFactory.update(arp);
        }catch(AAPermissionException pe){
            System.out.println("Permission denied: "+pe);
        }catch(Exception e){
@@ -403,7 +405,7 @@ class ArpUtil{
          
 
        try{
-           Arp arp = arpFactory.getInstance(arpName, false/* does not matter here */);
+           Arp arp = arpFactory.lookupArp(arpName, false/* does not matter here */);
            if(arp.isNew()){
                System.out.println("ARP not found: "+arp);
                return;
@@ -411,7 +413,7 @@ class ArpUtil{
            if(sharName == null){
                // set ACL fo the whole arp
                arp.setAcl(user, acl);
-               arpFactory.write(arp);
+               arpFactory.update(arp);
                return;
            }
            ArpShar s = arp.getShar(sharName);
@@ -422,7 +424,7 @@ class ArpUtil{
            if(resourceName == null){
                // set ACL the whole shar
                s.setAcl(user, acl);
-               arpFactory.write(arp);
+               arpFactory.update(arp);
                return;
            }
            ArpResource r = s.getResource(resourceName);
@@ -432,7 +434,7 @@ class ArpUtil{
            }
            // set ACL the resource
            r.setAcl(user, acl);
-           arpFactory.write(arp);
+           arpFactory.update(arp);
            return;
        }catch(AAPermissionException pe){
            System.out.println("Permission denied: "+pe);
old mode 100644 (file)
new mode 100755 (executable)
similarity index 100%
rename from webApplication/arps/admin
rename to webApplication/WEB-INF/conf/arps/admin
index 4f1653c..4a8ed86 100755 (executable)
                    <param-name>ctxFactoryClass</param-name>
                    <param-value>edu.internet2.middleware.shibboleth.aaLocal.EchoCtxFactory</param-value>
                </init-param>
-               <init-param>
-                   <param-name>arpFactoryMethod</param-name>
-                   <param-value>edu.internet2.middleware.shibboleth.aa.ArpFileFactory</param-value>
-               </init-param>
        </servlet>
        <servlet>
                <servlet-name>WAYF</servlet-name>