001/*
002 * Copyright 2009-2019 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright (C) 2015-2019 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.NotMutable;
026import com.unboundid.util.ThreadSafety;
027import com.unboundid.util.ThreadSafetyLevel;
028
029
030
031/**
032 * This class provides a data structure that holds information about a log
033 * message that may appear in the Directory Server access log about a
034 * connection that has been established.
035 * <BR>
036 * <BLOCKQUOTE>
037 *   <B>NOTE:</B>  This class, and other classes within the
038 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
039 *   supported for use against Ping Identity, UnboundID, and
040 *   Nokia/Alcatel-Lucent 8661 server products.  These classes provide support
041 *   for proprietary functionality or for external specifications that are not
042 *   considered stable or mature enough to be guaranteed to work in an
043 *   interoperable way with other types of LDAP servers.
044 * </BLOCKQUOTE>
045 */
046@NotMutable()
047@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
048public final class ConnectAccessLogMessage
049       extends AccessLogMessage
050{
051  /**
052   * The serial version UID for this serializable class.
053   */
054  private static final long serialVersionUID = 4254346309071273212L;
055
056
057
058  // The name of the client connection policy selected for the client.
059  private final String clientConnectionPolicy;
060
061  // The name of the protocol used by the client.
062  private final String protocolName;
063
064  // The source address for the client connection.
065  private final String sourceAddress;
066
067  // The server address to which the client connection is established.
068  private final String targetAddress;
069
070
071
072  /**
073   * Creates a new connect access log message from the provided message string.
074   *
075   * @param  s  The string to be parsed as a connect access log message.
076   *
077   * @throws  LogException  If the provided string cannot be parsed as a valid
078   *                        log message.
079   */
080  public ConnectAccessLogMessage(final String s)
081         throws LogException
082  {
083    this(new LogMessage(s));
084  }
085
086
087
088  /**
089   * Creates a new connect access log message from the provided log message.
090   *
091   * @param  m  The log message to be parsed as a connect access log message.
092   */
093  public ConnectAccessLogMessage(final LogMessage m)
094  {
095    super(m);
096
097    sourceAddress          = getNamedValue("from");
098    targetAddress          = getNamedValue("to");
099    protocolName           = getNamedValue("protocol");
100    clientConnectionPolicy = getNamedValue("clientConnectionPolicy");
101  }
102
103
104
105  /**
106   * Retrieves the source address for the client connection.
107   *
108   * @return  The source address for the client connection, or {@code null} if
109   *          it is not included in the log message.
110   */
111  public String getSourceAddress()
112  {
113    return sourceAddress;
114  }
115
116
117
118  /**
119   * Retrieves the server address to which the client connection is established.
120   *
121   * @return  The server address to which the client connection is established,
122   *          or {@code null} if it is not included in the log message.
123   */
124  public String getTargetAddress()
125  {
126    return targetAddress;
127  }
128
129
130
131  /**
132   * Retrieves the name of the protocol the client is using to communicate with
133   * the Directory Server.
134   *
135   * @return  The name of the protocol the client is using to communicate with
136   *          the Directory Server, or {@code null} if it is not included in the
137   *          log message.
138   */
139  public String getProtocolName()
140  {
141    return protocolName;
142  }
143
144
145
146  /**
147   * Retrieves the name of the client connection policy that was selected for
148   * the client connection.
149   *
150   * @return  The name of the client connection policy that was selected for the
151   *          client connection, or {@code null} if it is not included in the
152   *          log message.
153   */
154  public String getClientConnectionPolicy()
155  {
156    return clientConnectionPolicy;
157  }
158
159
160
161  /**
162   * {@inheritDoc}
163   */
164  @Override()
165  public AccessLogMessageType getMessageType()
166  {
167    return AccessLogMessageType.CONNECT;
168  }
169}