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