Changeset 2191

Show
Ignore:
Timestamp:
05/27/08 15:11:42 (6 months ago)
Author:
dsugar
Message:

fix a bunch of null pointer exceptions

Files:

Legend:

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

    r2188 r2191  
    209209                 
    210210                Collection endpoints = (Collection) m_endpoints.get (netRes); 
     211                if (endpoints == null) 
     212                        return; 
     213                 
    211214                { 
    212215                        NetworkInfo netInfo = new NetworkInfo (labRes.getNetworkInfo ()); 
  • trunk/framework-plugin/src/com/tresys/framework/compiler/policy/PolicyParser.jj

    r2188 r2191  
    618618                                { 
    619619                                        NetResource netResource = m_netConfig.getResource (tokResourceName.image); 
     620                                        if (netResource == null) 
     621                                                return; 
    620622 
    621623                                        resource = new NetworkResource (addHandlerToToken(tokResourceName), netResource, m_policy); 
  • trunk/framework-plugin/src/com/tresys/framework/compiler/systemResources/SystemResourcesParser.jj

    r2188 r2191  
    318318        } 
    319319        <LBRACE> 
    320         (RdefPath(comp, dobj)|RdefNetwork(comp, dobj))+ 
     320        (RdefPath(comp, dobj)|RdefNetwork(comp, dobj))* 
    321321        <NR_RBRACE> 
    322322} 
  • trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/model/NetworkResourceShape.java

    r2189 r2191  
    101101        private String[] rdefsArray = null; 
    102102 
     103        private static final String EMPTY_STRING = new String (); 
     104         
    103105        private Rdef m_rdef; 
    104106        private NetResource m_netResource; 
     
    114116                Token tok = new Token (sName, getErrorHandler ()); 
    115117 
    116                 NetResource netResource = new NetResource(tok, null);          
    117                 NetworkResource resource = new NetworkResource (tok, netResource, i_system.getPolicy ()); 
     118                m_netResource = new NetResource(tok, null);            
     119                NetworkResource resource = new NetworkResource (tok, m_netResource, i_system.getPolicy ()); 
    118120         
    119121                SELinuxSystem sys = getSystem (); 
    120122                NetworkConfig config = sys.getNetworkConfig (); 
    121                 config.Add (netResource); 
     123                config.Add (m_netResource); 
    122124 
    123125                setComponent (resource); 
     
    418420 
    419421                if (NETWORK_PROTOCOL_INDEX.equals (propertyId)) 
    420                         return this.GetNetworkProtocolIndex ( ((IPTablesNetworkResource) sysResource) 
    421                                 .getProtocol ()); 
     422                { 
     423                        return GetNetworkProtocolIndex ( ((IPTablesNetworkResource) sysResource).getProtocol ()); 
     424                } 
    422425 
    423426                NetworkInfo localInfo = null; 
     
    437440                if (NETWORK_LOCAL_DEVICE.equals (propertyId)) 
    438441                { 
     442                        if (localInfo == null) 
     443                                return EMPTY_STRING; 
     444                         
    439445                        String retValue = localInfo.getDevice (); 
    440446                        if (retValue == null) 
    441                                 return ""
     447                                return EMPTY_STRING
    442448                         
    443449                        return retValue; 
     
    446452                if (NETWORK_LOCAL_IP_ADDRESS.equals (propertyId)) 
    447453                { 
     454                        if (localInfo == null) 
     455                                return EMPTY_STRING; 
     456                         
    448457                        String retValue = localInfo.getIPAddr (); 
    449458                        if (retValue == null) 
    450                                 return ""
     459                                return EMPTY_STRING
    451460                         
    452461                        return retValue; 
     
    455464                if (NETWORK_LOCAL_MASK.equals (propertyId)) 
    456465                { 
     466                        if (localInfo == null) 
     467                                return EMPTY_STRING; 
     468                         
    457469                        String retValue = localInfo.getMask (); 
    458470                        if (retValue == null) 
    459                                 return ""
     471                                return EMPTY_STRING
    460472                         
    461473                        return retValue; 
     
    463475 
    464476                if (NETWORK_LOCAL_IP_PORTS.equals (propertyId)) 
     477                { 
     478                        if (localInfo == null) 
     479                                return EMPTY_STRING; 
     480                         
    465481                        return BuildPortsString (localInfo.getPorts ()); 
     482                } 
    466483 
    467484                if (NETWORK_LOCAL_ENCRYPTION_TYPE_INDEX.equals (propertyId)) 
     
    482499                if (NETWORK_REMOTE_DEVICE.equals (propertyId)) 
    483500                { 
     501                        if (remoteInfo == null) 
     502                                return EMPTY_STRING; 
     503                         
    484504                        String retValue = remoteInfo.getDevice (); 
    485505                        if (retValue == null) 
    486                                 return ""
     506                                return EMPTY_STRING
    487507                         
    488508                        return retValue; 
     
    491511                if (NETWORK_REMOTE_IP_ADDRESS.equals (propertyId)) 
    492512                { 
     513                        if (remoteInfo == null) 
     514                                return EMPTY_STRING; 
     515 
    493516                        String retValue = remoteInfo.getIPAddr (); 
    494517                        if (retValue == null) 
    495                                 return ""
     518                                return EMPTY_STRING
    496519                         
    497520                        return retValue; 
     
    500523                if (NETWORK_REMOTE_MASK.equals (propertyId)) 
    501524                { 
     525                        if (remoteInfo == null) 
     526                                return EMPTY_STRING; 
     527 
    502528                        String retValue = remoteInfo.getMask (); 
    503529                        if (retValue == null) 
    504                                 return ""
     530                                return EMPTY_STRING
    505531                         
    506532                        return retValue; 
     
    508534 
    509535                if (NETWORK_REMOTE_IP_PORTS.equals (propertyId)) 
     536                { 
     537                        if (remoteInfo == null) 
     538                                return EMPTY_STRING; 
     539 
    510540                        return BuildPortsString (remoteInfo.getPorts ()); 
     541                } 
    511542 
    512543                return super.getPropertyValue (propertyId); 
     
    565596                { 
    566597                        NetworkResource resource = (NetworkResource) getComponent (); 
    567                         SystemResource sysResource = (SystemResource) resource.GetSystemResources (m_rdef).get (0); 
     598                        SystemResource sysResource = resource.getSystemResource (m_rdef); 
     599//                      resource.GetSystemResources (m_rdef).get (0); 
    568600 
    569601                        NetworkInfo localInfo = null; 
    570602                        NetworkInfo remoteInfo = null; 
    571603 
     604                         
     605                        if (sysResource == null) 
     606                        { 
     607                                if (m_rdef.GetSysResourceState (SystemResourceTypes.ipsec) != SysResourceState.No) 
     608                                { 
     609                                        localInfo = new NetworkInfo (null, null, null, null); 
     610                                        sysResource = new LabeledNetworkResource (localInfo, m_rdef); 
     611                                } 
     612                                else if (m_rdef.GetSysResourceState (SystemResourceTypes.secmark) != SysResourceState.No) 
     613                                { 
     614                                        localInfo = new NetworkInfo (null, null, null, null); 
     615                                        remoteInfo = new NetworkInfo (null, null, null, null); 
     616                                        sysResource = new IPTablesNetworkResource (localInfo, remoteInfo, EMPTY_STRING, m_rdef); 
     617                                } 
     618 
     619                                resource.AddSystemResource (m_rdef, sysResource); 
     620                        } 
     621                         
    572622                        if (sysResource instanceof LabeledNetworkResource) 
    573623                        { 
     
    648698                                ports[i] = Integer.parseInt (sPorts[i]); 
    649699                } 
     700 
    650701                return ports; 
    651702        } 
    652703         
    653         public static String BuildPortsString (int[] ports) 
     704        private static String BuildPortsString (int[] ports) 
    654705        { 
    655706                if (ports == null) 
    656                         return ""
     707                        return EMPTY_STRING
    657708                 
    658709                StringBuilder s_ports = new StringBuilder (); 
     
    669720        } 
    670721 
    671         public String GetNetworkEncryptionType(Object index) 
     722        private String GetNetworkEncryptionType(Object index) 
    672723        { 
    673724                ArrayList list = NetResource.GetNetworkEncryptionTypes (); 
     
    676727         
    677728 
    678         public Integer GetNetworkProtocolIndex (String protocol) 
     729        private Integer GetNetworkProtocolIndex (String protocol) 
    679730        { 
    680731                ArrayList list = new ArrayList (GetNetworkProtcols ()); 
     
    682733        } 
    683734 
    684         public Integer GetNetworkEncryptionTypeIndex (String encryption) 
     735        private Integer GetNetworkEncryptionTypeIndex (String encryption) 
    685736        { 
    686737                ArrayList list = new ArrayList (NetResource.GetNetworkEncryptionTypes ()); 
     
    688739        } 
    689740 
    690         public void SetNetworkProtocolIndex (Object index) 
     741        private void SetNetworkProtocolIndex (Object index) 
    691742        { 
    692743                ArrayList list = new ArrayList (GetNetworkProtcols ());