source: fedd/abac-src/ttg/process/AckFact.java @ 2f14616

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: 3.2 KB
Line 
1package com.nailabs.abac.process;
2
3import edu.stanford.peer.rbtm.credential.*;
4
5public class AckFact {
6
7    /**
8     * This attribute defines the scope of the AckFact instance.
9     */
10    protected EntityExpression attribute;
11
12    /**
13     * Optional string meta-identifier for the value field.
14     */
15    protected String field;
16
17    /**
18     * Optional value corresponding to the named field.
19     */
20    protected Object value;
21
22    /**
23     * The credential role required to match with the requesting subject.
24     */
25    protected EntityExpression requirement;
26   
27    /**
28     * A constant to represent a default value (aka a wildcard).
29     */
30    static final String DEFAULT = "default";
31
32    /**
33     * A true constant for denoting that no requirements are necessary.
34     * This can also be implicitly represented as a null requirement.
35     */
36    static final String TRUE = "true";
37
38    /**
39     * Basic constructor method. This method subtitutes a default key-value
40     * pair.
41     */
42    public AckFact(EntityExpression attribute, EntityExpression req) {
43        this(attribute, DEFAULT, DEFAULT, req);
44    }
45
46    /**
47     * Explicit constructor method. This represents a fully expanded policy
48     * fact.
49     */
50    public AckFact(EntityExpression attr,String key,Object val,EntityExpression req) {
51        attribute = attr;
52        field = key;
53        value = val;
54        requirement = req;
55    }
56
57
58    /**
59     * An accessor method for the attribute which needs to be unlocked.
60     * <B> This is private policy information and should not be xmitted </B>
61     */
62    public RoleName getAttribute() { 
63        if(attribute instanceof Role) {
64            return ((Role)attribute).getName(); 
65        }
66        else if(attribute instanceof LinkedRole) {       
67            return ((LinkedRole)attribute).getFirstRole().getName();
68        }
69        else {
70            return null;
71        }
72    }
73
74    /**
75     * An accessor method for the optional special case meta-type.
76     * <B> This is private policy information and should not be xmitted </B>
77     */
78    public String getField() { return field; }
79
80    /**
81     * An accessor method for the optional special case value.
82     * <B> This is private policy information and should not be xmitted </B>
83     */
84    public Object getValue() { return value; }
85
86    /**
87     * An accessor method for an expression which can unlocked the attribute
88     * if the expression is proved to be true.
89     * <B> This is public policy information but if transmitted may indicate
90     * that particular credential is possessed.</B>
91     */
92    public EntityExpression getRequirement() { return requirement; }
93
94    /**
95     * Unique hash function, which is based on the attribute's hash code.
96     */
97    public int hashCode() { return attribute.hashCode(); }
98
99    /**
100     * Tabular printout of the fact in the following order: attribute,
101     * field, value, and attribute expression. The list is comma delimited.
102     */
103    public String toString() {
104        StringBuffer buff = new StringBuffer("[AckFact ");
105        String separator = ", ";
106        buff.append(attribute).append(separator);
107        buff.append(field).append(separator);
108        buff.append(value).append(separator);
109        buff.append(requirement).append("]");
110        return buff.toString();
111    }
112
113}
114
115
116
117
118
119
120
121
Note: See TracBrowser for help on using the repository browser.