Merge pull request #60 from GideonLeGrange/login-change
Updated login code to support RouterOS 6.43+
This commit is contained in:
commit
8cba90814f
|
|
@ -22,3 +22,6 @@ nbactions.xml
|
|||
|
||||
# Maven
|
||||
pom.xml.versionsBackup
|
||||
|
||||
# MacOS
|
||||
.DS_Store
|
||||
|
|
|
|||
|
|
@ -55,13 +55,17 @@ public final class ApiConnectionImpl extends ApiConnection {
|
|||
if (username.trim().isEmpty()) {
|
||||
throw new ApiConnectionException("API username cannot be empty");
|
||||
}
|
||||
List<Map<String, String>> list = execute("/login");
|
||||
List<Map<String, String>> list = execute("/login name=" + username + " password=" + password);
|
||||
if (!list.isEmpty()) {
|
||||
Map<String, String> res = list.get(0);
|
||||
if (res.containsKey("ret")) {
|
||||
String hash = res.get("ret");
|
||||
String chal = Util.hexStrToStr("00") + new String(password.toCharArray()) + Util.hexStrToStr(hash);
|
||||
chal = Util.hashMD5(chal);
|
||||
execute("/login name=" + username + " response=00" + chal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, String>> execute(String cmd) throws MikrotikApiException {
|
||||
|
|
|
|||
Loading…
Reference in New Issue