source: fedd/abac-src/ttg/process/ResourcePolicy.java @ 181cf9c

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

ABAC sources from Cobham

  • Property mode set to 100644
File size: 1.8 KB
Line 
1package com.nailabs.abac.process;
2
3import java.util.*;
4import edu.stanford.peer.rbtm.credential.*;
5//import edu.stanford.peer.rbtm.engine.StaticCredential;
6
7/**
8 * Resource policy for negotiations. The policy can be queried using the
9 * <code>requires</code> method with a specific credential resource
10 * identifier, which can be a URl or a mnemonic identifier.
11 */
12public class ResourcePolicy implements java.io.Serializable {
13    /** Internal hash table for policy storage */
14    private HashMap resourcePolicy = null;
15
16    /** Default constructor with a non-resstrictive policy */
17    public ResourcePolicy() {
18        resourcePolicy = new HashMap();
19    }
20
21    /** Accessor for all the access control policy keys */
22    public Vector getResourceIdentifiers() { 
23        return new Vector(resourcePolicy.keySet()); 
24    }
25
26    /**
27     * Useful for forward discovery.
28     * @return a set of all roles which satisfy the AC policy requirements
29     */
30    public Vector getRequiredRoles() {
31        return new Vector(resourcePolicy.values());
32    }
33
34    /** Adds a single policy atom from String parameters. */
35    public void addResourceFact(String resourceID, String role) 
36        throws CredentialParsingException {
37        try {
38            addResourceFact(resourceID, (Role)StaticCredential.getRole(role));
39        } catch(Exception ex) {
40            ex.printStackTrace();
41        }
42    }
43
44    /** Adds a single policy atom. */
45    public void addResourceFact(String key, Role role) {
46        resourcePolicy.put(key, role);
47    }
48
49    /** Query the policy to determine the required role for a credential */
50    public Role requires(String resource) {
51        return (Role)resourcePolicy.get(resource);
52    }
53
54    /** Returns the underlying storage data structure in a printable format */
55    public String toString() {
56        if(resourcePolicy == null)
57            return null;
58        else 
59            return resourcePolicy.toString();
60    }
61
62}
Note: See TracBrowser for help on using the repository browser.