source: fedd/abac-src/ttg/process/ACPolicy.java @ c2dbca8

axis_examplecompt_changesinfo-opsversion-1.30version-2.00version-3.01version-3.02
Last change on this file since c2dbca8 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
6/**
7 * Access control policy for credentials. The policy can be queried using the
8 * <code>requires</code> method with a specific credential.
9 */
10public class ACPolicy implements java.io.Serializable {
11    /** Implicitly allow access if there is no relevant policy */
12    public static final Role TRUE = null;
13
14    /** Internal hash table for policy storage */
15    private HashMap accessControl = null;
16
17    /** Default constructor with a non-resstrictive policy */
18    public ACPolicy() {
19        accessControl = new HashMap();
20    }
21
22    /** Accessor for all the access control policy keys */
23    public Vector getProtectedCredentials() { 
24        return new Vector(accessControl.keySet()); 
25    }
26
27    /**
28     * Useful for forward discovery.
29     * @return a set of all roles which satisfy the AC policy requirements
30     */
31    public Vector getRequiredRoles() {
32        return new Vector(accessControl.values());
33    }
34
35    /** Adds a single policy atom from String parameters. */
36    public void addACFact(String cred, String expr) 
37        throws CredentialParsingException {
38        addACFact(new StaticCredential(cred), 
39             StaticCredential.getEntityExpression(expr));
40    }
41
42    /** Adds a single policy atom. */
43    public void addACFact(Credential key, EntityExpression expr) {
44        accessControl.put(key, expr);
45    }
46
47    /** Query the policy to determine the required role for a credential */
48    public EntityExpression requires(Credential resource) {
49        return (EntityExpression)accessControl.get(resource);
50    }
51
52    /** Returns the underlying storage data structure in a printable format */
53    public String toString() {
54        if(accessControl == null)
55            return null;
56        else 
57            return accessControl.toString();
58    }
59
60}
Note: See TracBrowser for help on using the repository browser.