use of org.apache.manifoldcf.csws.CswsSession 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;
}
Aggregations