X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fprotocol_plugins%2Fopenflow%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fprotocol_plugin%2Fopenflow%2Fcore%2Finternal%2FSecureMessageReadWriteService.java;h=f27d30eaae620312a75a7da2d47fa878936f5ccd;hp=d60bcab8b32fdf299d68505c348fe5b4fc5ec831;hb=2a4c88aa665a45c5394642cb3604603bebf8c0da;hpb=94d0d20b41d64bb6696c2a573ec367fcfddc44e9 diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/SecureMessageReadWriteService.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/SecureMessageReadWriteService.java index d60bcab8b3..f27d30eaae 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/SecureMessageReadWriteService.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/SecureMessageReadWriteService.java @@ -54,6 +54,12 @@ public class SecureMessageReadWriteService implements IMessageReadWrite { // switch private ByteBuffer peerNetData; // encrypted message from the switch private FileInputStream kfd = null, tfd = null; + private final String keyStoreFileDefault = "./configuration/tlsKeyStore"; + private final String trustStoreFileDefault = "./configuration/tlsTrustStore"; + private final String keyStorePasswordPropName = "controllerKeyStorePassword"; + private final String trustStorePasswordPropName = "controllerTrustStorePassword"; + private static String keyStorePassword = null; + private static String trustStorePassword = null; public SecureMessageReadWriteService(SocketChannel socket, Selector selector) throws Exception { @@ -80,32 +86,44 @@ public class SecureMessageReadWriteService implements IMessageReadWrite { */ private void createSecureChannel(SocketChannel socket) throws Exception { String keyStoreFile = System.getProperty("controllerKeyStore"); - String keyStorePassword = System - .getProperty("controllerKeyStorePassword"); String trustStoreFile = System.getProperty("controllerTrustStore"); - String trustStorePassword = System - .getProperty("controllerTrustStorePassword"); + String keyStorePasswordProp = System.getProperty(keyStorePasswordPropName); + String trustStorePasswordProp = System.getProperty(trustStorePasswordPropName); if (keyStoreFile != null) { keyStoreFile = keyStoreFile.trim(); + } else { + keyStoreFile = keyStoreFileDefault; } if ((keyStoreFile == null) || keyStoreFile.isEmpty()) { throw new FileNotFoundException("TLS KeyStore file not found."); } + + if ((keyStorePassword == null) || ((keyStorePasswordProp != null) && !keyStorePasswordProp.isEmpty())) { + keyStorePassword = keyStorePasswordProp; + } if (keyStorePassword != null) { keyStorePassword = keyStorePassword.trim(); + System.setProperty(keyStorePasswordPropName, ""); } if ((keyStorePassword == null) || keyStorePassword.isEmpty()) { throw new FileNotFoundException("TLS KeyStore Password not provided."); } if (trustStoreFile != null) { trustStoreFile = trustStoreFile.trim(); + } else { + trustStoreFile = trustStoreFileDefault; } if ((trustStoreFile == null) || trustStoreFile.isEmpty()) { throw new FileNotFoundException("TLS TrustStore file not found"); } + + if ((trustStorePassword == null) || ((trustStorePasswordProp != null) && !trustStorePasswordProp.isEmpty())) { + trustStorePassword = trustStorePasswordProp; + } if (trustStorePassword != null) { trustStorePassword = trustStorePassword.trim(); + System.setProperty(trustStorePasswordPropName, ""); } if ((trustStorePassword == null) || trustStorePassword.isEmpty()) { throw new FileNotFoundException("TLS TrustStore Password not provided."); @@ -407,9 +425,9 @@ public class SecureMessageReadWriteService implements IMessageReadWrite { this.myAppData = ByteBuffer .allocate(session.getApplicationBufferSize()); this.peerAppData = ByteBuffer.allocate(session - .getApplicationBufferSize() * 2); + .getApplicationBufferSize() * 20); this.myNetData = ByteBuffer.allocate(session.getPacketBufferSize()); - this.peerNetData = ByteBuffer.allocate(session.getPacketBufferSize() * 2); + this.peerNetData = ByteBuffer.allocate(session.getPacketBufferSize() * 20); } @Override