[pjlinkdevice] fix authentication (#11472)
Signed-off-by: Nils Schnabel <github@to.nilsschnabel.de>
This commit is contained in:
parent
b73bf672ab
commit
4423b166cb
|
@ -152,11 +152,11 @@ public class PJLinkDevice {
|
||||||
socket.connect(socketAddress, timeout);
|
socket.connect(socketAddress, timeout);
|
||||||
socket.setSoTimeout(timeout);
|
socket.setSoTimeout(timeout);
|
||||||
BufferedReader reader = getReader();
|
BufferedReader reader = getReader();
|
||||||
String header = reader.readLine();
|
String rawHeader = reader.readLine();
|
||||||
if (header == null) {
|
if (rawHeader == null) {
|
||||||
throw new ResponseException("No PJLink header received from the device");
|
throw new ResponseException("No PJLink header received from the device");
|
||||||
}
|
}
|
||||||
header = header.toUpperCase();
|
String header = rawHeader.toUpperCase();
|
||||||
switch (header.substring(0, "PJLINK x".length())) {
|
switch (header.substring(0, "PJLINK x".length())) {
|
||||||
case "PJLINK 0":
|
case "PJLINK 0":
|
||||||
logger.debug("Authentication not needed");
|
logger.debug("Authentication not needed");
|
||||||
|
@ -170,7 +170,7 @@ public class PJLinkDevice {
|
||||||
throw new AuthenticationException("No password provided, but device requires authentication");
|
throw new AuthenticationException("No password provided, but device requires authentication");
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
authenticate(header.substring("PJLINK 1 ".length()));
|
authenticate(rawHeader.substring("PJLINK 1 ".length()));
|
||||||
} catch (AuthenticationException e) {
|
} catch (AuthenticationException e) {
|
||||||
// propagate AuthenticationException
|
// propagate AuthenticationException
|
||||||
throw e;
|
throw e;
|
||||||
|
|
Loading…
Reference in New Issue