Changeset 1408
- Timestamp:
- 01/11/07 11:50:41 (2 years ago)
- Files:
-
- branches/gefeditor/Junit/com/tresys/framework/compiler/policy/TestPolicy.java (modified) (16 diffs)
- branches/gefeditor/src/com/tresys/framework/compiler/PolicyGenerator.java (modified) (1 diff)
- branches/gefeditor/src/com/tresys/framework/compiler/policy/Access.java (modified) (1 diff)
- branches/gefeditor/src/com/tresys/framework/compiler/policy/AccessBaseResource.java (modified) (2 diffs)
- branches/gefeditor/src/com/tresys/framework/compiler/policy/AccessBoolean.java (modified) (1 diff)
- branches/gefeditor/src/com/tresys/framework/compiler/policy/AccessModule.java (deleted)
- branches/gefeditor/src/com/tresys/framework/compiler/policy/AccessResource.java (modified) (8 diffs)
- branches/gefeditor/src/com/tresys/framework/compiler/policy/Enter.java (modified) (2 diffs)
- branches/gefeditor/src/com/tresys/framework/compiler/policy/Export.java (modified) (1 diff)
- branches/gefeditor/src/com/tresys/framework/compiler/policy/Policy.java (modified) (40 diffs)
- branches/gefeditor/src/com/tresys/framework/compiler/policy/PolicyParser.jj (modified) (22 diffs)
- branches/gefeditor/src/com/tresys/framework/compiler/policy/components/BaseDomain.java (modified) (9 diffs)
- branches/gefeditor/src/com/tresys/framework/compiler/policy/components/BaseResource.java (modified) (5 diffs)
- branches/gefeditor/src/com/tresys/framework/compiler/policy/components/Component.java (modified) (6 diffs)
- branches/gefeditor/src/com/tresys/framework/compiler/policy/components/ComponentWithDictObjects.java (modified) (6 diffs)
- branches/gefeditor/src/com/tresys/framework/compiler/policy/components/Conditional.java (modified) (3 diffs)
- branches/gefeditor/src/com/tresys/framework/compiler/policy/components/ControlResource.java (modified) (2 diffs)
- branches/gefeditor/src/com/tresys/framework/compiler/policy/components/Domain.java (modified) (14 diffs)
- branches/gefeditor/src/com/tresys/framework/compiler/policy/components/EntrypointResource.java (modified) (2 diffs)
- branches/gefeditor/src/com/tresys/framework/compiler/policy/components/IDomain.java (modified) (5 diffs)
- branches/gefeditor/src/com/tresys/framework/compiler/policy/components/Module.java (deleted)
- branches/gefeditor/src/com/tresys/framework/compiler/policy/components/Resource.java (modified) (2 diffs)
- branches/gefeditor/src/com/tresys/framework/compiler/policy/components/UserDomain.java (modified) (6 diffs)
- branches/gefeditor/src/com/tresys/framework/compiler/systemResources/SystemResourcesParser.jj (modified) (2 diffs)
- branches/gefeditor/src/com/tresys/framework/compiler/translator/Translator.java (modified) (13 diffs)
- branches/gefeditor/src/com/tresys/framework/plugin/builder/SELinuxSystem.java (modified) (1 diff)
- branches/gefeditor/src/com/tresys/framework/plugin/editor/policy/PolicyDocumentProvider.java (modified) (1 diff)
- branches/gefeditor/src/com/tresys/framework/plugin/editor/policy/graphic/GraphicPolicyRefresh.java (modified) (1 diff)
- branches/gefeditor/src/com/tresys/framework/plugin/editor/policy/graphic/action (deleted)
- branches/gefeditor/src/com/tresys/framework/plugin/editor/policy/graphic/commands/AddCommand.java (modified) (3 diffs)
- branches/gefeditor/src/com/tresys/framework/plugin/editor/policy/graphic/model/AccessConnection.java (modified) (2 diffs)
- branches/gefeditor/src/com/tresys/framework/plugin/editor/policy/graphic/model/DomainShape.java (modified) (1 diff)
- branches/gefeditor/src/com/tresys/framework/plugin/editor/policy/graphic/model/EntryConnection.java (modified) (4 diffs)
- branches/gefeditor/src/com/tresys/framework/plugin/editor/policy/graphic/model/EntryPointShape.java (modified) (1 diff)
- branches/gefeditor/src/com/tresys/framework/plugin/editor/policy/graphic/model/ResourceShape.java (modified) (1 diff)
- branches/gefeditor/src/com/tresys/framework/plugin/editor/policy/graphic/model/Shape.java (modified) (6 diffs)
- branches/gefeditor/src/com/tresys/framework/plugin/editor/policy/graphic/model/UserDomainShape.java (modified) (1 diff)
- branches/gefeditor/src/com/tresys/framework/plugin/editor/policy/text/PolicyCompletionProcessor.java (modified) (10 diffs)
- branches/gefeditor/src/com/tresys/framework/plugin/editor/policy/text/PolicyHoverController.java (modified) (6 diffs)
- branches/gefeditor/src/com/tresys/framework/plugin/editor/policy/text/PolicyOutlinePage.java (modified) (3 diffs)
- branches/gefeditor/src/com/tresys/framework/plugin/editor/sysresource/SystemResourcesCompletionProcessor.java (modified) (5 diffs)
- branches/gefeditor/src/com/tresys/framework/plugin/editor/sysresource/SystemResourcesHoverController.java (modified) (4 diffs)
- branches/gefeditor/src/com/tresys/framework/plugin/marker/resolution/PolicyMarkerResolutionGenerator.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/gefeditor/Junit/com/tresys/framework/compiler/policy/TestPolicy.java
r1389 r1408 56 56 private void initPolicy(Component components[]) 57 57 { 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);65 58 66 59 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) 68 69 if (components != null) 69 70 { … … 91 92 */ 92 93 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); 94 95 assertNotNull(domain1); 95 96 … … 98 99 99 100 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); 101 102 assertNotNull(domain3); 102 103 assertTrue(thePolicy.Add(domain3)); … … 108 109 private void domainDoubleAdd() 109 110 { 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); 111 112 assertNotNull(domain1); 112 113 113 114 thePolicy.Add(domain1); 114 115 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); 116 117 assertNotNull(domain2); 117 118 … … 125 126 { 126 127 // 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); 128 129 assertNotNull(domain4); 129 130 assertTrue(thePolicy.Add(domain4)); 130 131 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); 132 133 assertNotNull(domain5); 133 134 assertTrue(thePolicy.Add(domain5)); 134 135 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); 136 137 assertNotNull(domain6); 137 138 assertTrue(thePolicy.Add(domain6)); … … 142 143 */ 143 144 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); 145 146 domain1.Add(theDict.GetRdef("dirFiles"), new Token("dirFiles", 0, 0, 0, 0, handler)); 146 147 … … 149 150 assertNotNull(thePolicy.GetDomain("Domain1")); 150 151 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); 152 153 resource1.Add(theDict.GetRdef("dirFiles"), new Token("dirFiles", 0, 0, 0, 0, handler)); 153 154 assertNotNull(resource1); 154 155 155 156 assertTrue(thePolicy.Add(resource1)); 156 assertNotNull(thePolicy.Get Resource("Resource1"));157 assertNotNull(thePolicy.GetComponent("Resource1")); 157 158 158 159 resourceDoubleAdd(); … … 169 170 void resourceDoubleAdd() 170 171 { 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); 172 173 173 174 resource1.Add(theDict.GetRdef("dirFiles"), new Token("dirFiles", 0, 0, 0, 0, handler)); 174 175 assertNotNull(resource1); 175 176 assertTrue(thePolicy.Add(resource1)); 176 assertNotNull(thePolicy.Get Resource("Resource2"));177 assertNotNull(thePolicy.GetComponent("Resource2")); 177 178 178 179 assertFalse(thePolicy.Add(resource1)); … … 180 181 181 182 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); 184 185 185 186 assertNotNull(resource1); … … 189 190 void resourceRdefDup() 190 191 { 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); 192 193 assertTrue(resource1.Add(theDict.GetRdef("dirFiles"), new Token("dirFiles", 0, 0, 0, 0, handler))); 193 194 assertFalse(resource1.Add(theDict.GetRdef("dirFiles"), new Token("dirFiles", 0, 0, 0, 0, handler))); … … 196 197 void resourceRdefNotInParent() 197 198 { 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); 199 200 assertNotNull(domain1); 200 201 assertTrue(thePolicy.Add(domain1)); 201 202 assertNotNull(thePolicy.GetDomain("Domain1")); 202 203 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); 204 205 resource1.Add(theDict.GetRdef("dirFiles"), new Token("dirFiles", 0, 0, 0, 0, handler)); 205 206 … … 212 213 */ 213 214 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); 215 216 assertNotNull(domain1); 216 217 assertTrue(thePolicy.Add(domain1)); 217 218 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); 219 220 assertNotNull(entryResource1); 220 221 assertTrue(thePolicy.Add(entryResource1)); 221 222 assertFalse(thePolicy.Add(entryResource1)); 222 223 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); 224 225 assertNotNull(entryResource2); 225 226 assertTrue(thePolicy.Add(entryResource2)); … … 345 346 } 346 347 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 351 351 initPolicy(new Component [] { domain1 }); 352 352 353 353 // Will fail due to user being a reserved word 354 354 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); 357 357 initPolicy(new Component [] { resource1 }); 358 358 … … 360 360 } 361 361 362 private void validateNoChildDomain() 363 { 362 private void validateNoChildDomain() { 364 363 initPolicy(new Component [] { domain3, resource2 }); 365 364 // Will fail due to domain 3 not having a child domain … … 371 370 */ 372 371 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); 374 373 assertNotNull(domain1); 375 374 assertTrue(thePolicy.Add(domain1)); 376 375 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); 378 377 assertNotNull(domain2); 379 378 assertTrue(thePolicy.Add(domain2)); 380 379 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); 382 381 assertNotNull(entryResource1); 383 382 assertTrue(thePolicy.Add(entryResource1)); … … 389 388 assertFalse(thePolicy.Add(enter)); 390 389 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); 392 391 assertNotNull(entryResource2); 393 392 assertTrue(thePolicy.Add(entryResource2)); branches/gefeditor/src/com/tresys/framework/compiler/PolicyGenerator.java
r1396 r1408 126 126 buf 127 127 .append("access " + i_access.getDomain().getName() + " " 128 + i_access. GetResource().getName() + " " + i_access.getVerb()128 + i_access.getResource().getName() + " " + i_access.getVerb() 129 129 + ";"); 130 130 buf.append(newLine); branches/gefeditor/src/com/tresys/framework/compiler/policy/Access.java
r1396 r1408 38 38 Domain = dom; 39 39 resource = res; 40 this.m_verb = verb;40 m_verb = verb; 41 41 Token = token; 42 42 m_bool = bool; branches/gefeditor/src/com/tresys/framework/compiler/policy/AccessBaseResource.java
r1403 r1408 90 90 if(Domain.GetChildDomains().size() > 0) { 91 91 /*for (Domain child: Domain.GetChildDomains())*/ 92 Iterator iter = Domain.GetChildDomains(). iterator();92 Iterator iter = Domain.GetChildDomains().values().iterator(); 93 93 while(iter.hasNext()) { 94 94 Domain child = (Domain) iter.next(); 95 95 /*for (Access childAccess: child.GetAccess(verb).values())*/ 96 Iterator iter2 = child.GetAccess (m_verb).values().iterator();96 Iterator iter2 = child.GetAccesses().iterator(); 97 97 while(iter2.hasNext()) { 98 98 Access childAccess = (Access) iter2.next(); … … 113 113 if(domainParent != null) { 114 114 115 Map/*<Component, Access>*/parentAccesses = domainParent 116 .GetAccess(m_verb); 115 Map parentAccesses = domainParent.GetAccessMap(m_verb.intValue()); 117 116 118 if(parentAccesses == null) {117 if(parentAccesses.isEmpty()) { 119 118 Token 120 119 .Warning("Constraint violation: Child domain has attempted to exceed parent domain \"" branches/gefeditor/src/com/tresys/framework/compiler/policy/AccessBoolean.java
r1396 r1408 30 30 if(domainParent != null) { 31 31 32 Map/*<Component, Access>*/parentAccesses = domainParent 33 .GetAccess(m_verb); 32 Map/*<Component, Access>*/parentAccesses = domainParent.GetAccessMap(m_verb.intValue()); 34 33 35 if(parentAccesses == null) {34 if(parentAccesses.isEmpty()) { 36 35 Token 37 36 .Warning("Constraint violation: Child domain has attempted to exceed parent domain \"" branches/gefeditor/src/com/tresys/framework/compiler/policy/AccessResource.java
r1403 r1408 19 19 import com.tresys.framework.compiler.dictionary.IDictionaryObject; 20 20 import com.tresys.framework.compiler.dictionary.Verb; 21 import com.tresys.framework.compiler.policy.components.Component; 21 22 import com.tresys.framework.compiler.policy.components.ComponentWithDictObjects; 22 23 import com.tresys.framework.compiler.policy.components.Domain; … … 72 73 AccessDefnGroup rdefGroup; 73 74 74 Rdef rdef = GetResource().getRdef();75 Rdef rdef = res.getRdef(); 75 76 if(rdef != null) { 76 77 rdefGroup = rdef.GetAccessDefnGroup(this.m_verb.intValue()); … … 99 100 } 100 101 101 public Resource GetResource() {102 return (Resource)resource;102 public Component getResource() { 103 return resource; 103 104 } 104 105 … … 130 131 */ 131 132 /*@Override*/public String toString() { 132 return Domain.toString() + Utility.DELIM + GetResource().toString()133 return Domain.toString() + Utility.DELIM + getResource().toString() 133 134 + Utility.DELIM + Verb.toString(this.m_verb); 134 135 } … … 170 171 if(Domain.GetChildDomains().size() > 0) { 171 172 /*for (Domain child: Domain.GetChildDomains())*/ 172 Iterator iter = Domain.GetChildDomains(). iterator();173 Iterator iter = Domain.GetChildDomains().values().iterator(); 173 174 while(iter.hasNext()) { 174 175 Domain child = (Domain) iter.next(); 175 176 /*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(); 177 178 while(iter2.hasNext()) { 178 179 Access childAccess = (Access) iter2.next(); 179 180 if(childAccess instanceof AccessResource 180 && ((AccessResource) childAccess). GetResource() == GetResource()) {181 && ((AccessResource) childAccess).getResource() == getResource()) { 181 182 return true; 182 183 } … … 186 187 return false; 187 188 } 189 188 190 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() 190 192 + " defines a " + Verb.toString(this.m_verb) + " access", 191 193 ErrorHandler.ERROR_INVALID_ACCESS, getResource().getName()); … … 196 198 if(domainParent != null && domainParent != resource.getParent()) { 197 199 198 Map/*<Component, Access>*/parentAccesses = domainParent 199 .GetAccess(m_verb); 200 Map/*<Component, Access>*/parentAccesses = domainParent.GetAccessMap(m_verb.intValue()); 200 201 201 202 if(parentAccesses == null) { … … 251 252 return false; 252 253 253 if(! GetResource().equals(access.GetResource()))254 if(!getResource().equals(access.getResource())) 254 255 return false; 255 256 branches/gefeditor/src/com/tresys/framework/compiler/policy/Enter.java
r1403 r1408 162 162 if(m_domain_end.GetChildDomains().size() > 0) { 163 163 /*for (Domain child: DomainStart.GetChildDomains())*/ 164 Iterator iter = m_domain_start.GetChildDomains(). iterator();164 Iterator iter = m_domain_start.GetChildDomains().values().iterator(); 165 165 while(iter.hasNext()) { 166 166 Domain child = (Domain) iter.next(); … … 183 183 } else { 184 184 /*for (Domain child: DomainStart.GetChildDomains())*/ 185 Iterator iter = m_domain_start.GetChildDomains(). iterator();185 Iterator iter = m_domain_start.GetChildDomains().values().iterator(); 186 186 while(iter.hasNext()) { 187 187 Domain child = (Domain) iter.next(); branches/gefeditor/src/com/tresys/framework/compiler/policy/Export.java
r1396 r1408 64 64 verb = v; 65 65 Token = tok; 66 67 66 accessDefs = new HashMap/*<String, AccessDefn>*/(); 68 67 branches/gefeditor/src/com/tresys/framework/compiler/policy/Policy.java
r1396 r1408 17 17 import java.util.TreeMap; 18 18 import java.util.HashMap; 19 import java.util.LinkedList;20 19 import java.util.Vector; 21 20 … … 27 26 import com.tresys.framework.compiler.IPolicyVisitable; 28 27 import com.tresys.framework.compiler.IPolicyVisitor; 29 import com.tresys.framework.compiler.Utility;30 28 import com.tresys.framework.compiler.dictionary.Dictionary; 31 29 import com.tresys.framework.compiler.dictionary.IDictionaryObject; … … 51 49 public final class Policy { 52 50 // 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; 67 53 68 54 private final Map/*<String, BaseResource>*/m_baseResources; 69 70 // set of exported interfaces71 private final Map/*<String, Export>*/exports;72 73 // set of entries74 private final Map/*<String, LinkedList<Enter>>*/entries;75 55 76 56 // the policy level list of system resources (needed for efficient duplicate checks) 77 57 private final Map/*<SystemResource, Component>*/sysResources; 78 58 79 private final TreeMap /*<Token, IPolicyVisitable>*/allItems;59 private final Vector /*<String>*/ comments; 80 60 81 61 private final Linkage linkage; … … 99 79 100 80 // 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>*/(); 104 82 sysResources = new TreeMap/*<SystemResource, Component>*/(); 105 components = new TreeMap/*<String, Component>*/();106 83 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>*/();111 84 frameworkBooleans = new TreeMap /*<String, PolicyBoolean>*/(); 85 comments = new Vector /*<Vector>*/ (); 112 86 } 113 87 … … 141 115 142 116 public boolean AddComment(Comment i_comment) { 143 allItems.put(i_comment.GetNameToken(),i_comment);117 comments.add(i_comment); 144 118 return true; 145 119 } … … 181 155 handler.CriticalError(e.getMessage()); 182 156 } 183 184 157 } 185 158 … … 192 165 */ 193 166 public boolean Add(IDomain dom) { 194 if( components.containsKey(dom.getName())) {167 if(GetComponent(dom.getName()) != null) { 195 168 dom.getToken().Error( 196 169 "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) { 204 174 dom.getParent().AddChild((Domain) dom); 205 } 175 } else { 176 topLevelComponents.put(dom.getSubName(), dom); 177 } 178 206 179 return true; 207 180 } … … 215 188 */ 216 189 public boolean Add(Resource res) { 217 boolean bResult = true; 218 if(components.containsKey(res.getName())) { 190 if(GetComponent(res.getName()) != null) { 219 191 res.getToken().Error( 220 192 "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 233 196 if(res.getParent() != null) { 234 197 res.getParent().AddChild(res); 235 } 236 return bResult; 198 } else { 199 topLevelComponents.put(res.getSubName(), res); 200 } 201 202 return true; 237 203 } 238 204 … … 245 211 */ 246 212 public boolean Add(EntrypointResource ep) { 247 if( components.containsKey(ep.getName())) {213 if(GetComponent(ep.getName()) != null) { 248 214 ep.getToken().Error( 249 215 "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 } 256 218 257 219 if(ep.getParent() != null) { 258 220 ep.getParent().AddChild(ep); 259 } 221 } else { 222 topLevelComponents.put(ep.getSubName(), ep); 223 } 224 260 225 return true; 261 226 } … … 269 234 */ 270 235 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)) { 287 237 axx.Token 288 238 .Error("Constraint violation: a domain cannot access its children"); … … 290 240 } 291 241 292 Domain resourceParent = axx. GetResource().getParent();242 Domain resourceParent = axx.getResource().getParent(); 293 243 294 244 if(resourceParent != null && !axx.Domain.IsDescendant(resourceParent)) { … … 298 248 } 299 249 300 accesses.put(key, axx);301 allItems.put(axx.GetNameToken(), axx);302 303 250 // 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); 337 258 return true; 338 259 } … … 346 267 */ 347 268 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)){ 356 271 axx.Token.Warning("Domain \"" + axx.Domain.getName() 357 272 + "\" already has \"" + Verb.toString(axx.m_verb) … … 360 275 return false; 361 276 } 362 363 accesses.put(key, axx);364 allItems.put(axx.GetNameToken(), axx);365 366 // update graph links for information flow367 axx.Domain.Add(axx);368 277 return true; 369 278 }
