0

best way to interrupt the page create

asked 2018-11-27 11:10:14 +0800

superium gravatar image superium
29 5

i would like to interrupt the page create if user not logged in,but ...

public class Authentication implements Initiator,InitiatorExt {
    private final Logger logger = Logger.getLogger(Authentication.class);

    @Override
    public void doInit(Page page, Map<String, Object> args) throws Exception {
        if (....) {
            Executions.sendRedirect("/login.zul");
            throw new Exception("not authenticated!");  //without this, the page will be created before redirect to login.zul.
                                    //with this, the console and client got an "not authenticated!" Exception .
        }
    }

    @Override
    public boolean doCatch(Throwable ex) throws Exception {

        return false;
    }

    ....
}
delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-05-03 11:28:27 +0800

cor3000 gravatar image cor3000
4606 2 7
ZK Team

Most security libraries (e.g. spring security, apache shiro, cas, ...) do this at a lower level, e.g. using a servlet filter, which can perform the redirect, before entering the application logic.

link publish delete flag offensive edit

Comments

thank you very much. zk is so convenient that let me forget servlet. i was misleaded by zkessentials-book .

superium ( 2019-08-07 11:14:57 +0800 )edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2018-11-27 11:10:14 +0800

Seen: 8 times

Last updated: May 03

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More