-
Notifications
You must be signed in to change notification settings - Fork 0
Using the "secure" module
pramode edited this page Jun 29, 2011
·
2 revisions
Check official documentation
Suppose you want only user "pce" to execute a controller action. Here is what you do:
First, annotate the controller action:
@Check("pce")
public static void index() {
render();
}
Now, define a class Security.java (in the "controllers" folder):
package controllers;
public class Security extends Secure.Security {
static boolean authenticate(String username, String password)
{
return (username.equals("admin") || username.equals("pce")) && password.equals("asdfgh");
}
static boolean check(String profile)
{
return profile.equals(Security.connected());
}
}
The @Check annotation results in the function "check" being called with the annotation parameter as argument to the function ("profile"). If the function returns FALSE, the annotated controller action is disallowed.