001/* 002 * Copyright 2009-2024 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright 2009-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) 2009-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; 037 038 039 040import com.unboundid.util.Debug; 041import com.unboundid.util.NotExtensible; 042import com.unboundid.util.NotNull; 043import com.unboundid.util.Nullable; 044import com.unboundid.util.NotMutable; 045import com.unboundid.util.ThreadSafety; 046import com.unboundid.util.ThreadSafetyLevel; 047 048 049 050/** 051 * This class provides a data structure that holds information about a log 052 * message that may appear in the Directory Server access log about a bind 053 * request received from a client. 054 * <BR> 055 * <BLOCKQUOTE> 056 * <B>NOTE:</B> This class, and other classes within the 057 * {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only 058 * supported for use against Ping Identity, UnboundID, and 059 * Nokia/Alcatel-Lucent 8661 server products. These classes provide support 060 * for proprietary functionality or for external specifications that are not 061 * considered stable or mature enough to be guaranteed to work in an 062 * interoperable way with other types of LDAP servers. 063 * </BLOCKQUOTE> 064 */ 065@NotExtensible() 066@NotMutable() 067@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 068public class BindRequestAccessLogMessage 069 extends OperationRequestAccessLogMessage 070{ 071 /** 072 * The serial version UID for this serializable class. 073 */ 074 private static final long serialVersionUID = 8603928027823970L; 075 076 077 078 // The type of authentication requested by the client. 079 @Nullable private final BindRequestAuthenticationType authenticationType; 080 081 // The DN of the user attempting to bind. 082 @Nullable private final String dn; 083 084 // The string representation of the protocol version. 085 @Nullable private final String protocolVersion; 086 087 // The name of the SASL mechanism requested by the client. 088 @Nullable private final String saslMechanismName; 089 090 091 092 /** 093 * Creates a new bind request access log message from the provided message 094 * string. 095 * 096 * @param s The string to be parsed as an bind request access log 097 * message. 098 * 099 * @throws LogException If the provided string cannot be parsed as a valid 100 * log message. 101 */ 102 public BindRequestAccessLogMessage(@NotNull final String s) 103 throws LogException 104 { 105 this(new LogMessage(s)); 106 } 107 108 109 110 /** 111 * Creates a new bind request access log message from the provided message 112 * string. 113 * 114 * @param m The log message to be parsed as a bind request access log 115 * message. 116 */ 117 public BindRequestAccessLogMessage(@NotNull final LogMessage m) 118 { 119 super(m); 120 121 dn = getNamedValue("dn"); 122 saslMechanismName = getNamedValue("saslMechanism"); 123 protocolVersion = getNamedValue("version"); 124 125 BindRequestAuthenticationType authType = null; 126 try 127 { 128 authType = 129 BindRequestAuthenticationType.valueOf(getNamedValue("authType")); 130 } 131 catch (final Exception e) 132 { 133 Debug.debugException(e); 134 } 135 authenticationType = authType; 136 } 137 138 139 140 /** 141 * Retrieves the type of authentication requested by the client. 142 * 143 * @return The type of authentication requested by the client, or 144 * {@code null} if it is not included in the log message. 145 */ 146 @Nullable() 147 public final BindRequestAuthenticationType getAuthenticationType() 148 { 149 return authenticationType; 150 } 151 152 153 154 /** 155 * Retrieves the DN of the user attempting to bind. This value may not be 156 * useful for authentication types other than "SIMPLE". 157 * 158 * @return The DN of the user attempting to bind, or {@code null} if it is 159 * not included in the log message. 160 */ 161 @Nullable() 162 public final String getDN() 163 { 164 return dn; 165 } 166 167 168 169 /** 170 * Retrieves the protocol version for the bind request. 171 * 172 * @return The protocol version for the bind request, or {@code null} if it 173 * is not included in the log message. 174 */ 175 @Nullable() 176 public final String getProtocolVersion() 177 { 178 return protocolVersion; 179 } 180 181 182 183 /** 184 * Retrieves the name of the requested SASL mechanism. This should only be 185 * included for SASL bind attempts. 186 * 187 * @return The name of the requested SASL mechanism, or {@code null} if it 188 * is not included in the log message. 189 */ 190 @Nullable() 191 public final String getSASLMechanismName() 192 { 193 return saslMechanismName; 194 } 195 196 197 198 /** 199 * {@inheritDoc} 200 */ 201 @Override() 202 @NotNull() 203 public final AccessLogOperationType getOperationType() 204 { 205 return AccessLogOperationType.BIND; 206 } 207}