001/*
002 * Copyright 2022-2024 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright 2022-2024 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) 2022-2024 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.v2.text;
037
038
039
040import java.util.Set;
041
042import com.unboundid.ldap.sdk.unboundidds.logs.AccessLogMessageType;
043import com.unboundid.ldap.sdk.unboundidds.logs.v2.
044            OperationRequestAccessLogMessage;
045import com.unboundid.util.NotExtensible;
046import com.unboundid.util.NotNull;
047import com.unboundid.util.Nullable;
048import com.unboundid.util.ThreadSafety;
049import com.unboundid.util.ThreadSafetyLevel;
050
051
052
053/**
054 * This class provides a data structure that holds information about a
055 * text-formatted operation request access log message.
056 * <BR>
057 * <BLOCKQUOTE>
058 *   <B>NOTE:</B>  This class, and other classes within the
059 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
060 *   supported for use against Ping Identity, UnboundID, and
061 *   Nokia/Alcatel-Lucent 8661 server products.  These classes provide support
062 *   for proprietary functionality or for external specifications that are not
063 *   considered stable or mature enough to be guaranteed to work in an
064 *   interoperable way with other types of LDAP servers.
065 * </BLOCKQUOTE>
066 */
067@NotExtensible()
068@ThreadSafety(level=ThreadSafetyLevel.INTERFACE_THREADSAFE)
069public abstract class TextFormattedRequestAccessLogMessage
070       extends TextFormattedAccessLogMessage
071       implements OperationRequestAccessLogMessage
072{
073  /**
074   * The serial version UID for this serializable class.
075   */
076  private static final long serialVersionUID = -4966579210690500174L;
077
078
079
080  // Indicates whether the operation was processed using an admin session
081  // worker thread.
082  @Nullable private final Boolean usingAdminSessionWorkerThread;
083
084  // The message ID for this log message.
085  @Nullable private final Integer messageID;
086
087  // The operation ID for this log message.
088  @Nullable private final Long operationID;
089
090  // The triggered by connection ID for this log message.
091  @Nullable private final Long triggeredByConnectionID;
092
093  // The triggered by operation ID for this log message.
094  @Nullable private final Long triggeredByOperationID;
095
096  // The request control OIDs for this log message.
097  @NotNull private final Set<String> requestControlOIDs;
098
099  // The administrative operation message for this log message.
100  @Nullable private final String administrativeOperationMessage;
101
102  // A string representation of an intermediate client request control for this
103  // log message.
104  @Nullable private final String intermediateClientRequestControl;
105
106  // A string representation of an operation purpose request control for this
107  // log message.
108  @Nullable private final String operationPurposeRequestControl;
109
110  // The origin for this log message.
111  @Nullable private final String origin;
112
113  // The requester DN for this log message.
114  @Nullable private final String requesterDN;
115
116  // The requester IP address for this log message.
117  @Nullable private final String requesterIPAddress;
118
119
120
121  /**
122   * Creates a new text-formatted request access log message from the provided
123   * message.
124   *
125   * @param  logMessage  The log message to use to create this request access
126   *                     log message.  It must not be {@code null}.
127   */
128  protected TextFormattedRequestAccessLogMessage(
129                 @NotNull final TextFormattedLogMessage logMessage)
130  {
131    super(logMessage);
132
133    operationID = getLongNoThrow(TextFormattedAccessLogFields.OPERATION_ID);
134    messageID = getIntegerNoThrow(TextFormattedAccessLogFields.MESSAGE_ID);
135    origin = getString(TextFormattedAccessLogFields.ORIGIN);
136    triggeredByConnectionID = getLongNoThrow(
137         TextFormattedAccessLogFields.TRIGGERED_BY_CONNECTION_ID);
138    triggeredByOperationID = getLongNoThrow(
139         TextFormattedAccessLogFields.TRIGGERED_BY_OPERATION_ID);
140    requesterDN = getString(TextFormattedAccessLogFields.REQUESTER_DN);
141    requesterIPAddress = getString(
142         TextFormattedAccessLogFields.REQUESTER_IP_ADDRESS);
143    requestControlOIDs = getCommaDelimitedStringSet(
144         TextFormattedAccessLogFields.REQUEST_CONTROL_OIDS);
145    usingAdminSessionWorkerThread = getBooleanNoThrow(
146         TextFormattedAccessLogFields.USING_ADMIN_SESSION_WORKER_THREAD);
147    administrativeOperationMessage = getString(
148         TextFormattedAccessLogFields.ADMINISTRATIVE_OPERATION);
149    intermediateClientRequestControl = getString(
150         TextFormattedAccessLogFields.INTERMEDIATE_CLIENT_REQUEST);
151    operationPurposeRequestControl = getString(
152         TextFormattedAccessLogFields.OPERATION_PURPOSE);
153  }
154
155
156
157  /**
158   * {@inheritDoc}
159   */
160  @Override()
161  @NotNull()
162  public AccessLogMessageType getMessageType()
163  {
164    return AccessLogMessageType.REQUEST;
165  }
166
167
168
169  /**
170   * {@inheritDoc}
171   */
172  @Override()
173  @Nullable()
174  public final Long getOperationID()
175  {
176    return operationID;
177  }
178
179
180
181  /**
182   * {@inheritDoc}
183   */
184  @Override()
185  @Nullable()
186  public final Integer getMessageID()
187  {
188    return messageID;
189  }
190
191
192
193  /**
194   * {@inheritDoc}
195   */
196  @Override()
197  @Nullable()
198  public final String getOrigin()
199  {
200    return origin;
201  }
202
203
204
205  /**
206   * {@inheritDoc}
207   */
208  @Override()
209  @Nullable()
210  public final Long getTriggeredByConnectionID()
211  {
212    return triggeredByConnectionID;
213  }
214
215
216
217  /**
218   * {@inheritDoc}
219   */
220  @Override()
221  @Nullable()
222  public final Long getTriggeredByOperationID()
223  {
224    return triggeredByOperationID;
225  }
226
227
228
229  /**
230   * {@inheritDoc}
231   */
232  @Override()
233  @Nullable()
234  public final String getRequesterDN()
235  {
236    return requesterDN;
237  }
238
239
240
241  /**
242   * {@inheritDoc}
243   */
244  @Override()
245  @Nullable()
246  public final String getRequesterIPAddress()
247  {
248    return requesterIPAddress;
249  }
250
251
252
253  /**
254   * {@inheritDoc}
255   */
256  @Override()
257  @NotNull()
258  public final Set<String> getRequestControlOIDs()
259  {
260    return requestControlOIDs;
261  }
262
263
264
265  /**
266   * {@inheritDoc}
267   */
268  @Override()
269  @Nullable()
270  public final Boolean getUsingAdminSessionWorkerThread()
271  {
272    return usingAdminSessionWorkerThread;
273  }
274
275
276
277  /**
278   * {@inheritDoc}
279   */
280  @Override()
281  @Nullable()
282  public final String getAdministrativeOperationMessage()
283  {
284    return administrativeOperationMessage;
285  }
286
287
288
289  /**
290   * Retrieves a string representation of an intermediate client request control
291   * included in the log message.
292   *
293   * @return  A string representation of an intermediate client request control
294   *          included in the log message, or {@code null} if there is none.
295   */
296  @Nullable()
297  public final String getIntermediateClientRequestControl()
298  {
299    return intermediateClientRequestControl;
300  }
301
302
303
304  /**
305   * Retrieves a string representation of an operation purpose request control
306   * included in the log message.
307   *
308   * @return  A string representation of an operation purpose request control
309   *          included in the log message, or {@code null} if there is none.
310   */
311  @Nullable()
312  public final String getOperationPurposeRequestControl()
313  {
314    return operationPurposeRequestControl;
315  }
316}