• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2009 Google Inc.  All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.google.polo.ssl;
18 
19 import java.security.KeyManagementException;
20 import java.security.NoSuchAlgorithmException;
21 
22 import javax.net.ssl.KeyManager;
23 import javax.net.ssl.SSLSocketFactory;
24 import javax.net.ssl.TrustManager;
25 
26 
27 /**
28  * An {@link SSLSocketFactory} that performs no verification on server
29  * certificates; ie, is all-trusting.
30  *
31  * @see DummyTrustManager
32  */
33 public class DummySSLSocketFactory extends SSLSocketFactoryWrapper {
34 
DummySSLSocketFactory(KeyManager[] keyManagers, TrustManager[] trustManagers)35   DummySSLSocketFactory(KeyManager[] keyManagers,
36       TrustManager[] trustManagers) throws KeyManagementException,
37       NoSuchAlgorithmException {
38     super(keyManagers, trustManagers);
39   }
40 
fromKeyManagers(KeyManager[] keyManagers)41   public static DummySSLSocketFactory fromKeyManagers(KeyManager[] keyManagers)
42       throws KeyManagementException, NoSuchAlgorithmException {
43     TrustManager[] trustManagers = { new DummyTrustManager() };
44     return new DummySSLSocketFactory(keyManagers, trustManagers);
45   }
46 
47 }
48