Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 91df235e33e0519f76eb9fb9f6c19cd9a830782e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*******************************************************************************
 * Copyright (c) 2009 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.ecf.internal.provider.filetransfer.httpclient;

import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;
import javax.net.ssl.SSLSocketFactory;
import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory;
import org.eclipse.ecf.filetransfer.events.socket.ISocketEventSource;
import org.eclipse.ecf.filetransfer.events.socket.ISocketListener;
import org.eclipse.ecf.filetransfer.events.socketfactory.INonconnectedSocketFactory;

public final class ECFHttpClientSecureProtocolSocketFactory extends ECFHttpClientProtocolSocketFactory implements SecureProtocolSocketFactory {

	private ISSLSocketFactoryModifier sslSocketFactoryModifier;

	public ECFHttpClientSecureProtocolSocketFactory(final ISSLSocketFactoryModifier sslSocketFactoryModifier, ISocketEventSource source, ISocketListener socketConnectListener) {
		super(new INonconnectedSocketFactory() {
			public Socket createSocket() throws IOException {
				return sslSocketFactoryModifier.getNonconnnectedSocketFactory().createSocket();
			}

		}, source, socketConnectListener);

		this.sslSocketFactoryModifier = sslSocketFactoryModifier;
	}

	public boolean equals(Object obj) {
		return ((obj != null) && obj.getClass().equals(ECFHttpClientSecureProtocolSocketFactory.class));
	}

	public int hashCode() {
		return ECFHttpClientSecureProtocolSocketFactory.class.hashCode();
	}

	public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException, UnknownHostException {
		// Socket over the tunnel need not be monitored or do they ?
		SSLSocketFactory sslSocketFactory = sslSocketFactoryModifier.getSSLSocketFactory();
		return sslSocketFactory.createSocket(socket, host, port, autoClose);
	}

}

Back to the top