source: fedd/abac-src/ttg/trust/IntersectionTTNode.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.8 KB
Line 
1package com.nailabs.abac.trust;
2
3import java.util.*;
4import com.nailabs.abac.test.*;
5import com.nailabs.abac.process.*;
6import edu.stanford.peer.rbtm.credential.*;
7
8public class IntersectionTTNode extends TargetNode {
9    TTGNodeSet intersectionChildren = new TTGNodeSet();
10    int k = 0, satisfactionCount = 0;
11
12    public IntersectionTTNode(TrustTarget target) {
13        super(target);
14        k = ((Intersection)target.getTargetRole()).getPartsCount();
15        subName = "Intersection";
16    }
17
18    public void addIntersectionChild(TargetNode child) {
19        intersectionChildren.add(child);
20    }
21
22    protected TTGNodeSet send(TrustTarget source, SatisfactionState state) {
23        TTGNodeSet results = new TTGNodeSet();
24        setState(state);
25        Iterator i = implicationParents.values().iterator();
26        while(i.hasNext()) {
27            try { // this will fail if the parent is a linking goal
28                SatisfactionListener listener = (SatisfactionListener)i.next();
29                TTGNodeSet branchResult = 
30                    listener.receive((TrustTarget)getGoal(), state);
31                if(branchResult == null && branchResult.size() > 0) {
32                    results.addAll(branchResult);
33                }
34            }
35            catch(Exception ex) { // to print out exception uncomment
36                ex.printStackTrace();
37            }
38        }
39        i = controlParents.values().iterator();
40        Strategy strategy = context.getStrategy();
41        while(i.hasNext()) {
42            // add each control parent to the work list
43            strategy.addToWorklist((TTGNode)i.next());
44        } 
45        return results;
46    }
47   
48
49    public  TTGNodeSet receive(TrustTarget source, SatisfactionState state) {
50        debug("satisfaction", getGoal() + " received " + state + " from " +
51              source + " with count = " + satisfactionCount);
52        switch(state.getState()) {
53        case SatisfactionState.SATISFIED:
54            satisfactionCount += 1;
55            if(satisfactionCount < k) {
56                debug("statisfaction", "Intersection received partial satisfaction = " 
57                      + satisfactionCount + "/" + k);
58                break;
59            }
60        case SatisfactionState.FAILED:
61            debug("satisfaction", "Intersection is propagating received " + 
62                  state + " with " + satisfactionCount + "/" + k);
63            return send(source, state);
64        default:
65            debug("satisfaction", "Intersection default received " + 
66                  state + " with " + satisfactionCount + "/" + k);
67        }
68        return new TTGNodeSet();
69    }
70
71    private void intersectionProcess(NegotiationContext context) {
72        debug("satisfaction", "target expression = " + getTargetExpression());
73        Intersection i = (Intersection)getTargetExpression();
74        EntityExpression subject = getSubject();
75        Entity verifier = getVerifier();
76        Iterator parts = i.getParts();
77        //k = i.getPartsCount();
78       
79        while(parts.hasNext()) {
80            EntityExpression aDotR = (EntityExpression)parts.next();
81            try {
82                TrustTarget child = new TrustTarget(verifier, aDotR, subject);
83                context.getGraph().addIntersectionEdge((TrustTarget)getGoal(),
84                                                       child);
85            }
86            catch(Exception ex) {
87                ex.printStackTrace();
88            }
89        }
90    }
91
92    public void opponentProcess(NegotiationContext context) {
93        if(processor.isOpponentProcessed()) {
94            return;
95        }
96        intersectionProcess(context);
97        processor.opponentProcess();
98    }
99
100    public void verifierProcess(NegotiationContext context) {
101        if(processor.isVerifierProcessed()) {
102            return;
103        }
104        intersectionProcess(context);
105        processor.verifierProcess();
106    }
107
108}
Note: See TracBrowser for help on using the repository browser.