Search in sources :

Example 6 with UriRouterContext

use of org.forgerock.http.routing.UriRouterContext in project OpenAM by OpenRock.

the class ServerContextUtils method getId.

/**
     * Returns the UriRouterContext's "id" UriTemplateVariable from the provided Context.
     *
     * @param context from which to pull the id
     * @return the id, otherwise null.
     */
public static String getId(Context context) {
    if (context.containsContext(UriRouterContext.class)) {
        UriRouterContext routerContext = context.asContext(UriRouterContext.class);
        Map<String, String> templateVars = routerContext.getUriTemplateVariables();
        if (templateVars != null && !templateVars.isEmpty()) {
            return templateVars.get("id");
        }
    }
    return null;
}
Also used : UriRouterContext(org.forgerock.http.routing.UriRouterContext)

Example 7 with UriRouterContext

use of org.forgerock.http.routing.UriRouterContext in project OpenAM by OpenRock.

the class ServerContextUtils method getMatchedUri.

/**
     * Returns the UriRouterContext's matchedUri, and appends its id, if there is one.
     * Id is retrieved via {@link ServerContextUtils#getId(Context)}.
     *
     * @param context from which to gather the matched Uri and id information
     * @return a String in the form <code>matchedUri | id</code>, omitting either if they are null.
     */
public static String getMatchedUri(Context context) {
    String resource = "";
    if (context.containsContext(UriRouterContext.class)) {
        UriRouterContext routerContext = context.asContext(UriRouterContext.class);
        resource = routerContext.getMatchedUri();
    }
    String id = getId(context);
    if (id != null) {
        resource += "|" + id;
    }
    return resource;
}
Also used : UriRouterContext(org.forgerock.http.routing.UriRouterContext)

Example 8 with UriRouterContext

use of org.forgerock.http.routing.UriRouterContext in project OpenAM by OpenRock.

the class RealmContextFilterTest method verifyUriRouterContextForInvalidRealm.

private void verifyUriRouterContextForInvalidRealm(Context context) {
    UriRouterContext routerContext = context.asContext(UriRouterContext.class);
    assertThat(routerContext.getBaseUri()).isEqualTo(JSON_PATH_ELEMENT);
    assertThat(routerContext.getMatchedUri()).isEmpty();
}
Also used : UriRouterContext(org.forgerock.http.routing.UriRouterContext)

Aggregations

UriRouterContext (org.forgerock.http.routing.UriRouterContext)8 InternalServerErrorException (org.forgerock.json.resource.InternalServerErrorException)2 SubjectContext (org.forgerock.openam.rest.resource.SubjectContext)2 Session (com.iplanet.dpro.session.Session)1 SSOException (com.iplanet.sso.SSOException)1 SSOToken (com.iplanet.sso.SSOToken)1 DelegationException (com.sun.identity.delegation.DelegationException)1 DelegationPermission (com.sun.identity.delegation.DelegationPermission)1 HashMap (java.util.HashMap)1 Set (java.util.Set)1 BadRequestException (org.forgerock.json.resource.BadRequestException)1 RealmContext (org.forgerock.openam.rest.RealmContext)1 AdminSubjectContext (org.forgerock.openam.rest.resource.AdminSubjectContext)1 CollectionUtils.transformSet (org.forgerock.openam.utils.CollectionUtils.transformSet)1 RootContext (org.forgerock.services.context.RootContext)1