axis_examplecompt_changesinfo-opsversion-2.00version-3.01version-3.02
Last change
on this file since 70caa72 was
8780cbec,
checked in by Jay Jacobs <Jay.Jacobs@…>, 15 years ago
|
ABAC sources from Cobham
|
-
Property mode set to
100644
|
File size:
1.6 KB
|
Rev | Line | |
---|
[8780cbec] | 1 | package edu.stanford.peer.rbtm.engine; |
---|
| 2 | |
---|
| 3 | import edu.stanford.peer.rbtm.credential.*; |
---|
| 4 | import edu.stanford.peer.rbtm.util.*; |
---|
| 5 | |
---|
| 6 | import java.util.*; |
---|
| 7 | |
---|
| 8 | /** |
---|
| 9 | * A predicate for determining whether a credential is sensitive. |
---|
| 10 | */ |
---|
| 11 | public class Sens implements Predicate { |
---|
| 12 | |
---|
| 13 | /** A list of sensitive credentials for this predicate */ |
---|
| 14 | protected Vector sens; |
---|
| 15 | |
---|
| 16 | /** |
---|
| 17 | * Create a new sens predicate with no sensitive credentials. |
---|
| 18 | */ |
---|
| 19 | public Sens() { sens = new Vector(); } |
---|
| 20 | |
---|
| 21 | /** |
---|
| 22 | * Create a new sens predicate with a list of pre-defined sensitive |
---|
| 23 | * credentials. |
---|
| 24 | */ |
---|
| 25 | public Sens(Vector creds) { |
---|
| 26 | sens = new Vector(); |
---|
| 27 | for(int i = 0; i < creds.size(); i++) { |
---|
| 28 | try { |
---|
| 29 | Role r = (Role)creds.elementAt(i); |
---|
| 30 | sens.addElement(r); |
---|
| 31 | } |
---|
| 32 | catch(Exception ex) { |
---|
| 33 | ex.printStackTrace(); |
---|
| 34 | } |
---|
| 35 | } |
---|
| 36 | } |
---|
| 37 | |
---|
| 38 | /** Mark a credential as sensitive w/o exposing internal data structures */ |
---|
| 39 | public void addSensCred(Role role) { sens.add(role); } |
---|
| 40 | |
---|
| 41 | /** Remove a credential from the sensitive list (opaquely) */ |
---|
| 42 | public void removeSensCred(Role role) { sens.remove(role); } |
---|
| 43 | |
---|
| 44 | /** |
---|
| 45 | * Predicate function to test whether the supplied role expression is |
---|
| 46 | * sensitive or not. The obj must be a credential for the test to succeed. |
---|
| 47 | * |
---|
| 48 | * @param obj a credential instance for the predicate to test |
---|
| 49 | * @return success of failure of the predicate |
---|
| 50 | */ |
---|
| 51 | public boolean test(EntityExpression obj) { |
---|
| 52 | if(!(obj instanceof Role))return true; |
---|
| 53 | Role role = (Role)obj; |
---|
| 54 | return (sens.contains(role)); |
---|
| 55 | /* |
---|
| 56 | if(!sens.contains(role)) { |
---|
| 57 | return false; |
---|
| 58 | } |
---|
| 59 | return true; |
---|
| 60 | */ |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.