auth.scheme = UriParser.extractScheme(uri, name);
// Expecting "//"
if (name.length() < 2 || name.charAt(0) != '/' || name.charAt(1) != '/')
{
throw new FileSystemException("vfs.provider/missing-double-slashes.error", uri);
}
name.delete(0, 2);
// Extract userinfo, and split into username and password
final String userInfo = extractUserInfo(name);
final String userName;
final String password;
if (userInfo != null)
{
int idx = userInfo.indexOf(':');
if (idx == -1)
{
userName = userInfo;
password = null;
}
else
{
userName = userInfo.substring(0, idx);
password = userInfo.substring(idx + 1);
}
}
else
{
userName = null;
password = null;
}
auth.userName = UriParser.decode(userName);
auth.password = UriParser.decode(password);
if (auth.password != null && auth.password.startsWith("{") && auth.password.endsWith("}"))
{
try
{
Cryptor cryptor = CryptorFactory.getCryptor();
auth.password = cryptor.decrypt(auth.password.substring(1, auth.password.length() - 1));
}
catch (Exception ex)
{
throw new FileSystemException("Unable to decrypt password", ex);
}
}
// Extract hostname, and normalise (lowercase)
final String hostName = extractHostName(name);
if (hostName == null)
{
throw new FileSystemException("vfs.provider/missing-hostname.error", uri);
}
auth.hostName = hostName.toLowerCase();
// Extract port
auth.port = extractPort(name, uri);
// Expecting '/' or empty name
if (name.length() > 0 && name.charAt(0) != '/')
{
throw new FileSystemException("vfs.provider/missing-hostname-path-sep.error", uri);
}
return auth;
}