mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Matthew Swift
18.26.2016 142f955cce8647d62a964226bb4975e4b6a8505a
OPENDJ-2950 Add support for cs-uri and cs-uri-stem fields in HTTP access log
4 files modified
51 ■■■■■ changed files
opendj-maven-plugin/src/main/resources/config/xml/org/forgerock/opendj/server/config/FileBasedHTTPAccessLogPublisherConfiguration.xml 12 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/loggers/HTTPRequestInfo.java 10 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/loggers/TextHTTPAccessLogPublisher.java 17 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/protocols/http/HTTPClientConnection.java 12 ●●●● patch | view | raw | blame | history
opendj-maven-plugin/src/main/resources/config/xml/org/forgerock/opendj/server/config/FileBasedHTTPAccessLogPublisherConfiguration.xml
@@ -12,7 +12,7 @@
  Header, with the fields enclosed by brackets [] replaced by your own identifying
  information: "Portions Copyright [year] [name of copyright owner]".
  Copyright 2013-2015 ForgeRock AS.
  Copyright 2013-2016 ForgeRock AS.
  ! -->
<adm:managed-object name="file-based-http-access-log-publisher"
  plural-name="file-based-http-access-log-publishers"
@@ -133,7 +133,7 @@
  </adm:property>
  <adm:property name="time-interval" advanced="true">
    <adm:synopsis>
      Specifies the interval at which to check whether the log files
      Specifies the interval at which to check whether the log files
      need to be rotated.
    </adm:synopsis>
    <adm:default-behavior>
@@ -267,7 +267,7 @@
    </adm:synopsis>
    <adm:default-behavior>
      <adm:defined>
        <adm:value>cs-host c-ip cs-username x-datetime cs-method cs-uri-query
        <adm:value>cs-host c-ip cs-username x-datetime cs-method cs-uri-stem cs-uri-query
        cs-version sc-status cs(User-Agent) x-connection-id x-etime x-transaction-id</adm:value>
      </adm:defined>
    </adm:default-behavior>
@@ -284,10 +284,10 @@
            http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/676400bc-8969-4aa7-851a-9319490a9bbb.mspx?mfr=true
            OpenDJ supports the following standard fields: "c-ip", "c-port",
            "cs-host", "cs-method", "cs-uri-query", "cs(User-Agent)",
            "cs-host", "cs-method", "cs-uri", "cs-uri-stem", "cs-uri-query", "cs(User-Agent)",
            "cs-username", "cs-version", "s-computername", "s-ip", "s-port",
            "sc-status".
            OpenDJ supports the following application specific field extensions:
            "x-connection-id"  displays the internal connection ID assigned to
            the HTTP client connection, "x-datetime"  displays the completion
@@ -322,7 +322,7 @@
        <adm:regex>.*</adm:regex>
        <adm:usage>STRING</adm:usage>
          <adm:synopsis>
            Any valid format string that can be used with the
            Any valid format string that can be used with the
            java.text.SimpleDateFormat class.
          </adm:synopsis>
        </adm:pattern>
opendj-server-legacy/src/main/java/org/opends/server/loggers/HTTPRequestInfo.java
@@ -11,10 +11,12 @@
 * Header, with the fields enclosed by brackets [] replaced by your own identifying
 * information: "Portions Copyright [year] [name of copyright owner]".
 *
 * Copyright 2013-2015 ForgeRock AS.
 * Copyright 2013-2016 ForgeRock AS.
 */
package org.opends.server.loggers;
import java.net.URI;
/**
 * Contains the information required for logging the HTTP request.
 */
@@ -78,11 +80,11 @@
  String getMethod();
  /**
   * Returns the query issued by the client.
   * Returns the URI issued by the client.
   *
   * @return the query
   * @return the URI
   */
  String getQuery();
  URI getUri();
  /**
   * Returns the user agent used by the client.
opendj-server-legacy/src/main/java/org/opends/server/loggers/TextHTTPAccessLogPublisher.java
@@ -30,6 +30,7 @@
import java.util.Map;
import java.util.Set;
import org.forgerock.http.MutableUri;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.config.server.ConfigChangeResult;
import org.forgerock.opendj.config.server.ConfigException;
@@ -58,6 +59,8 @@
  private static final String ELF_C_PORT = "c-port";
  private static final String ELF_CS_HOST = "cs-host";
  private static final String ELF_CS_METHOD = "cs-method";
  private static final String ELF_CS_URI = "cs-uri";
  private static final String ELF_CS_URI_STEM = "cs-uri-stem";
  private static final String ELF_CS_URI_QUERY = "cs-uri-query";
  private static final String ELF_CS_USER_AGENT = "cs(User-Agent)";
  private static final String ELF_CS_USERNAME = "cs-username";
@@ -74,9 +77,10 @@
  private static final Set<String> ALL_SUPPORTED_FIELDS = new HashSet<>(
      Arrays.asList(ELF_C_IP, ELF_C_PORT, ELF_CS_HOST, ELF_CS_METHOD,
          ELF_CS_URI_QUERY, ELF_CS_USER_AGENT, ELF_CS_USERNAME, ELF_CS_VERSION,
          ELF_S_COMPUTERNAME, ELF_S_IP, ELF_S_PORT, ELF_SC_STATUS,
          X_CONNECTION_ID, X_DATETIME, X_ETIME, X_TRANSACTION_ID));
          ELF_CS_URI, ELF_CS_URI_STEM, ELF_CS_URI_QUERY, ELF_CS_USER_AGENT,
          ELF_CS_USERNAME, ELF_CS_VERSION, ELF_S_COMPUTERNAME, ELF_S_IP,
          ELF_S_PORT, ELF_SC_STATUS, X_CONNECTION_ID, X_DATETIME, X_ETIME,
          X_TRANSACTION_ID));
  /**
   * Returns an instance of the text HTTP access log publisher that will print
@@ -420,7 +424,12 @@
    fields.put(ELF_C_PORT, ri.getClientPort());
    fields.put(ELF_CS_HOST, ri.getClientHost());
    fields.put(ELF_CS_METHOD, ri.getMethod());
    fields.put(ELF_CS_URI_QUERY, ri.getQuery());
    final MutableUri uri = ri.getUri();
    fields.put(ELF_CS_URI, uri.toString());
    fields.put(ELF_CS_URI_STEM, uri.getRawPath());
    fields.put(ELF_CS_URI_QUERY, uri.getRawQuery());
    fields.put(ELF_CS_USER_AGENT, ri.getUserAgent());
    fields.put(ELF_CS_USERNAME, ri.getAuthUser());
    fields.put(ELF_CS_VERSION, ri.getProtocol());
opendj-server-legacy/src/main/java/org/opends/server/protocols/http/HTTPClientConnection.java
@@ -23,6 +23,7 @@
import static org.opends.server.loggers.AccessLogger.logDisconnect;
import java.net.InetAddress;
import java.net.URI;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Collection;
@@ -194,8 +195,8 @@
  /** The HTTP method/verb used for this request. */
  private final String method;
  /** The query issued by the client. */
  private final String query;
  /** The URI issued by the client. */
  private final MutableUri uri;
  /** The user agent used by the client. */
  private final String userAgent;
@@ -254,14 +255,13 @@
    this.clientPort = clientCtx.getRemotePort();
    this.isSecure = clientCtx.isSecure();
    final MutableUri uri = request.getUri();
    this.uri = request.getUri();
    this.serverAddress = uri.getHost();
    this.localAddress = toInetAddress(serverAddress);
    this.serverPort = uri.getPort();
    this.securityStrengthFactor = calcSSF(
            context.asContext(AttributesContext.class).getAttributes().get(SERVLET_SSF_CONSTANT));
    this.method = request.getMethod();
    this.query = uri.getQuery();
    this.protocol = request.getVersion();
    this.userAgent = clientCtx.getUserAgent();
@@ -578,9 +578,9 @@
  }
  @Override
  public String getQuery()
  public URI getUri()
  {
    return this.query;
    return this.uri.asURI();
  }
  @Override