String decoded = new String(new sun.misc.BASE64Decoder().decodeBuffer(authCode));
i = decoded.indexOf(':');
if (i > -1) {
String username = decoded.substring(0, i);
String password = decoded.substring(i + 1);
Citizen citizen = context.getCitizen();
if (citizen != null) {
if (!citizen.getRealm().equals(realm)) {
citizen = null;
} else if (!citizen.getName().equals(username)) {
citizen = null;
}
}
if (citizen == null) {
context.log().info("basic: login="+username);
citizen = realm.getCitizen(username);
}
if (citizen != null) {
if (citizen.verifyCredentials(password)) {
context.setCitizen(citizen);
context.log().info("basic: authentication ok");
authenticated = true;
} else {
context.log().info("basic: authentication failed");