- Fixed bug where config files in src-conf did not have IDP_HOME/SP_HOME properly...
[java-idp.git] / src / edu / internet2 / middleware / shibboleth / wayf / OriginSitesDigester.java
1 /*
2  * Copyright [2005] [University Corporation for Advanced Internet Development, Inc.]
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package edu.internet2.middleware.shibboleth.wayf;
18
19 import javax.xml.parsers.SAXParser;
20
21 import org.xml.sax.XMLReader;
22
23 import edu.internet2.middleware.shibboleth.common.ServletDigester;
24
25 /**
26  * @author Administrator
27  * 
28  * To change this generated comment edit the template variable "typecomment": Window>Preferences>Java>Templates. To
29  * enable and disable the creation of type comments go to Window>Preferences>Java>Code Generation.
30  */
31 public class OriginSitesDigester extends ServletDigester {
32
33         protected String originClass = "edu.internet2.middleware.shibboleth.wayf.Origin";
34         protected String originSetClass = "edu.internet2.middleware.shibboleth.wayf.OriginSet";
35
36         private boolean configured = false;
37
38         /**
39          * Constructor for OriginSitesDigester.
40          */
41         public OriginSitesDigester() {
42
43                 super();
44         }
45
46         /**
47          * Constructor for OriginSitesDigester.
48          * 
49          * @param parser
50          */
51         public OriginSitesDigester(SAXParser parser) {
52
53                 super(parser);
54         }
55
56         /**
57          * Constructor for OriginSitesDigester.
58          * 
59          * @param reader
60          */
61         public OriginSitesDigester(XMLReader reader) {
62
63                 super(reader);
64         }
65
66         /**
67          * @see Digester#configure()
68          */
69         protected void configure() {
70
71                 if (configured == true) { return; }
72                 push(new WayfOrigins());
73                 // Digest sites that are nested in a group
74                 addObjectCreate("SiteGroup", originSetClass);
75                 addSetNext("SiteGroup", "addOriginSet", originSetClass);
76                 addCallMethod("SiteGroup", "setName", 1);
77                 addCallParam("SiteGroup", 0, "Name");
78
79                 addObjectCreate("SiteGroup/OriginSite", originClass);
80                 addSetNext("SiteGroup/OriginSite", "addOrigin", originClass);
81                 addCallMethod("SiteGroup/OriginSite", "setName", 1);
82                 addCallParam("SiteGroup/OriginSite", 0, "Name");
83                 addSetProperties("SiteGroup/OriginSite");
84                 addCallMethod("SiteGroup/OriginSite/Alias", "addAlias", 0);
85                 addCallMethod("SiteGroup/OriginSite", "setHandleService", 1);
86                 addCallParam("SiteGroup/OriginSite/HandleService", 0, "Location");
87
88                 // Digest sites without nesting and add them to the default group
89                 addObjectCreate("OriginSite", originSetClass);
90                 addSetNext("OriginSite", "addOriginSet", originSetClass);
91                 addObjectCreate("OriginSite", originClass);
92                 addSetNext("OriginSite", "addOrigin", originClass);
93                 addCallMethod("OriginSite", "setName", 1);
94                 addCallParam("OriginSite", 0, "Name");
95                 addSetProperties("OriginSite");
96                 addCallMethod("OriginSite/Alias", "addAlias", 0);
97                 addCallMethod("OriginSite", "setHandleService", 1);
98                 addCallParam("OriginSite/HandleService", 0, "Location");
99
100                 // Handle 1.3 Metadata
101         addObjectCreate("EntitiesDescriptor", originSetClass);
102                 addSetNext("EntitiesDescriptor", "addOriginSet", originSetClass);
103                 addCallMethod("EntitiesDescriptor", "setName", 1);
104                 addCallParam("EntitiesDescriptor", 0, "Name");
105
106                 addObjectCreate("EntitiesDescriptor/EntityDescriptor", originClass);
107                 addSetNext("EntitiesDescriptor/EntityDescriptor", "addOrigin", originClass);
108
109                 addCallMethod("EntitiesDescriptor/EntityDescriptor", "setName", 1);
110                 addCallParam("EntitiesDescriptor/EntityDescriptor", 0, "entityID");
111
112                 addCallMethod("EntitiesDescriptor/EntityDescriptor/Organization/OrganizationName", "addAlias", 0);
113                 addCallMethod("EntitiesDescriptor/EntityDescriptor/Organization/OrganizationDisplayName", "addAlias", 0);
114                 
115                 addCallMethod("EntitiesDescriptor/EntityDescriptor/IDPSSODescriptor/SingleSignOnService", "setHandleService", 1);
116                 addCallParam("EntitiesDescriptor/EntityDescriptor/IDPSSODescriptor/SingleSignOnService", 0, "Location");
117                                 
118                 
119                 
120                 configured = true;
121
122         }
123
124 }