SecurityInfo.java
01 /*
02  *  SecurityInfo.java
03  *
04  *  Copyright (c) 1995-2010, The University of Sheffield. See the file
05  *  COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
06  *
07  *  This file is part of GATE (see http://gate.ac.uk/), and is free
08  *  software, licenced under the GNU Library General Public License,
09  *  Version 2, June 1991 (in the distribution as file licence.html,
10  *  and also available at http://gate.ac.uk/gate/licence.html).
11  *
12  *  Marin Dimitrov, 10/Oct/2001
13  *
14  *  $Id: SecurityInfo.java 12006 2009-12-01 17:24:28Z thomas_heitz $
15  */
16 
17 package gate.security;
18 
19 import junit.framework.Assert;
20 
21 public class SecurityInfo {
22 
23   /** world read/ group write */
24   public static final int ACCESS_WR_GW = 1;
25   /** group read/ group write */
26   public static final int ACCESS_GR_GW = 2;
27   /** group read/ owner write */
28   public static final int ACCESS_GR_OW = 3;
29   /** owner read/ owner write */
30   public static final int ACCESS_OR_OW = 4;
31 
32 
33   protected Group grp;
34   protected User  usr;
35   protected int   accessMode;
36 
37   public SecurityInfo(int accessMode,User usr,Group grp) {
38 
39     //0. preconditions
40     Assert.assertTrue(accessMode == SecurityInfo.ACCESS_GR_GW ||
41                   accessMode == SecurityInfo.ACCESS_GR_OW ||
42                   accessMode == SecurityInfo.ACCESS_OR_OW ||
43                   accessMode == SecurityInfo.ACCESS_WR_GW);
44 
45     this.accessMode = accessMode;
46     this.usr = usr;
47     this.grp = grp;
48 
49     //don't register as change listener for froups/users
50     //because if an attempt to delete group/user is performed
51     //and they own documents then the attempt will fail
52   }
53 
54 
55   public Group getGroup() {
56     return this.grp;
57   }
58 
59 
60   public User getUser() {
61     return this.usr;
62   }
63 
64   public int getAccessMode() {
65     return this.accessMode;
66   }
67 }