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 java.security.cert.X509CRL;
21  import java.security.cert.X509Certificate;
22  import java.util.ArrayList;
23  import java.util.List;
24  
25  import org.opensaml.xml.security.x509.BasicPKIXValidationInformation;
26  import org.opensaml.xml.security.x509.PKIXValidationInformation;
27  import org.springframework.beans.factory.config.AbstractFactoryBean;
28  
29  /**
30   * Factory bean for building instances of {@link PKIXValidationInformation}.
31   */
32  public class PKIXValidationInformationFactoryBean extends AbstractFactoryBean {
33  
34      /** Certificates respresented by this info set. */
35      private List<X509Certificate> certificates;
36  
37      /** CRL respresented by this info set. */
38      private List<X509CRL> x509crls;
39      
40      /** Max verify depth represented by this info set. */
41      private Integer verifyDepth;
42      
43  
44      /** {@inheritDoc} */
45      protected Object createInstance() throws Exception {
46          List<X509Certificate> certs = new ArrayList<X509Certificate>();
47          if (getCertificates() != null) {
48              certs.addAll(getCertificates());
49          }
50          List<X509CRL> crls = new ArrayList<X509CRL>();
51          if (getCrls() != null) {
52              crls.addAll(getCrls());
53          }
54          
55          return new BasicPKIXValidationInformation(certs, crls, getVerifyDepth());
56      }
57      
58      /** {@inheritDoc} */
59      public Class getObjectType() {
60          return PKIXValidationInformation.class;
61      }
62  
63      /**
64       * Gets the cerificates respresented by this info set.
65       * 
66       * @return cerificates respresented by this info set
67       */
68      public List<X509Certificate> getCertificates() {
69          return certificates;
70      }
71      
72      /**
73       * Gets the CRLs respresented by this info set.
74       * 
75       * @return CRLs respresented by this info set
76       */
77      public List<X509CRL> getCrls() {
78          return x509crls;
79      }
80      
81      /**
82       * Get the max verify depth represented by this info set.
83       * 
84       * @return the max verify depth
85       */
86      public Integer getVerifyDepth() {
87          return verifyDepth;
88      }
89  
90      /**
91       * Sets the cerificates respresented by this info set.
92       * 
93       * @param certs cerificates respresented by this info set
94       */
95      public void setCertificates(List<X509Certificate> certs) {
96          certificates = certs;
97      }
98  
99      /**
100      * Sets the CRLs respresented by this info set.
101      * 
102      * @param crls CRLs respresented by this info set
103      */
104     public void setCrls(List<X509CRL> crls) {
105         this.x509crls = crls;
106     }
107 
108     /**
109      * Set the max verify depth represented by this info set.
110      * 
111      * @param newDepth the new max verify depth
112      */
113     public void setVerifyDepth(Integer newDepth) {
114         verifyDepth = newDepth;
115     }
116  
117 }