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.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 Alcatel-Lucent 8661
040 *   server products.  These classes provide support for proprietary
041 *   functionality or for external specifications that are not considered stable
042 *   or mature enough to be guaranteed to work in an interoperable way with
043 *   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  /**
074   * Creates a new connect access log message from the provided message string.
075   *
076   * @param  s  The string to be parsed as a connect access log message.
077   *
078   * @throws  LogException  If the provided string cannot be parsed as a valid
079   *                        log message.
080   */
081  public ConnectAccessLogMessage(final String s)
082         throws LogException
083  {
084    this(new LogMessage(s));
085  }
086
087
088
089  /**
090   * Creates a new connect access log message from the provided log message.
091   *
092   * @param  m  The log message to be parsed as a connect access log message.
093   */
094  public ConnectAccessLogMessage(final LogMessage m)
095  {
096    super(m);
097
098    sourceAddress          = getNamedValue("from");
099    targetAddress          = getNamedValue("to");
100    protocolName           = getNamedValue("protocol");
101    clientConnectionPolicy = getNamedValue("clientConnectionPolicy");
102  }
103
104
105
106  /**
107   * Retrieves the source address for the client connection.
108   *
109   * @return  The source address for the client connection, or {@code null} if
110   *          it is not included in the log message.
111   */
112  public String getSourceAddress()
113  {
114    return sourceAddress;
115  }
116
117
118
119  /**
120   * Retrieves the server address to which the client connection is established.
121   *
122   * @return  The server address to which the client connection is established,
123   *          or {@code null} if it is not included in the log message.
124   */
125  public String getTargetAddress()
126  {
127    return targetAddress;
128  }
129
130
131
132  /**
133   * Retrieves the name of the protocol the client is using to communicate with
134   * the Directory Server.
135   *
136   * @return  The name of the protocol the client is using to communicate with
137   *          the Directory Server, or {@code null} if it is not included in the
138   *          log message.
139   */
140  public String getProtocolName()
141  {
142    return protocolName;
143  }
144
145
146
147  /**
148   * Retrieves the name of the client connection policy that was selected for
149   * the client connection.
150   *
151   * @return  The name of the client connection policy that was selected for the
152   *          client connection, or {@code null} if it is not included in the
153   *          log message.
154   */
155  public String getClientConnectionPolicy()
156  {
157    return clientConnectionPolicy;
158  }
159
160
161
162  /**
163   * {@inheritDoc}
164   */
165  @Override()
166  public AccessLogMessageType getMessageType()
167  {
168    return AccessLogMessageType.CONNECT;
169  }
170}