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