001    /*
002     * Copyright 2014-2015 UnboundID Corp.
003     * All Rights Reserved.
004     */
005    /*
006     * Copyright (C) 2014-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.util.ssl;
022    
023    
024    
025    import javax.net.ssl.SSLSocket;
026    
027    import com.unboundid.ldap.sdk.LDAPException;
028    import com.unboundid.util.NotMutable;
029    import com.unboundid.util.ThreadSafety;
030    import com.unboundid.util.ThreadSafetyLevel;
031    
032    
033    
034    /**
035     * This class provides an implementation of an {@code SSLSocket} verifier that
036     * will blindly accept any {@code SSLSocket}.
037     */
038    @NotMutable()
039    @ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
040    public final class TrustAllSSLSocketVerifier
041           extends SSLSocketVerifier
042    {
043      /**
044       * A singleton instance of this SSL socket verifier.
045       */
046      private static final TrustAllSSLSocketVerifier INSTANCE =
047           new TrustAllSSLSocketVerifier();
048    
049    
050    
051      /**
052       * Creates a new instance of this {@code SSLSocket} verifier.
053       */
054      private TrustAllSSLSocketVerifier()
055      {
056        // No implementation is required.
057      }
058    
059    
060    
061      /**
062       * Retrieves a singleton instance of this SSL socket verifier.
063       *
064       * @return  A singleton instance of this SSL socket verifier.
065       */
066      public static TrustAllSSLSocketVerifier getInstance()
067      {
068        return INSTANCE;
069      }
070    
071    
072    
073      /**
074       * Verifies that the provided {@code SSLSocket} is acceptable and the
075       * connection should be allowed to remain established.
076       *
077       * @param  host       The address to which the client intended the connection
078       *                    to be established.
079       * @param  port       The port to which the client intended the connection to
080       *                    be established.
081       * @param  sslSocket  The {@code SSLSocket} that should be verified.
082       *
083       * @throws LDAPException  If a problem is identified that should prevent the
084       *                         provided {@code SSLSocket} from remaining
085       *                         established.
086       */
087      @Override()
088      public void verifySSLSocket(final String host, final int port,
089                                  final SSLSocket sslSocket)
090           throws LDAPException
091      {
092        // No implementation is required.  The SSLSocket will be considered
093        // acceptable as long as this method does not throw an exception.
094      }
095    }