Changeset 1531

Show
Ignore:
Timestamp:
03/13/07 16:10:53 (2 years ago)
Author:
dsugar
Message:

more work on ticket:126 (last commit was also). Now as parents are changed the access retains any access definitions that are set.
still need to work on enters.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/framework-plugin/src/com/tresys/framework/compiler/PolicyGenerator.java

    r1524 r1531  
    1111package com.tresys.framework.compiler; 
    1212 
     13import java.util.Collection; 
    1314import java.util.Iterator; 
    1415import java.util.Map; 
     
    147148                if (!i_access.isDefault()) 
    148149                { 
    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() + " "; 
    163159                        } 
    164160                         
     
    200196                if (!i_access.isDefault()) 
    201197                { 
    202                         Set /*<baseAccessDefn>*/ accessDefns = i_access.GetAccessDefns(); 
     198                        Collection /*<baseAccessDefn>*/ accessDefns = i_access.GetAccessDefns(); 
    203199                        for (Iterator itr = accessDefns.iterator(); itr.hasNext(); ) 
    204200                        { 
  • trunk/framework-plugin/src/com/tresys/framework/compiler/policy/Access.java

    r1524 r1531  
    1010 
    1111package com.tresys.framework.compiler.policy; 
     12 
     13import java.util.Collection; 
    1214 
    1315import com.tresys.framework.compiler.IPolicyVisitable; 
     
    106108 
    107109        public abstract void Accept(IPolicyVisitor i_visitor); 
    108          
     110 
     111        /** 
     112         * reset the access definition to default 
     113         */ 
    109114        public abstract void ResetToDefaults (); 
    110115         
     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         */ 
    111140        public abstract boolean isDefault (); 
    112141 
  • trunk/framework-plugin/src/com/tresys/framework/compiler/policy/AccessBaseResource.java

    r1523 r1531  
    99package com.tresys.framework.compiler.policy; 
    1010 
     11import java.util.Collection; 
    1112import java.util.HashSet; 
    1213import java.util.Iterator; 
     
    4546        } 
    4647 
     48        /* 
     49         *  (non-Javadoc) 
     50         * @see com.tresys.framework.compiler.policy.Access#ResetToDefaults() 
     51         */ 
    4752        public void ResetToDefaults()  
    4853        { 
     
    5358        } 
    5459         
     60        /* 
     61         *  (non-Javadoc) 
     62         * @see com.tresys.framework.compiler.policy.Access#isDefault() 
     63         */ 
    5564        public boolean isDefault()  
    5665        { 
     
    6473        } 
    6574         
     75        /* 
     76         *  (non-Javadoc) 
     77         * @see com.tresys.framework.compiler.policy.Access#ClearAccess() 
     78         */ 
    6679        public void ClearAccess () 
    6780        { 
     
    8497        } 
    8598 
     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         
    86113        /** 
    87114         * Get all of the AccessDefn(s) associated with this AccessResource. 
    88115         *  
    89          * @return      Map&lt;String, AccessDefn&gt; of associated AccessDefn  
    90          *                      keyed by name 
    91          */ 
    92         public Set/*<BaseAccessDefn>*/GetAccessDefns()  
     116         * @return      Collection&lt;BaseAccessDefn&gt; of associated AccessDefn  
     117         */ 
     118        public Collection/*<BaseAccessDefn>*/GetAccessDefns()  
    93119        { 
    94120                return baseAccessDefns; 
  • trunk/framework-plugin/src/com/tresys/framework/compiler/policy/AccessBoolean.java

    r1523 r1531  
    88package com.tresys.framework.compiler.policy; 
    99 
     10import java.util.Collection; 
    1011import java.util.Map; 
    1112 
     
    2829         
    2930        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 
    3043        {} 
    3144         
  • trunk/framework-plugin/src/com/tresys/framework/compiler/policy/AccessResource.java

    r1523 r1531  
    2121import com.tresys.framework.compiler.dictionary.Verb; 
    2222 
     23import java.util.ArrayList; 
     24import java.util.Collection; 
    2325import java.util.HashMap; 
    2426import java.util.Iterator; 
     
    7375         * Get all of the AccessDefn(s) associated with this AccessResource. 
    7476         *  
    75          * @return      Map&lt;String, AccessDefn&gt; of associated AccessDefn  
    76          *                      keyed by name 
    77          */ 
    78         public Map/*<AccessDefn>>*/GetAccessDefns() { 
    79                 return accessDefs; 
    80         } 
    81  
     77         * @return      Collection&lt;AccessDefn&gt; 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         
    82104        /** 
    83105         * Add access definition to list of those for this access 
     
    158180        } 
    159181         
     182        /* 
     183         *  (non-Javadoc) 
     184         * @see com.tresys.framework.compiler.policy.Access#ResetToDefaults() 
     185         */ 
    160186        public void ResetToDefaults() 
    161187        { 
     
    183209        } 
    184210         
     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         
    185226        public void ClearAccess (Rdef rdef) 
    186227        { 
     
    188229        } 
    189230         
     231        /* 
     232         *  (non-Javadoc) 
     233         * @see com.tresys.framework.compiler.policy.Access#isDefault() 
     234         */ 
    190235        public boolean isDefault () 
    191236        { 
  • trunk/framework-plugin/src/com/tresys/framework/compiler/translator/Translator.java

    r1500 r1531  
    703703                // for each AccessTarget associated with this AccessDefn 
    704704                /*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"); 
    726718 
    727719                        // Create the perms for other 
     
    754746                                } 
    755747                        } 
    756                 } 
    757748                } 
    758749        } 
  • trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/commands/AbstractAccessConnectionCommand.java

    r1476 r1531  
    99package com.tresys.framework.plugin.editor.policy.graphic.commands; 
    1010 
     11import java.util.Collection; 
    1112import java.util.Iterator; 
    1213import java.util.Vector; 
     
    3435        protected Vector m_NewConnections; 
    3536        protected Integer m_nVerb = new Integer (Verb.readwrite); 
     37        protected Collection m_accessDefn; 
    3638 
    3739        public AbstractAccessConnectionCommand () 
     
    101103                System.out.println ("Create Access Connection: Source: " +  i_resource.toString() + " Target: " + i_domain.toString()); 
    102104                AccessConnection connection = new AccessConnection (i_domain, i_resource, access, outerConn); 
     105                 
     106                if (m_accessDefn != null) 
     107                        connection.setAccessDefn(m_accessDefn); 
     108                 
    103109                if (m_NewConnections == null) 
    104110                        m_NewConnections = new Vector (); 
  • trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/commands/AccessConnectionCreateCommand.java

    r1530 r1531  
    99package com.tresys.framework.plugin.editor.policy.graphic.commands; 
    1010 
     11import java.util.Collection; 
    1112import java.util.Iterator; 
    1213 
     
    9091                } 
    9192        } 
     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         
    92100         
    93101        public AccessConnectionCreateCommand (Shape i_source, Shape i_target) 
  • trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/commands/AddCommand.java

    r1530 r1531  
    106106                        { 
    107107                                AccessConnection oldConnection = (AccessConnection) connection; 
     108                                Collection accessDefn = oldConnection.getAccessDefn(); 
    108109                                 
    109110                                // moved shape is source of connection 
     
    116117                                                // create new connection and execute if valid 
    117118                                                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); 
    119120                                                if (createCommand.canExecute()) 
    120121                                                { 
     
    130131                                        // create new connection and execute if valid 
    131132                                        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); 
    133134                                        if (createCommand.canExecute()) 
    134135                                        { 
  • trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/model/AccessConnection.java

    r1530 r1531  
    99package com.tresys.framework.plugin.editor.policy.graphic.model; 
    1010 
     11import java.util.Collection; 
    1112import java.util.Iterator; 
    1213import java.util.Map; 
     
    136137                        reconnect();     
    137138        } 
     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        } 
    138166         
    139167        public void Accept (IShapeVisitor i_visitor)