}
@Override
public void setBasicAuthorization(final String username, final String password) {
try {
BasicAuthentication auth = new BasicAuthentication(new Realm() {
@Override public String getPrincipal() { return username; }
@Override public String getId() { return null; }
@Override public String getCredentials() { return password; }
});
// The Jetty Client uses the ISO-8859-1 char-set for Basic Authentication,
// the same as the Jetty Server. See
// https://github.com/eclipse/jetty.project/blob/master/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/BasicAuthenticator.java
auth.setCredentials(exchange);
} catch (IOException e) {
// This happens only in the highly unlikely case that ISO-8859-1 would not be supported.
// (BasicAuthentication should throw a RuntimeException in this case, instead of propagating a checked exception).
// BasicAuthentication.setCredentials doesn't actually throw an IOException.
throw new RuntimeException(e);