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