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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/mobile/android/thirdparty/ch/boye/httpclientandroidlib/conn/scheme/SocketFactory.java	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,127 @@
     1.4 +/*
     1.5 + * ====================================================================
     1.6 + * Licensed to the Apache Software Foundation (ASF) under one
     1.7 + * or more contributor license agreements.  See the NOTICE file
     1.8 + * distributed with this work for additional information
     1.9 + * regarding copyright ownership.  The ASF licenses this file
    1.10 + * to you under the Apache License, Version 2.0 (the
    1.11 + * "License"); you may not use this file except in compliance
    1.12 + * with the License.  You may obtain a copy of the License at
    1.13 + *
    1.14 + *   http://www.apache.org/licenses/LICENSE-2.0
    1.15 + *
    1.16 + * Unless required by applicable law or agreed to in writing,
    1.17 + * software distributed under the License is distributed on an
    1.18 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    1.19 + * KIND, either express or implied.  See the License for the
    1.20 + * specific language governing permissions and limitations
    1.21 + * under the License.
    1.22 + * ====================================================================
    1.23 + *
    1.24 + * This software consists of voluntary contributions made by many
    1.25 + * individuals on behalf of the Apache Software Foundation.  For more
    1.26 + * information on the Apache Software Foundation, please see
    1.27 + * <http://www.apache.org/>.
    1.28 + *
    1.29 + */
    1.30 +
    1.31 +package ch.boye.httpclientandroidlib.conn.scheme;
    1.32 +
    1.33 +import java.io.IOException;
    1.34 +import java.net.InetAddress;
    1.35 +import java.net.Socket;
    1.36 +import java.net.UnknownHostException;
    1.37 +
    1.38 +import ch.boye.httpclientandroidlib.conn.ConnectTimeoutException;
    1.39 +import ch.boye.httpclientandroidlib.params.HttpParams;
    1.40 +
    1.41 +/**
    1.42 + * A factory for creating, initializing and connecting sockets.
    1.43 + * The factory encapsulates the logic for establishing a socket connection.
    1.44 + *
    1.45 + * @since 4.0
    1.46 + *
    1.47 + * @deprecated use {@link SchemeSocketFactory}
    1.48 + */
    1.49 +@Deprecated
    1.50 +public interface SocketFactory {
    1.51 +
    1.52 +    /**
    1.53 +     * Creates a new, unconnected socket.
    1.54 +     * The socket should subsequently be passed to
    1.55 +     * {@link #connectSocket connectSocket}.
    1.56 +     *
    1.57 +     * @return  a new socket
    1.58 +     *
    1.59 +     * @throws IOException if an I/O error occurs while creating the socket
    1.60 +     */
    1.61 +    Socket createSocket()
    1.62 +        throws IOException;
    1.63 +
    1.64 +    /**
    1.65 +     * Connects a socket to the given host.
    1.66 +     *
    1.67 +     * @param sock      the socket to connect, as obtained from
    1.68 +     *                  {@link #createSocket createSocket}.
    1.69 +     *                  <code>null</code> indicates that a new socket
    1.70 +     *                  should be created and connected.
    1.71 +     * @param host      the host to connect to
    1.72 +     * @param port      the port to connect to on the host
    1.73 +     * @param localAddress the local address to bind the socket to, or
    1.74 +     *                  <code>null</code> for any
    1.75 +     * @param localPort the port on the local machine,
    1.76 +     *                  0 or a negative number for any
    1.77 +     * @param params    additional {@link HttpParams parameters} for connecting
    1.78 +     *
    1.79 +     * @return  the connected socket. The returned object may be different
    1.80 +     *          from the <code>sock</code> argument if this factory supports
    1.81 +     *          a layered protocol.
    1.82 +     *
    1.83 +     * @throws IOException if an I/O error occurs
    1.84 +     * @throws UnknownHostException if the IP address of the target host
    1.85 +     *          can not be determined
    1.86 +     * @throws ConnectTimeoutException if the socket cannot be connected
    1.87 +     *          within the time limit defined in the <code>params</code>
    1.88 +     */
    1.89 +    Socket connectSocket(
    1.90 +        Socket sock,
    1.91 +        String host,
    1.92 +        int port,
    1.93 +        InetAddress localAddress,
    1.94 +        int localPort,
    1.95 +        HttpParams params
    1.96 +    ) throws IOException, UnknownHostException, ConnectTimeoutException;
    1.97 +
    1.98 +    /**
    1.99 +     * Checks whether a socket provides a secure connection.
   1.100 +     * The socket must be {@link #connectSocket connected}
   1.101 +     * by this factory.
   1.102 +     * The factory will <i>not</i> perform I/O operations
   1.103 +     * in this method.
   1.104 +     * <br/>
   1.105 +     * As a rule of thumb, plain sockets are not secure and
   1.106 +     * TLS/SSL sockets are secure. However, there may be
   1.107 +     * application specific deviations. For example, a plain
   1.108 +     * socket to a host in the same intranet ("trusted zone")
   1.109 +     * could be considered secure. On the other hand, a
   1.110 +     * TLS/SSL socket could be considered insecure based on
   1.111 +     * the cipher suite chosen for the connection.
   1.112 +     *
   1.113 +     * @param sock      the connected socket to check
   1.114 +     *
   1.115 +     * @return  <code>true</code> if the connection of the socket
   1.116 +     *          should be considered secure, or
   1.117 +     *          <code>false</code> if it should not
   1.118 +     *
   1.119 +     * @throws IllegalArgumentException
   1.120 +     *  if the argument is invalid, for example because it is
   1.121 +     *  not a connected socket or was created by a different
   1.122 +     *  socket factory.
   1.123 +     *  Note that socket factories are <i>not</i> required to
   1.124 +     *  check these conditions, they may simply return a default
   1.125 +     *  value when called with an invalid socket argument.
   1.126 +     */
   1.127 +    boolean isSecure(Socket sock)
   1.128 +        throws IllegalArgumentException;
   1.129 +
   1.130 +}

mercurial