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