use of org.forgerock.services.context.RootContext in project OpenAM by OpenRock.
the class ResourceApiVersionRoutingFilter method handle.
void handle(Request request, Response response, RestletRouter next) {
ApiVersionRouterContext apiVersionRouterContext = createApiVersionRouterContext(new RootContext());
next.handle(apiVersionRouterContext, request, response);
if (apiVersionRouterContext.getResourceVersion() != null) {
addContentAPIVersion(response, enforcedProtocolVersion, apiVersionRouterContext.getResourceVersion());
// If warnings are wanted, and we haven't thrown an exception by this point let's see what we can do...
if (behaviourManager.isWarningEnabled()) {
Version requestedVersion = parseResourceApiVersion(request);
if (requestedVersion == null) {
// If no version specified at all, we can warn about that
AdviceWarning warningHeader = AdviceWarning.newAdviceWarning(AGENT_NAME, "No " + AcceptApiVersionHeader.NAME + " specified");
ServletUtils.getResponse(response).addHeader("Warning", warningHeader.toString());
}
}
}
}
use of org.forgerock.services.context.RootContext in project OpenAM by OpenRock.
the class HttpRouterProviderTest method shouldAddRoutesToRouter.
@Test(dataProvider = "routeRequestsData")
public void shouldAddRoutesToRouter(String requestUri, Handler exceptedHandler) {
//Given
Context context = new RootContext();
Request request = new Request().setUri(URI.create(requestUri));
Router router = httpRouterProvider.get();
//When
router.handle(context, request);
//Then
verify(exceptedHandler).handle(any(Context.class), eq(request));
}
use of org.forgerock.services.context.RootContext in project OpenAM by OpenRock.
the class SessionResourceAuthzModuleTest method shouldDeferAllOthers.
@Test
public void shouldDeferAllOthers() {
//given
RootContext rootContext = new RootContext();
ActionRequest mockRequest = mock(ActionRequest.class);
given(mockRequest.getAction()).willReturn("something else");
//when
Promise<AuthorizationResult, ResourceException> promise = testModule.authorizeAction(rootContext, mockRequest);
//then
assertThat(promise).failedWithException().isExactlyInstanceOf(ForbiddenException.class);
}
use of org.forgerock.services.context.RootContext in project OpenAM by OpenRock.
the class AuditEventPublisherImpl method publishToDefault.
private void publishToDefault(String topic, AuditEvent auditEvent) throws ResourceException {
AMAuditService auditService = auditServiceProvider.getDefaultAuditService();
Connection connection = newInternalConnection(auditService);
CreateRequest request = newCreateRequest(topic, auditEvent.getValue());
connection.create(new RootContext(), request);
}
Aggregations