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