Java Code Examples for com.jfinal.aop.Invocation#getActionKey()

The following examples show how to use com.jfinal.aop.Invocation#getActionKey() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RouterInterceptor.java    From zrlog with Apache License 2.0 6 votes vote down vote up
@Override
public void intercept(Invocation invocation) {
    try {
        String actionKey = invocation.getActionKey();
        //这样写一点页不优雅,路径少还好,多了就痛苦了
        if (actionKey.startsWith("/admin") || actionKey.startsWith("/api/admin")) {
            adminInterceptor.intercept(invocation);
        } else {
            visitorInterceptor.intercept(invocation);
        }
        GlobalResourceHandler.printUserTime("Router");
    } catch (Exception e) {
        LOGGER.error("interceptor exception ", e);
        invocation.getController().renderError(500);
    }
}
 
Example 2
Source File: AuthInterceptor.java    From jboot-admin with Apache License 2.0 5 votes vote down vote up
@Override
public void intercept(Invocation ai) {
    if (urls == null) {
        init();
    }

    String url = ai.getActionKey();
    boolean flag = SecurityUtils.getSubject() != null && SecurityUtils.getSubject().isPermitted(url);

    if (urls.contains(url) && !flag) {
        ai.getController().renderError(403);
    } else {
        ai.invoke();
    }
}
 
Example 3
Source File: VisitorInterceptor.java    From zrlog with Apache License 2.0 5 votes vote down vote up
@Override
public void intercept(Invocation ai) {
    String actionKey = ai.getActionKey();
    if (actionKey.startsWith("/install")) {
        installPermission(ai);
    } else {
        if (ZrLogConfig.isInstalled()) {
            if (actionKey.startsWith("/api")) {
                apiPermission(ai);
            } else if (actionKey.startsWith("/")) {
                visitorPermission(ai);
            }
        }
    }
}