2 * The Shibboleth License, Version 1. Copyright (c) 2002 University Corporation for Advanced Internet Development, Inc.
3 * All rights reserved Redistribution and use in source and binary forms, with or without modification, are permitted
4 * provided that the following conditions are met: Redistributions of source code must retain the above copyright
5 * notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above
6 * copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials
7 * provided with the distribution, if any, must include the following acknowledgment: "This product includes software
8 * developed by the University Corporation for Advanced Internet Development <http://www.ucaid.edu> Internet2 Project.
9 * Alternately, this acknowledegement may appear in the software itself, if and wherever such third-party
10 * acknowledgments normally appear. Neither the name of Shibboleth nor the names of its contributors, nor Internet2, nor
11 * the University Corporation for Advanced Internet Development, Inc., nor UCAID may be used to endorse or promote
12 * products derived from this software without specific prior written permission. For written permission, please contact
13 * shibboleth@shibboleth.org Products derived from this software may not be called Shibboleth, Internet2, UCAID, or the
14 * University Corporation for Advanced Internet Development, nor may Shibboleth appear in their name, without prior
15 * written permission of the University Corporation for Advanced Internet Development. THIS SOFTWARE IS PROVIDED BY THE
16 * COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND WITH ALL FAULTS. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT ARE
18 * DISCLAIMED AND THE ENTIRE RISK OF SATISFACTORY QUALITY, PERFORMANCE, ACCURACY, AND EFFORT IS WITH LICENSEE. IN NO
19 * EVENT SHALL THE COPYRIGHT OWNER, CONTRIBUTORS OR THE UNIVERSITY CORPORATION FOR ADVANCED INTERNET DEVELOPMENT, INC.
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
23 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 package edu.internet2.middleware.shibboleth.idp;
28 import java.net.MalformedURLException;
30 import java.net.URISyntaxException;
33 import org.apache.log4j.Logger;
34 import org.w3c.dom.Element;
36 import edu.internet2.middleware.shibboleth.common.ShibbolethConfigurationException;
39 * @author Walter Hoehn
41 public class IdPConfig {
43 private String defaultRelyingPartyName;
44 private String providerId;
45 public static final String originConfigNamespace = "urn:mace:shibboleth:idp:config:1.0";
46 private String resolverConfig = "/conf/resolver.xml";
47 private boolean passThruErrors = false;
48 private int maxThreads = 5;
49 private String authHeaderName = "REMOTE_USER";
50 private URI defaultAuthMethod;
53 private static Logger log = Logger.getLogger(IdPConfig.class.getName());
55 public IdPConfig(Element config) throws ShibbolethConfigurationException {
57 if (!config.getTagName().equals("IdPConfig") && !config.getTagName().equals("ShibbolethOriginConfig")) {
58 throw new ShibbolethConfigurationException(
59 "Unexpected configuration data. <IdPConfig/> is needed."); }
61 log.debug("Loading global configuration properties.");
64 providerId = ((Element) config).getAttribute("providerId");
65 if (providerId == null || providerId.equals("")) {
66 log.error("Global providerId not set. Add a (providerId) attribute to <IdPConfig/>.");
67 throw new ShibbolethConfigurationException("Required configuration not specified.");
70 // Default Relying Party
71 defaultRelyingPartyName = ((Element) config).getAttribute("defaultRelyingParty");
72 if (defaultRelyingPartyName == null || defaultRelyingPartyName.equals("")) {
73 log.error("Default Relying Party not set. Add a (defaultRelyingParty) attribute to <IdPConfig/>.");
74 throw new ShibbolethConfigurationException("Required configuration not specified.");
77 // Attribute resolver config file location
78 String rawResolverConfig = ((Element) config).getAttribute("resolverConfig");
79 if (rawResolverConfig != null && !rawResolverConfig.equals("")) {
80 resolverConfig = rawResolverConfig;
83 // Global Pass thru error setting
84 String attribute = ((Element) config).getAttribute("passThruErrors");
85 if (attribute != null && !attribute.equals("")) {
86 passThruErrors = Boolean.valueOf(attribute).booleanValue();
89 attribute = ((Element) config).getAttribute("AAUrl");
90 if (attribute == null || attribute.equals("")) {
91 log.error("Global Attribute Authority URL not set. Add an (AAUrl) attribute to <IdPConfig/>.");
92 throw new ShibbolethConfigurationException("Required configuration not specified.");
95 AAUrl = new URL(attribute);
96 } catch (MalformedURLException e) {
97 log.error("(AAUrl) attribute to is not a valid URL.");
98 throw new ShibbolethConfigurationException("Required configuration is invalid.");
101 attribute = ((Element) config).getAttribute("defaultAuthMethod");
102 if (attribute == null || attribute.equals("")) {
104 defaultAuthMethod = new URI("urn:oasis:names:tc:SAML:1.0:am:unspecified");
105 } catch (URISyntaxException e1) {
107 throw new ShibbolethConfigurationException("Default Auth Method URI could not be constructed.");
111 defaultAuthMethod = new URI(attribute);
112 } catch (URISyntaxException e1) {
113 log.error("(defaultAuthMethod) attribute to is not a valid URI.");
114 throw new ShibbolethConfigurationException("Required configuration is invalid.");
117 attribute = ((Element) config).getAttribute("maxHSThreads");
118 if (attribute != null && !attribute.equals("")) {
120 maxThreads = Integer.parseInt(attribute);
121 } catch (NumberFormatException e) {
122 log.error("(maxHSThreads) attribute to is not a valid integer.");
123 throw new ShibbolethConfigurationException("Configuration is invalid.");
127 attribute = ((Element) config).getAttribute("authHeaderName");
128 if (attribute != null && !attribute.equals("")) {
129 authHeaderName = attribute;
132 log.debug("Global IdP config: (AAUrl) = (" + getAAUrl() + ").");
133 log.debug("Global IdP config: (defaultAuthMethod) = (" + getDefaultAuthMethod() + ").");
134 log.debug("Global IdP config: (maxHSThreads) = (" + getMaxThreads() + ").");
135 log.debug("Global IdP config: (authHeaderName) = (" + getAuthHeaderName() + ").");
137 log.debug("Global IdP config: (resolverConfig) = (" + getResolverConfigLocation() + ").");
138 log.debug("Global IdP config: (passThruErrors) = (" + passThruErrors() + ").");
139 log.debug("Global IdP config: Default Relying Party: (" + getDefaultRelyingPartyName() + ").");
142 public String getProviderId() {
147 public String getDefaultRelyingPartyName() {
149 return defaultRelyingPartyName;
152 public String getResolverConfigLocation() {
154 return resolverConfig;
157 public boolean passThruErrors() {
159 return passThruErrors;
162 public int getMaxThreads() {
167 public String getAuthHeaderName() {
169 return authHeaderName;
172 public URI getDefaultAuthMethod() {
174 return defaultAuthMethod;
177 public URL getAAUrl() {