michael@0: /*
michael@0: * ====================================================================
michael@0: * Licensed to the Apache Software Foundation (ASF) under one
michael@0: * or more contributor license agreements. See the NOTICE file
michael@0: * distributed with this work for additional information
michael@0: * regarding copyright ownership. The ASF licenses this file
michael@0: * to you under the Apache License, Version 2.0 (the
michael@0: * "License"); you may not use this file except in compliance
michael@0: * with the License. You may obtain a copy of the License at
michael@0: *
michael@0: * http://www.apache.org/licenses/LICENSE-2.0
michael@0: *
michael@0: * Unless required by applicable law or agreed to in writing,
michael@0: * software distributed under the License is distributed on an
michael@0: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
michael@0: * KIND, either express or implied. See the License for the
michael@0: * specific language governing permissions and limitations
michael@0: * under the License.
michael@0: * ====================================================================
michael@0: *
michael@0: * This software consists of voluntary contributions made by many
michael@0: * individuals on behalf of the Apache Software Foundation. For more
michael@0: * information on the Apache Software Foundation, please see
michael@0: *
michael@0: * The following parameters can be used to customize the behavior of this michael@0: * class: michael@0: *
false
michael@0: *
michael@0: * @throws IllegalArgumentException if the argument is invalid
michael@0: */
michael@0: public final boolean isSecure(Socket sock)
michael@0: throws IllegalArgumentException {
michael@0:
michael@0: if (sock == null) {
michael@0: throw new IllegalArgumentException("Socket may not be null.");
michael@0: }
michael@0: // This check is performed last since it calls a method implemented
michael@0: // by the argument object. getClass() is final in java.lang.Object.
michael@0: if (sock.isClosed()) {
michael@0: throw new IllegalArgumentException("Socket is closed.");
michael@0: }
michael@0: return false;
michael@0: }
michael@0:
michael@0: /**
michael@0: * @deprecated Use {@link #connectSocket(Socket, InetSocketAddress, InetSocketAddress, HttpParams)}
michael@0: */
michael@0: @Deprecated
michael@0: public Socket connectSocket(
michael@0: final Socket socket,
michael@0: final String host, int port,
michael@0: final InetAddress localAddress, int localPort,
michael@0: final HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
michael@0: InetSocketAddress local = null;
michael@0: if (localAddress != null || localPort > 0) {
michael@0: // we need to bind explicitly
michael@0: if (localPort < 0) {
michael@0: localPort = 0; // indicates "any"
michael@0: }
michael@0: local = new InetSocketAddress(localAddress, localPort);
michael@0: }
michael@0: InetAddress remoteAddress;
michael@0: if (this.nameResolver != null) {
michael@0: remoteAddress = this.nameResolver.resolve(host);
michael@0: } else {
michael@0: remoteAddress = InetAddress.getByName(host);
michael@0: }
michael@0: InetSocketAddress remote = new InetSocketAddress(remoteAddress, port);
michael@0: return connectSocket(socket, remote, local, params);
michael@0: }
michael@0:
michael@0: }