OPENDJ-2950 Add support for cs-uri and cs-uri-stem fields in HTTP access log
| | |
| | | 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" |
| | |
| | | </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> |
| | |
| | | </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> |
| | |
| | | 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 |
| | |
| | | <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> |
| | |
| | | * 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. |
| | | */ |
| | |
| | | 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. |
| | |
| | | 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; |
| | |
| | | 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"; |
| | |
| | | |
| | | 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 |
| | |
| | | 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()); |
| | |
| | | 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; |
| | |
| | | |
| | | /** 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; |
| | | |
| | |
| | | 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(); |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public String getQuery() |
| | | public URI getUri() |
| | | { |
| | | return this.query; |
| | | return this.uri.asURI(); |
| | | } |
| | | |
| | | @Override |