2 * Copyright [2005] [University Corporation for Advanced Internet Development, Inc.]
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package edu.internet2.middleware.shibboleth.idp;
19 import java.net.MalformedURLException;
21 import java.net.URISyntaxException;
24 import org.apache.log4j.Logger;
25 import org.w3c.dom.Element;
27 import edu.internet2.middleware.shibboleth.common.ShibbolethConfigurationException;
30 * @author Walter Hoehn
32 public class IdPConfig {
34 private String defaultRelyingPartyName;
35 private String providerId;
36 public static final String configNameSpace = "urn:mace:shibboleth:idp:config:1.0";
37 private String resolverConfig = "/conf/resolver.xml";
38 private boolean passThruErrors = false;
39 private int maxThreads = 5;
40 private String authHeaderName = "REMOTE_USER";
41 private URI defaultAuthMethod;
44 private static Logger log = Logger.getLogger(IdPConfig.class.getName());
46 public IdPConfig(Element config) throws ShibbolethConfigurationException {
48 if (!config.getTagName().equals("IdPConfig")) { throw new ShibbolethConfigurationException(
49 "Unexpected configuration data. <IdPConfig/> is needed."); }
51 log.debug("Loading global configuration properties.");
54 providerId = ((Element) config).getAttribute("providerId");
55 if (providerId == null || providerId.equals("")) {
56 log.error("Global providerId not set. Add a (providerId) attribute to <IdPConfig/>.");
57 throw new ShibbolethConfigurationException("Required configuration not specified.");
60 // Default Relying Party
61 defaultRelyingPartyName = ((Element) config).getAttribute("defaultRelyingParty");
62 if (defaultRelyingPartyName == null || defaultRelyingPartyName.equals("")) {
63 log.error("Default Relying Party not set. Add a (defaultRelyingParty) attribute to <IdPConfig/>.");
64 throw new ShibbolethConfigurationException("Required configuration not specified.");
67 // Attribute resolver config file location
68 String rawResolverConfig = ((Element) config).getAttribute("resolverConfig");
69 if (rawResolverConfig != null && !rawResolverConfig.equals("")) {
70 resolverConfig = rawResolverConfig;
73 // Global Pass thru error setting
74 String attribute = ((Element) config).getAttribute("passThruErrors");
75 if (attribute != null && !attribute.equals("")) {
76 passThruErrors = Boolean.valueOf(attribute).booleanValue();
79 attribute = ((Element) config).getAttribute("AAUrl");
80 if (attribute == null || attribute.equals("")) {
81 log.error("Global Attribute Authority URL not set. Add an (AAUrl) attribute to <IdPConfig/>.");
82 throw new ShibbolethConfigurationException("Required configuration not specified.");
85 AAUrl = new URL(attribute);
86 } catch (MalformedURLException e) {
87 log.error("(AAUrl) attribute to is not a valid URL.");
88 throw new ShibbolethConfigurationException("Required configuration is invalid.");
91 attribute = ((Element) config).getAttribute("defaultAuthMethod");
92 if (attribute == null || attribute.equals("")) {
94 defaultAuthMethod = new URI("urn:oasis:names:tc:SAML:1.0:am:unspecified");
95 } catch (URISyntaxException e1) {
97 throw new ShibbolethConfigurationException("Default Auth Method URI could not be constructed.");
101 defaultAuthMethod = new URI(attribute);
102 } catch (URISyntaxException e1) {
103 log.error("(defaultAuthMethod) attribute to is not a valid URI.");
104 throw new ShibbolethConfigurationException("Required configuration is invalid.");
108 attribute = ((Element) config).getAttribute("maxSigningThreads");
109 if (attribute != null && !attribute.equals("")) {
111 maxThreads = Integer.parseInt(attribute);
112 } catch (NumberFormatException e) {
113 log.error("(maxSigningThreads) attribute to is not a valid integer.");
114 throw new ShibbolethConfigurationException("Configuration is invalid.");
118 attribute = ((Element) config).getAttribute("authHeaderName");
119 if (attribute != null && !attribute.equals("")) {
120 authHeaderName = attribute;
123 log.debug("Global IdP config: (AAUrl) = (" + getAAUrl() + ").");
124 log.debug("Global IdP config: (defaultAuthMethod) = (" + getDefaultAuthMethod() + ").");
125 log.debug("Global IdP config: (maxSigningThreads) = (" + getMaxThreads() + ").");
126 log.debug("Global IdP config: (authHeaderName) = (" + getAuthHeaderName() + ").");
128 log.debug("Global IdP config: (resolverConfig) = (" + getResolverConfigLocation() + ").");
129 log.debug("Global IdP config: (passThruErrors) = (" + passThruErrors() + ").");
130 log.debug("Global IdP config: Default Relying Party: (" + getDefaultRelyingPartyName() + ").");
133 public String getProviderId() {
138 public String getDefaultRelyingPartyName() {
140 return defaultRelyingPartyName;
143 public String getResolverConfigLocation() {
145 return resolverConfig;
148 public boolean passThruErrors() {
150 return passThruErrors;
153 public int getMaxThreads() {
158 public String getAuthHeaderName() {
160 return authHeaderName;
163 public URI getDefaultAuthMethod() {
165 return defaultAuthMethod;
168 public URL getAAUrl() {