use of org.apache.manifoldcf.connectorcommon.common.InterruptibleSocketFactory in project manifoldcf by apache.
the class ElasticSearchConnector method getSession.
protected HttpClient getSession() throws ManifoldCFException {
if (client == null) {
int socketTimeout = 900000;
int connectionTimeout = 60000;
// Load configuration from parameters
final ElasticSearchConfig config = new ElasticSearchConfig(params);
final IKeystoreManager keystoreManager = config.getSSLKeystore();
final String userName = config.getUserName();
final String password = config.getPassword();
final Credentials credentials;
if (userName != null && userName.length() > 0)
credentials = new UsernamePasswordCredentials(userName, password);
else
credentials = null;
// Set up ingest ssl if indicated
SSLConnectionSocketFactory myFactory = null;
if (keystoreManager != null) {
myFactory = new SSLConnectionSocketFactory(new InterruptibleSocketFactory(keystoreManager.getSecureSocketFactory(), connectionTimeout), NoopHostnameVerifier.INSTANCE);
} else {
myFactory = SSLConnectionSocketFactory.getSocketFactory();
}
// Set up connection manager
PoolingHttpClientConnectionManager poolingConnectionManager = new PoolingHttpClientConnectionManager(RegistryBuilder.<ConnectionSocketFactory>create().register("http", PlainConnectionSocketFactory.getSocketFactory()).register("https", myFactory).build());
poolingConnectionManager.setDefaultMaxPerRoute(1);
poolingConnectionManager.setValidateAfterInactivity(2000);
poolingConnectionManager.setDefaultSocketConfig(SocketConfig.custom().setTcpNoDelay(true).setSoTimeout(socketTimeout).build());
connectionManager = poolingConnectionManager;
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
if (credentials != null) {
credentialsProvider.setCredentials(AuthScope.ANY, credentials);
}
RequestConfig.Builder requestBuilder = RequestConfig.custom().setCircularRedirectsAllowed(true).setSocketTimeout(socketTimeout).setExpectContinueEnabled(true).setConnectTimeout(connectionTimeout).setConnectionRequestTimeout(socketTimeout);
client = HttpClients.custom().setConnectionManager(connectionManager).setMaxConnTotal(1).disableAutomaticRetries().setDefaultRequestConfig(requestBuilder.build()).setDefaultCredentialsProvider(credentialsProvider).setRequestExecutor(new HttpRequestExecutor(socketTimeout)).build();
}
expirationTime = System.currentTimeMillis() + EXPIRATION_INTERVAL;
return client;
}
use of org.apache.manifoldcf.connectorcommon.common.InterruptibleSocketFactory in project manifoldcf by apache.
the class CswsConnector method getSession.
protected void getSession() throws ManifoldCFException, ServiceInterruption {
getSessionParameters();
if (hasConnected == false) {
int socketTimeout = 900000;
int connectionTimeout = 300000;
// Set up ingest ssl if indicated
final SSLConnectionSocketFactory myFactory;
final javax.net.ssl.SSLSocketFactory mySslFactory;
if (serverHTTPSKeystore != null) {
mySslFactory = new InterruptibleSocketFactory(serverHTTPSKeystore.getSecureSocketFactory(), connectionTimeout);
myFactory = new SSLConnectionSocketFactory(mySslFactory, NoopHostnameVerifier.INSTANCE);
} else {
mySslFactory = null;
myFactory = SSLConnectionSocketFactory.getSocketFactory();
}
// Set up connection manager
PoolingHttpClientConnectionManager poolingConnectionManager = new PoolingHttpClientConnectionManager(RegistryBuilder.<ConnectionSocketFactory>create().register("http", PlainConnectionSocketFactory.getSocketFactory()).register("https", myFactory).build());
poolingConnectionManager.setDefaultMaxPerRoute(1);
poolingConnectionManager.setValidateAfterInactivity(2000);
poolingConnectionManager.setDefaultSocketConfig(SocketConfig.custom().setTcpNoDelay(true).setSoTimeout(socketTimeout).build());
connectionManager = poolingConnectionManager;
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
// Set up authentication to use
if (serverHTTPNTLMDomain != null) {
credentialsProvider.setCredentials(AuthScope.ANY, new NTCredentials(serverHTTPNTLMUsername, serverHTTPNTLMPassword, currentHost, serverHTTPNTLMDomain));
}
HttpClientBuilder builder = HttpClients.custom().setConnectionManager(connectionManager).disableAutomaticRetries().setDefaultRequestConfig(RequestConfig.custom().setCircularRedirectsAllowed(true).setSocketTimeout(socketTimeout).setExpectContinueEnabled(true).setConnectTimeout(connectionTimeout).setConnectionRequestTimeout(socketTimeout).build()).setDefaultCredentialsProvider(credentialsProvider).setRequestExecutor(new HttpRequestExecutor(socketTimeout)).setRedirectStrategy(new LaxRedirectStrategy());
httpClient = builder.build();
// Construct the various URLs we need
final String baseURL = serverProtocol + "://" + serverName + ":" + serverPort;
final String authenticationServiceURL = baseURL + authenticationServicePath;
final String documentManagementServiceURL = baseURL + documentManagementServicePath;
final String contentServiceServiceURL = baseURL + contentServiceServicePath;
final String memberServiceServiceURL = baseURL + memberServiceServicePath;
final String searchServiceServiceURL = baseURL + searchServiceServicePath;
// Build web services connection management object
if (Logging.connectors.isDebugEnabled()) {
String passwordExists = (serverPassword != null && serverPassword.length() > 0) ? "password exists" : "";
Logging.connectors.debug("Csws: Csws Session: Server='" + serverName + "'; port='" + serverPort + "'; user name='" + serverUsername + "'; " + passwordExists);
}
// Construct a new csws session object for setting up this session
cswsSession = new CswsSession(serverUsername, serverPassword, serverHTTPSKeystore, 1000L * 60L * 15L, authenticationServiceURL, documentManagementServiceURL, contentServiceServiceURL, memberServiceServiceURL, searchServiceServiceURL);
final GetSessionThread t = new GetSessionThread();
try {
t.start();
t.finishUp();
hasConnected = true;
} catch (InterruptedException e) {
t.interrupt();
throw new ManifoldCFException("Interrupted: " + e.getMessage(), e, ManifoldCFException.INTERRUPTED);
}
}
expirationTime = System.currentTimeMillis() + expirationInterval;
}
use of org.apache.manifoldcf.connectorcommon.common.InterruptibleSocketFactory in project manifoldcf by apache.
the class ConfluenceClient method connect.
/**
* <p>Connect methods used to initialize the underlying client</p>
* @throws ManifoldCFException
*/
private void connect() throws ManifoldCFException {
int socketTimeout = 900000;
int connectionTimeout = 60000;
javax.net.ssl.SSLSocketFactory httpsSocketFactory = KeystoreManagerFactory.getTrustingSecureSocketFactory();
SSLConnectionSocketFactory myFactory = new SSLConnectionSocketFactory(new InterruptibleSocketFactory(httpsSocketFactory, connectionTimeout), NoopHostnameVerifier.INSTANCE);
PoolingHttpClientConnectionManager poolingConnectionManager = new PoolingHttpClientConnectionManager(RegistryBuilder.<ConnectionSocketFactory>create().register("http", PlainConnectionSocketFactory.getSocketFactory()).register("https", myFactory).build());
poolingConnectionManager.setDefaultMaxPerRoute(1);
poolingConnectionManager.setValidateAfterInactivity(2000);
poolingConnectionManager.setDefaultSocketConfig(SocketConfig.custom().setTcpNoDelay(true).setSoTimeout(socketTimeout).build());
RequestConfig.Builder requestBuilder = RequestConfig.custom().setCircularRedirectsAllowed(true).setSocketTimeout(socketTimeout).setExpectContinueEnabled(true).setConnectTimeout(connectionTimeout).setConnectionRequestTimeout(socketTimeout);
httpClient = HttpClients.custom().setConnectionManager(poolingConnectionManager).disableAutomaticRetries().setDefaultRequestConfig(requestBuilder.build()).setRequestExecutor(new HttpRequestExecutor(socketTimeout)).setRedirectStrategy(new LaxRedirectStrategy()).build();
}
use of org.apache.manifoldcf.connectorcommon.common.InterruptibleSocketFactory in project manifoldcf by apache.
the class LivelinkConnector method getSession.
protected void getSession() throws ManifoldCFException, ServiceInterruption {
getSessionParameters();
if (hasConnected == false) {
int socketTimeout = 900000;
int connectionTimeout = 300000;
// Set up ingest ssl if indicated
SSLConnectionSocketFactory myFactory = null;
if (ingestKeystoreManager != null) {
myFactory = new SSLConnectionSocketFactory(new InterruptibleSocketFactory(ingestKeystoreManager.getSecureSocketFactory(), connectionTimeout), NoopHostnameVerifier.INSTANCE);
} else {
myFactory = SSLConnectionSocketFactory.getSocketFactory();
}
// Set up connection manager
PoolingHttpClientConnectionManager poolingConnectionManager = new PoolingHttpClientConnectionManager(RegistryBuilder.<ConnectionSocketFactory>create().register("http", PlainConnectionSocketFactory.getSocketFactory()).register("https", myFactory).build());
poolingConnectionManager.setDefaultMaxPerRoute(1);
poolingConnectionManager.setValidateAfterInactivity(2000);
poolingConnectionManager.setDefaultSocketConfig(SocketConfig.custom().setTcpNoDelay(true).setSoTimeout(socketTimeout).build());
connectionManager = poolingConnectionManager;
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
// Set up authentication to use
if (ingestNtlmDomain != null) {
credentialsProvider.setCredentials(AuthScope.ANY, new NTCredentials(ingestNtlmUsername, ingestNtlmPassword, currentHost, ingestNtlmDomain));
}
HttpClientBuilder builder = HttpClients.custom().setConnectionManager(connectionManager).disableAutomaticRetries().setDefaultRequestConfig(RequestConfig.custom().setCircularRedirectsAllowed(true).setSocketTimeout(socketTimeout).setExpectContinueEnabled(true).setConnectTimeout(connectionTimeout).setConnectionRequestTimeout(socketTimeout).build()).setDefaultCredentialsProvider(credentialsProvider).setRequestExecutor(new HttpRequestExecutor(socketTimeout)).setRedirectStrategy(new LaxRedirectStrategy());
httpClient = builder.build();
// System.out.println("Connection server object = "+llServer.toString());
// Establish the actual connection
int sanityRetryCount = FAILURE_RETRY_COUNT;
while (true) {
GetSessionThread t = new GetSessionThread();
try {
t.start();
t.finishUp();
hasConnected = true;
break;
} catch (InterruptedException e) {
t.interrupt();
throw new ManifoldCFException("Interrupted: " + e.getMessage(), e, ManifoldCFException.INTERRUPTED);
} catch (RuntimeException e2) {
sanityRetryCount = handleLivelinkRuntimeException(e2, sanityRetryCount, true);
}
}
}
expirationTime = System.currentTimeMillis() + expirationInterval;
}
use of org.apache.manifoldcf.connectorcommon.common.InterruptibleSocketFactory in project manifoldcf by apache.
the class ConfluenceClient method connect.
/**
* <p>
* Connect methods used to initialize the underlying client
* </p>
*
* @throws ManifoldCFException
*/
private void connect() throws ManifoldCFException {
final javax.net.ssl.SSLSocketFactory httpsSocketFactory = KeystoreManagerFactory.getTrustingSecureSocketFactory();
final SSLConnectionSocketFactory myFactory = new SSLConnectionSocketFactory(new InterruptibleSocketFactory(httpsSocketFactory, connectionTimeout), NoopHostnameVerifier.INSTANCE);
final PoolingHttpClientConnectionManager poolingConnectionManager = new PoolingHttpClientConnectionManager(RegistryBuilder.<ConnectionSocketFactory>create().register("http", PlainConnectionSocketFactory.getSocketFactory()).register("https", myFactory).build());
poolingConnectionManager.setDefaultMaxPerRoute(1);
poolingConnectionManager.setValidateAfterInactivity(2000);
poolingConnectionManager.setDefaultSocketConfig(SocketConfig.custom().setTcpNoDelay(true).setSoTimeout(socketTimeout).build());
final RequestConfig.Builder requestBuilder = RequestConfig.custom().setCircularRedirectsAllowed(true).setSocketTimeout(socketTimeout).setExpectContinueEnabled(true).setConnectTimeout(connectionTimeout).setConnectionRequestTimeout(socketTimeout);
httpClient = HttpClients.custom().setConnectionManager(poolingConnectionManager).disableAutomaticRetries().setDefaultRequestConfig(requestBuilder.build()).setRequestExecutor(new HttpRequestExecutor(socketTimeout)).setRedirectStrategy(new LaxRedirectStrategy()).build();
}
Aggregations