Class MeHandler

java.lang.Object
org.codelibs.fess.api.v2.handlers.MeHandler

public class MeHandler extends Object
Handles GET /api/v2/auth/me.

Returns the current authentication state. When the session has a bound FessUserBean the response includes the user's id, roles, groups, permissions, and editable flag; otherwise just authenticated:false so anonymous callers receive a stable, well-formed envelope rather than a 401 (the v2 contract treats "anonymous" as a valid state, not an error).

MJ-28: The user shape is produced by UserPayloads.toJson(FessUserBean) to guarantee wire-identity with LoginHandler. All array fields are always JSON arrays, never null.

MJ-30 i18n contract: error.message values in this handler are developer-facing English strings. Clients MUST use error.code (the V2ErrorCode token) for user-facing i18n.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected org.dbflute.optional.OptionalThing<org.codelibs.fess.mylasta.action.FessUserBean>
    Resolves the saved login user bean.
    void
    handle(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res)
    Processes one /api/v2/auth/me GET request.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MeHandler

      public MeHandler()
      Default constructor. The handler is stateless and intended to be instantiated once by the API manager and shared across concurrent requests.
  • Method Details

    • handle

      public void handle(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res) throws IOException
      Processes one /api/v2/auth/me GET request.

      Rejects non-GET methods with V2ErrorCode.METHOD_NOT_ALLOWED. Resolves the bound FessUserBean from the login subsystem (treating any lookup failure as anonymous), then writes a success envelope describing the current authentication state — including the user payload via UserPayloads.toJson(FessUserBean) when authenticated, or just authenticated:false otherwise.

      Parameters:
      req - the incoming HTTP request
      res - the HTTP response to write to
      Throws:
      IOException - if writing the envelope fails
    • getSavedUserBean

      protected org.dbflute.optional.OptionalThing<org.codelibs.fess.mylasta.action.FessUserBean> getSavedUserBean()
      Resolves the saved login user bean. Exposed as a seam so unit tests can supply a stub user (or an empty/anonymous result) by overriding this method, instead of registering a FessLoginAssist stub via ComponentUtil.register.
      Returns:
      the saved user bean, or empty when no user is logged in