Create parser pool interface and move current pool to an implementation of this inter...
[java-idp.git] / src / edu / internet2 / middleware / shibboleth / idp / IdPConfig.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.idp;
18
19 import org.apache.log4j.Logger;
20 import org.w3c.dom.Element;
21
22 import edu.internet2.middleware.shibboleth.common.ShibbolethConfigurationException;
23
24 /**
25  * @author Walter Hoehn
26  */
27 public class IdPConfig {
28
29         // TODO re-evaluate whether or not we need this class... most of it has gone away anyway
30
31         public static final String configNameSpace = "urn:mace:shibboleth:idp:config:1.0";
32         private String resolverConfig = "/conf/resolver.xml";
33
34         private int maxThreads = 30;
35
36         private static Logger log = Logger.getLogger(IdPConfig.class.getName());
37
38         public IdPConfig(Element config) throws ShibbolethConfigurationException {
39
40                 if (!config.getTagName().equals("IdPConfig")) { throw new ShibbolethConfigurationException(
41                                 "Unexpected configuration data.  <IdPConfig/> is needed."); }
42
43                 log.debug("Loading global configuration properties.");
44
45                 // Attribute resolver config file location
46                 String rawResolverConfig = ((Element) config).getAttribute("resolverConfig");
47                 if (rawResolverConfig != null && !rawResolverConfig.equals("")) {
48                         resolverConfig = rawResolverConfig;
49                 }
50
51                 String attribute = ((Element) config).getAttribute("maxSigningThreads");
52                 if (attribute != null && !attribute.equals("")) {
53                         try {
54                                 maxThreads = Integer.parseInt(attribute);
55                         } catch (NumberFormatException e) {
56                                 log.error("(maxSigningThreads) attribute to is not a valid integer.");
57                                 throw new ShibbolethConfigurationException("Configuration is invalid.");
58                         }
59                 }
60
61                 attribute = ((Element) config).getAttribute("authHeaderName");
62
63                 log.debug("Global IdP config: (maxSigningThreads) = (" + getMaxThreads() + ").");
64
65                 log.debug("Global IdP config: (resolverConfig) = (" + getResolverConfigLocation() + ").");
66
67         }
68
69         public String getResolverConfigLocation() {
70
71                 return resolverConfig;
72         }
73
74         public int getMaxThreads() {
75
76                 return maxThreads;
77         }
78
79 }