use of org.forgerock.http.MutableUri in project OpenAM by OpenRock.
the class AMAccessAuditEventBuilder method forRequest.
/**
* Sets client, server and http details from CHF Request and Context.
*
* @param request Request from which client, server and http details will be retrieved.
* @param context Context from which client, server and http details will be retrieved.
* @return this builder
*/
public final AMAccessAuditEventBuilder forRequest(Request request, Context context) {
String clientIpAddress = ClientUtils.getClientIPAddress(context, request);
String ipAddrHeader = SystemPropertiesManager.get(Constants.CLIENT_IP_ADDR_HEADER);
if (ipAddressHeaderPropertyIsSet(ipAddrHeader) && requestHasIpAddressHeader(request, ipAddrHeader)) {
client(clientIpAddress);
} else {
ClientContext clientContext = context.asContext(ClientContext.class);
client(clientIpAddress, clientContext.getRemotePort());
}
MutableUri uri = request.getUri();
String uriScheme = request.getUri().getScheme();
if (StringUtils.isNotEmpty(uriScheme)) {
uriScheme = uriScheme.toLowerCase();
}
boolean isSecure = "https".equals(uriScheme);
httpRequest(isSecure, request.getMethod(), uri.getScheme() + "://" + uri.getHost() + ":" + uri.getPort() + uri.getPath(), getQueryParametersAsMap(request.getForm()), getHeadersAsMap(request.getHeaders()));
return this;
}
Aggregations