@Before(unless={"login", "authenticate", "logout"}) static void checkAccess() throws Throwable { // Authent if(!session.contains("username")) { flash.put("url", "GET".equals(request.method) ? request.url : Play.ctxPath + "/"); // seems a good default login(); } // Checks Check check = getActionAnnotation(Check.class); if(check != null) { check(check); } check = getControllerInheritedAnnotation(Check.class); if(check != null) { check(check); } }
@Before(unless = {"index", "topology", "search", "log"}) static void hasWritePermission() throws SinfonierException { String id = request.params.get("id"); if (id != null) { Topology topology = Topology.findById(id); if (topology == null || !topology.hasWritePermission(getCurrentUser())) forbidden(); } else if (!request.actionMethod.equals("save")) { forbidden(); } }
@Before() public static void getUserInfo() { User user = User.find("username = :u").bind("u", Security.connected()).first(); if (user!=null) { user.lastActivity = new Date(); user.save(); setUser(user); if (!request.action.equals("Profile.passwordChange") && !request.action.equals("Profile.changePassword") && user.needsPasswordReset) { Profile.passwordChange(); } } }
@Before(unless={"login", "authenticate", "logout"}, priority = 1) static void checkAccess() throws Throwable { // Checks Check check = getActionAnnotation(Check.class); if (check != null) { check(check); } check = getControllerInheritedAnnotation(Check.class); if (check != null) { check(check); } }
@Before protected static void check () { Http.Header auth = request.headers.get("authorization"); if(auth != null) { String encodedPassword = auth.value().substring("Basic ".length()); String password = new String(Codec.decodeBASE64(encodedPassword)); String user = password.substring(0, password.indexOf(':')); String pwd = password.substring((user + ":").length()); System.out.println("user is " + user + " , passwd is " + pwd); if (! pwd.equals(Play.configuration.getProperty("play.search.password","search"))) unauthorized("You are not authorized"); } else { unauthorized("You are not authorized"); } }
/** * Find the first public static method of a controller class * @param name The method name * @param clazz The class * @return The method or null */ public static Method findActionMethod(String name, Class clazz) { while (!clazz.getName().equals("java.lang.Object")) { for (Method m : clazz.getDeclaredMethods()) { if (m.getName().equalsIgnoreCase(name) && Modifier.isPublic(m.getModifiers())) { // Check that it is not an intercepter if (!m.isAnnotationPresent(Before.class) && !m.isAnnotationPresent(After.class) && !m.isAnnotationPresent(Finally.class)) { return m; } } } clazz = clazz.getSuperclass(); } return null; }
public static void main(String[] args) { Arrays.asList(""); new Deployment(); new Job(); new Before(); new Restrict(); new Javax(); new Restricts(); }
@Before(unless="guest") static void before() { if (Security.isConnected()) { if (getUser().role == Role.Guest) { guest(); } renderArgs.put(CLIPBOARD, new Clipboard(getUser().clipboard)); renderArgs.put(EXPORTS, ClipboardExporter.getExports(session)); } }
@Before(unless = { "login", "authenticate", "logout" }) static void checkAccess() throws Throwable { if (isConnected() == false) { login(); } Check check = getActionAnnotation(Check.class); if (check != null) { check(check); } check = getControllerInheritedAnnotation(Check.class); if (check != null) { check(check); } }
@Before public static void before() throws Throwable { Security.invoke("before"); }
@Before public static void addType() throws Exception { ObjectType type = ObjectType.get(getControllerClass()); renderArgs.put("type", type); }
@Before public static String beforeMethod() { return "before"; }
@Before static void log() { if (Security.isConnected() && !request.isAjax() && !"false".equals(Properties.getString("log.actions"))) { Logger.info(Security.connected() + " " + request.action); } }