* @param uri the URI to get the user info from
* @return a new BasicPrincipal containing the user info, or
* <code>null</code> if none was specified
*/
public static BasicPrincipal getPrincipal(URI uri) {
BasicPrincipal principal = null;
String userinfo = uri.getUserinfo();
if (userinfo != null && userinfo.length() != 0) {
int index = userinfo.indexOf(":");
String user;
String password = "";
if (index != -1) {
user = userinfo.substring(0, index);
password = userinfo.substring(index + 1);
} else {
user = userinfo;
}
principal = new BasicPrincipal(user, password);
}
return principal;
}