001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.camel.spring.xml;
018
019import javax.xml.bind.annotation.XmlRootElement;
020import javax.xml.bind.annotation.XmlTransient;
021import javax.xml.bind.annotation.XmlType;
022
023import org.apache.camel.CamelContext;
024import org.apache.camel.core.xml.util.jsse.AbstractSSLContextParametersFactoryBean;
025import org.apache.camel.spi.Metadata;
026import org.apache.camel.spring.util.CamelContextResolverHelper;
027import org.apache.camel.support.jsse.SSLContextParameters;
028import org.springframework.beans.factory.FactoryBean;
029import org.springframework.context.ApplicationContext;
030import org.springframework.context.ApplicationContextAware;
031
032/**
033 * Secure socket protocol configuration
034 */
035@Metadata(label = "security,configuration")
036@XmlRootElement(name = "sslContextParameters")
037@XmlType(propOrder = {})
038public class SSLContextParametersFactoryBean extends AbstractSSLContextParametersFactoryBean
039        implements FactoryBean<SSLContextParameters>, ApplicationContextAware {
040
041    private KeyManagersParametersFactoryBean keyManagers;
042
043    private TrustManagersParametersFactoryBean trustManagers;
044
045    private SecureRandomParametersFactoryBean secureRandom;
046
047    private SSLContextClientParametersFactoryBean clientParameters;
048
049    private SSLContextServerParametersFactoryBean serverParameters;
050
051    @XmlTransient
052    private ApplicationContext applicationContext;
053
054    @Override
055    public KeyManagersParametersFactoryBean getKeyManagers() {
056        return keyManagers;
057    }
058
059    public void setKeyManagers(KeyManagersParametersFactoryBean keyManagers) {
060        this.keyManagers = keyManagers;
061    }
062
063    @Override
064    public TrustManagersParametersFactoryBean getTrustManagers() {
065        return trustManagers;
066    }
067
068    public void setTrustManagers(TrustManagersParametersFactoryBean trustManagers) {
069        this.trustManagers = trustManagers;
070    }
071
072    @Override
073    public SecureRandomParametersFactoryBean getSecureRandom() {
074        return secureRandom;
075    }
076
077    public void setSecureRandom(SecureRandomParametersFactoryBean secureRandom) {
078        this.secureRandom = secureRandom;
079    }
080
081    @Override
082    public SSLContextClientParametersFactoryBean getClientParameters() {
083        return clientParameters;
084    }
085
086    public void setClientParameters(SSLContextClientParametersFactoryBean clientParameters) {
087        this.clientParameters = clientParameters;
088    }
089
090    @Override
091    public SSLContextServerParametersFactoryBean getServerParameters() {
092        return serverParameters;
093    }
094
095    public void setServerParameters(SSLContextServerParametersFactoryBean serverParameters) {
096        this.serverParameters = serverParameters;
097    }
098
099    @Override
100    protected CamelContext getCamelContextWithId(String camelContextId) {
101        return CamelContextResolverHelper.getCamelContextWithId(applicationContext, camelContextId);
102    }
103
104    @Override
105    public void setApplicationContext(ApplicationContext applicationContext) {
106        this.applicationContext = applicationContext;
107    }
108}