protected UserSession handleBasicAuthentication(String credentials, HttpServletRequest request) {
    // This example uses sun.misc.* classes.
    // You will need to provide your own
    // if you are not comfortable with that.
    String userPass = StringHelper.decodeBase64(credentials);

    // The decoded string is in the form
    // "userID:password".
    int p = userPass.indexOf(":");
    if (p != -1) {
      String userID = userPass.substring(0, p);
      String password = userPass.substring(p + 1);

      // Validate user ID and password
      // and set valid true if valid.
      // In this example, we simply check
      // that neither field is blank
      Identity identity = webDAVAuthManager.authenticate(null, userID, password);
      if (identity != null) {
        return afterAuthorization(identity, request);
      }
    }
    return null;
  }