KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portlets > content > FileACL


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.portlets.content;
6
7 import javax.faces.context.FacesContext;
8 import org.exoplatform.portlets.content.explorer.component.model.NodeDescriptor;
9 /**
10  * Sat, Jan 03, 2004 @ 11:16
11  * @author: Tuan Nguyen
12  * @email: tuan08@users.sourceforge.net
13  * @version: $Id: FileACL.java,v 1.6 2004/08/26 22:12:38 benjmestrallet Exp $
14  */

15 public class FileACL implements ACL {
16   private String JavaDoc user_ ;
17   private String JavaDoc readRole_ ;
18   private String JavaDoc writeRole_ ;
19   
20   public FileACL(String JavaDoc user, String JavaDoc readRole, String JavaDoc writeRole) {
21     user_ = user ;
22     readRole_ = readRole ;
23     writeRole_ = writeRole ;
24   }
25     
26   public boolean hasReadRole(NodeDescriptor node) {
27     if(readRole_ == null || readRole_.length() == 0 || "any".equals(readRole_)) {
28       return true ;
29     }
30     FacesContext context = FacesContext.getCurrentInstance() ;
31     return context.getExternalContext().isUserInRole(readRole_) ;
32   }
33   
34   public boolean hasWriteRole(NodeDescriptor node) {
35     if(writeRole_ == null || writeRole_.length() == 0 || "any".equals(writeRole_)) {
36       return true ;
37     }
38     FacesContext context = FacesContext.getCurrentInstance() ;
39     return context.getExternalContext().isUserInRole(writeRole_) ;
40   }
41 }
Popular Tags