Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require valid uid/pw from websocket clients #32

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/main/java/com/github/ibm/mapepire/SystemConnection.java
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading