Skip to content

Commit

Permalink
Add needClientAuth element to netty tcp/udp config
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith Babo committed Nov 18, 2013
1 parent 46dd448 commit b6fb34d
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package org.switchyard.component.camel.netty.model;

import org.switchyard.component.camel.common.model.CamelBindingModel;
import org.switchyard.component.camel.netty.model.v1.V1CamelNettyBindingModel;

/**
* Configuration binding for netty.
Expand Down Expand Up @@ -111,6 +112,20 @@ public interface CamelNettyBindingModel extends CamelBindingModel {
* @return a reference to this binding model
*/
CamelNettyBindingModel setSslHandler(String sslHandler);

/**
* Indicates whether client authentication will be performed for SSL connections.
* @return true if client auth will be performed, false otherwise
*/
public Boolean isNeedClientAuth();

/**
* Specifies whether client authentication should be performed as part of an
* SSL exchange.
* @param needClientAuth true to enable client authentication, false to disable
* @return a reference to this binding model
*/
public V1CamelNettyBindingModel setNeedClientAuth(Boolean needClientAuth);

/**
* Password bean used to access keystore.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public abstract class V1CamelNettyBindingModel extends V1BaseCamelBindingModel
private static final String SEND_BUFFER_SIZE = "sendBufferSize";
private static final String SSL = "ssl";
private static final String SSL_HANDLER = "sslHandler";
private static final String NEED_CLIENT_AUTH = "needClientAuth";
private static final String PASSPHRASE = "passphrase";
private static final String SECURITY_PROVIDER = "securityProvider";
private static final String KEY_STORE_FORMAT = "keyStoreFormat";
Expand Down Expand Up @@ -69,7 +70,7 @@ protected V1CamelNettyBindingModel(String namespace, String name) {
super(namespace, name);

setModelChildrenOrder(HOST, PORT, RECEIVE_BUFFER_SIZE, SEND_BUFFER_SIZE,
SSL, SSL_HANDLER, PASSPHRASE, SECURITY_PROVIDER, KEY_STORE_FORMAT,
SSL, SSL_HANDLER, NEED_CLIENT_AUTH, PASSPHRASE, SECURITY_PROVIDER, KEY_STORE_FORMAT,
KEY_STORE_FILE, TRUST_STORE_FILE, SSL_CONTEXT_PARAMETERS_REF, REUSE_ADDRESS,
ENCODERS, DECODERS, ALLOW_DEFAULT_CODEC, WORKER_COUNT, SYNC, DISCONNECT);
}
Expand Down Expand Up @@ -134,6 +135,16 @@ public V1CamelNettyBindingModel setSslHandler(String sslHandler) {
return setConfig(SSL_HANDLER, sslHandler);
}

@Override
public Boolean isNeedClientAuth() {
return getBooleanConfig(NEED_CLIENT_AUTH);
}

@Override
public V1CamelNettyBindingModel setNeedClientAuth(Boolean needClientAuth) {
return setConfig(NEED_CLIENT_AUTH, needClientAuth);
}

@Override
public String getPassphrase() {
return getConfig(PASSPHRASE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<element name="sendBufferSize" type="switchyard:propLong" minOccurs="0" maxOccurs="1"/>
<element name="ssl" type="boolean" minOccurs="0" maxOccurs="1" />
<element name="sslHandler" type="string" minOccurs="0" maxOccurs="1" />
<element name="needClientAuth" type="boolean" minOccurs="0" maxOccurs="1" />
<choice minOccurs="0" maxOccurs="1">
<sequence>
<element name="passphrase" type="string" minOccurs="0" maxOccurs="1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class V1CamelNettyTcpBindingModelTest extends V1BaseCamelServiceBindingMo
private static final Boolean ALLOW_DEFAULT_CODEC = false;
private static final Integer WORKER_COUNT = 10;
private static final Boolean SYNC = false;
private static final Boolean NEED_CLIENT_AUTH = true;
private static final Boolean DISCONNECT = true;
private static final Boolean TEXTLINE = false;
private static final Boolean TCP_NO_DELAY = true;
Expand All @@ -52,7 +53,7 @@ public class V1CamelNettyTcpBindingModelTest extends V1BaseCamelServiceBindingMo
"receiveBufferSize=1024&sendBufferSize=128&reuseAddress=true&allowDefaultCodec=false&" +
"workerCount=10&sync=false&disconnect=true&textline=false&tcpNoDelay=true&" +
"keepAlive=false&keyStoreFormat=PCKS12&passphrase=camelRider&keyStoreFile=#ks&trustStoreFile=#ts&" +
"ssl=true&sslHandler=#myCustomHandler&securityProvider=BC";
"ssl=true&sslHandler=#myCustomHandler&needClientAuth=true&securityProvider=BC";

public V1CamelNettyTcpBindingModelTest() {
super(NettyEndpoint.class, CAMEL_XML);
Expand All @@ -62,13 +63,14 @@ public V1CamelNettyTcpBindingModelTest() {

@Override
protected V1CamelNettyTcpBindingModel createTestModel() {
return ((V1CamelNettyTcpBindingModel) new V1CamelNettyTcpBindingModel(CamelNettyNamespace.V_1_0.uri())
return ((V1CamelNettyTcpBindingModel) new V1CamelNettyTcpBindingModel(CamelNettyNamespace.V_1_1.uri())
.setHost(HOST)
.setPort(PORT)
.setReceiveBufferSize(RECEIVE_BUFFER_SIZE)
.setSendBufferSize(SEND_BUFFER_SIZE)
.setSsl(SSL)
.setSslHandler(SSL_HANDLER)
.setNeedClientAuth(NEED_CLIENT_AUTH)
.setPassphrase(PASSPHRASE)
.setSecurityProvider(SECURITY_PROVIDER)
.setKeyStoreFormat(KEY_STORE_FORMAT)
Expand All @@ -93,6 +95,7 @@ protected void createModelAssertions(V1CamelNettyTcpBindingModel model) {
assertEquals(SEND_BUFFER_SIZE, model.getSendBufferSize());
assertEquals(SSL, model.isSsl());
assertEquals(SSL_HANDLER, model.getSslHandler());
assertEquals(NEED_CLIENT_AUTH, model.isNeedClientAuth());
assertEquals(SECURITY_PROVIDER, model.getSecurityProvider());
assertEquals(PASSPHRASE, model.getPassphrase());
assertEquals(KEY_STORE_FORMAT, model.getKeyStoreFormat());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
- See the License for the specific language governing permissions and
- limitations under the License.
-->
<switchyard xmlns="urn:switchyard-config:switchyard:1.0"
<switchyard xmlns="urn:switchyard-config:switchyard:1.1"
xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
xmlns:netty="urn:switchyard-component-camel-netty:config:1.0">
xmlns:netty="urn:switchyard-component-camel-netty:config:1.1">

<sca:composite name="camelTest" targetNamespace="urn:camel-core:test:1.0">
<sca:service name="camelTest" promote="SimpleCamelService">
Expand All @@ -25,6 +25,7 @@
<netty:sendBufferSize>128</netty:sendBufferSize>
<netty:ssl>true</netty:ssl>
<netty:sslHandler>#myCustomHandler</netty:sslHandler>
<netty:needClientAuth>true</netty:needClientAuth>
<netty:passphrase>camelRider</netty:passphrase>
<netty:securityProvider>BC</netty:securityProvider>
<netty:keyStoreFormat>PCKS12</netty:keyStoreFormat>
Expand Down

0 comments on commit b6fb34d

Please sign in to comment.