mirror of
https://github.com/magefree/mage.git
synced 2025-12-29 23:12:10 -08:00
Merge pull request #1442 from menocar/password
Add a password user authentication when connecting to servers.
This commit is contained in:
commit
aadc253afa
12 changed files with 258 additions and 24 deletions
|
|
@ -56,7 +56,7 @@ import mage.view.UserView;
|
|||
public interface MageServer {
|
||||
|
||||
// connection methods
|
||||
boolean registerClient(String userName, String sessionId, MageVersion version) throws MageException;
|
||||
boolean registerClient(String userName, String password, String sessionId, MageVersion version) throws MageException;
|
||||
|
||||
boolean registerAdmin(String password, String sessionId, MageVersion version) throws MageException;
|
||||
// Not used
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ public class Connection {
|
|||
private int port;
|
||||
private String username;
|
||||
private String password;
|
||||
private String adminPassword;
|
||||
private ProxyType proxyType;
|
||||
private String proxyHost;
|
||||
private int proxyPort;
|
||||
|
|
@ -172,6 +173,14 @@ public class Connection {
|
|||
this.password = password;
|
||||
}
|
||||
|
||||
public String getAdminPassword() {
|
||||
return adminPassword;
|
||||
}
|
||||
|
||||
public void setAdminPassword(String adminPassword) {
|
||||
this.adminPassword = adminPassword;
|
||||
}
|
||||
|
||||
public String getProxyHost() {
|
||||
return proxyHost;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -278,14 +278,14 @@ public class SessionImpl implements Session {
|
|||
|
||||
this.sessionId = callbackClient.getSessionId();
|
||||
boolean registerResult;
|
||||
if (connection.getPassword() == null) {
|
||||
if (connection.getAdminPassword() == null) {
|
||||
// for backward compatibility. don't remove twice call - first one does nothing but for version checking
|
||||
registerResult = server.registerClient(connection.getUsername(), sessionId, client.getVersion());
|
||||
registerResult = server.registerClient(connection.getUsername(), connection.getPassword(), sessionId, client.getVersion());
|
||||
if (registerResult) {
|
||||
server.setUserData(connection.getUsername(), sessionId, connection.getUserData());
|
||||
}
|
||||
} else {
|
||||
registerResult = server.registerAdmin(connection.getPassword(), sessionId, client.getVersion());
|
||||
registerResult = server.registerAdmin(connection.getAdminPassword(), sessionId, client.getVersion());
|
||||
}
|
||||
if (registerResult) {
|
||||
sessionState = SessionState.CONNECTED;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue