Changeset 2009

Show
Ignore:
Timestamp:
03/24/08 15:15:03 (8 months ago)
Author:
dsugar
Message:

cleanup
work on verifying customizations

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/custome_policy/framework-plugin/src/com/tresys/framework/compiler/FSysGenerator.java

    r1949 r2009  
    1313 
    1414import java.io.ByteArrayInputStream; 
    15 import java.io.InputStream; 
    1615import java.util.Iterator; 
    1716import java.util.List; 
     
    5251        } 
    5352 
    54         public InputStream getData()  
     53        public ByteArrayInputStream getData()  
    5554        { 
    5655                return new ByteArrayInputStream(toString().getBytes()); 
  • branches/custome_policy/framework-plugin/src/com/tresys/framework/compiler/custom/CPolicyRefresher.java

    r2004 r2009  
    2929import com.tresys.framework.compiler.policy.Enter; 
    3030import com.tresys.framework.compiler.policy.EntrypointResource; 
     31import com.tresys.framework.compiler.policy.IDomain; 
    3132import com.tresys.framework.compiler.policy.IPolicyVisitor; 
    3233import com.tresys.framework.compiler.policy.Policy; 
     
    3435import com.tresys.framework.compiler.policy.UserDomain; 
    3536 
    36 public class CPolicyRefresher implements IPolicyVisitor 
     37public class CPolicyRefresher  
     38        implements IPolicyVisitor 
    3739{ 
    38         Set mKey; 
    39         StringBuffer mPrefix; 
     40        private final Set mKey; 
     41        private final String m_sModuleName; 
     42        private final String m_sPrefix; 
    4043         
    41         public CPolicyRefresher(Set keyset, StringBuffer buffer
     44        public CPolicyRefresher (Set keyset, String i_sPrefix, String i_sModuleName
    4245        { 
    4346                mKey = keyset; 
    44                 mPrefix = buffer; 
     47                m_sModuleName = i_sModuleName; 
     48                m_sPrefix = i_sPrefix; 
    4549        } 
    4650 
    47         public void PostVisit(Policy i_policy) { 
    48        
     51        public void PostVisit(Policy i_policy)  
     52        {
    4953 
    50         public void PreVisit(Policy i_policy) { 
    51        
     54        public void PreVisit(Policy i_policy)  
     55        {
    5256 
    53         public void Visit(Ability i_ability) { 
    54        
     57        public void Visit(Ability i_ability)  
     58        {
    5559 
    56         public void Visit(AccessBaseResource i_access) { 
    57                  
    58         } 
     60        public void Visit(AccessBaseResource i_access)  
     61        {} 
    5962 
    6063        public void Visit(AccessBoolean i_access)  
    61         { 
    62         } 
     64        {} 
    6365 
    6466        public void Visit(AccessResource i_access)  
    6567        { 
    66                 //TODO::implement 
    67                 System.out.println (i_access.GetNameToken ()); 
     68                IDomain domain = i_access.getDomain (); 
     69                Resource resource = (Resource) i_access.getResource (); 
     70 
     71                for (Iterator rdefitr = i_access.GetAccessRdefs ().iterator (); rdefitr.hasNext (); ) 
     72                { 
     73                        Rdef rdef = (Rdef) rdefitr.next (); 
     74                         
     75                        StringBuffer sCustomName = new StringBuffer(50); 
     76                        sCustomName.append (m_sPrefix).append ("access_"); 
     77                        sCustomName.append (m_sModuleName).append ("_").append(domain.getOutputName ()); 
     78                        sCustomName.append ("_").append(resource.getOutputName ()).append("_").append(rdef.GetOutputName());  
     79 
     80                        if (mKey.contains(sCustomName.toString ())) 
     81                                i_access.markCustomized(); 
     82                        else 
     83                                i_access.removeCustomization(); 
     84 
     85                } 
    6886        } 
    6987 
    7088        public void Visit(BaseDomain domain)  
    71         { 
    72         } 
     89        {} 
    7390 
    7491        public void Visit(BaseResource resource)  
    75         { 
    76         } 
     92        {} 
    7793 
    7894        public void Visit(Comment i_comment)  
    79         { 
    80         } 
     95        {} 
    8196 
    8297        public void Visit(Conditional i_conditional)  
    83         { 
    84         } 
     98        {} 
    8599 
    86100        public void Visit(ControlResource i_resource)  
     
    91105        public void Visit(Domain i_domain)  
    92106        { 
    93                 String name = mPrefix + "_" + i_domain.getName (); 
     107                String name = m_sPrefix + m_sModuleName + "_" + i_domain.getOutputName (); 
    94108                boolean state = mKey.contains(name); 
    95109                if( state ) 
     
    102116        { 
    103117                //TODO::implement 
    104                 boolean state = mKey.contains(i_enter.getEndDomain().getName());  
     118                boolean state = mKey.contains(i_enter.getEndDomain().getOutputName());  
    105119                if( state ) 
    106120                        i_enter.markCustomized(); 
     
    112126        { 
    113127                //TODO::implement 
    114                 boolean state = mKey.contains(point.getName());  
     128                boolean state = mKey.contains(point.getOutputName());  
    115129                if( state ) 
    116130                        point.markCustomized(); 
     
    130144                { 
    131145                        Rdef rdef = (Rdef) itr.next(); 
    132                         StringBuffer temp = new StringBuffer(mPrefix); 
     146                        StringBuffer temp = new StringBuffer(100); 
     147                        temp.append (m_sPrefix); 
     148                        temp.append (m_sModuleName); 
    133149                        temp.append("_"); 
    134                         temp.append(i_resource.getName ()); 
     150                        temp.append(i_resource.getOutputName ()); 
    135151                        temp.append("_"); 
    136152                        temp.append(rdef.GetOutputName()); 
     
    142158                 
    143159                int size = 0; 
    144                 for( Iterator itr = template_names.iterator(); itr.hasNext();) 
     160                for (Iterator itr = template_names.iterator(); itr.hasNext();) 
    145161                { 
    146162                        StringBuffer sb = (StringBuffer)itr.next(); 
    147                         if ( mKey.contains(sb.toString())
     163                        if (mKey.contains(sb.toString())
    148164                                ++size; 
    149165                } 
    150166                 
    151                 if( size == template_names.size()
     167                if (size == template_names.size()
    152168                        i_resource.markCustomized(); 
    153169                else 
  • branches/custome_policy/framework-plugin/src/com/tresys/framework/compiler/dictionary/Rdef.java

    r1949 r2009  
    189189        public boolean AddToAllSelf (PermVector map) 
    190190        { 
    191                 // add if tevector association hasnt been previously defined 
     191                // add if the vector association hasn't been previously defined 
    192192                if (accessAllSelf.containsKey (map.getObjectClass ())) 
    193193                { 
  • branches/custome_policy/framework-plugin/src/com/tresys/framework/compiler/policy/Component.java

    r1991 r2009  
    184184                        else  
    185185                        { 
    186                                 m_sType = parent.getName().replaceAll("\\.", "_") + "_" + m_subName + "_t"; 
     186                                m_sType = parent.getOutputName() + "_" + m_subName + "_t"; 
    187187                        } 
    188188                } 
     
    295295                        return parent.getName() + "." + m_subName; 
    296296                return m_subName; 
     297        } 
     298         
     299        /** 
     300         * get name in a way that is safe to use in an interface/template name 
     301         * @return 
     302         */ 
     303        public String getOutputName () 
     304        { 
     305                return getName ().replaceAll("\\.", "_"); 
    297306        } 
    298307 
  • branches/custome_policy/framework-plugin/src/com/tresys/framework/compiler/policy/IDomain.java

    r1989 r2009  
    7171 
    7272        public String getName(); 
     73        public String getOutputName (); 
    7374 
    7475        public String getSubName(); 
  • branches/custome_policy/framework-plugin/src/com/tresys/framework/compiler/translator/SELinuxPolicy.java

    r2004 r2009  
    9393        implements IPolicyVisitor 
    9494{        
    95         public final static String NEWLINE = System.getProperty("line.separator"); 
    96          
    97  
    98         private final static String XML_START = "##############################################"+ NEWLINE; 
    99         private final static String XML_SUMMARY_OPEN = "## <summary>"+ NEWLINE; 
    100         private final static String XML_SUMMARY_CLOSE = "## </summary>"+ NEWLINE; 
    101         private final static String XML_PARAM_OPEN = "## <param name ="; 
    102         private final static String XML_PARAM_CLOSE = "## </param>"+ NEWLINE; 
    103          
    104          
    105  
     95        private final static String XML_START = "##############################################"; 
     96        private final static String XML_SUMMARY_OPEN = "## <summary>"; 
     97        private final static String XML_SUMMARY_CLOSE = "## </summary>"; 
     98        private final static String XML_PARAM_OPEN = "## <param name = "; 
     99        private final static String XML_PARAM_CLOSE = "## </param>"; 
     100         
     101        public final static String CUSTOM_PREFIX = "cds_custom_"; 
     102         
    106103        private final Linkage m_linkage; 
    107104        private final boolean m_bGeneratePolicyTemplate; 
     
    110107        private boolean m_errorEncountered = false; 
    111108         
    112         private final String m_moduleName; 
    113         private final String mCPolicyMacroPrefix; 
     109        private final String m_sModuleName; 
    114110         
    115111        final private ByteArrayOutputStream m_dataPolicy = new ByteArrayOutputStream (); 
     
    125121        private TreeSet/*<String>*/m_dirPermSet = new TreeSet/*<String>*/(); 
    126122         
    127         public SELinuxPolicy (Linkage _linkage, String _moduleName, File fcFile)  
     123        public SELinuxPolicy (Linkage _linkage, String i_sModuleName, File fcFile)  
    128124        { 
    129125                m_linkage = _linkage; 
    130                 m_moduleName = _moduleName; 
     126                m_sModuleName = i_sModuleName; 
    131127                m_hasFileContext = false; 
    132128                m_bGeneratePolicyTemplate = false; 
    133                 mCPolicyMacroPrefix = null; 
    134129         
    135130                if(fcFile != null && fcFile.exists())  
     
    141136        } 
    142137         
    143         public SELinuxPolicy (Linkage i_linkage, boolean i_bGenerateTemplates, String prefix
     138        public SELinuxPolicy (Linkage i_linkage, boolean i_bGenerateTemplates, String i_sModuleName
    144139        { 
    145140                m_linkage = i_linkage; 
    146141                m_bGeneratePolicyTemplate = i_bGenerateTemplates; 
    147                 m_moduleName = "template"; 
    148                 mCPolicyMacroPrefix = prefix; 
    149         } 
    150          
     142                m_sModuleName = i_sModuleName; 
     143        } 
    151144         
    152145        protected void finalize () 
     
    201194                 
    202195                m_bufferPolicy.print("# SEFramework policy output\n"); 
    203                 m_linkage.InitPolicy(m_bufferPolicy, m_moduleName); 
     196                m_linkage.InitPolicy(m_bufferPolicy, m_sModuleName); 
    204197                m_bufferPolicy.print("# These types are generated by the framework for internal use\n"); 
    205198                 
     
    228221 
    229222//                      String sCustomName = "customize_" + i_resource.getName () + "_" + rdef.GetOutputName(); 
    230                         String sCustomName = mCPolicyMacroPrefix + "_" + i_resource.getName () + "_" + rdef.GetOutputName(); 
     223                        String sCustomName = CUSTOM_PREFIX + m_sModuleName + "_" + i_resource.getOutputName () + "_" + rdef.GetOutputName(); 
    231224 
    232225                        if (m_bGeneratePolicyTemplate) 
    233226                        { 
    234227                                outStream = m_bufferInterfaces; 
    235                                 StringBuffer buffer = new StringBuffer(200); 
    236                                 outStream.println(); 
    237                                 buffer.append(XML_START); 
    238                                 buffer.append(XML_SUMMARY_OPEN); 
    239                                 buffer.append("## Customization for resource ").append(i_resource.getName ()).append (NEWLINE);  
    240                                 buffer.append(XML_SUMMARY_CLOSE); 
    241                                 buffer.append(XML_PARAM_OPEN); 
    242                                 buffer.append("'resource'>").append (NEWLINE); 
    243                                 buffer.append("## Type of resource being customized").append (NEWLINE); 
    244                                 buffer.append(XML_PARAM_CLOSE); 
    245                                 buffer.append("template(`").append(sCustomName).append("',`"); 
    246                                 buffer.append (NEWLINE); 
    247                                 outStream.print (buffer); 
     228                                outStream.println (); 
     229                                outStream.println (XML_START); 
     230                                outStream.println (XML_SUMMARY_OPEN); 
     231                                outStream.println ("## Customization for resource " + i_resource.getName ());  
     232                                outStream.println (XML_SUMMARY_CLOSE); 
     233                                outStream.print (XML_PARAM_OPEN); 
     234                                outStream.println ("'resource'>"); 
     235                                outStream.println ("## Type of resource being customized"); 
     236                                outStream.println (XML_PARAM_CLOSE); 
     237                                outStream.println (); 
     238                                outStream.println ("template(`" + sCustomName + "',`"); 
    248239                        } 
    249240 
     
    290281                PrintStream outStream = m_bufferPolicy; 
    291282 
     283                String sCustomName = CUSTOM_PREFIX + m_sModuleName + "_" + i_domain.getOutputName (); 
    292284                if (m_bGeneratePolicyTemplate) 
    293285                { 
    294286                        outStream = m_bufferInterfaces; 
    295                         StringBuffer buffer = new StringBuffer(150); 
    296                         buffer.append(NEWLINE); 
    297                          
    298                         buffer.append(XML_START); 
    299                         buffer.append(XML_SUMMARY_OPEN); 
    300                         buffer.append("## Customization for domain ").append(i_domain.getName ()).append(NEWLINE);  
    301                         buffer.append(XML_SUMMARY_CLOSE); 
    302                         buffer.append(XML_PARAM_OPEN); 
    303                         buffer.append("'domain'>").append(NEWLINE); 
    304                         buffer.append("## Type of resource being customized").append(NEWLINE); 
    305                         buffer.append(XML_PARAM_CLOSE); 
    306                         StringBuffer sCustomName = new StringBuffer("template(`"); 
    307                         sCustomName.append(mCPolicyMacroPrefix).append("_").append(i_domain.getName ()).append("',`"); 
    308                         sCustomName.append(NEWLINE); 
    309                         buffer.append(sCustomName); 
    310                         outStream.print (buffer); 
     287                        outStream.println (); 
     288                        outStream.println (XML_START); 
     289                        outStream.println (XML_SUMMARY_OPEN); 
     290                        outStream.println ("## Customization for domain " + i_domain.getName ());  
     291                        outStream.println (XML_SUMMARY_CLOSE); 
     292                        outStream.print (XML_PARAM_OPEN); 
     293                        outStream.println ("'domain'>"); 
     294                        outStream.println ("## Type for domain being customized"); 
     295                        outStream.println (XML_PARAM_CLOSE); 
     296                        outStream.println (); 
     297                        outStream.println ("template(`" + sCustomName + "',`"); 
    311298                } 
    312299                 
     
    324311                if (!m_bGeneratePolicyTemplate && i_domain.hasCustomization ()) 
    325312                { 
    326                         String sCustomName = mCPolicyMacroPrefix + i_domain.getName () + "(" + sType + ")"; 
    327                         outStream.println (sCustomName); 
     313                        outStream.print (sCustomName); 
     314                        outStream.print ("("); 
     315                        outStream.print (sType); 
     316                        outStream.println (")"); 
    328317                } 
    329318 
     
    331320                { 
    332321                        m_linkage.MakeDomain (sType, outStream); 
    333                         StringBuffer buffer = new StringBuffer(200); 
    334                         OutputAbilities (i_domain, buffer); 
    335                         outStream.print(buffer); 
     322                        OutputAbilities (i_domain, outStream); 
    336323                } 
    337324 
     
    407394                                        if (i_domain.GetChildren().size() > 0)  
    408395                                        { 
    409                                                 StringBuffer buffer = new StringBuffer(100); 
    410                                                 makeAllowsOnSelf(i_domain, rdef.getAccessAllResource(), buffer); 
    411                                                 outStream.print(buffer); 
     396                                                makeAllowsOnSelf(i_domain, rdef.getAccessAllResource(), outStream); 
    412397                                        } 
    413398                                } 
     
    514499                PrintStream outStream = m_bufferPolicy; 
    515500 
    516                 if (!m_bGeneratePolicyTemplate && i_entryPoint.hasCustomization ()) 
    517                 { 
    518                         String buffer = mCPolicyMacroPrefix + i_entryPoint.getName () + "(" + i_entryPoint.getType () + ")"; 
    519                         outStream.println (buffer); 
    520                         return; 
    521                 } 
    522  
     501                String sCustomName = CUSTOM_PREFIX + m_sModuleName + i_entryPoint.getOutputName ();  
     502                 
    523503                if (m_bGeneratePolicyTemplate) 
    524504                { 
    525505                        outStream = m_bufferInterfaces; 
    526          
    527                         StringBuffer buffer = new StringBuffer(200); 
    528                         buffer.append(XML_START); 
    529                         buffer.append(XML_SUMMARY_OPEN); 
    530                         buffer.append("## Customization for entrypoint ").append(i_entryPoint.getName ()).append(NEWLINE);  
    531                         buffer.append(XML_SUMMARY_CLOSE); 
    532                         buffer.append(XML_PARAM_OPEN); 
    533                         buffer.append("'entrypoint'>").append(NEWLINE); 
    534                         buffer.append("## Entrypoint Resource being customized").append(NEWLINE); 
    535                         buffer.append(XML_PARAM_CLOSE); 
    536                         buffer.append("template(`'"); 
    537                         buffer.append(mCPolicyMacroPrefix).append("_").append(i_entryPoint.getName ()).append("',`"); 
    538                         buffer.append(NEWLINE); 
    539                         outStream.print(buffer); 
     506                        outStream.println (); 
     507                        outStream.println (XML_START); 
     508                        outStream.println (XML_SUMMARY_OPEN); 
     509                        outStream.println ("## Customization for entrypoint " + i_entryPoint.getName ());  
     510                        outStream.println (XML_SUMMARY_CLOSE); 
     511                        outStream.print (XML_PARAM_OPEN); 
     512                        outStream.println ("'entrypoint'>"); 
     513                        outStream.println ("## Entrypoint Resource being customized"); 
     514                        outStream.println (XML_PARAM_CLOSE); 
     515                        outStream.print ("template(`'"); 
     516                        outStream.print (sCustomName); 
     517                        outStream.println ("',`"); 
    540518                } 
    541519                 
     
    549527                        m_bufferPolicy.println("type " + sType + ";"); 
    550528                } 
    551                  
     529 
     530                if (!m_bGeneratePolicyTemplate && i_entryPoint.hasCustomization ()) 
     531                { 
     532                        outStream.print (sCustomName); 
     533                        outStream.print ("("); 
     534                        outStream.print (i_entryPoint.getType ()); 
     535                        outStream.println (")"); 
     536                } 
     537 
    552538                // this call obtains the actual definition of the type 
    553539                m_linkage.MakeEntrypoint(sType, outStream); 
     
    563549        { 
    564550                boolean isBoolean = false; 
    565                 StringBuffer buffer = new StringBuffer(200); 
     551                 
    566552                if(i_access.getBool () != null) 
    567553                { 
    568                         buffer.append("if(").append(i_access.getBool().image).append(") {"); 
     554                        m_bufferPolicy.println ("if(" + i_access.getBool().image + ") {"); 
    569555 
    570556                        isBoolean = true; 
    571557                        if (i_access.getOnOrOff ().booleanValue () == false) 
    572                                 buffer.append("} else {"); 
    573                 } 
    574                  
    575                 buffer.append("# CDSFramework access (domain baseresource verb): "); 
    576                 buffer.append(i_access.toString().replace(Utility.DELIM, ' ')); 
     558                                m_bufferPolicy.println ("} else {"); 
     559                } 
     560                 
     561                m_bufferPolicy.print("# CDSFramework access (domain baseresource verb): "); 
     562                m_bufferPolicy.println (i_access.toString().replace(Utility.DELIM, ' ')); 
    577563                 
    578564                IDomain domain = i_access.getDomain(); 
     
    581567 
    582568                // This gets all global interface calls in the verb 
    583                 callInterfaces(domain, i_access.GetInterfaces(), buffer); 
     569                callInterfaces(domain, i_access.GetInterfaces(), m_bufferPolicy); 
    584570 
    585571                // for each AccessDefn associated with this AccessResource bundle 
     
    589575                        BaseAccessDefn axxDefn = (BaseAccessDefn) accessDefns.next(); 
    590576 
    591                         callInterfaces(domain, axxDefn.GetAllInterfaces().values(), buffer); 
     577                        callInterfaces(domain, axxDefn.GetAllInterfaces().values(), m_bufferPolicy); 
    592578 
    593579                        // for each AccessTarget associated with this AccessDefn 
     
    601587                                { 
    602588                                        case Target.self: 
    603                                                 makeAllowsOnSelf(domain, axxTarget.GetPermVectors(), buffer); 
     589                                                makeAllowsOnSelf(domain, axxTarget.GetPermVectors(), m_bufferPolicy); 
    604590                                                break; 
    605591                                        case Target.other_read: 
     
    620606                                        { 
    621607                                                Component entry = (Component) iter4.next(); 
    622                                                 makeAllows(domain, entry, axxTarget.GetPermVectors(), buffer); 
     608                                                makeAllows(domain, entry, axxTarget.GetPermVectors(), m_bufferPolicy); 
    623609                                        } 
    624610                                } 
     
    626612                } 
    627613                 
    628                 if(isBoolean) 
    629                 { 
    630                         buffer.append ("}"); 
    631                         buffer.append (NEWLINE); 
    632                 } 
    633                 m_bufferPolicy.print (buffer); 
     614                if (isBoolean) 
     615                { 
     616                        m_bufferPolicy.println ("}"); 
     617                } 
    634618        } 
    635619 
     
    678662 
    679663                        StringBuffer sCustomName = new StringBuffer(50); 
    680                         sCustomName.append(mCPolicyMacroPrefix).append(domain.getName ()); 
    681                         sCustomName.append("_").append(resource.getName ()).append("_").append(rdef.GetOutputName());  
     664                        sCustomName.append(CUSTOM_PREFIX).append ("access_").append (m_sModuleName).append ("_").append(domain.getOutputName ()); 
     665                        sCustomName.append("_").append(resource.getOutputName ()).append("_").append(rdef.GetOutputName());  
    682666                         
    683667                        if (m_bGeneratePolicyTemplate) 
    684668                        { 
    685669                                outStream = m_bufferInterfaces; 
    686                                 StringBuffer buffer = new StringBuffer(400); 
    687                                 buffer.append(XML_START); 
    688                                 buffer.append(XML_SUMMARY_OPEN); 
    689                                 buffer.append("## Customization for access domain: ").append(domain.getName ()).append(" resource: ").append(NEWLINE); 
    690                                 buffer.append(resource.getName ()).append(" rdef: ").append(rdef.GetOutputName()).append(NEWLINE);  
    691                                 buffer.append(XML_SUMMARY_CLOSE); 
    692                                 buffer.append(XML_PARAM_OPEN); 
    693                                 buffer.append("'domain'>").append(NEWLINE); 
    694                                 buffer.append("## Domain accessing resource").append(NEWLINE); 
    695                                 buffer.append(XML_PARAM_CLOSE); 
    696                                 buffer.append(XML_PARAM_OPEN); 
    697                                 buffer.append("'resource'>").append(NEWLINE); 
    698                                 buffer.append("## Resource being accessed").append(NEWLINE); 
    699                                 buffer.append(XML_PARAM_CLOSE); 
    700                                 buffer.append("template(`").append(sCustomName).append("',`").append(NEWLINE); 
    701                                 outStream.print (buffer); 
     670                                outStream.println (); 
     671                                outStream.println (XML_START); 
     672                                outStream.println (XML_SUMMARY_OPEN); 
     673                                outStream.print ("## Customization for access domain: " + domain.getName () + " resource: "); 
     674                                outStream.println (resource.getName () + " rdef: " + rdef.GetOutputName());  
     675                                outStream.println (XML_SUMMARY_CLOSE); 
     676                                outStream.print (XML_PARAM_OPEN); 
     677                                outStream.println ("'domain'>"); 
     678                                outStream.println ("## Domain accessing resource"); 
     679                                outStream.println (XML_PARAM_CLOSE); 
     680                                outStream.print (XML_PARAM_OPEN); 
     681                                outStream.println ("'resource'>"); 
     682                                outStream.println ("## Resource being accessed"); 
     683                                outStream.println (XML_PARAM_CLOSE); 
     684                                outStream.println ("template(`" + sCustomName + "',`"); 
    702685                        } 
    703686 
     
    740723                        { 
    741724//                              Rdef rdef = axxDefn.getAccessDefnGroup ().getRdef (); 
    742                                 StringBuffer buffer = new StringBuffer(100); 
    743725                                if (rdef.GetSysResourceState (SystemResourceTypes.file) != SysResourceState.No) 
    744                                         generateParentSearchPerms (i_access.getDomain (), resource, false, buffer); 
    745                                 outStream.print (buffer); 
    746                         } 
    747                          
    748                          
    749                         { 
    750                                 StringBuffer buffer = new StringBuffer(100); 
    751                                 // Create the perms for other 
    752                                 for (Iterator iter2 = axxDefn.getAccessTargets().values().iterator(); iter2.hasNext(); )  
    753                                 { 
    754                                         AccessTarget axxTarget = (AccessTarget) iter2.next(); 
    755                                         Integer /*Target*/target = axxTarget.getTargetName(); 
    756                                         Map accesses = null; 
    757                                         switch(target.intValue())  
    758                                         { 
    759                                                 case Target.other_read: 
    760                                                         accesses = ((Resource)i_access.getResource()).GetAccessMap(Verb.read); 
    761                                                         break; 
    762                                                 case Target.other_write: 
    763                                                         accesses = ((Resource)i_access.getResource()).GetAccessMap(Verb.write); 
    764                                                         break; 
    765                                                 case Target.other_readwrite: 
    766                                                         accesses = ((Resource)i_access.getResource()).GetAccessMap(Verb.readwrite); 
    767                                                         break; 
    768                                         } 
    769                                          
    770                                         if (accesses != null)  
    771                                         { 
    772                                                 for (Iterator iter3 = accesses.keySet().iterator(); iter3.hasNext(); )  
    773                                                 { 
    774                                                         Component entry = (Component) iter3.next(); 
    775                                                         makeAllows(i_access.getDomain(), entry, axxTarget.GetPermVectors(), buffer); 
    776                                                 }        
    777                                         } 
    778                                 } 
    779                                 outStream.print (buffer); 
     726                                        generateParentSearchPerms (i_access.getDomain (), resource, false, outStream); 
     727                        } 
     728                         
     729                         
     730                        // Create the perms for other 
     731                        for (Iterator iter2 = axxDefn.getAccessTargets().values().iterator(); iter2.hasNext(); )  
     732                        { 
     733                                AccessTarget axxTarget = (AccessTarget) iter2.next(); 
     734                                Integer /*Target*/target = axxTarget.getTargetName(); 
     735                                Map accesses = null; 
     736                                switch(target.intValue())  
     737                                { 
     738                                        case Target.other_read: 
     739                                                accesses = ((Resource)i_access.getResource()).GetAccessMap(Verb.read); 
     740                                                break; 
     741                                        case Target.other_write: 
     742                                                accesses = ((Resource)i_access.getResource()).GetAccessMap(Verb.write); 
     743                                                break; 
     744                                        case Target.other_readwrite: 
     745                                                accesses = ((Resource)i_access.getResource()).GetAccessMap(Verb.readwrite); 
     746                                                break; 
     747                                } 
     748                                 
     749                                if (accesses != null)  
     750                                { 
     751                                        for (Iterator iter3 = accesses.keySet().iterator(); iter3.hasNext(); )  
     752                                        { 
     753                                                Component entry = (Component) iter3.next(); 
     754                                                makeAllows(i_access.getDomain(), entry, axxTarget.GetPermVectors(), outStream); 
     755                                        }        
     756                                } 
    780757                        } 
    781758                         
     
    841818        public void Visit (BaseDomain domain) 
    842819        { 
    843                 StringBuffer buffer = new StringBuffer(70); 
    844                 buffer.append("optional_policy(`"); 
    845                 buffer.append("\tgen_require(`");  
    846                 buffer.append("\t\ttype ").append(domain.getType()).append(";");   
    847                 buffer.append("\t\trole ").append(domain.getRole()).append(";");  
    848                 buffer.append("\t')");  
     820                m_bufferPolicy.println ("optional_policy(`"); 
     821                m_bufferPolicy.println ("\tgen_require(`");  
     822                m_bufferPolicy.println ("\t\ttype " + domain.getType() + ";");   
     823                m_bufferPolicy.println ("\t\trole " + domain.getRole() + ";");  
     824                m_bufferPolicy.println ("\t')");  
    849825                 
    850                 OutputAbilities (domain, buffer); 
    851                buffer.append(NEWLINE).append("')"); 
    852                m_bufferPolicy.println(buffer); 
     826                OutputAbilities (domain, m_bufferPolicy); 
     827               m_bufferPolicy.println (); 
     828               m_bufferPolicy.println ("')"); 
    853829        } 
    854830 
     
    868844        { 
    869845                m_linkage.MakeUserDomain (dom.getName (), m_bufferPolicy); 
    870                 StringBuffer buffer = new StringBuffer(100); 
    871                 OutputAbilities (dom, buffer); 
    872                 m_bufferPolicy.print(buffer); 
     846                OutputAbilities (dom, m_bufferPolicy); 
    873847        } 
    874848 
     
    885859        } 
    886860         
    887         private void OutputAbilities (IDomain i_domain, StringBuffer buffer
     861        private void OutputAbilities (IDomain i_domain, PrintStream i_outputStream
    888862        { 
    889863                for (Iterator itr = i_domain.getAbilities().values().iterator(); itr.hasNext(); )  
    890864                { 
    891865                        Ability ability = (Ability) itr.next(); 
    892                         buffer.append("#Framework ability: ").append(ability.getName()).append("\n"); 
    893                         makeAllowsOnSelf (i_domain, ability.GetPermVectors(), buffer); 
    894                         callInterfaces (i_domain, ability.getAllInterfaces().values(), buffer); 
    895                         buffer.append("#End of Framework ability: ").append(ability.getName()).append("\n"); 
    896                 } 
    897         } 
    898          
    899         private void callInterfaces(IDomain domain, Collection interfaces, StringBuffer buffer)  
     866                        i_outputStream.print ("#Framework ability: "); 
     867                        i_outputStream.println (ability.getName()); 
     868                        makeAllowsOnSelf (i_domain, ability.GetPermVectors(), i_outputStream); 
     869                        callInterfaces (i_domain, ability.getAllInterfaces().values(), i_outputStream); 
     870                        i_outputStream.print ("#End of Framework ability: "); 
     871                        i_outputStream.println (ability.getName()); 
     872                } 
     873        } 
     874         
     875        private void callInterfaces(IDomain domain, Collection interfaces, PrintStream stream)  
    900876        { 
    901877                if (interfaces == null) 
     
    910886                { 
    911887                        Interface currInterface = (Interface) interfaceItr.next(); 
    912                         buffer.append(currInterface.getName()).append("("); 
     888                        stream.prin