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 configNameSpace = "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")) { throw new ShibbolethConfigurationException(
58 "Unexpected configuration data. <IdPConfig/> is needed."); }
60 log.debug("Loading global configuration properties.");
63 providerId = ((Element) config).getAttribute("providerId");
64 if (providerId == null || providerId.equals("")) {
65 log.error("Global providerId not set. Add a (providerId) attribute to <IdPConfig/>.");
66 throw new ShibbolethConfigurationException("Required configuration not specified.");
69 // Default Relying Party
70 defaultRelyingPartyName = ((Element) config).getAttribute("defaultRelyingParty");
71 if (defaultRelyingPartyName == null || defaultRelyingPartyName.equals("")) {
72 log.error("Default Relying Party not set. Add a (defaultRelyingParty) attribute to <IdPConfig/>.");
73 throw new ShibbolethConfigurationException("Required configuration not specified.");
76 // Attribute resolver config file location
77 String rawResolverConfig = ((Element) config).getAttribute("resolverConfig");
78 if (rawResolverConfig != null && !rawResolverConfig.equals("")) {
79 resolverConfig = rawResolverConfig;
82 // Global Pass thru error setting
83 String attribute = ((Element) config).getAttribute("passThruErrors");
84 if (attribute != null && !attribute.equals("")) {
85 passThruErrors = Boolean.valueOf(attribute).booleanValue();
88 attribute = ((Element) config).getAttribute("AAUrl");
89 if (attribute == null || attribute.equals("")) {
90 log.error("Global Attribute Authority URL not set. Add an (AAUrl) attribute to <IdPConfig/>.");
91 throw new ShibbolethConfigurationException("Required configuration not specified.");
94 AAUrl = new URL(attribute);
95 } catch (MalformedURLException e) {
96 log.error("(AAUrl) attribute to is not a valid URL.");
97 throw new ShibbolethConfigurationException("Required configuration is invalid.");
100 attribute = ((Element) config).getAttribute("defaultAuthMethod");
101 if (attribute == null || attribute.equals("")) {
103 defaultAuthMethod = new URI("urn:oasis:names:tc:SAML:1.0:am:unspecified");
104 } catch (URISyntaxException e1) {
106 throw new ShibbolethConfigurationException("Default Auth Method URI could not be constructed.");
110 defaultAuthMethod = new URI(attribute);
111 } catch (URISyntaxException e1) {
112 log.error("(defaultAuthMethod) attribute to is not a valid URI.");
113 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() {