Skip to content

Commit

Permalink
Check canAuthenticate before beginning to authenticate (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
sjamesr authored Jan 12, 2018
1 parent f0f7df3 commit c34b4f8
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/main/java/au/com/southsky/jfreesane/SaneSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,6 @@ void authorize(String resource) throws IOException {
"Authorization failed - no password provider present "
+ "(you must call setPasswordProvider)");
}
// RPC code FOR SANE_NET_AUTHORIZE
outputStream.write(SaneRpcCode.SANE_NET_AUTHORIZE);
outputStream.write(resource);
outputStream.flush();

if (!passwordProvider.canAuthenticate(resource)) {
// the password provider has indicated that there's no way it can provide
Expand All @@ -361,6 +357,9 @@ void authorize(String resource) throws IOException {
+ "]");
}

// RPC code FOR SANE_NET_AUTHORIZE
outputStream.write(SaneRpcCode.SANE_NET_AUTHORIZE);
outputStream.write(resource);
outputStream.write(passwordProvider.getUsername(resource));
writePassword(resource, passwordProvider.getPassword(resource));
outputStream.flush();
Expand Down

0 comments on commit c34b4f8

Please # to comment.