001/*
002 * Copyright 2009-2020 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright 2009-2020 Ping Identity Corporation
007 *
008 * Licensed under the Apache License, Version 2.0 (the "License");
009 * you may not use this file except in compliance with the License.
010 * You may obtain a copy of the License at
011 *
012 *    http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing, software
015 * distributed under the License is distributed on an "AS IS" BASIS,
016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017 * See the License for the specific language governing permissions and
018 * limitations under the License.
019 */
020/*
021 * Copyright (C) 2015-2020 Ping Identity Corporation
022 *
023 * This program is free software; you can redistribute it and/or modify
024 * it under the terms of the GNU General Public License (GPLv2 only)
025 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
026 * as published by the Free Software Foundation.
027 *
028 * This program is distributed in the hope that it will be useful,
029 * but WITHOUT ANY WARRANTY; without even the implied warranty of
030 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
031 * GNU General Public License for more details.
032 *
033 * You should have received a copy of the GNU General Public License
034 * along with this program; if not, see <http://www.gnu.org/licenses>.
035 */
036package com.unboundid.ldap.sdk.unboundidds.logs;
037
038
039
040import java.util.Collections;
041import java.util.LinkedList;
042import java.util.List;
043import java.util.StringTokenizer;
044
045import com.unboundid.util.NotExtensible;
046import com.unboundid.util.ThreadSafety;
047import com.unboundid.util.ThreadSafetyLevel;
048
049
050
051/**
052 * This class provides a data structure that holds information about a log
053 * message that may appear in the Directory Server access log about an
054 * operation request received from a client.
055 * <BR>
056 * <BLOCKQUOTE>
057 *   <B>NOTE:</B>  This class, and other classes within the
058 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
059 *   supported for use against Ping Identity, UnboundID, and
060 *   Nokia/Alcatel-Lucent 8661 server products.  These classes provide support
061 *   for proprietary functionality or for external specifications that are not
062 *   considered stable or mature enough to be guaranteed to work in an
063 *   interoperable way with other types of LDAP servers.
064 * </BLOCKQUOTE>
065 */
066@NotExtensible()
067@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
068public abstract class OperationRequestAccessLogMessage
069       extends OperationAccessLogMessage
070{
071  /**
072   * The serial version UID for this serializable class.
073   */
074  private static final long serialVersionUID = -8942685623238040482L;
075
076
077
078  // Indicates whether the request is being processed using a worker thread from
079  // the dedicated administrative session pool.
080  private final Boolean usingAdminSessionWorkerThread;
081
082  // The OIDs of the request controls contained in the request.
083  private final List<String> requestControlOIDs;
084
085  // Information from the intermediate client request control contained in the
086  // request.
087  private final String intermediateClientRequest;
088
089  // Information from the operation purpose control contained in the request.
090  private final String operationPurpose;
091
092  // The DN of the user that requested the message.
093  private final String requesterDN;
094
095  // The IP address of the client that requested the message.
096  private final String requesterIP;
097
098
099
100  /**
101   * Creates a new operation request access log message from the provided log
102   * message.
103   *
104   * @param  m  The log message to be parsed as an operation request access log
105   *            message.
106   */
107  protected OperationRequestAccessLogMessage(final LogMessage m)
108  {
109    super(m);
110
111    intermediateClientRequest = getNamedValue("via");
112    operationPurpose          = getNamedValue("opPurpose");
113    requesterDN               = getNamedValue("requesterDN");
114    requesterIP               = getNamedValue("requesterIP");
115
116    usingAdminSessionWorkerThread =
117         getNamedValueAsBoolean("usingAdminSessionWorkerThread");
118
119    final String controlStr = getNamedValue("requestControls");
120    if (controlStr == null)
121    {
122      requestControlOIDs = Collections.emptyList();
123    }
124    else
125    {
126      final LinkedList<String> controlList = new LinkedList<>();
127      final StringTokenizer t = new StringTokenizer(controlStr, ",");
128      while (t.hasMoreTokens())
129      {
130        controlList.add(t.nextToken());
131      }
132      requestControlOIDs = Collections.unmodifiableList(controlList);
133    }
134  }
135
136
137
138  /**
139   * Retrieves the DN of the user that requested the operation.
140   *
141   * @return  The DN of the user that requested the operation, or {@code null}
142   *          if it is not included in the log message.
143   */
144  public final String getRequesterDN()
145  {
146    return requesterDN;
147  }
148
149
150
151  /**
152   * Retrieves the IP address of the client that requested the operation.
153   *
154   * @return  The IP address of the client that requested the operation, or
155   *          {@code null} if it is not included in the log message.
156   */
157  public final String getRequesterIPAddress()
158  {
159    return requesterIP;
160  }
161
162
163
164  /**
165   * Retrieves the content of any intermediate client request control contained
166   * in the request.
167   *
168   * @return  The content of any intermediate client request control contained
169   *          in the request, or {@code null} if it is not included in the log
170   *          message.
171   */
172  public final String getIntermediateClientRequest()
173  {
174    return intermediateClientRequest;
175  }
176
177
178
179  /**
180   * Retrieves the content of any operation purpose request control contained in
181   * the request.
182   *
183   * @return  The content of any operation purpose request control included in
184   *          the request, or {@code null} if it is not included in the log
185   *          message.
186   */
187  public final String getOperationPurpose()
188  {
189    return operationPurpose;
190  }
191
192
193
194  /**
195   * Retrieves the OIDs of any request controls contained in the log message.
196   *
197   * @return  The OIDs of any request controls contained in the log message, or
198   *          an empty list if it is not included in the log message.
199   */
200  public final List<String> getRequestControlOIDs()
201  {
202    return requestControlOIDs;
203  }
204
205
206
207  /**
208   * Indicates whether the operation was processed using a worker thread from
209   * the dedicated administrative session thread pool.
210   *
211   * @return  {@code true} if the operation was processed using a worker thread
212   *          from the dedicated administrative session thread pool,
213   *          {@code false} if it was not, or {@code null} if that information
214   *          was not included in the log message.
215   */
216  public final Boolean usingAdminSessionWorkerThread()
217  {
218    return usingAdminSessionWorkerThread;
219  }
220
221
222
223  /**
224   * {@inheritDoc}
225   */
226  @Override()
227  public AccessLogMessageType getMessageType()
228  {
229    return AccessLogMessageType.REQUEST;
230  }
231}