Class RoleQueryHelper

java.lang.Object
org.codelibs.fess.helper.RoleQueryHelper

public class RoleQueryHelper extends Object
This class returns a list of a role from a request parameter, a request header and a cookie. The format of the default value is "[\d]+\nrole1,role2,role3", which you can encrypt.
  • Field Details

    • USER_ROLES

      protected static final String USER_ROLES
      The key for user roles in the request attribute.
      See Also:
    • cipher

      protected org.codelibs.core.crypto.CachedCipher cipher
      The cached cipher for encryption and decryption.
    • valueSeparator

      protected String valueSeparator
      The separator for values in the role string.
    • roleSeparator

      protected String roleSeparator
      The separator for roles in the role string.
    • parameterKey

      protected String parameterKey
      The key for the request parameter that contains role information.
    • encryptedParameterValue

      protected boolean encryptedParameterValue
      Whether the parameter value is encrypted.
    • headerKey

      protected String headerKey
      The key for the request header that contains role information.
    • encryptedHeaderValue

      protected boolean encryptedHeaderValue
      Whether the header value is encrypted.
    • cookieKey

      protected String cookieKey
      The key for the cookie that stores role information.
    • encryptedCookieValue

      protected boolean encryptedCookieValue
      Whether the cookie value is encrypted.
    • maxAge

      protected long maxAge
      The maximum age of the role information in seconds.
    • cookieNameMap

      protected Map<String,String> cookieNameMap
      A map of cookie names to role names.
    • defaultRoleList

      protected final List<String> defaultRoleList
      A list of default roles.
  • Constructor Details

    • RoleQueryHelper

      public RoleQueryHelper()
      Constructor.
  • Method Details

    • init

      @PostConstruct public void init()
      Initializes the RoleQueryHelper.
    • build

      public Set<String> build(SearchRequestParams.SearchRequestType searchRequestType)
      Builds a set of roles from the request.
      Parameters:
      searchRequestType - The type of the search request.
      Returns:
      A set of roles.
    • processAccessToken

      protected boolean processAccessToken(jakarta.servlet.http.HttpServletRequest request, Set<String> roleSet, boolean isApiRequest)
      Processes the access token.
      Parameters:
      request - The HTTP request.
      roleSet - The set of roles.
      isApiRequest - Whether the request is an API request.
      Returns:
      true if the access token is processed, false otherwise.
    • findUserBean

      protected org.dbflute.optional.OptionalThing<org.codelibs.fess.mylasta.action.FessUserBean> findUserBean(org.lastaflute.web.servlet.request.RequestManager requestManager)
      Resolves the logged-in user bean for the current request. Exposed as a protected seam so unit tests can substitute an empty result without driving the shared LastaFlute container to resolve FessLoginAssist (and its OpenSearch-backed UserBhv), which is unavailable in the unit test environment.
      Parameters:
      requestManager - The request manager.
      Returns:
      the optional user bean, empty when no user is logged in.
    • processParameter

      protected void processParameter(jakarta.servlet.http.HttpServletRequest request, Set<String> roleSet)
      Processes the request parameter.
      Parameters:
      request - The HTTP request.
      roleSet - The set of roles.
    • processHeader

      protected void processHeader(jakarta.servlet.http.HttpServletRequest request, Set<String> roleSet)
      Processes the request header.
      Parameters:
      request - The HTTP request.
      roleSet - The set of roles.
    • processCookie

      protected void processCookie(jakarta.servlet.http.HttpServletRequest request, Set<String> roleSet)
      Processes the cookie.
      Parameters:
      request - The HTTP request.
      roleSet - The set of roles.
    • buildByCookieNameMapping

      protected void buildByCookieNameMapping(jakarta.servlet.http.HttpServletRequest request, Set<String> roleSet)
      Builds roles from the cookie name mapping.
      Parameters:
      request - The HTTP request.
      roleSet - The set of roles.
    • addRoleFromCookieMapping

      protected void addRoleFromCookieMapping(Set<String> roleNameList, jakarta.servlet.http.Cookie cookie)
      Adds a role from the cookie mapping.
      Parameters:
      roleNameList - The list of role names.
      cookie - The cookie.
    • parseRoleSet

      protected void parseRoleSet(String value, boolean encrypted, Set<String> roleSet)
      Parses the role set from a string.
      Parameters:
      value - The string to parse.
      encrypted - Whether the string is encrypted.
      roleSet - The set of roles.
    • getCurrentTime

      protected long getCurrentTime()
      Gets the current time in milliseconds.
      Returns:
      The current time in milliseconds.
    • addCookieNameMapping

      public void addCookieNameMapping(String cookieName, String roleName)
      Adds a cookie name mapping.
      Parameters:
      cookieName - The name of the cookie.
      roleName - The name of the role.
    • setCipher

      public void setCipher(org.codelibs.core.crypto.CachedCipher cipher)
      Sets the cached cipher.
      Parameters:
      cipher - The cached cipher.
    • setValueSeparator

      public void setValueSeparator(String valueSeparator)
      Sets the value separator.
      Parameters:
      valueSeparator - The value separator.
    • setRoleSeparator

      public void setRoleSeparator(String roleSeparator)
      Sets the role separator.
      Parameters:
      roleSeparator - The role separator.
    • setParameterKey

      public void setParameterKey(String parameterKey)
      Sets the parameter key.
      Parameters:
      parameterKey - The parameter key.
    • setEncryptedParameterValue

      public void setEncryptedParameterValue(boolean encryptedParameterValue)
      Sets whether the parameter value is encrypted.
      Parameters:
      encryptedParameterValue - Whether the parameter value is encrypted.
    • setHeaderKey

      public void setHeaderKey(String headerKey)
      Sets the header key.
      Parameters:
      headerKey - The header key.
    • setEncryptedHeaderValue

      public void setEncryptedHeaderValue(boolean encryptedHeaderValue)
      Sets whether the header value is encrypted.
      Parameters:
      encryptedHeaderValue - Whether the header value is encrypted.
    • setCookieKey

      public void setCookieKey(String cookieKey)
      Sets the cookie key.
      Parameters:
      cookieKey - The cookie key.
    • setEncryptedCookieValue

      public void setEncryptedCookieValue(boolean encryptedCookieValue)
      Sets whether the cookie value is encrypted.
      Parameters:
      encryptedCookieValue - Whether the cookie value is encrypted.
    • setMaxAge

      public void setMaxAge(long maxAge)
      Sets the maximum age of the role information in seconds.
      Parameters:
      maxAge - The maximum age of the role information in seconds.