View Javadoc

1   /*
2    * Copyright [2007] [University Corporation for Advanced Internet Development, Inc.]
3    *
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
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
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.
15   */
16  
17  package edu.internet2.middleware.shibboleth.common.config.profile;
18  
19  import org.slf4j.Logger;
20  import org.slf4j.LoggerFactory;
21  import org.springframework.beans.factory.support.BeanDefinitionBuilder;
22  import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
23  import org.w3c.dom.Element;
24  
25  import edu.internet2.middleware.shibboleth.common.profile.provider.JSPErrorHandler;
26  
27  /**
28   * Spring bean definition parser for {@link JSPErrorHandler}s.
29   */
30  public class JSPErrorHandlerBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
31  
32      /** Element name. */
33      public static final String ELEMENT_NAME = "JSPErrorHandler";
34  
35      /** Class logger. */
36      private static Logger log = LoggerFactory.getLogger(JSPErrorHandlerBeanDefinitionParser.class);
37  
38      /** {@inheritDoc} */
39      protected Class getBeanClass(Element arg0) {
40          return JSPErrorHandler.class;
41      }
42  
43      /** {@inheritDoc} */
44      protected void doParse(Element config, BeanDefinitionBuilder builder) {
45          log.info("Parsing configuration for JSP error handler.");
46          super.doParse(config, builder);
47  
48          if(config.hasAttributeNS(null, "jspPagePath")){
49              builder.addConstructorArgValue(config.getAttributeNS(null, "jspPagePath"));
50          }else{
51              builder.addConstructorArgValue(config.getAttributeNS(null, "/error.jsp"));
52          }
53      }
54  
55      /** {@inheritDoc} */
56      protected boolean shouldGenerateId() {
57          return true;
58      }
59  }