source: fedd/abac-src/ttg/trust/LinkingGoal.java @ 8780cbec

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

ABAC sources from Cobham

  • Property mode set to 100644
File size: 3.1 KB
Line 
1package com.nailabs.abac.trust;
2
3import com.nailabs.abac.process.*;
4import edu.stanford.peer.rbtm.credential.*;
5import java.util.*;
6
7/**
8 * An instance of this class represents a linking goal of the form: <BR>
9 * <CENTER> &lt;V: ?X.r2 &lt;-- S &gt; </CENTER> <BR>
10 * where V is on the negotiators;
11 * r2 is a simple role name; and
12 * ?X represents entities
13 * S is a role expression called the subject role. S is frequently the
14 * opponent negotiator of V.
15 */
16public class LinkingGoal extends Goal {
17    /** The role name suffix (in ?X.r2 this is r2) */
18    private RoleName targetRoleName;
19
20    private Entity x = new SimpleEntity("X");
21
22    /** Itemized default constructor */
23    public LinkingGoal(Entity v, RoleName e, EntityExpression s) 
24        throws TrustTargetParsingException, CredentialParsingException {
25        verifier = v;
26        targetRoleName = e;
27        subject = s;
28    }
29
30    /** Construct a new trust target from a string */
31    public LinkingGoal(String s) 
32        throws TrustTargetParsingException, CredentialParsingException {
33        StringTokenizer st = new StringTokenizer(s, ":<-? ");
34        try {
35            verifier = new SimpleEntity(st.nextToken());
36            StringTokenizer rt = new StringTokenizer(st.nextToken(), ".");
37            x = new SimpleEntity(rt.nextToken());
38            targetRoleName = new SimpleRoleName(rt.nextToken());
39            subject = new SimpleEntity(st.nextToken());
40        } catch (NoSuchElementException nonesuch) {
41            throw new TrustTargetParsingException("Bad linking goal: ", s);
42        }
43
44    }
45
46    /** Unique hash function based on a verifier-target-subject triplet */
47    public int hashCode() {
48        return verifier.hashCode() * 4 + targetRoleName.hashCode() * 2 + 
49            subject.hashCode();
50    }
51    /** processing state for a node repsenting this goal is added to a TTG */ 
52    public ProcessingState  getInitialProcessingState(NegotiationContext ctx) {
53        // a linking goal is initially verifier-processed */
54        return new ProcessingState(true, false); 
55    }
56   
57    /** accessor method for the target role expressin of this target */
58    public RoleName getTargetRoleName() { return targetRoleName; }
59
60    /** type name for pretty printing an instance */
61    public String getType() {
62        return new String("LinkingGoal");
63    }
64
65    public String toString() {
66        StringBuffer buff = new StringBuffer();
67        buff.append(getVerifier().toString()).append(": ");
68        buff.append("?").append(x).append(".").append(targetRoleName);
69        buff.append(" <<-?- ").append(getSubject().toString());
70        return buff.toString();
71    }
72
73    public String toXML() {
74    /*
75        StringBuffer buff = new StringBuffer("<LinkingGoal>\n");
76        buff.append("\t<Verifier>");
77        buff.append(getVerifier().toString());
78        buff.append("</Verifier>\n");
79        buff.append("\t<TargetRoleName>");
80        buff.append(targetRoleName.toString());
81        buff.append("</TargetRoleName>\n");
82        buff.append("\t<Subject>");
83        buff.append(getSubject().toString());
84        buff.append("</Subject>\n");
85        buff.append("</TrustTarget>\n");
86        return buff.toString();
87    */
88        return toString().replaceAll("<", "&lt;");
89    }
90}
91
92
93
94
95
96
97
98
Note: See TracBrowser for help on using the repository browser.