String decoded = Base64.decodeToString(encoded, _charset);
if (decoded.indexOf(':') != -1) {
String[] split = decoded.split(":", 2);
String name = split.length > 0 ? split[0] : null;
if (name != null) {
credentials.add(new NameCredential(name));
}
String password = split.length > 1 ? split[1] : null;
if (password != null) {
credentials.add(new PasswordCredential(password));
}
}
} else if (source.startsWith("Digest ")) {
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// https://issues.jboss.org/browse/SWITCHYARD-1082
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Map<String,String> map = new HashMap<String,String>();
String everything = source.substring(6, source.length()).trim();
List<String> list = Strings.splitTrimToNull(everything, ",\n");
for (String pair : list) {
String[] split = pair.split("=", 2);
String key = split.length > 0 ? split[0] : null;
String value = split.length > 1 ? split[1] : null;
if (key != null && value != null) {
if (value.startsWith("\"") && value.endsWith("\"")) {
value = value.substring(1, value.length() - 1);
}
map.put(key, value);
}
}
String username = map.get("username");
if (username != null) {
credentials.add(new NameCredential(username));
}
// TODO: complete per SWITCHYARD-1082
}
}
return credentials;