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 client
040     * certificate that has been presented to the server.
041     */
042    @NotMutable()
043    @ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
044    public final class ClientCertificateAccessLogMessage
045           extends AccessLogMessage
046    {
047      /**
048       * The serial version UID for this serializable class.
049       */
050      private static final long serialVersionUID = -2585979292882352926L;
051    
052    
053    
054      // The subject DN for the issuer certificate.
055      private final String issuerSubject;
056    
057      // The subject DN for the client certificate.
058      private final String peerSubject;
059    
060    
061    
062      /**
063       * Creates a new client certificate access log message from the provided
064       * message string.
065       *
066       * @param  s  The string to be parsed as a client certificate access log
067       *            message.
068       *
069       * @throws  LogException  If the provided string cannot be parsed as a valid
070       *                        log message.
071       */
072      public ClientCertificateAccessLogMessage(final String s)
073             throws LogException
074      {
075        this(new LogMessage(s));
076      }
077    
078    
079    
080      /**
081       * Creates a new connect access log message from the provided log message.
082       *
083       * @param  m  The log message to be parsed as a connect access log message.
084       */
085      public ClientCertificateAccessLogMessage(final LogMessage m)
086      {
087        super(m);
088    
089        peerSubject   = getNamedValue("peerSubject");
090        issuerSubject = getNamedValue("issuerSubject");
091      }
092    
093    
094    
095      /**
096       * Retrieves the subject of the peer certificate.
097       *
098       * @return  The subject of the peer certificate, or {@code null} if it is not
099       *          included in the log message.
100       */
101      public String getPeerSubject()
102      {
103        return peerSubject;
104      }
105    
106    
107    
108      /**
109       * Retrieves the subject of the issuer certificate.
110       *
111       * @return  The subject of the issuer certificate, or {@code null} if it is
112       *          not included in the log message.
113       */
114      public String getIssuerSubject()
115      {
116        return issuerSubject;
117      }
118    
119    
120    
121      /**
122       * {@inheritDoc}
123       */
124      @Override()
125      public AccessLogMessageType getMessageType()
126      {
127        return AccessLogMessageType.CLIENT_CERTIFICATE;
128      }
129    }