realmRouter.attach("/groups/{group-id}/{facet}/",GroupResource.class).getTemplate().setMatchingMode(Template.MODE_EQUALS);
realmRouter.attach("/groups/{group-id}/{facet}/{facet-id}",GroupResource.class).getTemplate().setMatchingMode(Template.MODE_EQUALS);
realmRouter.attach("/groups/{group-id}/{facet}/a/{facet-name}",GroupResource.class).getTemplate().setMatchingMode(Template.MODE_EQUALS);
realmRouter.attach("/groups/{group-id}/{facet}/n/{facet-name}",GroupResource.class).getTemplate().setMatchingMode(Template.MODE_EQUALS);
Filter realmByName = new RealmFilter(getContext(),db);
mainRouter.attach("/realms/n/{realm-name}",realmByName);
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;
}
}
};
realmByIdGuard.addPermission(realmSuperuser);
realmById.setNext(realmByIdGuard);
realmByIdGuard.setNext(realmRouter);
UserGuard adminGuard = new UserGuard(getContext(),db,ChallengeScheme.HTTP_BASIC,"users");
adminGuard.setPermission(superuser);
mainRouter.attach("/admin",adminGuard);