Changeset 1531
- Timestamp:
- 03/13/07 16:10:53 (2 years ago)
- Files:
-
- trunk/framework-plugin/src/com/tresys/framework/compiler/PolicyGenerator.java (modified) (3 diffs)
- trunk/framework-plugin/src/com/tresys/framework/compiler/policy/Access.java (modified) (2 diffs)
- trunk/framework-plugin/src/com/tresys/framework/compiler/policy/AccessBaseResource.java (modified) (5 diffs)
- trunk/framework-plugin/src/com/tresys/framework/compiler/policy/AccessBoolean.java (modified) (2 diffs)
- trunk/framework-plugin/src/com/tresys/framework/compiler/policy/AccessResource.java (modified) (5 diffs)
- trunk/framework-plugin/src/com/tresys/framework/compiler/translator/Translator.java (modified) (2 diffs)
- trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/commands/AbstractAccessConnectionCommand.java (modified) (3 diffs)
- trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/commands/AccessConnectionCreateCommand.java (modified) (2 diffs)
- trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/commands/AddCommand.java (modified) (3 diffs)
- trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/model/AccessConnection.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/framework-plugin/src/com/tresys/framework/compiler/PolicyGenerator.java
r1524 r1531 11 11 package com.tresys.framework.compiler; 12 12 13 import java.util.Collection; 13 14 import java.util.Iterator; 14 15 import java.util.Map; … … 147 148 if (!i_access.isDefault()) 148 149 { 149 Map /*<AccessDefn>*/ accessDefns = i_access.GetAccessDefns(); 150 for (Iterator itr = accessDefns.values().iterator(); itr.hasNext(); ) 151 { 152 Set axxDefs = (Set) itr.next(); 153 Iterator itr2 = axxDefs.iterator(); 154 while(itr2.hasNext()) 155 { 156 AccessDefn accessDefn = (AccessDefn) itr2.next(); 157 Rdef rdef = accessDefn.getAccessDefnGroup().getRdef(); 158 if (i_access.isDefault(rdef)) 159 continue; 160 161 sAccessDefinitions += rdef.GetName() + ":" + accessDefn.getName() + " "; 162 } 150 Collection /*<AccessDefn>*/ accessDefns = i_access.GetAccessDefns(); 151 for (Iterator itr = accessDefns.iterator(); itr.hasNext (); ) 152 { 153 AccessDefn accessDefn = (AccessDefn) itr.next(); 154 Rdef rdef = accessDefn.getAccessDefnGroup().getRdef(); 155 if (i_access.isDefault(rdef)) 156 continue; 157 158 sAccessDefinitions += rdef.GetName() + ":" + accessDefn.getName() + " "; 163 159 } 164 160 … … 200 196 if (!i_access.isDefault()) 201 197 { 202 Set/*<baseAccessDefn>*/ accessDefns = i_access.GetAccessDefns();198 Collection /*<baseAccessDefn>*/ accessDefns = i_access.GetAccessDefns(); 203 199 for (Iterator itr = accessDefns.iterator(); itr.hasNext(); ) 204 200 { trunk/framework-plugin/src/com/tresys/framework/compiler/policy/Access.java
r1524 r1531 10 10 11 11 package com.tresys.framework.compiler.policy; 12 13 import java.util.Collection; 12 14 13 15 import com.tresys.framework.compiler.IPolicyVisitable; … … 106 108 107 109 public abstract void Accept(IPolicyVisitor i_visitor); 108 110 111 /** 112 * reset the access definition to default 113 */ 109 114 public abstract void ResetToDefaults (); 110 115 116 /** 117 * clear all access definitions from the access 118 */ 119 public abstract void ClearAccess (); 120 121 /** 122 * Get collection of all accesses assigned to the access 123 * @return collection based on the type of access 124 */ 125 public abstract Collection GetAccessDefns (); 126 127 /** 128 * Set the access definitions to hose passed in. 129 * @param i_accessDefns - collection of access definitions to set to the access, all others will be cleared 130 * @throws VerbMismatchException 131 * @throws UnrevokableException 132 */ 133 public abstract void SetAccessDefns (Collection i_accessDefns) 134 throws VerbMismatchException, UnrevokableException; 135 136 /** 137 * is the access definition at the default state 138 * @return true/false 139 */ 111 140 public abstract boolean isDefault (); 112 141 trunk/framework-plugin/src/com/tresys/framework/compiler/policy/AccessBaseResource.java
r1523 r1531 9 9 package com.tresys.framework.compiler.policy; 10 10 11 import java.util.Collection; 11 12 import java.util.HashSet; 12 13 import java.util.Iterator; … … 45 46 } 46 47 48 /* 49 * (non-Javadoc) 50 * @see com.tresys.framework.compiler.policy.Access#ResetToDefaults() 51 */ 47 52 public void ResetToDefaults() 48 53 { … … 53 58 } 54 59 60 /* 61 * (non-Javadoc) 62 * @see com.tresys.framework.compiler.policy.Access#isDefault() 63 */ 55 64 public boolean isDefault() 56 65 { … … 64 73 } 65 74 75 /* 76 * (non-Javadoc) 77 * @see com.tresys.framework.compiler.policy.Access#ClearAccess() 78 */ 66 79 public void ClearAccess () 67 80 { … … 84 97 } 85 98 99 /* 100 * (non-Javadoc) 101 * @see com.tresys.framework.compiler.policy.Access#SetAccessDefns(java.util.Collection) 102 */ 103 public void SetAccessDefns (Collection i_accessDefns) 104 throws VerbMismatchException, UnrevokableException 105 { 106 ClearAccess(); 107 for (Iterator itr = i_accessDefns.iterator(); itr.hasNext(); ) 108 { 109 AddAccessDefn((BaseAccessDefn) itr.next ()); 110 } 111 } 112 86 113 /** 87 114 * Get all of the AccessDefn(s) associated with this AccessResource. 88 115 * 89 * @return Map<String, AccessDefn> of associated AccessDefn 90 * keyed by name 91 */ 92 public Set/*<BaseAccessDefn>*/GetAccessDefns() 116 * @return Collection<BaseAccessDefn> of associated AccessDefn 117 */ 118 public Collection/*<BaseAccessDefn>*/GetAccessDefns() 93 119 { 94 120 return baseAccessDefns; trunk/framework-plugin/src/com/tresys/framework/compiler/policy/AccessBoolean.java
r1523 r1531 8 8 package com.tresys.framework.compiler.policy; 9 9 10 import java.util.Collection; 10 11 import java.util.Map; 11 12 … … 28 29 29 30 public void ResetToDefaults () 31 {} 32 33 public void ClearAccess () 34 {} 35 36 public Collection GetAccessDefns () 37 { 38 return null; 39 } 40 41 public void SetAccessDefns (Collection i_accessDefns) 42 throws VerbMismatchException, UnrevokableException 30 43 {} 31 44 trunk/framework-plugin/src/com/tresys/framework/compiler/policy/AccessResource.java
r1523 r1531 21 21 import com.tresys.framework.compiler.dictionary.Verb; 22 22 23 import java.util.ArrayList; 24 import java.util.Collection; 23 25 import java.util.HashMap; 24 26 import java.util.Iterator; … … 73 75 * Get all of the AccessDefn(s) associated with this AccessResource. 74 76 * 75 * @return Map<String, AccessDefn> of associated AccessDefn 76 * keyed by name 77 */ 78 public Map/*<AccessDefn>>*/GetAccessDefns() { 79 return accessDefs; 80 } 81 77 * @return Collection<AccessDefn> of associated AccessDefn 78 */ 79 80 public Collection GetAccessDefns () 81 { 82 ArrayList allDefns = new ArrayList (); 83 for (Iterator itr = accessDefs.values().iterator(); itr.hasNext(); ) 84 allDefns.addAll((Collection) itr.next()); 85 86 return allDefns; 87 } 88 89 /* 90 * (non-Javadoc) 91 * @see com.tresys.framework.compiler.policy.Access#SetAccessDefns(java.util.Collection) 92 */ 93 public void SetAccessDefns (Collection i_accessDefns) 94 throws VerbMismatchException, UnrevokableException 95 { 96 ClearAccess(); 97 for (Iterator itr = i_accessDefns.iterator(); itr.hasNext(); ) 98 { 99 AddAccessDefn ((AccessDefn) itr.next ()); 100 } 101 102 } 103 82 104 /** 83 105 * Add access definition to list of those for this access … … 158 180 } 159 181 182 /* 183 * (non-Javadoc) 184 * @see com.tresys.framework.compiler.policy.Access#ResetToDefaults() 185 */ 160 186 public void ResetToDefaults() 161 187 { … … 183 209 } 184 210 211 /* 212 * (non-Javadoc) 213 * @see com.tresys.framework.compiler.policy.Access#ClearAccess() 214 */ 215 public void ClearAccess () 216 { 217 Map rdefs = ((Resource) getResource ()).GetRdefs(); 218 Iterator itr = rdefs.values().iterator(); 219 while (itr.hasNext()) 220 { 221 Rdef rdef = (Rdef) itr.next(); 222 ClearAccess (rdef); 223 } 224 } 225 185 226 public void ClearAccess (Rdef rdef) 186 227 { … … 188 229 } 189 230 231 /* 232 * (non-Javadoc) 233 * @see com.tresys.framework.compiler.policy.Access#isDefault() 234 */ 190 235 public boolean isDefault () 191 236 { trunk/framework-plugin/src/com/tresys/framework/compiler/translator/Translator.java
r1500 r1531 703 703 // for each AccessTarget associated with this AccessDefn 704 704 /*for (Map.Entry<Integer *//*Target*//*, AccessTarget> at : axxDefn.AccessTargets.entrySet())*/ 705 Map accessDefns = access.GetAccessDefns(); 706 if(accessDefns == null) { 707 //TODO: This was throwing NULL pointer exception - fixed for demo 708 System.err.println("Null access defns - fix policy"); 709 return; 710 } 711 712 Iterator axxDefSets = accessDefns.values().iterator(); 713 while(axxDefSets.hasNext()) { 714 Set axxDefSet = (Set) axxDefSets.next(); 715 Iterator axxDefs = axxDefSet.iterator(); 716 while(axxDefs.hasNext()) { 717 AccessDefn axxDefn = (AccessDefn) axxDefs.next(); 718 Iterator iter2 = axxDefn.getAccessTargets().values().iterator(); 719 String templateName = "framework_" 720 + axxDefn.getAccessDefnGroup().getRdef().GetName().replaceAll("@", "_AT") + "_" 721 + axxDefn.getAccessDefnGroup().getName() + "_" 722 + axxDefn.getName(); 723 policyStream.print(templateName + "(" 724 + access.getDomain().getType() + ","); 725 policyStream.print(((Resource)access.getResource()).GetTypeWithDictionaryObject(axxDefn.getAccessDefnGroup().getRdef().GetName()) + ")\n"); 705 Collection accessDefns = access.GetAccessDefns(); 706 Iterator axxDefs = accessDefns.iterator(); 707 while(axxDefs.hasNext()) 708 { 709 AccessDefn axxDefn = (AccessDefn) axxDefs.next(); 710 Iterator iter2 = axxDefn.getAccessTargets().values().iterator(); 711 String templateName = "framework_" 712 + axxDefn.getAccessDefnGroup().getRdef().GetName().replaceAll("@", "_AT") + "_" 713 + axxDefn.getAccessDefnGroup().getName() + "_" 714 + axxDefn.getName(); 715 policyStream.print(templateName + "(" 716 + access.getDomain().getType() + ","); 717 policyStream.print(((Resource)access.getResource()).GetTypeWithDictionaryObject(axxDefn.getAccessDefnGroup().getRdef().GetName()) + ")\n"); 726 718 727 719 // Create the perms for other … … 754 746 } 755 747 } 756 }757 748 } 758 749 } trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/commands/AbstractAccessConnectionCommand.java
r1476 r1531 9 9 package com.tresys.framework.plugin.editor.policy.graphic.commands; 10 10 11 import java.util.Collection; 11 12 import java.util.Iterator; 12 13 import java.util.Vector; … … 34 35 protected Vector m_NewConnections; 35 36 protected Integer m_nVerb = new Integer (Verb.readwrite); 37 protected Collection m_accessDefn; 36 38 37 39 public AbstractAccessConnectionCommand () … … 101 103 System.out.println ("Create Access Connection: Source: " + i_resource.toString() + " Target: " + i_domain.toString()); 102 104 AccessConnection connection = new AccessConnection (i_domain, i_resource, access, outerConn); 105 106 if (m_accessDefn != null) 107 connection.setAccessDefn(m_accessDefn); 108 103 109 if (m_NewConnections == null) 104 110 m_NewConnections = new Vector (); trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/commands/AccessConnectionCreateCommand.java
r1530 r1531 9 9 package com.tresys.framework.plugin.editor.policy.graphic.commands; 10 10 11 import java.util.Collection; 11 12 import java.util.Iterator; 12 13 … … 90 91 } 91 92 } 93 94 public AccessConnectionCreateCommand (IDomainShape i_dom, IResourceShape i_res, Integer i_nDirection, Collection i_accessDefn) 95 { 96 this (i_dom, i_res, i_nDirection); 97 m_accessDefn = i_accessDefn; 98 } 99 92 100 93 101 public AccessConnectionCreateCommand (Shape i_source, Shape i_target) trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/commands/AddCommand.java
r1530 r1531 106 106 { 107 107 AccessConnection oldConnection = (AccessConnection) connection; 108 Collection accessDefn = oldConnection.getAccessDefn(); 108 109 109 110 // moved shape is source of connection … … 116 117 // create new connection and execute if valid 117 118 Shape target = (Shape) itr2.next(); 118 createCommand = new AccessConnectionCreateCommand ((IDomainShape) target, (IResourceShape) m_child, oldConnection.getVerb() );119 createCommand = new AccessConnectionCreateCommand ((IDomainShape) target, (IResourceShape) m_child, oldConnection.getVerb(), accessDefn); 119 120 if (createCommand.canExecute()) 120 121 { … … 130 131 // create new connection and execute if valid 131 132 Shape source = oldConnection.getSourceTerminal(); 132 createCommand = new AccessConnectionCreateCommand ((IDomainShape) m_child, (IResourceShape) source, oldConnection.getVerb() );133 createCommand = new AccessConnectionCreateCommand ((IDomainShape) m_child, (IResourceShape) source, oldConnection.getVerb(), accessDefn); 133 134 if (createCommand.canExecute()) 134 135 { trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/model/AccessConnection.java
r1530 r1531 9 9 package com.tresys.framework.plugin.editor.policy.graphic.model; 10 10 11 import java.util.Collection; 11 12 import java.util.Iterator; 12 13 import java.util.Map; … … 136 137 reconnect(); 137 138 } 139 140 /** 141 * get all access definitions set for the connection 142 * @return 143 */ 144 public Collection getAccessDefn () 145 { 146 return m_access.GetAccessDefns(); 147 } 148 149 public void setAccessDefn (Collection i_accessDef) 150 { 151 try 152 { 153 m_access.SetAccessDefns(i_accessDef); 154 } 155 catch (VerbMismatchException e) 156 { 157 // TODO Auto-generated catch block 158 e.printStackTrace(); 159 } 160 catch (UnrevokableException e) 161 { 162 // TODO Auto-generated catch block 163 e.printStackTrace(); 164 } 165 } 138 166 139 167 public void Accept (IShapeVisitor i_visitor)
