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