Java 类play.mvc.Before 实例源码

项目:ovirt-engine-disaster-recovery    文件:Secure.java   
@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);
    }
}
项目:fiware-sinfonier    文件:Topologies.java   
@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();
  }
}
项目:ovirt-engine-disaster-recovery    文件:AuthenticatedController.java   
@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();
           }
    }
}
项目:play-restsecure    文件:RestSecure.java   
@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);
    }
}
项目:restcommander    文件:Administration.java   
@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");
     }
}
项目:restcommander    文件:Java.java   
/**
 * 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;
}
项目:EclipseCodeFormatter    文件:Main2.java   
public static void main(String[] args) {
    Arrays.asList("");
    new Deployment();
    new Job();
    new Before();
    new Restrict();
    new Javax();
    new Restricts();
}
项目:MRIdb    文件:Application.java   
@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));
    }
}
项目:MyDMAM    文件:Secure.java   
@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);
    }
}
项目:play-restsecure    文件:RestSecure.java   
@Before
public static void before() throws Throwable {
    Security.invoke("before");
}
项目:restcommander    文件:CRUD.java   
@Before
public static void addType() throws Exception {
    ObjectType type = ObjectType.get(getControllerClass());
    renderArgs.put("type", type);
}
项目:restcommander    文件:JavaTest.java   
@Before
public static String beforeMethod() {
    return "before";
}
项目:MRIdb    文件:SecureController.java   
@Before
static void log() {
    if (Security.isConnected() && !request.isAjax() && !"false".equals(Properties.getString("log.actions"))) {
        Logger.info(Security.connected() + " " + request.action);
    }
}