public static Pair<String,String> getCredentials(Headers requestHeaders)
throws HttpExceptionImpl {
List<String> auth = requestHeaders.get("Authorization");
if (auth == null || auth.size() != 1) {
throw new HttpExceptionImpl(new IllegalArgumentException(
"Incorrect Authorization"), 401);
}
String base64 = auth.get(0);
try {
String decoded = new String(Base64.decode(base64.split(" ")[1]));
String[] parts = decoded.split(":");
return new Pair<String, String>(parts[0],parts[1]);
} catch (IOException e) {
throw new HttpExceptionImpl(e, 401);
}
}