コード例 #1
0
  @Override
  public boolean authenticate(RequestContext context, String header) {
    if (header == null || "".equals(header)) return false;

    try {
      Pair<String, String> credentials = decodeAuthentication(header);
      if (credentials == null) return false;

      Long userid = authenticateUser(context, credentials.getFirst(), credentials.getSecond());
      if (userid == null) return false;
      context.setAuthenticatedUser(userid);
      return true;
    } catch (Exception e) {
      log.error("Error during Basic authentication", e);
    }
    return false;
  }