Fixed bug with regex and style cleanup.

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
Lachlan Roberts 2018-04-17 17:34:16 +10:00
parent 29dccf668c
commit 497b87eb2e
1 changed files with 8 additions and 5 deletions

View File

@ -42,7 +42,7 @@ public abstract class AuthenticationProtocolHandler implements ProtocolHandler
{
public static final int DEFAULT_MAX_CONTENT_LENGTH = 16*1024;
public static final Logger LOG = Log.getLogger(AuthenticationProtocolHandler.class);
private static final Pattern AUTHENTICATE_PATTERN = Pattern.compile("([^\\s]+)\\s(.*,\\s*)?realm=\"([^\"]*)\"\\s*,?\\s*(.*)", Pattern.CASE_INSENSITIVE);
private static final Pattern AUTHENTICATE_PATTERN = Pattern.compile("([^\\s]+)\\s+(.*,\\s*)?realm=\"([^\"]*)\"\\s*,?\\s*(.*)", Pattern.CASE_INSENSITIVE);
private final HttpClient client;
private final int maxContentLength;
@ -242,12 +242,15 @@ public abstract class AuthenticationProtocolHandler implements ProtocolHandler
{
String type = matcher.group(1);
String realm = matcher.group(3);
String beforeRealm = matcher.group(2);
String afterRealm = matcher.group(4);
String params;
if(matcher.group(2) != null)
params = matcher.group(2) + matcher.group(4);
if (beforeRealm != null)
params = beforeRealm + afterRealm;
else
params = matcher.group(4);
params = afterRealm;
Authentication.HeaderInfo headerInfo = new Authentication.HeaderInfo(type, realm, params, getAuthorizationHeader());
result.add(headerInfo);
}