View Javadoc

1   /*
2    * ====================================================================
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *   http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing,
14   * software distributed under the License is distributed on an
15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16   * KIND, either express or implied.  See the License for the
17   * specific language governing permissions and limitations
18   * under the License.
19   * ====================================================================
20   *
21   * This software consists of voluntary contributions made by many
22   * individuals on behalf of the Apache Software Foundation.  For more
23   * information on the Apache Software Foundation, please see
24   * <http://www.apache.org/>.
25   *
26   */
27  package org.apache.http.impl.conn;
28  
29  import org.apache.http.annotation.ThreadSafe;
30  import org.apache.http.conn.scheme.PlainSocketFactory;
31  import org.apache.http.conn.scheme.Scheme;
32  import org.apache.http.conn.scheme.SchemeRegistry;
33  import org.apache.http.conn.ssl.SSLSocketFactory;
34  
35  /**
36   * @since 4.1
37   *
38   * @deprecated (4.3) use {@link org.apache.http.impl.client.HttpClientBuilder}.
39   */
40  @ThreadSafe
41  @Deprecated
42  public final class SchemeRegistryFactory {
43  
44      /**
45       * Initializes default scheme registry based on JSSE defaults. System properties will
46       * not be taken into consideration.
47       */
48      public static SchemeRegistry createDefault() {
49          final SchemeRegistry registry = new SchemeRegistry();
50          registry.register(
51                  new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
52          registry.register(
53                  new Scheme("https", 443, SSLSocketFactory.getSocketFactory()));
54          return registry;
55      }
56  
57      /**
58       * Initializes default scheme registry using system properties as described in
59       * <a href="http://download.oracle.com/javase/1,5.0/docs/guide/security/jsse/JSSERefGuide.html">
60       * "JavaTM Secure Socket Extension (JSSE) Reference Guide for the JavaTM 2 Platform
61       * Standard Edition 5</a>
62       * <p>
63       * The following system properties are taken into account by this method:
64       * <ul>
65       *  <li>ssl.TrustManagerFactory.algorithm</li>
66       *  <li>javax.net.ssl.trustStoreType</li>
67       *  <li>javax.net.ssl.trustStore</li>
68       *  <li>javax.net.ssl.trustStoreProvider</li>
69       *  <li>javax.net.ssl.trustStorePassword</li>
70       *  <li>java.home</li>
71       *  <li>ssl.KeyManagerFactory.algorithm</li>
72       *  <li>javax.net.ssl.keyStoreType</li>
73       *  <li>javax.net.ssl.keyStore</li>
74       *  <li>javax.net.ssl.keyStoreProvider</li>
75       *  <li>javax.net.ssl.keyStorePassword</li>
76       * </ul>
77       * <p>
78       *
79       * @since 4.2
80       */
81      public static SchemeRegistry createSystemDefault() {
82          final SchemeRegistry registry = new SchemeRegistry();
83          registry.register(
84                  new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
85          registry.register(
86                  new Scheme("https", 443, SSLSocketFactory.getSystemSocketFactory()));
87          return registry;
88      }
89  }
90