break;
}
}
if (method == null) return null;
NtlmMessage message = (authorization != null) ?
new Type2Message(Base64Decoder.decodeToBytes(authorization)) : null;
reconnect();
if (message == null) {
message = new Type1Message();
if (LM_COMPATIBILITY > 2) {
message.setFlag(NtlmFlags.NTLMSSP_REQUEST_TARGET, true);
}
} else {
String domain = DEFAULT_DOMAIN;
String user = Type3Message.getDefaultUser();
String password = Type3Message.getDefaultPassword();
String userInfo = url.getUserInfo();
if (userInfo != null) {
userInfo = URLDecoder.decode(userInfo);
int index = userInfo.indexOf(':');
user = (index != -1) ? userInfo.substring(0, index) : userInfo;
if (index != -1) password = userInfo.substring(index + 1);
index = user.indexOf('\\');
if (index == -1) index = user.indexOf('/');
domain = (index != -1) ? user.substring(0, index) : domain;
user = (index != -1) ? user.substring(index + 1) : user;
}
if (user == null) {
try {
URL url = getURL();
String protocol = url.getProtocol();
int port = url.getPort();
if (port == -1) {
port = "https".equalsIgnoreCase(protocol) ? 443 : 80;
}
PasswordAuthentication auth =
Authenticator.requestPasswordAuthentication(null,
port, protocol, "", method);
if (auth != null) {
user = auth.getUserName();
password = new String(auth.getPassword());
}
} catch (Exception ex) { }
}
Type2Message type2 = (Type2Message) message;
message = new Type3Message(type2, password, domain, user,
Type3Message.getDefaultWorkstation());
}
return message;
}