Class ServerContextUtils


  • public class ServerContextUtils
    extends Object
    For the convenience of generating information from different types of ServerContexts.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static String getActionString​(org.forgerock.json.resource.ActionRequest request)
      Generates for logging a String in the form ACTION | actionId from the CreateRequest.
      static String getCreateString​(org.forgerock.json.resource.CreateRequest request)
      Generates for logging a String in the form CREATE | newResourceId from the CreateRequest.
      static String getDeleteString​(org.forgerock.json.resource.DeleteRequest request)
      Generates for logging a String in the form DELETE | revision from the CreateRequest.
      static String getId​(org.forgerock.services.context.Context context)
      Returns the UriRouterContext's "id" UriTemplateVariable from the provided Context.
      static Locale getLocaleFromContext​(org.forgerock.services.context.Context context)
      Get the Context as an HttpContext, read the accept-language from the header and create a Locale object from that.
      static String getMatchedUri​(org.forgerock.services.context.Context context)
      Returns the UriRouterContext's matchedUri, and appends its id, if there is one.
      static String getPatchString​(org.forgerock.json.resource.PatchRequest request)
      Generates for logging a String in the form PATCH | resourceRevision from the PatchRequest.
      static String getQueryString​(org.forgerock.json.resource.QueryRequest request)
      Generates for logging a String in the form QUERY | queryId from the QueryRequest.
      static String getReadString​(org.forgerock.json.resource.ReadRequest request)
      Generates for logging a String in the form READ from the CreateRequest.
      static String getRealm​(org.forgerock.services.context.Context context)
      Gets the resolved realm from the context.
      static String getResourceId​(org.forgerock.json.resource.Request request, org.forgerock.services.context.Context context)
      Returns the name of the resource requested, and appends its id, if there is one.
      static SSOToken getTokenFromContext​(org.forgerock.services.context.Context context, Debug debug)
      Retrieves a link to the user's SSO Token, if it exists in the context.
      static String getUpdateString​(org.forgerock.json.resource.UpdateRequest request)
      Generates for logging a String in the form UPDATE | resourceRevision from the UpdateRequest.
    • Constructor Detail

      • ServerContextUtils

        public ServerContextUtils()
    • Method Detail

      • getTokenFromContext

        public static SSOToken getTokenFromContext​(org.forgerock.services.context.Context context,
                                                   Debug debug)
        Retrieves a link to the user's SSO Token, if it exists in the context.
        Parameters:
        context - from which to pull the SSO Token
      • getId

        public static String getId​(org.forgerock.services.context.Context context)
        Returns the UriRouterContext's "id" UriTemplateVariable from the provided Context.
        Parameters:
        context - from which to pull the id
        Returns:
        the id, otherwise null.
      • getMatchedUri

        public static String getMatchedUri​(org.forgerock.services.context.Context context)
        Returns the UriRouterContext's matchedUri, and appends its id, if there is one. Id is retrieved via getId(Context).
        Parameters:
        context - from which to gather the matched Uri and id information
        Returns:
        a String in the form matchedUri | id, omitting either if they are null.
      • getResourceId

        public static String getResourceId​(org.forgerock.json.resource.Request request,
                                           org.forgerock.services.context.Context context)
        Returns the name of the resource requested, and appends its id, if there is one. Id is retrieved via getId(Context). If the resource path can not be found on the request, the Matched Uri on the context will be queried via getMatchedUri(Context).
        Parameters:
        request - the request for a resource
        context - the context of the request, including its UriRouterContext
        Returns:
        a String in the form resourceName | id, omitting either if they are null.
      • getCreateString

        public static String getCreateString​(org.forgerock.json.resource.CreateRequest request)
        Generates for logging a String in the form CREATE | newResourceId from the CreateRequest.
        Parameters:
        request - from which to generate information
        Returns:
        the logging string
      • getReadString

        public static String getReadString​(org.forgerock.json.resource.ReadRequest request)
        Generates for logging a String in the form READ from the CreateRequest.
        Parameters:
        request - from which to generate information
        Returns:
        the logging string
      • getActionString

        public static String getActionString​(org.forgerock.json.resource.ActionRequest request)
        Generates for logging a String in the form ACTION | actionId from the CreateRequest.
        Parameters:
        request - from which to generate information
        Returns:
        the logging string
      • getDeleteString

        public static String getDeleteString​(org.forgerock.json.resource.DeleteRequest request)
        Generates for logging a String in the form DELETE | revision from the CreateRequest.
        Parameters:
        request - from which to generate information
        Returns:
        the logging string
      • getPatchString

        public static String getPatchString​(org.forgerock.json.resource.PatchRequest request)
        Generates for logging a String in the form PATCH | resourceRevision from the PatchRequest.
        Parameters:
        request - from which to generate information
        Returns:
        the logging string
      • getUpdateString

        public static String getUpdateString​(org.forgerock.json.resource.UpdateRequest request)
        Generates for logging a String in the form UPDATE | resourceRevision from the UpdateRequest.
        Parameters:
        request - from which to generate information
        Returns:
        the logging string
      • getQueryString

        public static String getQueryString​(org.forgerock.json.resource.QueryRequest request)
        Generates for logging a String in the form QUERY | queryId from the QueryRequest.
        Parameters:
        request - from which to generate information
        Returns:
        the logging string
      • getLocaleFromContext

        public static Locale getLocaleFromContext​(org.forgerock.services.context.Context context)
        Get the Context as an HttpContext, read the accept-language from the header and create a Locale object from that.
        Parameters:
        context - The server context from which the language header can be read.
        Returns:
        The Local instance or null if no accept-language header was found.
      • getRealm

        public static String getRealm​(org.forgerock.services.context.Context context)
        Gets the resolved realm from the context.
        Parameters:
        context - The context.
        Returns:
        The resolved realm.