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