Jerome Poichet | 7c99785 | 2014-05-20 10:50:05 -0700 | [diff] [blame^] | 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.SSLServerSocketFactory; |
| 24 | import javax.net.ssl.TrustManager; |
| 25 | |
| 26 | |
| 27 | /** |
| 28 | * An {@link SSLServerSocketFactory} that performs no verification on client |
| 29 | * certificates; ie, is all-trusting. |
| 30 | * |
| 31 | * @see DummyTrustManager |
| 32 | */ |
| 33 | public class DummySSLServerSocketFactory extends SSLServerSocketFactoryWrapper { |
| 34 | |
| 35 | DummySSLServerSocketFactory(KeyManager[] keyManagers, |
| 36 | TrustManager[] trustManagers) throws KeyManagementException, |
| 37 | NoSuchAlgorithmException { |
| 38 | super(keyManagers, trustManagers); |
| 39 | } |
| 40 | |
| 41 | public static DummySSLServerSocketFactory fromKeyManagers( |
| 42 | KeyManager[] keyManagers) throws KeyManagementException, |
| 43 | NoSuchAlgorithmException { |
| 44 | TrustManager[] trustManagers = { new DummyTrustManager() }; |
| 45 | return new DummySSLServerSocketFactory(keyManagers, trustManagers); |
| 46 | } |
| 47 | |
| 48 | } |