Class ServerContextUtils
- java.lang.Object
-
- org.forgerock.openam.forgerockrest.utils.ServerContextUtils
-
public class ServerContextUtils extends Object
For the convenience of generating information from different types of ServerContexts.
-
-
Constructor Summary
Constructors Constructor Description ServerContextUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringgetActionString(org.forgerock.json.resource.ActionRequest request)Generates for logging a String in the formACTION | actionIdfrom the CreateRequest.static StringgetCreateString(org.forgerock.json.resource.CreateRequest request)Generates for logging a String in the formCREATE | newResourceIdfrom the CreateRequest.static StringgetDeleteString(org.forgerock.json.resource.DeleteRequest request)Generates for logging a String in the formDELETE | revisionfrom the CreateRequest.static StringgetId(org.forgerock.services.context.Context context)Returns the UriRouterContext's "id" UriTemplateVariable from the provided Context.static LocalegetLocaleFromContext(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 StringgetMatchedUri(org.forgerock.services.context.Context context)Returns the UriRouterContext's matchedUri, and appends its id, if there is one.static StringgetPatchString(org.forgerock.json.resource.PatchRequest request)Generates for logging a String in the formPATCH | resourceRevisionfrom the PatchRequest.static StringgetQueryString(org.forgerock.json.resource.QueryRequest request)Generates for logging a String in the formQUERY | queryIdfrom the QueryRequest.static StringgetReadString(org.forgerock.json.resource.ReadRequest request)Generates for logging a String in the formREADfrom the CreateRequest.static StringgetRealm(org.forgerock.services.context.Context context)Gets the resolved realm from the context.static StringgetResourceId(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 SSOTokengetTokenFromContext(org.forgerock.services.context.Context context, Debug debug)Retrieves a link to the user's SSO Token, if it exists in the context.static StringgetUpdateString(org.forgerock.json.resource.UpdateRequest request)Generates for logging a String in the formUPDATE | resourceRevisionfrom the UpdateRequest.
-
-
-
Field Detail
-
CREATE
public static final String CREATE
- See Also:
- Constant Field Values
-
READ
public static final String READ
- See Also:
- Constant Field Values
-
UPDATE
public static final String UPDATE
- See Also:
- Constant Field Values
-
DELETE
public static final String DELETE
- See Also:
- Constant Field Values
-
PATCH
public static final String PATCH
- See Also:
- Constant Field Values
-
ACTION
public static final String ACTION
- See Also:
- Constant Field Values
-
QUERY
public static final String QUERY
- See Also:
- Constant Field Values
-
ACCEPT_LANGUAGE
public static final String ACCEPT_LANGUAGE
- See Also:
- Constant Field Values
-
-
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 viagetId(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 viagetId(Context). If the resource path can not be found on the request, the Matched Uri on the context will be queried viagetMatchedUri(Context).- Parameters:
request- the request for a resourcecontext- 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 formCREATE | newResourceIdfrom 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 formREADfrom 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 formACTION | actionIdfrom 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 formDELETE | revisionfrom 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 formPATCH | resourceRevisionfrom 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 formUPDATE | resourceRevisionfrom 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 formQUERY | queryIdfrom 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.
-
-