Skip to content

Commit

Permalink
[pjlinkdevice] fix authentication (openhab#11472)
Browse files Browse the repository at this point in the history
Signed-off-by: Nils Schnabel <github@to.nilsschnabel.de>
  • Loading branch information
nils authored and jpg0 committed Nov 10, 2021
1 parent 8c196d9 commit eed83ec
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,11 @@ protected Socket connect(boolean forceReconnect) throws IOException, ResponseExc
socket.connect(socketAddress, timeout);
socket.setSoTimeout(timeout);
BufferedReader reader = getReader();
String header = reader.readLine();
if (header == null) {
String rawHeader = reader.readLine();
if (rawHeader == null) {
throw new ResponseException("No PJLink header received from the device");
}
header = header.toUpperCase();
String header = rawHeader.toUpperCase();
switch (header.substring(0, "PJLINK x".length())) {
case "PJLINK 0":
logger.debug("Authentication not needed");
Expand All @@ -170,7 +170,7 @@ protected Socket connect(boolean forceReconnect) throws IOException, ResponseExc
throw new AuthenticationException("No password provided, but device requires authentication");
} else {
try {
authenticate(header.substring("PJLINK 1 ".length()));
authenticate(rawHeader.substring("PJLINK 1 ".length()));
} catch (AuthenticationException e) {
// propagate AuthenticationException
throw e;
Expand Down

0 comments on commit eed83ec

Please sign in to comment.