Added support for grouped and non-grouped origin sites.
authorwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Wed, 19 Jun 2002 21:04:22 +0000 (21:04 +0000)
committerwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Wed, 19 Jun 2002 21:04:22 +0000 (21:04 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@151 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

src/edu/internet2/middleware/shibboleth/wayf/Origin.java
src/edu/internet2/middleware/shibboleth/wayf/OriginSet.java
src/edu/internet2/middleware/shibboleth/wayf/OriginSitesDigester.java
src/edu/internet2/middleware/shibboleth/wayf/WayfConfigDigester.java
src/edu/internet2/middleware/shibboleth/wayf/WayfOrigins.java

index 114a272..bb6c072 100755 (executable)
@@ -6,6 +6,8 @@ import java.util.Enumeration;
 import java.util.Iterator;
 import java.util.StringTokenizer;
 
+import org.apache.log4j.Logger;
+
 /**
  * This class represents an Origin site in the shibboleth parlance.
  * 
@@ -14,6 +16,7 @@ import java.util.StringTokenizer;
 
 public class Origin {
 
+       private static Logger log = Logger.getLogger(Origin.class.getName());
     private String name;
     private ArrayList aliases = new ArrayList();
     private String handleService;
index a583498..70023e7 100755 (executable)
@@ -1,6 +1,7 @@
 package edu.internet2.middleware.shibboleth.wayf;
 
 import java.util.ArrayList;
+import java.util.HashSet;
 
 import org.apache.log4j.Logger;
 
@@ -14,9 +15,9 @@ import org.apache.log4j.Logger;
 
 public class OriginSet {
 
-       private ArrayList origins = new ArrayList();
+       private HashSet origins = new HashSet();
        private static Logger log = Logger.getLogger(OriginSet.class.getName());
-       private String name;
+       private String name = "";
 
 
        public String getName() {
@@ -33,7 +34,7 @@ public class OriginSet {
 
        public void addOrigin(Origin origin) {
                origins.add(origin);
-               log.debug("Adding an origin site to configuration.");
+               log.debug("Adding origin site :"+ origin.getName() + ":  to set.");
        }
 
 }
index b1ba1de..365b2d7 100755 (executable)
@@ -16,13 +16,10 @@ import edu.internet2.middleware.shibboleth.common.ServletDigester;
  * Window>Preferences>Java>Code Generation.
  */
 public class OriginSitesDigester extends ServletDigester {
-       
-           protected String originClass =
-                "edu.internet2.middleware.shibboleth.wayf.Origin";
-        protected String wayfDataClass =
-                "edu.internet2.middleware.shibboleth.wayf.WayfOrigins";
-        protected String originSetClass =
-                "edu.internet2.middleware.shibboleth.wayf.OriginSet";
+
+       protected String originClass = "edu.internet2.middleware.shibboleth.wayf.Origin";
+       protected String wayfDataClass = "edu.internet2.middleware.shibboleth.wayf.WayfOrigins";
+       protected String originSetClass = "edu.internet2.middleware.shibboleth.wayf.OriginSet";
 
        private boolean configured = false;
 
@@ -56,20 +53,24 @@ public class OriginSitesDigester extends ServletDigester {
        public OriginSitesDigester(XMLReader reader) {
                super(reader);
        }
-       
-               /**
-        * @see Digester#configure()
-        */
+
+       /**
+       * @see Digester#configure()
+       */
        protected void configure() {
 
                if (configured == true) {
                        return;
                }
+               //Create data container
                addObjectCreate("Sites", wayfDataClass);
+
+               //Digest sites that are nested in a group
                addObjectCreate("Sites/SiteGroup", originSetClass);
                addSetNext("Sites/SiteGroup", "addOriginSet", originSetClass);
                addCallMethod("Sites/SiteGroup", "setName", 1);
                addCallParam("Sites/SiteGroup", 0, "Name");
+
                addObjectCreate("Sites/SiteGroup/OriginSite", originClass);
                addSetNext("Sites/SiteGroup/OriginSite", "addOrigin", originClass);
                addCallMethod("Sites/SiteGroup/OriginSite", "setName", 1);
@@ -79,9 +80,20 @@ public class OriginSitesDigester extends ServletDigester {
                addCallMethod("Sites/SiteGroup/OriginSite", "setHandleService", 1);
                addCallParam("Sites/SiteGroup/OriginSite/HandleService", 0, "Location");
 
+               //Digest sites without nesting and add them to the default group
+               addObjectCreate("Sites/OriginSite", originSetClass);
+               addSetNext("Sites/OriginSite", "addOriginSet", originSetClass);
+               addObjectCreate("Sites/OriginSite", originClass);
+               addSetNext("Sites/OriginSite", "addOrigin", originClass);
+               addCallMethod("Sites/OriginSite", "setName", 1);
+               addCallParam("Sites/OriginSite", 0, "Name");
+               addSetProperties("Sites/OriginSite");
+               addCallMethod("Sites/OriginSite/Alias", "addAlias", 0);
+               addCallMethod("Sites/OriginSite", "setHandleService", 1);
+               addCallParam("Sites/OriginSite/HandleService", 0, "Location");
+
                configured = true;
 
        }
 
 }
-
index a31ed5f..89de372 100755 (executable)
@@ -18,8 +18,7 @@ import edu.internet2.middleware.shibboleth.common.ServletDigester;
 
 public class WayfConfigDigester extends ServletDigester {
 
-       protected String wayfConfigClass =
-               "edu.internet2.middleware.shibboleth.wayf.WayfConfig";
+       protected String wayfConfigClass = "edu.internet2.middleware.shibboleth.wayf.WayfConfig";
        private boolean configured = false;
 
        public WayfConfigDigester() {
@@ -36,7 +35,6 @@ public class WayfConfigDigester extends ServletDigester {
                super(context);
        }
 
-
        public WayfConfigDigester(XMLReader reader) {
                super(reader);
                configure();
@@ -53,14 +51,8 @@ public class WayfConfigDigester extends ServletDigester {
                addObjectCreate("WayfConfig", wayfConfigClass);
                addSetProperties("WayfConfig");
                addCallMethod("WayfConfig/HelpText", "setHelpText", 0);
-               addCallMethod(
-                       "WayfConfig/SearchResultEmptyText",
-                       "setSearchResultEmptyText",
-                       0);
-               addCallMethod(
-                       "WayfConfig/SearchIgnore/IgnoreText",
-                       "addIgnoredForMatch",
-                       0);
+               addCallMethod("WayfConfig/SearchResultEmptyText", "setSearchResultEmptyText", 0);
+               addCallMethod("WayfConfig/SearchIgnore/IgnoreText", "addIgnoredForMatch", 0);
 
                configured = true;
 
index 880ce7c..8983459 100755 (executable)
@@ -1,6 +1,6 @@
 package edu.internet2.middleware.shibboleth.wayf;
 
-import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 
@@ -14,21 +14,29 @@ import org.apache.log4j.Logger;
 
 public class WayfOrigins {
 
-       private ArrayList originSets = new ArrayList();
+       private HashMap origins = new HashMap();
        private static Logger log = Logger.getLogger(WayfOrigins.class.getName());
 
        public OriginSet[] getOriginSets() {
-               return (OriginSet[]) originSets.toArray(new OriginSet[0]);
+               return (OriginSet[]) origins.values().toArray(new OriginSet[0]);
        }
 
        public void addOriginSet(OriginSet originSet) {
-               originSets.add(originSet);
-               log.debug("Adding an origin set to configuration");
+               if (origins.containsKey(originSet.getName())) {
+                       OriginSet previousOrigins = (OriginSet) origins.get(originSet.getName());
+                       Origin[] newOrigins = originSet.getOrigins();
+                       for (int i = 0;(i < newOrigins.length); i++) {
+                               previousOrigins.addOrigin(newOrigins[i]);
+                       }
+               } else {
+                       origins.put(originSet.getName(), originSet);
+               }
+               log.debug("Adding origin set :" + originSet.getName() + ": to configuration");
        }
 
        public String lookupHSbyName(String originName) {
                if (originName != null) {
-                       Iterator originSetIt = originSets.iterator();
+                       Iterator originSetIt = origins.values().iterator();
                        while (originSetIt.hasNext()) {
 
                                OriginSet originSet = (OriginSet) originSetIt.next();
@@ -47,7 +55,7 @@ public class WayfOrigins {
 
        public Origin[] seachForMatchingOrigins(String searchString, WayfConfig config) {
 
-               Iterator originSetIt = originSets.iterator();
+               Iterator originSetIt = origins.values().iterator();
                HashSet searchResults = new HashSet();
                while (originSetIt.hasNext()) {