diff --git a/src/main/java/com/github/ibm/mapepire/SystemConnection.java b/src/main/java/com/github/ibm/mapepire/SystemConnection.java index 491d43a..338d1a6 100644 --- a/src/main/java/com/github/ibm/mapepire/SystemConnection.java +++ b/src/main/java/com/github/ibm/mapepire/SystemConnection.java @@ -1,9 +1,11 @@ package com.github.ibm.mapepire; +import java.io.IOException; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; +import com.github.theprez.jcmdutils.StringUtils; import com.ibm.as400.access.AS400JDBCConnection; import com.ibm.as400.access.AS400JDBCDriver; @@ -96,9 +98,15 @@ public SystemConnection() { super(); } - public SystemConnection(String host, String user, String pass) { + public SystemConnection(String host, String user, String pass) throws IOException { super(); this.host = host; + if (StringUtils.isEmpty(user) || user.contains("*")) { + throw new IOException("Invalid Username"); + } + if (StringUtils.isEmpty(pass)) { + throw new IOException("Invalid Password"); + } this.userProfile = user; this.password = pass; } diff --git a/src/main/java/com/github/ibm/mapepire/ws/DbSocketCreator.java b/src/main/java/com/github/ibm/mapepire/ws/DbSocketCreator.java index 84a2570..3703a10 100644 --- a/src/main/java/com/github/ibm/mapepire/ws/DbSocketCreator.java +++ b/src/main/java/com/github/ibm/mapepire/ws/DbSocketCreator.java @@ -83,7 +83,7 @@ public Object createWebSocket(ServletUpgradeRequest jettyServerUpgradeRequest, S try { return new DbWebsocketClient(DbSocketCreator.getHost(), parts[0], parts[1]); - } catch (UnsupportedEncodingException e) { + } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); return null; diff --git a/src/main/java/com/github/ibm/mapepire/ws/DbWebsocketClient.java b/src/main/java/com/github/ibm/mapepire/ws/DbWebsocketClient.java index 3826c46..03d411d 100644 --- a/src/main/java/com/github/ibm/mapepire/ws/DbWebsocketClient.java +++ b/src/main/java/com/github/ibm/mapepire/ws/DbWebsocketClient.java @@ -6,21 +6,20 @@ import java.io.OutputStream; import java.io.PrintStream; import java.io.UnsupportedEncodingException; -import java.util.Locale; import java.util.concurrent.CountDownLatch; import org.eclipse.jetty.websocket.api.Session; -import org.eclipse.jetty.websocket.api.StatusCode; import org.eclipse.jetty.websocket.api.WebSocketAdapter; import com.github.ibm.mapepire.DataStreamProcessor; import com.github.ibm.mapepire.SystemConnection; +import com.github.theprez.jcmdutils.StringUtils; public class DbWebsocketClient extends WebSocketAdapter { private final CountDownLatch closureLatch = new CountDownLatch(1); private final DataStreamProcessor io; - DbWebsocketClient(String host, String user, String pass) throws UnsupportedEncodingException { + DbWebsocketClient(String host, String user, String pass) throws IOException { super(); SystemConnection conn = new SystemConnection(host, user, pass); io = getDataStream(this, conn);