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