RealmUserGuard realmByNameGuard = new RealmUserGuard(getContext(),db,null,ChallengeScheme.HTTP_BASIC,"Realm Users",superuser) {
protected boolean hasRealmSpecific(Request request,RealmUser user)
{
// we need to check the group because a user could have realm superuser for another realm
try {
Group admin = db.getGroup(user.getRealm(),"admin");
return user.isMemberOf(admin);
} catch (SQLException ex) {
getContext().getLogger().log(Level.SEVERE,"Cannot check role due to database error.",ex);
return false;
}
}
};
realmByNameGuard.addPermission(realmSuperuser);
realmByName.setNext(realmByNameGuard);
realmByNameGuard.setNext(realmRouter);
Filter realmById = new RealmFilter(getContext(),db);
mainRouter.attach("/realms/{realm-id}",realmById);
RealmUserGuard realmByIdGuard = new RealmUserGuard(getContext(),db,null,ChallengeScheme.HTTP_BASIC,"Realm Users",superuser) {
protected boolean hasRealmSpecific(Request request,RealmUser user)
{
try {
Group admin = db.getGroup(user.getRealm(),"admin");
return user.isMemberOf(admin);
} catch (SQLException ex) {
getContext().getLogger().log(Level.SEVERE,"Cannot check role due to database error.",ex);
return false;
}