Dashboard > WebWork > ... > 3rd Party Integration > Acegi Security
  WebWork Log In View a printable version of the current page.  
  Acegi Security
Added by tm_jee, last edited by Philip Luppens on Jan 03, 2007  (view change)
Labels: 
(None)

The following details a possible integration of Acegi Security with WebWork:-

Step 1 - Declaring Authz Interface

import org.acegisecurity.taglibs.velocity.Authz;
public interface AuthzAware {
        void setAuthz(Authz authz);
}

Step 2 - Implementing Authz Interceptor

import org.acegisecurity.taglibs.velocity.Authz;
import org.acegisecurity.taglibs.velocity.AuthzImpl;
import package.api.AuthzAware;

import com.opensymphony.xwork.ActionInvocation;
import com.opensymphony.xwork.interceptor.Interceptor;

public class AuthzInterceptor implements Interceptor {
        public void destroy()
        {}

        public void init()
        {}

        public String intercept(ActionInvocation invocation)
                throws Exception
        {
                if (invocation.getAction() instanceof AuthzAware) {
                        Authz authz = new AuthzImpl();

                        AuthzAware authzAware = (AuthzAware)invocation.getAction();
                        authzAware.setAuthz(authz);
                }

                return invocation.invoke();
        }
}

Step 3 - Making AuthzAware action

import org.acegisecurity.taglibs.velocity.Authz;
import package.api.AuthzAware;
import com.opensymphony.xwork.ActionSupport;


public class DashboardAction extends ActionSupport implements AuthzAware
{
        private Authz authz;

        public Authz getAuthz(){
                return authz;
        }

        public void setAuthz(Authz authz)
        {
                this.authz = authz;
        }

        public String execute() throws Exception
        {
                return SUCCESS;
        }
}

Step 4 - Declaring interceptor

<interceptor name="authz" class="package.interceptor.AuthzInterceptor"/>

Step 5 - Declaring action

<action name="dashboard" class="package.action.DashboardAction">
        <interceptor-ref name="authz" />
        <result type="velocity" name="success">dashboard.vm</result>
</action>

Step 6 - Implementing dashboard.vm

Actualy you are logged as $authz.principal

Contributed by Luca Marrocco.

Site powered by a free Open Source Project / Non-profit License (more) of Confluence - the Enterprise wiki.
Learn more or evaluate Confluence for your organisation.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.9 Build:#527 Sep 07, 2006) - Bug/feature request - Contact Administrators