2 * Copyright [2007] [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.config.profile;
19 import java.util.List;
22 import javax.xml.namespace.QName;
24 import org.opensaml.xml.util.XMLHelper;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
27 import org.springframework.beans.factory.support.AbstractBeanDefinition;
28 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
29 import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
30 import org.springframework.beans.factory.xml.ParserContext;
31 import org.w3c.dom.Element;
33 import edu.internet2.middleware.shibboleth.common.config.SpringConfigurationUtils;
36 * Spring bean definition parser for profile handler root element.
38 public class ProfileHandlerGroupBeanDefinitionParser extends AbstractBeanDefinitionParser {
40 /** Schema type name. */
41 public static final QName SCHEMA_TYPE = new QName(ProfileHandlerNamespaceHandler.NAMESPACE, "ProfileHandlerGroup");
44 private static Logger log = LoggerFactory.getLogger(ProfileHandlerGroupBeanDefinitionParser.class);
47 protected AbstractBeanDefinition parseInternal(Element config, ParserContext context) {
48 BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(ProfileHandlerGroup.class);
50 Map<QName, List<Element>> configChildren = XMLHelper.getChildElements(config);
51 List<Element> children;
53 children = configChildren.get(new QName(ProfileHandlerNamespaceHandler.NAMESPACE, "ErrorHandler"));
54 log.debug("{} error handler definitions found", children.size());
55 builder.addPropertyValue("errorHandler", SpringConfigurationUtils.parseCustomElement(children.get(0), context));
57 children = configChildren.get(new QName(ProfileHandlerNamespaceHandler.NAMESPACE, "ProfileHandler"));
58 log.debug("{} profile handler definitions found", children.size());
59 builder.addPropertyValue("profileHandlers", SpringConfigurationUtils.parseCustomElements(children, context));
61 children = configChildren.get(new QName(ProfileHandlerNamespaceHandler.NAMESPACE, "LoginHandler"));
62 log.debug("{} login handler definitions found", children.size());
63 builder.addPropertyValue("loginHandlers", SpringConfigurationUtils.parseCustomElements(children,
66 return builder.getBeanDefinition();
70 protected boolean shouldGenerateId() {