version-1.30
Last change
on this file since 2f14616 was
8780cbec,
checked in by Jay Jacobs <Jay.Jacobs@…>, 15 years ago
|
ABAC sources from Cobham
|
-
Property mode set to
100644
|
File size:
1.2 KB
|
Rev | Line | |
---|
[8780cbec] | 1 | /* |
---|
| 2 | * Role.java |
---|
| 3 | */ |
---|
| 4 | |
---|
| 5 | package edu.stanford.peer.rbtm.credential; |
---|
| 6 | |
---|
| 7 | import java.util.*; |
---|
| 8 | |
---|
| 9 | public class Role implements EntityExpression, PermissionExpression, java.io.Serializable |
---|
| 10 | { |
---|
| 11 | private Entity _base; |
---|
| 12 | private RoleName _name; |
---|
| 13 | |
---|
| 14 | public Role(Entity e, RoleName n) { _base = e; _name = n; } |
---|
| 15 | |
---|
| 16 | public Role(Entity e, String n) { |
---|
| 17 | _base = e; |
---|
| 18 | _name = new SimpleRoleName(n); |
---|
| 19 | } |
---|
| 20 | |
---|
| 21 | public Role(String e, String n) { |
---|
| 22 | _base = new SimpleEntity(e); |
---|
| 23 | _name = new SimpleRoleName(n); |
---|
| 24 | } |
---|
| 25 | |
---|
| 26 | /* |
---|
| 27 | public Role(RoleName name) { |
---|
| 28 | this(Entity.self, name); |
---|
| 29 | } |
---|
| 30 | |
---|
| 31 | public Role(String name) { |
---|
| 32 | this(Entity.self, name); |
---|
| 33 | } |
---|
| 34 | */ |
---|
| 35 | |
---|
| 36 | public Entity getBase() { return _base; } |
---|
| 37 | |
---|
| 38 | public RoleName getName() { return _name; } |
---|
| 39 | |
---|
| 40 | public String toString() { |
---|
| 41 | return _base.toString() + "." + _name.toString(); |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | public int hashCode() { |
---|
| 45 | return getBase().hashCode() * 2 + getName().hashCode(); |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | public boolean equals(Object o) { |
---|
| 49 | return (o instanceof Role) && |
---|
| 50 | getBase().equals(((Role)o).getBase()) && |
---|
| 51 | getName().equals(((Role)o).getName()); |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | public boolean isPermission() { |
---|
| 55 | return _name instanceof RPermission; |
---|
| 56 | } |
---|
| 57 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.