Router root = new Router();
// Attach test 1
ChallengeAuthenticator authenticator = new ChallengeAuthenticator(
getContext(), ChallengeScheme.HTTP_BASIC, "saas");
authenticator.setNext(new HelloWorldRestlet());
root.attach("/test1", authenticator);
// Attach test 2
Authorizer authorizer = Authorizer.ALWAYS;
authorizer.setNext(new HelloWorldRestlet());
root.attach("/test2", authorizer);
// Attach test 3
authorizer = Authorizer.NEVER;
authorizer.setNext(new HelloWorldRestlet());
root.attach("/test3", authorizer);
// Attach test 4
RoleAuthorizer roleAuthorizer = new RoleAuthorizer();
roleAuthorizer.getAuthorizedRoles().add(getRole("admin"));
roleAuthorizer.setNext(new HelloWorldRestlet());
authenticator = new ChallengeAuthenticator(getContext(),
ChallengeScheme.HTTP_BASIC, "saas");
authenticator.setNext(roleAuthorizer);
root.attach("/test4", authenticator);
// Attach test 5
roleAuthorizer = new RoleAuthorizer();
roleAuthorizer.getForbiddenRoles().add(getRole("admin"));
roleAuthorizer.setNext(new HelloWorldRestlet());
authenticator = new ChallengeAuthenticator(getContext(),
ChallengeScheme.HTTP_BASIC, "saas");
authenticator.setNext(roleAuthorizer);
root.attach("/test5", authenticator);