Changeset 1408

Show
Ignore:
Timestamp:
01/11/07 11:50:41 (2 years ago)
Author:
bwilliams
Message:

Here is the new backend stuff, God help you all

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/gefeditor/Junit/com/tresys/framework/compiler/policy/TestPolicy.java

    r1389 r1408  
    5656        private void initPolicy(Component components[]) 
    5757        { 
    58                 domain1 = new Domain(new Token("Domain1", 0, 0, 0, 0, handler),null ); 
    59                 domain2 = new Domain(new Token("Domain2", 0, 0, 0, 0, handler), domain1 ); 
    60                 domain3 = new Domain(new Token("Domain3", 0, 0, 0, 0, handler), null); 
    61                 domain4 = new Domain(new Token("Domain4", 0, 0, 0, 0, handler), domain2); 
    62                 resource1 = new Resource(new Token("Resource1", 0, 0, 0, 0, handler), null); 
    63                 resource2 = new Resource(new Token("Resource2", 0, 0, 0, 0, handler), domain3); 
    64                 resource3 = new Resource(new Token("Resource3", 0, 0, 0, 0, handler), domain1); 
    6558 
    6659                thePolicy = new Policy(theDict, theLinkage); 
    67 //              for(Component c: components) 
     60                domain1 = new Domain(new Token("Domain1", 0, 0, 0, 0, handler),null , thePolicy); 
     61                domain2 = new Domain(new Token("Domain2", 0, 0, 0, 0, handler), domain1 , thePolicy); 
     62                domain3 = new Domain(new Token("Domain3", 0, 0, 0, 0, handler), null, thePolicy); 
     63                domain4 = new Domain(new Token("Domain4", 0, 0, 0, 0, handler), domain2, thePolicy); 
     64                resource1 = new Resource(new Token("Resource1", 0, 0, 0, 0, handler), null, thePolicy); 
     65                resource2 = new Resource(new Token("Resource2", 0, 0, 0, 0, handler), domain3, thePolicy); 
     66                resource3 = new Resource(new Token("Resource3", 0, 0, 0, 0, handler), domain1, thePolicy); 
     67 
     68                //              for(Component c: components) 
    6869                if (components != null) 
    6970                { 
     
    9192         */ 
    9293        public void testAddDomain() { 
    93                 Domain domain1 = new Domain(new Token("Domain1", 0, 0, 0, 0, handler),null ); 
     94                Domain domain1 = new Domain(new Token("Domain1", 0, 0, 0, 0, handler),null , thePolicy); 
    9495                assertNotNull(domain1); 
    9596                 
     
    9899                 
    99100                 
    100                 Domain domain3 = new Domain(new Token("Tes.%$#@!~t2", 0, 0, 0, 0, handler), null ); 
     101                Domain domain3 = new Domain(new Token("Tes.%$#@!~t2", 0, 0, 0, 0, handler), null , thePolicy); 
    101102                assertNotNull(domain3); 
    102103                assertTrue(thePolicy.Add(domain3)); 
     
    108109        private void domainDoubleAdd() 
    109110        { 
    110                 Domain domain1 = new Domain(new Token("Domain1", 0, 0, 0, 0, handler),null); 
     111                Domain domain1 = new Domain(new Token("Domain1", 0, 0, 0, 0, handler),null, thePolicy); 
    111112                assertNotNull(domain1); 
    112113                 
    113114                thePolicy.Add(domain1); 
    114115                 
    115                 Domain domain2 = new Domain(new Token("Domain2", 0, 0, 0, 0, handler), domain1 ); 
     116                Domain domain2 = new Domain(new Token("Domain2", 0, 0, 0, 0, handler), domain1 , thePolicy); 
    116117                assertNotNull(domain2); 
    117118                 
     
    125126        { 
    126127                // Same name test, Domain4.Domain4.Domain4 
    127                 Domain domain4 = new Domain(new Token("Domain4", 0, 0, 0, 0, handler), null); 
     128                Domain domain4 = new Domain(new Token("Domain4", 0, 0, 0, 0, handler), null, thePolicy); 
    128129                assertNotNull(domain4); 
    129130                assertTrue(thePolicy.Add(domain4)); 
    130131                 
    131                 Domain domain5 = new Domain(new Token("Domain4", 0, 0, 0, 0, handler), domain4); 
     132                Domain domain5 = new Domain(new Token("Domain4", 0, 0, 0, 0, handler), domain4, thePolicy); 
    132133                assertNotNull(domain5); 
    133134                assertTrue(thePolicy.Add(domain5)); 
    134135                 
    135                 Domain domain6 = new Domain(new Token("Domain4", 0, 0, 0, 0, handler), domain5 ); 
     136                Domain domain6 = new Domain(new Token("Domain4", 0, 0, 0, 0, handler), domain5, thePolicy); 
    136137                assertNotNull(domain6); 
    137138                assertTrue(thePolicy.Add(domain6)); 
     
    142143         */ 
    143144        public void testAddResource() { 
    144                 Domain domain1 = new Domain(new Token("Domain1", 0, 0, 0, 0, handler),null); 
     145                Domain domain1 = new Domain(new Token("Domain1", 0, 0, 0, 0, handler),null, thePolicy); 
    145146                domain1.Add(theDict.GetRdef("dirFiles"), new Token("dirFiles", 0, 0, 0, 0, handler)); 
    146147 
     
    149150                assertNotNull(thePolicy.GetDomain("Domain1")); 
    150151                 
    151                 Resource resource1 = new Resource(new Token("Resource1", 0, 0, 0, 0, handler), null); 
     152                Resource resource1 = new Resource(new Token("Resource1", 0, 0, 0, 0, handler), null, thePolicy); 
    152153                resource1.Add(theDict.GetRdef("dirFiles"), new Token("dirFiles", 0, 0, 0, 0, handler)); 
    153154                assertNotNull(resource1); 
    154155                 
    155156                assertTrue(thePolicy.Add(resource1)); 
    156                 assertNotNull(thePolicy.GetResource("Resource1"));     
     157                assertNotNull(thePolicy.GetComponent("Resource1"));    
    157158                 
    158159                resourceDoubleAdd(); 
     
    169170        void resourceDoubleAdd() 
    170171        { 
    171                 Resource resource1 = new Resource(new Token("Resource2", 0, 0, 0, 0, handler), null ); 
     172                Resource resource1 = new Resource(new Token("Resource2", 0, 0, 0, 0, handler), null, thePolicy); 
    172173                 
    173174                resource1.Add(theDict.GetRdef("dirFiles"), new Token("dirFiles", 0, 0, 0, 0, handler)); 
    174175                assertNotNull(resource1); 
    175176                assertTrue(thePolicy.Add(resource1)); 
    176                 assertNotNull(thePolicy.GetResource("Resource2")); 
     177                assertNotNull(thePolicy.GetComponent("Resource2")); 
    177178                 
    178179                assertFalse(thePolicy.Add(resource1)); 
     
    180181         
    181182        void resourceNoRdefGiven() 
    182         {               
    183                 Resource resource1 = new Resource(new Token("Resource2", 0, 0, 0, 0, handler), null); 
     183        { 
     184                Resource resource1 = new Resource(new Token("Resource2", 0, 0, 0, 0, handler), null, thePolicy); 
    184185                 
    185186                assertNotNull(resource1); 
     
    189190        void resourceRdefDup() 
    190191        { 
    191                 Resource resource1 = new Resource(new Token("Resource2", 0, 0, 0, 0, handler), null); 
     192                Resource resource1 = new Resource(new Token("Resource2", 0, 0, 0, 0, handler), null, thePolicy); 
    192193                assertTrue(resource1.Add(theDict.GetRdef("dirFiles"), new Token("dirFiles", 0, 0, 0, 0, handler))); 
    193194                assertFalse(resource1.Add(theDict.GetRdef("dirFiles"), new Token("dirFiles", 0, 0, 0, 0, handler))); 
     
    196197        void resourceRdefNotInParent() 
    197198        {        
    198                 Domain domain1 = new Domain(new Token("Domain1", 0, 0, 0, 0, handler),null ); 
     199                Domain domain1 = new Domain(new Token("Domain1", 0, 0, 0, 0, handler),null, thePolicy); 
    199200                assertNotNull(domain1); 
    200201                assertTrue(thePolicy.Add(domain1)); 
    201202                assertNotNull(thePolicy.GetDomain("Domain1")); 
    202203                 
    203                 Resource resource1 = new Resource(new Token("Resource2", 0, 0, 0, 0, handler), domain1  ); 
     204                Resource resource1 = new Resource(new Token("Resource2", 0, 0, 0, 0, handler), domain1, thePolicy); 
    204205                resource1.Add(theDict.GetRdef("dirFiles"), new Token("dirFiles", 0, 0, 0, 0, handler)); 
    205206                 
     
    212213         */ 
    213214        public void testAddEntrypointResource() { 
    214                 Domain domain1 = new Domain(new Token("Domain1", 0, 0, 0, 0, handler),null); 
     215                Domain domain1 = new Domain(new Token("Domain1", 0, 0, 0, 0, handler),null, thePolicy); 
    215216                assertNotNull(domain1); 
    216217                assertTrue(thePolicy.Add(domain1)); 
    217218                 
    218                 EntrypointResource entryResource1 = new EntrypointResource(new Token("EntryRes1", 0, 0, 0, 0, handler), domain1, theDict.Entrypoint); 
     219                EntrypointResource entryResource1 = new EntrypointResource(new Token("EntryRes1", 0, 0, 0, 0, handler), domain1, theDict.Entrypoint, thePolicy); 
    219220                assertNotNull(entryResource1); 
    220221                assertTrue(thePolicy.Add(entryResource1)); 
    221222                assertFalse(thePolicy.Add(entryResource1)); 
    222223                 
    223                 EntrypointResource entryResource2 = new EntrypointResource(new Token("EntryRes2", 0, 0, 0, 0, handler), null, null); 
     224                EntrypointResource entryResource2 = new EntrypointResource(new Token("EntryRes2", 0, 0, 0, 0, handler), null, null, thePolicy); 
    224225                assertNotNull(entryResource2); 
    225226                assertTrue(thePolicy.Add(entryResource2)); 
     
    345346        } 
    346347         
    347         private void validateReservedWord() 
    348         { 
    349                 Domain domain1 = new Domain(new Token("user", 0, 0, 0, 0, handler), null); 
    350                  
     348        private void validateReservedWord() { 
     349                Domain domain1 = new Domain(new Token("user", 0, 0, 0, 0, handler), null, thePolicy); 
     350 
    351351                initPolicy(new Component [] { domain1 }); 
    352                  
     352 
    353353                // Will fail due to user being a reserved word 
    354354                assertTrue(thePolicy.Validate()); 
    355                  
    356                 Resource resource1 = new Resource(new Token("user", 0, 0, 0, 0, handler), null); 
     355 
     356                Resource resource1 = new Resource(new Token("user", 0, 0, 0, 0, handler), null, thePolicy); 
    357357                initPolicy(new Component [] { resource1 }); 
    358358                 
     
    360360        } 
    361361 
    362         private void validateNoChildDomain() 
    363         {                
     362        private void validateNoChildDomain() { 
    364363                initPolicy(new Component [] { domain3, resource2 }); 
    365364                // Will fail due to domain 3 not having a child domain 
     
    371370         */ 
    372371        public void testAddEnter() { 
    373                 Domain domain1 = new Domain(new Token("Domain1", 0, 0, 0, 0, handler),null); 
     372                Domain domain1 = new Domain(new Token("Domain1", 0, 0, 0, 0, handler),null, thePolicy); 
    374373                assertNotNull(domain1); 
    375374                assertTrue(thePolicy.Add(domain1)); 
    376375                 
    377                 Domain domain2 = new Domain(new Token("Domain2", 0, 0, 0, 0, handler),null); 
     376                Domain domain2 = new Domain(new Token("Domain2", 0, 0, 0, 0, handler),null, thePolicy); 
    378377                assertNotNull(domain2); 
    379378                assertTrue(thePolicy.Add(domain2)); 
    380379 
    381                 EntrypointResource entryResource1 = new EntrypointResource(new Token("EntryRes1", 0, 0, 0, 0, handler), domain1, theDict.Entrypoint); 
     380                EntrypointResource entryResource1 = new EntrypointResource(new Token("EntryRes1", 0, 0, 0, 0, handler), domain1, theDict.Entrypoint, thePolicy); 
    382381                assertNotNull(entryResource1); 
    383382                assertTrue(thePolicy.Add(entryResource1)); 
     
    389388                assertFalse(thePolicy.Add(enter)); 
    390389 
    391                 EntrypointResource entryResource2 = new EntrypointResource(new Token("EntryRes1", 0, 0, 0, 0, handler), null, theDict.Entrypoint); 
     390                EntrypointResource entryResource2 = new EntrypointResource(new Token("EntryRes1", 0, 0, 0, 0, handler), null, theDict.Entrypoint, thePolicy); 
    392391                assertNotNull(entryResource2); 
    393392                assertTrue(thePolicy.Add(entryResource2)); 
  • branches/gefeditor/src/com/tresys/framework/compiler/PolicyGenerator.java

    r1396 r1408  
    126126                buf 
    127127                        .append("access " + i_access.getDomain().getName() + " " 
    128                                 + i_access.GetResource().getName() + " " + i_access.getVerb() 
     128                                + i_access.getResource().getName() + " " + i_access.getVerb() 
    129129                                + ";"); 
    130130                buf.append(newLine); 
  • branches/gefeditor/src/com/tresys/framework/compiler/policy/Access.java

    r1396 r1408  
    3838                Domain = dom; 
    3939                resource = res; 
    40                 this.m_verb = verb; 
     40                m_verb = verb; 
    4141                Token = token; 
    4242                m_bool = bool; 
  • branches/gefeditor/src/com/tresys/framework/compiler/policy/AccessBaseResource.java

    r1403 r1408  
    9090                if(Domain.GetChildDomains().size() > 0) { 
    9191                        /*for (Domain child: Domain.GetChildDomains())*/ 
    92                         Iterator iter = Domain.GetChildDomains().iterator(); 
     92                        Iterator iter = Domain.GetChildDomains().values().iterator(); 
    9393                        while(iter.hasNext()) { 
    9494                                Domain child = (Domain) iter.next(); 
    9595                                /*for (Access childAccess: child.GetAccess(verb).values())*/ 
    96                                 Iterator iter2 = child.GetAccess(m_verb).values().iterator(); 
     96                                Iterator iter2 = child.GetAccesses().iterator(); 
    9797                                while(iter2.hasNext()) { 
    9898                                        Access childAccess = (Access) iter2.next(); 
     
    113113                if(domainParent != null) { 
    114114 
    115                         Map/*<Component, Access>*/parentAccesses = domainParent 
    116                                 .GetAccess(m_verb); 
     115                        Map parentAccesses = domainParent.GetAccessMap(m_verb.intValue()); 
    117116 
    118                         if(parentAccesses == null) { 
     117                        if(parentAccesses.isEmpty()) { 
    119118                                Token 
    120119                                        .Warning("Constraint violation: Child domain has attempted to exceed parent domain \"" 
  • branches/gefeditor/src/com/tresys/framework/compiler/policy/AccessBoolean.java

    r1396 r1408  
    3030                if(domainParent != null) { 
    3131 
    32                         Map/*<Component, Access>*/parentAccesses = domainParent 
    33                                 .GetAccess(m_verb); 
     32                        Map/*<Component, Access>*/parentAccesses = domainParent.GetAccessMap(m_verb.intValue()); 
    3433 
    35                         if(parentAccesses == null) { 
     34                        if(parentAccesses.isEmpty()) { 
    3635                                Token 
    3736                                        .Warning("Constraint violation: Child domain has attempted to exceed parent domain \"" 
  • branches/gefeditor/src/com/tresys/framework/compiler/policy/AccessResource.java

    r1403 r1408  
    1919import com.tresys.framework.compiler.dictionary.IDictionaryObject; 
    2020import com.tresys.framework.compiler.dictionary.Verb; 
     21import com.tresys.framework.compiler.policy.components.Component; 
    2122import com.tresys.framework.compiler.policy.components.ComponentWithDictObjects; 
    2223import com.tresys.framework.compiler.policy.components.Domain; 
     
    7273                AccessDefnGroup rdefGroup; 
    7374 
    74                 Rdef rdef = GetResource().getRdef(); 
     75                Rdef rdef = res.getRdef(); 
    7576                if(rdef != null) { 
    7677                        rdefGroup = rdef.GetAccessDefnGroup(this.m_verb.intValue()); 
     
    99100        } 
    100101 
    101         public Resource GetResource() { 
    102                 return (Resource) resource; 
     102        public Component getResource() { 
     103                return resource; 
    103104        } 
    104105 
     
    130131         */ 
    131132        /*@Override*/public String toString() { 
    132                 return Domain.toString() + Utility.DELIM + GetResource().toString() 
     133                return Domain.toString() + Utility.DELIM + getResource().toString() 
    133134                        + Utility.DELIM + Verb.toString(this.m_verb); 
    134135        } 
     
    170171                if(Domain.GetChildDomains().size() > 0) { 
    171172                        /*for (Domain child: Domain.GetChildDomains())*/ 
    172                         Iterator iter = Domain.GetChildDomains().iterator(); 
     173                        Iterator iter = Domain.GetChildDomains().values().iterator(); 
    173174                        while(iter.hasNext()) { 
    174175                                Domain child = (Domain) iter.next(); 
    175176                                /*for (Access childAccess: child.GetAccess(verb).values())*/ 
    176                                 Iterator iter2 = child.GetAccess(m_verb).values().iterator(); 
     177                                Iterator iter2 = child.GetAccesses(m_verb.intValue()).iterator(); 
    177178                                while(iter2.hasNext()) { 
    178179                                        Access childAccess = (Access) iter2.next(); 
    179180                                        if(childAccess instanceof AccessResource 
    180                                                 && ((AccessResource) childAccess).GetResource() == GetResource()) { 
     181                                                && ((AccessResource) childAccess).getResource() == getResource()) { 
    181182                                                return true; 
    182183                                        } 
     
    186187                        return false; 
    187188                } 
     189                 
    188190                if(accessDefs == null || accessDefs.isEmpty()) 
    189                         Token.Warning("No RDef in the resource " + GetResource().getName() 
     191                        Token.Warning("No RDef in the resource " + getResource().getName() 
    190192                                + " defines a " + Verb.toString(this.m_verb) + " access", 
    191193                                ErrorHandler.ERROR_INVALID_ACCESS, getResource().getName()); 
     
    196198                if(domainParent != null && domainParent != resource.getParent()) { 
    197199 
    198                         Map/*<Component, Access>*/parentAccesses = domainParent 
    199                                 .GetAccess(m_verb); 
     200                        Map/*<Component, Access>*/parentAccesses = domainParent.GetAccessMap(m_verb.intValue()); 
    200201 
    201202                        if(parentAccesses == null) { 
     
    251252                        return false; 
    252253 
    253                 if(!GetResource().equals(access.GetResource())) 
     254                if(!getResource().equals(access.getResource())) 
    254255                        return false; 
    255256 
  • branches/gefeditor/src/com/tresys/framework/compiler/policy/Enter.java

    r1403 r1408  
    162162                        if(m_domain_end.GetChildDomains().size() > 0) { 
    163163                                /*for (Domain child: DomainStart.GetChildDomains())*/ 
    164                                 Iterator iter = m_domain_start.GetChildDomains().iterator(); 
     164                                Iterator iter = m_domain_start.GetChildDomains().values().iterator(); 
    165165                                while(iter.hasNext()) { 
    166166                                        Domain child = (Domain) iter.next(); 
     
    183183                        } else { 
    184184                                /*for (Domain child: DomainStart.GetChildDomains())*/ 
    185                                 Iterator iter = m_domain_start.GetChildDomains().iterator(); 
     185                                Iterator iter = m_domain_start.GetChildDomains().values().iterator(); 
    186186                                while(iter.hasNext()) { 
    187187                                        Domain child = (Domain) iter.next(); 
  • branches/gefeditor/src/com/tresys/framework/compiler/policy/Export.java

    r1396 r1408  
    6464                verb = v; 
    6565                Token = tok; 
    66  
    6766                accessDefs = new HashMap/*<String, AccessDefn>*/(); 
    6867 
  • branches/gefeditor/src/com/tresys/framework/compiler/policy/Policy.java

    r1396 r1408  
    1717import java.util.TreeMap; 
    1818import java.util.HashMap; 
    19 import java.util.LinkedList; 
    2019import java.util.Vector; 
    2120 
     
    2726import com.tresys.framework.compiler.IPolicyVisitable; 
    2827import com.tresys.framework.compiler.IPolicyVisitor; 
    29 import com.tresys.framework.compiler.Utility; 
    3028import com.tresys.framework.compiler.dictionary.Dictionary; 
    3129import com.tresys.framework.compiler.dictionary.IDictionaryObject; 
     
    5149public final class Policy { 
    5250        // A policy contains a few nouns (domains, resources, & entrypoints) 
    53         // The domains defined in the policy   
    54         private final Map/*<String, IDomain> */domains; 
    55  
    56         // the resources defined in the policy  
    57         private final Map/*<String, Resource>*/resources; 
    58  
    59         // the entrypoints defined in the policy  
    60         private final Map/*<String, EntrypointResource> */entrypoints; 
    61  
    62         // the combination of all of the domains, resources, and entrypoints 
    63         private final Map/*<String, Component>*/components; 
    64  
    65         // set of accesses   
    66         private final Map/*<String, Access>*/accesses; 
     51 
     52        private final Map/*<String, Component> */topLevelComponents; 
    6753 
    6854        private final Map/*<String, BaseResource>*/m_baseResources; 
    69  
    70         // set of exported interfaces   
    71         private final Map/*<String, Export>*/exports; 
    72  
    73         // set of entries   
    74         private final Map/*<String, LinkedList<Enter>>*/entries; 
    7555 
    7656        // the policy level list of system resources (needed for efficient duplicate checks) 
    7757        private final Map/*<SystemResource, Component>*/sysResources; 
    7858 
    79         private final TreeMap /*<Token, IPolicyVisitable>*/allItems; 
     59        private final Vector /*<String>*/ comments; 
    8060 
    8161        private final Linkage linkage; 
     
    9979 
    10080                // initialize the policy contents 
    101                 domains = new TreeMap/*<String, IDomain>*/(); 
    102                 resources = new TreeMap/*<String, Resource>*/(); 
    103                 entrypoints = new TreeMap/*<String, EntrypointResource>*/(); 
     81                topLevelComponents = new TreeMap/*<IDomain>*/(); 
    10482                sysResources = new TreeMap/*<SystemResource, Component>*/(); 
    105                 components = new TreeMap/*<String, Component>*/(); 
    10683                m_baseResources = new TreeMap/*<String, Module>*/(); 
    107                 accesses = new TreeMap/*<String, Access>*/(); 
    108                 exports = new HashMap/*<String, Export>*/(); 
    109                 entries = new HashMap/*<String, LinkedList<Enter>>*/(); 
    110                 allItems = new TreeMap /*<Token, IPolicyVisitable>*/(); 
    11184                frameworkBooleans = new TreeMap /*<String, PolicyBoolean>*/(); 
     85                comments = new Vector /*<Vector>*/ (); 
    11286        } 
    11387 
     
    141115 
    142116        public boolean AddComment(Comment i_comment) { 
    143                 allItems.put(i_comment.GetNameToken(), i_comment); 
     117                comments.add(i_comment); 
    144118                return true; 
    145119        } 
     
    181155                        handler.CriticalError(e.getMessage()); 
    182156                } 
    183  
    184157        } 
    185158 
     
    192165         */ 
    193166        public boolean Add(IDomain dom) { 
    194                 if(components.containsKey(dom.getName())) { 
     167                if(GetComponent(dom.getName()) != null) { 
    195168                        dom.getToken().Error( 
    196169                                "The component \"" + dom.getName() + "\" is already defined"); 
    197                         return false; 
    198                 } 
    199  
    200                 components.put(dom.getName(), dom); 
    201                 domains.put(dom.getName(), dom); 
    202                 allItems.put(dom.getToken(), dom); 
    203                 if(dom.getParent() != null && dom instanceof Domain) { 
     170                        return false;                            
     171                } 
     172                 
     173                if(dom.getParent() != null) { 
    204174                        dom.getParent().AddChild((Domain) dom); 
    205                 } 
     175                } else { 
     176                        topLevelComponents.put(dom.getSubName(), dom); 
     177                } 
     178 
    206179                return true; 
    207180        } 
     
    215188         */ 
    216189        public boolean Add(Resource res) { 
    217                 boolean bResult = true; 
    218                 if(components.containsKey(res.getName())) { 
     190                if(GetComponent(res.getName()) != null) { 
    219191                        res.getToken().Error( 
    220192                                "The component \"" + res.getName() + "\" is already defined"); 
    221                         bResult = false; 
    222                 } 
    223  
    224                 if(res.getRdef() == null) { 
    225                         res.getToken().Warning("Shared resources must have at least one Rdef associated", 
    226                                 ErrorHandler.ERROR_TYPE_NO_RDEF_ASSIGNED, res.getName()); 
    227 //                      bResult = false; 
    228                 } 
    229  
    230                 components.put(res.getName(), res); 
    231                 resources.put(res.getName(), res); 
    232                 allItems.put(res.getToken(), res); 
     193                        return false;                            
     194                } 
     195                 
    233196                if(res.getParent() != null) { 
    234197                        res.getParent().AddChild(res); 
    235                 } 
    236                 return bResult; 
     198                } else { 
     199                        topLevelComponents.put(res.getSubName(), res); 
     200                } 
     201 
     202                return true; 
    237203        } 
    238204 
     
    245211         */ 
    246212        public boolean Add(EntrypointResource ep) { 
    247                 if(components.containsKey(ep.getName())) { 
     213                if(GetComponent(ep.getName()) != null) { 
    248214                        ep.getToken().Error( 
    249215                                "The component \"" + ep.getName() + "\" is already defined"); 
    250                         return false; 
    251                 } 
    252  
    253                 components.put(ep.getName(), ep); 
    254                 entrypoints.put(ep.getName(), ep); 
    255                 allItems.put(ep.getToken(), ep); 
     216                        return false;                            
     217                } 
    256218 
    257219                if(ep.getParent() != null) { 
    258220                        ep.getParent().AddChild(ep); 
    259                 } 
     221                } else { 
     222                        topLevelComponents.put(ep.getSubName(), ep); 
     223                } 
     224 
    260225                return true; 
    261226        } 
     
    269234         */ 
    270235        public boolean Add(AccessResource axx) { 
    271  
    272                 /* 
    273                  * the unique combination of domain-resource-verb strings 
    274                  * acts as a key 
    275                  */ 
    276                 String key = axx.toString(); 
    277  
    278                 if(accesses.containsKey(key)) { 
    279                         axx.Token.Warning("Domain \"" + axx.Domain.getName() 
    280                                 + "\" already has \"" + Verb.toString(axx.m_verb) 
    281                                 + "\" access to resource \"" + axx.GetResource().getName() 
    282                                 + "\""); 
    283                         return false; 
    284                 } 
    285  
    286                 if(axx.GetResource().IsDescendant(axx.Domain)) { 
     236                if(axx.getResource().IsDescendant(axx.Domain)) { 
    287237                        axx.Token 
    288238                                .Error("Constraint violation: a domain cannot access its children"); 
     
    290240                } 
    291241 
    292                 Domain resourceParent = axx.GetResource().getParent(); 
     242                Domain resourceParent = axx.getResource().getParent(); 
    293243 
    294244                if(resourceParent != null && !axx.Domain.IsDescendant(resourceParent)) { 
     
    298248                } 
    299249 
    300                 accesses.put(key, axx); 
    301                 allItems.put(axx.GetNameToken(), axx); 
    302  
    303250                // update graph links for information flow 
    304                 axx.Domain.Add(axx); 
    305                 axx.GetResource().Add(axx); 
    306                 return true; 
    307         } 
    308  
    309         /** 
    310          * Add an access to the policy. 
    311          *  
    312          * @param axx   AccessModule to be inserted into policy. 
    313          * @return              <code>true</code> on successful insertion, 
    314          *                              <code>false</code> otherwise. 
    315          */ 
    316         public boolean Add(AccessModule axx) { 
    317                 /* 
    318                  * the unique combination of domain-resource-verb strings 
    319                  * acts as a key 
    320                  */ 
    321                 String key = axx.toString(); 
    322  
    323                 if(accesses.containsKey(key)) { 
    324                         axx.Token 
    325                                 .Warning("Domain \"" + axx.Domain.getName() 
    326                                         + "\" already has \"" + Verb.toString(axx.m_verb) 
    327                                         + "\" access to resource \"" + axx.GetModule().getName() 
    328                                         + "\""); 
    329                         return false; 
    330                 } 
    331  
    332                 accesses.put(key, axx); 
    333                 allItems.put(axx.GetNameToken(), axx); 
    334  
    335                 // update graph links for information flow 
    336                 axx.Domain.Add(axx); 
     251                if(!axx.getDomain().Add(axx)) { 
     252                        axx.Token.Warning("Domain \"" + axx.Domain.getName() 
     253                                + "\" already has \"" + Verb.toString(axx.m_verb) 
     254                                + "\" access to resource \"" + axx.getResource().getName() 
     255                                + "\""); 
     256                } 
     257                ((Resource) axx.getResource()).Add(axx); 
    337258                return true; 
    338259        } 
     
    346267         */ 
    347268        public boolean Add(AccessBaseResource axx) { 
    348  
    349                 /* 
    350                  * the unique combination of domain-resource-verb strings 
    351                  * acts as a key 
    352                  */ 
    353                 String key = axx.toString(); 
    354  
    355                 if(accesses.containsKey(key)) { 
     269                // update graph links for information flow 
     270                if(! axx.Domain.Add(axx)){ 
    356271                        axx.Token.Warning("Domain \"" + axx.Domain.getName() 
    357272                                + "\" already has \"" + Verb.toString(axx.m_verb) 
     
    360275                        return false; 
    361276                } 
    362  
    363                 accesses.put(key, axx); 
    364                 allItems.put(axx.GetNameToken(), axx); 
    365  
    366                 // update graph links for information flow 
    367                 axx.Domain.Add(axx); 
    368277                return true; 
    369278        }