source: fedd/abac-src/ttg/trust/SatisfactionState.java @ 1fda364

axis_examplecompt_changesinfo-opsversion-2.00version-3.01version-3.02
Last change on this file since 1fda364 was 8780cbec, checked in by Jay Jacobs <Jay.Jacobs@…>, 15 years ago

ABAC sources from Cobham

  • Property mode set to 100644
File size: 2.2 KB
RevLine 
[8780cbec]1package com.nailabs.abac.trust;
2
3import java.util.*;
4import com.nailabs.abac.test.XMLizable;
5/**
6 * An instance used to represent the satisfaction state of a target node
7 * and its descendants.
8 */
9public class SatisfactionState extends Observable implements XMLizable {
10    /** The satisfaction state variable */
11    private int state;
12
13    /**
14     * The satisfaction state can be proved to be satisfied or unsatisfied.
15     * For example, an access mediator may want to later reassess a subgraph.
16     */
17    public static final int UNKNOWN = 0;
18
19    /**
20     * Satisfaction mean that a trust target node has been proven correct,
21     * possibly including a set of credential to verify the satisfaction.
22     */
23    public static final int SATISFIED = 1;
24
25    /**
26     * Unsatisified mean that the requirement of a trust target cannot be
27     * met. This generally means that an access mediator should not allow
28     * resource access.
29     */
30    public static final int FAILED = 2;
31
32    /** Default constructor where the state is UNKNOWN */
33    public SatisfactionState() { state = UNKNOWN; }
34
35    /** Explicitly defined statisfaction state. */   
36    public SatisfactionState(int i) { state = i; }
37
38    /** Accessor method for returninf the trust target satisfaction state. */
39    public int getState() { return state; }
40
41    /** Modifier method to change the satisfaction state */
42    public void setState(int i) { 
43        if(i > -1 && i < 3)state = i; 
44        setChanged();
45        notifyObservers();
46    }
47
48    /** convert this instance into an XML formatted string */
49    public String toXML() {
50        StringBuffer buff = new StringBuffer("<SatisfactionState>");
51        switch(state) {
52        case SATISFIED: 
53            buff.append("satisfied");
54            break;
55        case FAILED:
56            buff.append("failed");
57            break;
58        default:
59            buff.append("unknown");
60        }
61        buff.append("</SatisfactionState>");
62        return buff.append("\n").toString();
63    }
64
65
66    /** Print a human readable version of this instance */
67    public String toString() {
68        StringBuffer buff = new StringBuffer("[");
69        switch(state) {
70        case SATISFIED: 
71            buff.append("satisfied");
72            break;
73        case FAILED:
74            buff.append("failed");
75            break;
76        default:
77            buff.append("unknown");
78        }
79        return buff.append("]").toString();
80    }
81   
82}
83
Note: See TracBrowser for help on using the repository browser.