001 /* 002 * Copyright 2009-2015 UnboundID Corp. 003 * All Rights Reserved. 004 */ 005 /* 006 * Copyright (C) 2015 UnboundID Corp. 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 */ 021 package com.unboundid.ldap.sdk.unboundidds.logs; 022 023 024 025 import java.util.Collections; 026 import java.util.LinkedList; 027 import java.util.List; 028 import java.util.StringTokenizer; 029 030 import com.unboundid.util.NotExtensible; 031 import com.unboundid.util.ThreadSafety; 032 import com.unboundid.util.ThreadSafetyLevel; 033 034 035 036 /** 037 * <BLOCKQUOTE> 038 * <B>NOTE:</B> This class is part of the Commercial Edition of the UnboundID 039 * LDAP SDK for Java. It is not available for use in applications that 040 * include only the Standard Edition of the LDAP SDK, and is not supported for 041 * use in conjunction with non-UnboundID products. 042 * </BLOCKQUOTE> 043 * This class provides a data structure that holds information about a log 044 * message that may appear in the Directory Server access log about an 045 * operation request received from a client. 046 */ 047 @NotExtensible() 048 @ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 049 public abstract class OperationRequestAccessLogMessage 050 extends OperationAccessLogMessage 051 { 052 /** 053 * The serial version UID for this serializable class. 054 */ 055 private static final long serialVersionUID = -8942685623238040482L; 056 057 058 059 // Indicates whether the request is being processed using a worker thread from 060 // the dedicated administrative session pool. 061 private final Boolean usingAdminSessionWorkerThread; 062 063 // The OIDs of the request controls contained in the request. 064 private final List<String> requestControlOIDs; 065 066 // Information from the intermediate client request control contained in the 067 // request. 068 private final String intermediateClientRequest; 069 070 // Information from the operation purpose control contained in the request. 071 private final String operationPurpose; 072 073 // The DN of the user that requested the message. 074 private final String requesterDN; 075 076 // The IP address of the client that requested the message. 077 private final String requesterIP; 078 079 080 081 /** 082 * Creates a new operation request access log message from the provided log 083 * message. 084 * 085 * @param m The log message to be parsed as an operation request access log 086 * message. 087 */ 088 protected OperationRequestAccessLogMessage(final LogMessage m) 089 { 090 super(m); 091 092 intermediateClientRequest = getNamedValue("via"); 093 operationPurpose = getNamedValue("opPurpose"); 094 requesterDN = getNamedValue("requesterDN"); 095 requesterIP = getNamedValue("requesterIP"); 096 097 usingAdminSessionWorkerThread = 098 getNamedValueAsBoolean("usingAdminSessionWorkerThread"); 099 100 final String controlStr = getNamedValue("requestControls"); 101 if (controlStr == null) 102 { 103 requestControlOIDs = Collections.emptyList(); 104 } 105 else 106 { 107 final LinkedList<String> controlList = new LinkedList<String>(); 108 final StringTokenizer t = new StringTokenizer(controlStr, ","); 109 while (t.hasMoreTokens()) 110 { 111 controlList.add(t.nextToken()); 112 } 113 requestControlOIDs = Collections.unmodifiableList(controlList); 114 } 115 } 116 117 118 119 /** 120 * Retrieves the DN of the user that requested the operation. 121 * 122 * @return The DN of the user that requested the operation, or {@code null} 123 * if it is not included in the log message. 124 */ 125 public final String getRequesterDN() 126 { 127 return requesterDN; 128 } 129 130 131 132 /** 133 * Retrieves the IP address of the client that requested the operation. 134 * 135 * @return The IP address of the client that requested the operation, or 136 * {@code null} if it is not included in the log message. 137 */ 138 public final String getRequesterIPAddress() 139 { 140 return requesterIP; 141 } 142 143 144 145 /** 146 * Retrieves the content of any intermediate client request control contained 147 * in the request. 148 * 149 * @return The content of any intermediate client request control contained 150 * in the request, or {@code null} if it is not included in the log 151 * message. 152 */ 153 public final String getIntermediateClientRequest() 154 { 155 return intermediateClientRequest; 156 } 157 158 159 160 /** 161 * Retrieves the content of any operation purpose request control contained in 162 * the request. 163 * 164 * @return The content of any operation purpose request control included in 165 * the request, or {@code null} if it is not included in the log 166 * message. 167 */ 168 public final String getOperationPurpose() 169 { 170 return operationPurpose; 171 } 172 173 174 175 /** 176 * Retrieves the OIDs of any request controls contained in the log message. 177 * 178 * @return The OIDs of any request controls contained in the log message, or 179 * an empty list if it is not included in the log message. 180 */ 181 public final List<String> getRequestControlOIDs() 182 { 183 return requestControlOIDs; 184 } 185 186 187 188 /** 189 * Indicates whether the operation was processed using a worker thread from 190 * the dedicated administrative session thread pool. 191 * 192 * @return {@code true} if the operation was processed using a worker thread 193 * from the dedicated administrative session thread pool, 194 * {@code false} if it was not, or {@code null} if that information 195 * was not included in the log message. 196 */ 197 public final Boolean usingAdminSessionWorkerThread() 198 { 199 return usingAdminSessionWorkerThread; 200 } 201 202 203 204 /** 205 * {@inheritDoc} 206 */ 207 @Override() 208 public AccessLogMessageType getMessageType() 209 { 210 return AccessLogMessageType.REQUEST; 211 } 212 }