Well how i did it  ... 

Added shiro as a filter in web.xml 
Created 3 pages (BasePage, AuthPage and NotAllowedPage)
BasePage has login form so user can login (Login form component methods do
the login with shiro)
if login is successful user is redirected to AuthPage and is shown
components ... 
if not NotAllowedPage is displayed. 



/**
         * on login form submitted.
         */
        @Override
        public void onSubmit() {
                String username         = loginNameField.getModelObject();
                String password         = passwordField.getModelObject();
                
                //!!!!!!! Wrapper for SHIRO STUFF !!!!!!!!
                MySecurityController security   =
((MyApplication)this.getApplication()).getSecurityGuard(); 
                try {
                        security.login(username, password);
                        this.getRequestCycle().setRedirect(true);
                        this.setResponsePage(instanceOfMyAuthPage);
                } catch (Exception e) {
                        LOG.info("Error on login !", e);
                }
        }


in SHIRO Wrapper controller



/**
         * Login user if user is not authenticated yet!
         * 
         * @param loginName login name.
         * @param password  password.
         * 
         * @throws org.apache.shiro.authc.AuthenticationException if any other
error occurs.
         */
        public void login(final String loginName, final String password) {
                Subject currentUser = SecurityUtils.getSubject();
                
                if (!currentUser.isAuthenticated()) {
                        UsernamePasswordToken token = new 
UsernamePasswordToken(loginName,
password);
                        token.setRememberMe(false);
                        currentUser.login(token);
                }
        }



Any better ideas appreciated !

Regards

Armando

--
View this message in context: 
http://shiro-user.582556.n2.nabble.com/Use-shiro-in-wicket-application-tp6309015p6309057.html
Sent from the Shiro User mailing list archive at Nabble.com.

Reply via email to