throws ParseException {
String[] parts = header.split("\\s");
if (parts.length != 2)
throw new ParseException("Unexpected number of HTTP Authorization header value parts: " + parts.length);
if (! parts[0].equalsIgnoreCase("Basic"))
throw new ParseException("HTTP authentication must be \"Basic\"");
String credentialsString = new String(Base64.decodeBase64(parts[1]), UTF8_CHARSET);
String[] credentials = credentialsString.split(":", 2);
if (credentials.length != 2)
throw new ParseException("Missing credentials delimiter \":\"");
try {
String decodedClientID = URLDecoder.decode(credentials[0], UTF8_CHARSET.name());
String decodedSecret = URLDecoder.decode(credentials[1], UTF8_CHARSET.name());
return new ClientSecretBasic(new ClientID(decodedClientID), new Secret(decodedSecret));
} catch (UnsupportedEncodingException e) {
throw new ParseException(e.getMessage(), e);
}
}