Skip to content
Snippets Groups Projects
Commit dfe117f5 authored by kaloyane's avatar kaloyane
Browse files

[LMS-2580] bugfix: the timeout should be set to the socket (was for the...

[LMS-2580] bugfix: the timeout should be set to the socket (was for the internal httpclient connection pool)

SVN: 23436
parent f6960b71
No related merge requests found
...@@ -26,7 +26,6 @@ import java.util.regex.Matcher; ...@@ -26,7 +26,6 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpConnectionManager;
import org.apache.commons.httpclient.methods.PostMethod; import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.StringRequestEntity; import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringEscapeUtils;
...@@ -148,9 +147,8 @@ public class CrowdAuthenticationService implements IAuthenticationService ...@@ -148,9 +147,8 @@ public class CrowdAuthenticationService implements IAuthenticationService
try try
{ {
final HttpClient client = new HttpClient(); final HttpClient client = new HttpClient();
HttpConnectionManager connectionManager = client.getHttpConnectionManager();
connectionManager.getParams().setConnectionTimeout(CONNECTION_TIMEOUT);
final PostMethod post = new PostMethod(serviceUrl); final PostMethod post = new PostMethod(serviceUrl);
post.getParams().setSoTimeout(CONNECTION_TIMEOUT);
final StringRequestEntity entity = final StringRequestEntity entity =
new StringRequestEntity(message, "application/soap+xml", "utf-8"); new StringRequestEntity(message, "application/soap+xml", "utf-8");
post.setRequestEntity(entity); post.setRequestEntity(entity);
...@@ -238,7 +236,7 @@ public class CrowdAuthenticationService implements IAuthenticationService ...@@ -238,7 +236,7 @@ public class CrowdAuthenticationService implements IAuthenticationService
{ {
try try
{ {
final String xmlResponse = execute(AUTHENTICATE_APPL, application, applicationPassword); final String xmlResponse = executeAuthenticateApplication();
final String applicationToken = final String applicationToken =
StringEscapeUtils.unescapeXml(pickElementContent(xmlResponse, StringEscapeUtils.unescapeXml(pickElementContent(xmlResponse,
CrowdSoapElements.TOKEN)); CrowdSoapElements.TOKEN));
...@@ -324,12 +322,19 @@ public class CrowdAuthenticationService implements IAuthenticationService ...@@ -324,12 +322,19 @@ public class CrowdAuthenticationService implements IAuthenticationService
} }
} }
private String executeAuthenticateApplication()
{
operationLog
.info("CROWD: Attempting to authenticate as application " + application + "...");
return execute(AUTHENTICATE_APPL, application, applicationPassword);
}
private String getApplicationToken(boolean forceNewToken) private String getApplicationToken(boolean forceNewToken)
{ {
String applicationToken = applicationTokenHolder.get(); String applicationToken = applicationTokenHolder.get();
if (applicationToken == null || forceNewToken) if (applicationToken == null || forceNewToken)
{ {
final String xmlResponse = execute(AUTHENTICATE_APPL, application, applicationPassword); final String xmlResponse = executeAuthenticateApplication();
applicationToken = applicationToken =
StringEscapeUtils.unescapeXml(pickElementContent(xmlResponse, StringEscapeUtils.unescapeXml(pickElementContent(xmlResponse,
CrowdSoapElements.TOKEN)); CrowdSoapElements.TOKEN));
...@@ -339,11 +344,8 @@ public class CrowdAuthenticationService implements IAuthenticationService ...@@ -339,11 +344,8 @@ public class CrowdAuthenticationService implements IAuthenticationService
+ "' failed to authenticate."); + "' failed to authenticate.");
} else } else
{ {
if (operationLog.isDebugEnabled()) operationLog.info("CROWD: application '" + application
{ + "' successfully authenticated.");
operationLog.debug("CROWD: application '" + application
+ "' successfully authenticated.");
}
} }
applicationTokenHolder.set(applicationToken); applicationTokenHolder.set(applicationToken);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment