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 org.opensaml.saml2.metadata.provider.MetadataProvider;
20  import org.opensaml.xml.security.x509.PKIXX509CredentialTrustEngine;
21  import org.springframework.beans.factory.config.AbstractFactoryBean;
22  
23  import edu.internet2.middleware.shibboleth.common.security.MetadataPKIXValidationInformationResolver;
24  
25  /**
26   * Spring factory bean used to created {@link PKIXX509CredentialTrustEngine}s based on a metadata provider.
27   */
28  public class MetadataPKIXX509CredentialTrustEngineFactoryBean extends AbstractFactoryBean {
29  
30      /** Metadata provider used to look up key information for peer entities. */
31      private MetadataProvider metadataProvider;
32  
33      /**
34       * Gets the metadata provider used to look up key information for peer entities.
35       * 
36       * @return metadata provider used to look up key information for peer entities
37       */
38      public MetadataProvider getMetadataProvider() {
39          return metadataProvider;
40      }
41  
42      /**
43       * Sets the metadata provider used to look up key information for peer entities.
44       * 
45       * @param provider metadata provider used to look up key information for peer entities
46       */
47      public void setMetadataProvider(MetadataProvider provider) {
48          metadataProvider = provider;
49      }
50  
51      /** {@inheritDoc} */
52      public Class getObjectType() {
53          return PKIXX509CredentialTrustEngine.class;
54      }
55  
56      /** {@inheritDoc} */
57      protected Object createInstance() throws Exception {
58          MetadataPKIXValidationInformationResolver pviResolver = new MetadataPKIXValidationInformationResolver(
59                  getMetadataProvider());
60          return new PKIXX509CredentialTrustEngine(pviResolver);
61      }
62  }