1 5 package org.exoplatform.faces.core.event; 6 7 import javax.faces.context.ExternalContext; 8 import javax.faces.context.FacesContext; 9 import org.exoplatform.commons.exception.ExoMessageException; 10 import org.exoplatform.container.SessionContainer; 11 import org.exoplatform.portal.session.RequestInfo; 12 18 public class CheckAdminOrOwnerRoleInterceptor extends ActionInterceptor { 19 20 public void preExecute(ExoActionEvent event) throws Exception { 21 ExternalContext econtext = FacesContext.getCurrentInstance().getExternalContext() ; 22 RequestInfo rinfo = (RequestInfo)SessionContainer.getComponent(RequestInfo.class) ; 23 if(rinfo.getPortalOwner().equals(econtext.getRemoteUser())) { 24 return ; 25 } 26 if (econtext.isUserInRole("admin") ) { 27 return ; 28 } 29 Object [] args = {event.getAction()} ; 30 throw new ExoMessageException("CheckAdminOrOwnerRoleInterceptor.msg.owner-or-admin-require", args) ; 31 } 32 33 final public void postExecute(ExoActionEvent event) throws Exception { 34 35 } 36 } | Popular Tags |