mobile/android/thirdparty/ch/boye/httpclientandroidlib/conn/scheme/SocketFactory.java

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

michael@0 1 /*
michael@0 2 * ====================================================================
michael@0 3 * Licensed to the Apache Software Foundation (ASF) under one
michael@0 4 * or more contributor license agreements. See the NOTICE file
michael@0 5 * distributed with this work for additional information
michael@0 6 * regarding copyright ownership. The ASF licenses this file
michael@0 7 * to you under the Apache License, Version 2.0 (the
michael@0 8 * "License"); you may not use this file except in compliance
michael@0 9 * with the License. You may obtain a copy of the License at
michael@0 10 *
michael@0 11 * http://www.apache.org/licenses/LICENSE-2.0
michael@0 12 *
michael@0 13 * Unless required by applicable law or agreed to in writing,
michael@0 14 * software distributed under the License is distributed on an
michael@0 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
michael@0 16 * KIND, either express or implied. See the License for the
michael@0 17 * specific language governing permissions and limitations
michael@0 18 * under the License.
michael@0 19 * ====================================================================
michael@0 20 *
michael@0 21 * This software consists of voluntary contributions made by many
michael@0 22 * individuals on behalf of the Apache Software Foundation. For more
michael@0 23 * information on the Apache Software Foundation, please see
michael@0 24 * <http://www.apache.org/>.
michael@0 25 *
michael@0 26 */
michael@0 27
michael@0 28 package ch.boye.httpclientandroidlib.conn.scheme;
michael@0 29
michael@0 30 import java.io.IOException;
michael@0 31 import java.net.InetAddress;
michael@0 32 import java.net.Socket;
michael@0 33 import java.net.UnknownHostException;
michael@0 34
michael@0 35 import ch.boye.httpclientandroidlib.conn.ConnectTimeoutException;
michael@0 36 import ch.boye.httpclientandroidlib.params.HttpParams;
michael@0 37
michael@0 38 /**
michael@0 39 * A factory for creating, initializing and connecting sockets.
michael@0 40 * The factory encapsulates the logic for establishing a socket connection.
michael@0 41 *
michael@0 42 * @since 4.0
michael@0 43 *
michael@0 44 * @deprecated use {@link SchemeSocketFactory}
michael@0 45 */
michael@0 46 @Deprecated
michael@0 47 public interface SocketFactory {
michael@0 48
michael@0 49 /**
michael@0 50 * Creates a new, unconnected socket.
michael@0 51 * The socket should subsequently be passed to
michael@0 52 * {@link #connectSocket connectSocket}.
michael@0 53 *
michael@0 54 * @return a new socket
michael@0 55 *
michael@0 56 * @throws IOException if an I/O error occurs while creating the socket
michael@0 57 */
michael@0 58 Socket createSocket()
michael@0 59 throws IOException;
michael@0 60
michael@0 61 /**
michael@0 62 * Connects a socket to the given host.
michael@0 63 *
michael@0 64 * @param sock the socket to connect, as obtained from
michael@0 65 * {@link #createSocket createSocket}.
michael@0 66 * <code>null</code> indicates that a new socket
michael@0 67 * should be created and connected.
michael@0 68 * @param host the host to connect to
michael@0 69 * @param port the port to connect to on the host
michael@0 70 * @param localAddress the local address to bind the socket to, or
michael@0 71 * <code>null</code> for any
michael@0 72 * @param localPort the port on the local machine,
michael@0 73 * 0 or a negative number for any
michael@0 74 * @param params additional {@link HttpParams parameters} for connecting
michael@0 75 *
michael@0 76 * @return the connected socket. The returned object may be different
michael@0 77 * from the <code>sock</code> argument if this factory supports
michael@0 78 * a layered protocol.
michael@0 79 *
michael@0 80 * @throws IOException if an I/O error occurs
michael@0 81 * @throws UnknownHostException if the IP address of the target host
michael@0 82 * can not be determined
michael@0 83 * @throws ConnectTimeoutException if the socket cannot be connected
michael@0 84 * within the time limit defined in the <code>params</code>
michael@0 85 */
michael@0 86 Socket connectSocket(
michael@0 87 Socket sock,
michael@0 88 String host,
michael@0 89 int port,
michael@0 90 InetAddress localAddress,
michael@0 91 int localPort,
michael@0 92 HttpParams params
michael@0 93 ) throws IOException, UnknownHostException, ConnectTimeoutException;
michael@0 94
michael@0 95 /**
michael@0 96 * Checks whether a socket provides a secure connection.
michael@0 97 * The socket must be {@link #connectSocket connected}
michael@0 98 * by this factory.
michael@0 99 * The factory will <i>not</i> perform I/O operations
michael@0 100 * in this method.
michael@0 101 * <br/>
michael@0 102 * As a rule of thumb, plain sockets are not secure and
michael@0 103 * TLS/SSL sockets are secure. However, there may be
michael@0 104 * application specific deviations. For example, a plain
michael@0 105 * socket to a host in the same intranet ("trusted zone")
michael@0 106 * could be considered secure. On the other hand, a
michael@0 107 * TLS/SSL socket could be considered insecure based on
michael@0 108 * the cipher suite chosen for the connection.
michael@0 109 *
michael@0 110 * @param sock the connected socket to check
michael@0 111 *
michael@0 112 * @return <code>true</code> if the connection of the socket
michael@0 113 * should be considered secure, or
michael@0 114 * <code>false</code> if it should not
michael@0 115 *
michael@0 116 * @throws IllegalArgumentException
michael@0 117 * if the argument is invalid, for example because it is
michael@0 118 * not a connected socket or was created by a different
michael@0 119 * socket factory.
michael@0 120 * Note that socket factories are <i>not</i> required to
michael@0 121 * check these conditions, they may simply return a default
michael@0 122 * value when called with an invalid socket argument.
michael@0 123 */
michael@0 124 boolean isSecure(Socket sock)
michael@0 125 throws IllegalArgumentException;
michael@0 126
michael@0 127 }

mercurial