View Javadoc

1   /*
2    * Licensed to the University Corporation for Advanced Internet Development, 
3    * Inc. (UCAID) under one or more contributor license agreements.  See the 
4    * NOTICE file distributed with this work for additional information regarding
5    * copyright ownership. The UCAID licenses this file to You under the Apache 
6    * License, Version 2.0 (the "License"); you may not use this file except in 
7    * compliance with the License.  You may obtain a copy of the License at
8    *
9    *    http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package edu.internet2.middleware.shibboleth.common.config.security;
19  
20  import javax.xml.namespace.QName;
21  
22  import org.opensaml.xml.security.x509.PKIXValidationOptions;
23  import org.opensaml.xml.util.DatatypeHelper;
24  import org.opensaml.xml.util.XMLHelper;
25  import org.springframework.beans.factory.support.BeanDefinitionBuilder;
26  import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
27  import org.w3c.dom.Attr;
28  import org.w3c.dom.Element;
29  
30  /** Spring bean definition parser for {urn:mace:shibboleth:2.0:security}PKIXValidationOptions elements. */
31  public class PKIXValidationOptionsBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
32      
33      /** Element name. */
34      public static final QName ELEMENT_NAME = new QName(SecurityNamespaceHandler.NAMESPACE, "ValidationOptions");
35      
36      /** Schema type. */
37      public static final QName SCHEMA_TYPE = new QName(SecurityNamespaceHandler.NAMESPACE, "ValidationOptionsType");
38      
39      /** {@inheritDoc} */
40      protected Class getBeanClass(Element element) {
41          return PKIXValidationOptions.class;
42      }
43      
44      /** {@inheritDoc} */
45      protected boolean shouldGenerateId() {
46          return true;
47      }
48      
49      /** {@inheritDoc} */
50      protected void doParse(Element element, BeanDefinitionBuilder builder) {
51          if (element.hasAttributeNS(null, "processEmptyCRLs")) {
52              Attr attr = element.getAttributeNodeNS(null, "processEmptyCRLs");
53              builder.addPropertyValue("processEmptyCRLs", XMLHelper.getAttributeValueAsBoolean(attr));
54          }
55          
56          if (element.hasAttributeNS(null, "processExpiredCRLs")) {
57              Attr attr = element.getAttributeNodeNS(null, "processExpiredCRLs");
58              builder.addPropertyValue("processExpiredCRLs", XMLHelper.getAttributeValueAsBoolean(attr));
59          }
60          
61          if (element.hasAttributeNS(null, "processCredentialCRLs")) {
62              Attr attr = element.getAttributeNodeNS(null, "processCredentialCRLs");
63              builder.addPropertyValue("processCredentialCRLs", XMLHelper.getAttributeValueAsBoolean(attr));
64          }
65          
66          if (element.hasAttributeNS(null, "defaultVerificationDepth")) {
67              Integer depth = new Integer(DatatypeHelper.safeTrim(element.getAttributeNS(null, "defaultVerificationDepth")));
68              builder.addPropertyValue("defaultVerificationDepth", depth);
69          }
70          
71      }
72  
73  }