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.apache.log4j.Logger;
25 import org.opensaml.xml.util.XMLHelper;
26 import org.springframework.beans.factory.support.AbstractBeanDefinition;
27 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
28 import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
29 import org.springframework.beans.factory.xml.ParserContext;
30 import org.w3c.dom.Element;
32 import edu.internet2.middleware.shibboleth.common.config.SpringConfigurationUtils;
35 * Spring bean definition parser for profile handler root element.
37 public class ProfileHandlerGroupBeanDefinitionParser extends AbstractBeanDefinitionParser {
40 private static Logger log = Logger.getLogger(ProfileHandlerGroupBeanDefinitionParser.class);
42 /** Schema type name. */
43 public static final QName SCHEMA_TYPE = new QName(ProfileHandlerNamespaceHandler.NAMESPACE, "ProfileHandlerGroup");
46 protected AbstractBeanDefinition parseInternal(Element config, ParserContext context) {
47 BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(ProfileHandlerGroup.class);
49 Map<QName, List<Element>> configChildren = XMLHelper.getChildElements(config);
50 List<Element> children;
52 children = configChildren.get(new QName(ProfileHandlerNamespaceHandler.NAMESPACE, "ErrorHandler"));
53 if(log.isDebugEnabled()){
54 log.debug(children.size() + " error handler definitions found");
56 builder.addPropertyValue("errorHandler", SpringConfigurationUtils.parseCustomElement(children.get(0), context));
58 children = configChildren.get(new QName(ProfileHandlerNamespaceHandler.NAMESPACE, "ProfileHandler"));
59 if(log.isDebugEnabled()){
60 log.debug(children.size() + " profile handler definitions found");
62 builder.addPropertyValue("profileHandlers", SpringConfigurationUtils.parseCustomElements(children, context));
64 children = configChildren.get(new QName(ProfileHandlerNamespaceHandler.NAMESPACE, "AuthenticationHandler"));
65 if(log.isDebugEnabled()){
66 log.debug(children.size() + " authentication handler definitions found");
68 builder.addPropertyValue("authenticationHandlers", SpringConfigurationUtils.parseCustomElements(children,
71 return builder.getBeanDefinition();
75 protected boolean shouldGenerateId() {