code: boolean authorize(String resource) throws IOException {
      if (passwordProvider == null) {
        throw new IOException(
            "Authorization failed - no password provider present "
                + "(you must call setPasswordProvider)");
      }
  
      if (passwordProvider.canAuthenticate(resource)) {
        // 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();
  
        // Read dummy reply and discard (according to the spec, it is unused).
        inputStream.readWord();
        return true;
      }
  
      return false;
    }
docs: Authorize the resource for access.
  
  @throws IOException if an error occurs while communicating with the SANE daemon