KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > faces > core > event > CheckRoleInterceptor


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.faces.core.event;
6
7 import javax.faces.context.* ;
8 import org.exoplatform.commons.exception.ExoPermissionException;
9 /**
10  * Jun 3, 2004
11  * @author: Tuan Nguyen
12  * @email: tuan08@users.sourceforge.net
13  * @version: $ID$
14  **/

15 public class CheckRoleInterceptor extends ActionInterceptor {
16     private String JavaDoc role_ ;
17     
18     public CheckRoleInterceptor(String JavaDoc role) {
19         role_ = role ;
20     }
21     
22     public void preExecute(ExoActionEvent event) throws Exception JavaDoc {
23     ExternalContext econtext =
24       FacesContext.getCurrentInstance().getExternalContext() ;
25     if(!econtext.isUserInRole(role_)) {
26       throw new ExoPermissionException(event.getAction() , role_) ;
27     }
28     }
29     
30     final public void postExecute(ExoActionEvent event) throws Exception JavaDoc {
31         
32     }
33 }
Popular Tags