Search in sources :

Example 1 with AcceptApiVersionHeader

use of org.forgerock.http.header.AcceptApiVersionHeader in project OpenAM by OpenRock.

the class CrestProtocolEnforcementFilter method defaultProtocolVersion.

private Version defaultProtocolVersion(Request request) throws BadRequestException {
    AcceptApiVersionHeader apiVersionHeader;
    try {
        apiVersionHeader = AcceptApiVersionHeader.valueOf(request);
    } catch (IllegalArgumentException e) {
        throw new BadRequestException(e);
    }
    apiVersionHeader.withDefaultProtocolVersion(ENFORCE_PROTOCOL_VERSION);
    request.getHeaders().put(apiVersionHeader);
    return apiVersionHeader.getProtocolVersion();
}
Also used : BadRequestException(org.forgerock.json.resource.BadRequestException) AcceptApiVersionHeader(org.forgerock.http.header.AcceptApiVersionHeader)

Example 2 with AcceptApiVersionHeader

use of org.forgerock.http.header.AcceptApiVersionHeader in project OpenAM by OpenRock.

the class ResourceApiVersionRestlet method parseResourceApiVersion.

public static Version parseResourceApiVersion(Request request) {
    HttpServletRequest httpRequest = ServletUtils.getRequest(request);
    String versionHeader = httpRequest.getHeader(AcceptApiVersionHeader.NAME);
    AcceptApiVersionHeader apiVersionHeader = AcceptApiVersionHeader.valueOf(versionHeader);
    return apiVersionHeader.getResourceVersion();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) AcceptApiVersionHeader(org.forgerock.http.header.AcceptApiVersionHeader)

Example 3 with AcceptApiVersionHeader

use of org.forgerock.http.header.AcceptApiVersionHeader in project OpenAM by OpenRock.

the class LogWriter method sendEvent.

private static void sendEvent(String topic, JsonValue eventJson, String sessionId, String baseUrl) throws HttpApplicationException, URISyntaxException {
    Client client = new Client(new HttpClientHandler());
    Request request = new Request();
    request.setMethod("POST");
    if (eventJson.isDefined(EVENT_REALM)) {
        String realm = eventJson.get(EVENT_REALM).asString();
        baseUrl = baseUrl + "/json/realm-audit" + (realm.endsWith("/") ? realm : realm + "/");
    } else {
        baseUrl = baseUrl + "/json/global-audit/";
    }
    request.setUri(baseUrl + topic + "?_action=create");
    request.getHeaders().add(SystemProperties.get("com.iplanet.am.cookie.name"), sessionId);
    request.getHeaders().add(new AcceptApiVersionHeader(version(1), version(1)));
    request.getEntity().setJson(eventJson.getObject());
    client.send(request).then(WARN_OF_FAILURES_FUNCTION);
}
Also used : Request(org.forgerock.http.protocol.Request) Client(org.forgerock.http.Client) AcceptApiVersionHeader(org.forgerock.http.header.AcceptApiVersionHeader) HttpClientHandler(org.forgerock.http.handler.HttpClientHandler)

Aggregations

AcceptApiVersionHeader (org.forgerock.http.header.AcceptApiVersionHeader)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 Client (org.forgerock.http.Client)1 HttpClientHandler (org.forgerock.http.handler.HttpClientHandler)1 Request (org.forgerock.http.protocol.Request)1 BadRequestException (org.forgerock.json.resource.BadRequestException)1