String token;
try {
token = new String(decoded, "UTF-8");
} catch (final UnsupportedEncodingException e) {
throw new CredentialsException("Bad format of the basic auth header");
}
final int delim = token.indexOf(":");
if (delim < 0) {
throw new CredentialsException("Bad format of the basic auth header");
}
final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(token.substring(0, delim),
token.substring(delim + 1), getName());
logger.debug("usernamePasswordCredentials : {}", credentials);
try {