-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
738 additions
and
358 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
186 changes: 186 additions & 0 deletions
186
...tp.netty/src/main/java/org/wso2/transport/http/netty/config/OutboundSslConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,186 @@ | ||
/* | ||
* Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. | ||
* | ||
* WSO2 Inc. licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.wso2.transport.http.netty.config; | ||
|
||
import org.wso2.transport.http.netty.common.Util; | ||
import org.wso2.transport.http.netty.common.ssl.SSLConfig; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import javax.xml.bind.annotation.XmlAttribute; | ||
import javax.xml.bind.annotation.XmlElement; | ||
import javax.xml.bind.annotation.XmlElementWrapper; | ||
|
||
/** | ||
* SSL configuration for Outbound HTTP connection. | ||
*/ | ||
public class OutboundSslConfiguration { | ||
|
||
@XmlAttribute | ||
private String scheme = "http"; | ||
|
||
@XmlAttribute | ||
private String keyStoreFile; | ||
|
||
@XmlAttribute | ||
private String keyStorePassword; | ||
|
||
@XmlAttribute | ||
private String trustStoreFile; | ||
|
||
@XmlAttribute | ||
private String trustStorePass; | ||
|
||
@XmlAttribute | ||
private String certPass; | ||
|
||
@XmlAttribute | ||
private String sslProtocol; | ||
|
||
@XmlElementWrapper(name = "parameters") | ||
@XmlElement(name = "parameter") | ||
private List<Parameter> parameters = new ArrayList<>(); | ||
|
||
private String tlsStoreType; | ||
private boolean hostNameVerificationEnabled = true; | ||
private boolean validateCertEnabled; | ||
private int cacheValidityPeriod = 15; | ||
private int cacheSize = 50; | ||
private boolean ocspStaplingEnabled = false; | ||
|
||
public String getCertPass() { | ||
return certPass; | ||
} | ||
|
||
public void setCertPass(String certPass) { | ||
this.certPass = certPass; | ||
} | ||
|
||
public String getKeyStoreFile() { | ||
return keyStoreFile; | ||
} | ||
|
||
public void setKeyStoreFile(String keyStoreFile) { | ||
this.keyStoreFile = keyStoreFile; | ||
} | ||
|
||
public String getKeyStorePassword() { | ||
return keyStorePassword; | ||
} | ||
|
||
public void setKeyStorePassword(String keyStorePassword) { | ||
this.keyStorePassword = keyStorePassword; | ||
} | ||
|
||
public String getScheme() { | ||
return scheme; | ||
} | ||
|
||
public void setScheme(String scheme) { | ||
this.scheme = scheme; | ||
} | ||
|
||
public String getTrustStoreFile() { | ||
return trustStoreFile; | ||
} | ||
|
||
public void setTrustStoreFile(String trustStoreFile) { | ||
this.trustStoreFile = trustStoreFile; | ||
} | ||
|
||
public String getTrustStorePass() { | ||
return trustStorePass; | ||
} | ||
|
||
public void setTrustStorePass(String trustStorePass) { | ||
this.trustStorePass = trustStorePass; | ||
} | ||
|
||
public void setSSLProtocol(String sslProtocol) { | ||
this.sslProtocol = sslProtocol; | ||
} | ||
|
||
public String getSSLProtocol() { | ||
return sslProtocol; | ||
} | ||
|
||
public List<Parameter> getParameters() { | ||
return parameters; | ||
} | ||
|
||
public void setParameters(List<Parameter> parameters) { | ||
this.parameters = parameters; | ||
} | ||
|
||
public String getTLSStoreType() { | ||
return tlsStoreType; | ||
} | ||
|
||
public void setTLSStoreType(String storeType) { | ||
this.tlsStoreType = storeType; | ||
} | ||
|
||
public void setValidateCertEnabled(boolean validateCertEnabled) { | ||
this.validateCertEnabled = validateCertEnabled; | ||
} | ||
|
||
public boolean validateCertEnabled() { | ||
return validateCertEnabled; | ||
} | ||
|
||
public void setHostNameVerificationEnabled(boolean hostNameVerificationEnabled) { | ||
this.hostNameVerificationEnabled = hostNameVerificationEnabled; | ||
} | ||
|
||
public boolean hostNameVerificationEnabled() { | ||
return hostNameVerificationEnabled; | ||
} | ||
|
||
public void setCacheValidityPeriod(int cacheValidityPeriod) { | ||
this.cacheValidityPeriod = cacheValidityPeriod; | ||
} | ||
|
||
public int getCacheValidityPeriod() { | ||
return cacheValidityPeriod; | ||
} | ||
|
||
public void setCacheSize(int cacheSize) { | ||
this.cacheSize = cacheSize; | ||
} | ||
|
||
public int getCacheSize() { | ||
return cacheSize; | ||
} | ||
|
||
public void setOcspStaplingEnabled(boolean ocspStaplingEnabled) { | ||
this.ocspStaplingEnabled = ocspStaplingEnabled; | ||
} | ||
|
||
public boolean isOcspStaplingEnabled() { | ||
return ocspStaplingEnabled; | ||
} | ||
|
||
public SSLConfig generateSSLConfig() { | ||
if (scheme == null || !scheme.equalsIgnoreCase("https")) { | ||
return null; | ||
} | ||
return Util.getSSLConfigForSender(certPass, keyStorePassword, keyStoreFile, trustStoreFile, trustStorePass, | ||
parameters, sslProtocol, tlsStoreType); | ||
} | ||
} |
Oops, something went wrong.