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