X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-ssh%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fssh%2Fthreads%2FSocketThread.java;h=15d99a44ee4db4a7b31bd0ee2fd6abd25476079c;hp=95fdd48bfe31d6e83b1082eefedbfe7da06842a5;hb=f36b75d14923ba9cba3b0af9677d48b6682032e6;hpb=c73c1861af3d5eaab53843a82f021ccedac4a0f0 diff --git a/opendaylight/netconf/netconf-ssh/src/main/java/org/opendaylight/controller/netconf/ssh/threads/SocketThread.java b/opendaylight/netconf/netconf-ssh/src/main/java/org/opendaylight/controller/netconf/ssh/threads/SocketThread.java index 95fdd48bfe..15d99a44ee 100644 --- a/opendaylight/netconf/netconf-ssh/src/main/java/org/opendaylight/controller/netconf/ssh/threads/SocketThread.java +++ b/opendaylight/netconf/netconf-ssh/src/main/java/org/opendaylight/controller/netconf/ssh/threads/SocketThread.java @@ -28,6 +28,8 @@ public class SocketThread implements Runnable, ServerAuthenticationCallback, Ser private static final Logger logger = LoggerFactory.getLogger(SocketThread.class); private ServerConnection conn = null; private long sessionId; + private String currentUser; + private final String remoteAddressWithPort; public static void start(Socket socket, InetSocketAddress clientAddress, long sessionId) throws IOException{ @@ -40,6 +42,7 @@ public class SocketThread implements Runnable, ServerAuthenticationCallback, Ser this.socket = socket; this.clientAddress = clientAddress; this.sessionId = sessionId; + this.remoteAddressWithPort = socket.getRemoteSocketAddress().toString().replaceFirst("/",""); } @@ -81,7 +84,8 @@ public class SocketThread implements Runnable, ServerAuthenticationCallback, Ser netconf_ssh_input.start(); logger.trace("starting netconf_ssh_output thread"); - netconf_ssh_output = new IOThread(ss.getStdout(),echoSocket.getOutputStream(),"output_thread_"+sessionId,ss,conn); + final String customHeader = "["+currentUser+";"+remoteAddressWithPort+";ssh;;;;;;]\n"; + netconf_ssh_output = new IOThread(ss.getStdout(),echoSocket.getOutputStream(),"output_thread_"+sessionId,ss,conn,customHeader); netconf_ssh_output.setDaemon(false); netconf_ssh_output.start(); @@ -146,7 +150,8 @@ public class SocketThread implements Runnable, ServerAuthenticationCallback, Ser public String initAuthentication(ServerConnection sc) { - return ""; + logger.trace("Established connection with host {}",remoteAddressWithPort); + return "Established connection with host "+remoteAddressWithPort+"\r\n"; } public String[] getRemainingAuthMethods(ServerConnection sc) @@ -161,8 +166,12 @@ public class SocketThread implements Runnable, ServerAuthenticationCallback, Ser public AuthenticationResult authenticateWithPassword(ServerConnection sc, String username, String password) { - if (USER.equals(username) && PASSWORD.equals(password)) + if (USER.equals(username) && PASSWORD.equals(password)){ + currentUser = username; + logger.trace("user {}@{} authenticated",currentUser,remoteAddressWithPort); return AuthenticationResult.SUCCESS; + } + return AuthenticationResult.FAILURE; }