Changeset 2234

Show
Ignore:
Timestamp:
06/12/08 14:59:12 (3 months ago)
Author:
apatel
Message:

updated IP checking to understand alphanumeric URL separated by dots.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/model/NetworkResourceShape.java

    r2215 r2234  
    9797        public static final String NetworkResource_ipv4_address_pattern = "^(((25[0-5])|(2[0-4][0-9])|([01]?[0-9][0-9]?))\\.){3}((25[0-5])|(2[0-4][0-9])|([01]?[0-9][0-9]?))$"; 
    9898        public static final String NetworkResource_ipv6_address_pattern = "^(^(([0-9a-fA-F]{1,4}(((:[0-9a-fA-F]{1,4}){5}::[0-9a-fA-F]{1,4})|((:[0-9a-fA-F]{1,4}){4}::[0-9a-fA-F]{1,4}(:[0-9a-fA-F]{1,4}){0,1})|((:[0-9a-fA-F]{1,4}){3}::[0-9a-fA-F]{1,4}(:[0-9a-fA-F]{1,4}){0,2})|((:[0-9a-fA-F]{1,4}){2}::[0-9a-fA-F]{1,4}(:[0-9a-fA-F]{1,4}){0,3})|(:[0-9a-fA-F]{1,4}::[0-9a-fA-F]{1,4}(:[0-9a-fA-F]{1,4}){0,4})|(::[0-9a-fA-F]{1,4}(:[0-9a-fA-F]{1,4}){0,5})|(:[0-9a-fA-F]{1,4}){7}))$|^(::[0-9a-fA-F]{1,4}(:[0-9a-fA-F]{1,4}){0,6})$)|^::$)|^((([0-9a-fA-F]{1,4}(((:[0-9a-fA-F]{1,4}){3}::([0-9a-fA-F]{1,4}){1})|((:[0-9a-fA-F]{1,4}){2}::[0-9a-fA-F]{1,4}(:[0-9a-fA-F]{1,4}){0,1})|((:[0-9a-fA-F]{1,4}){1}::[0-9a-fA-F]{1,4}(:[0-9a-fA-F]{1,4}){0,2})|(::[0-9a-fA-F]{1,4}(:[0-9a-fA-F]{1,4}){0,3})|((:[0-9a-fA-F]{1,4}){0,5})))|([:]{2}[0-9a-fA-F]{1,4}(:[0-9a-fA-F]{1,4}){0,4})):|::)((25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{0,2})\\.){3}(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{0,2})$$"; 
     99        public static final String NetworkResource_ip_address_pattern = "\\w+.\\w+((.\\w+)+)"; 
     100 
    99101        public static final String NetworkResource_ip_ports_pattern = "([0-9]+( [0-9]+)*)?"; 
    100102 
  • trunk/framework-plugin/src/com/tresys/framework/plugin/wizards/shape/NetworkResourceShapePropertyPage.java

    r2233 r2234  
    168168                public ModifyValueListener(NetworkResourceShapePropertyPage Page, String IPVar) 
    169169                { 
    170                         super(); 
    171170                        this.page = Page; 
    172171                        this.ipVar = IPVar; 
     
    223222                        modifyValue (s); 
    224223                        updateStatus (); 
    225 
     224               
    226225 
    227226        } 
     
    269268                        modifyValue (s); 
    270269                         
    271                         if (!this.required && s.length () == 0) 
     270                        if (!this.required && s.trim().length () == 0) 
    272271                        { 
    273272                                updateStatus();                  
    274273                        } 
    275                          
    276274                        else 
    277275                        { 
    278                                 if (!Pattern.matches (NetworkResourceShape.NetworkResource_ipv4_address_pattern, s) && 
    279                                         !Pattern.matches(NetworkResourceShape.NetworkResource_ipv6_address_pattern, s)) 
     276                                boolean match = Pattern.matches(NetworkResourceShape.NetworkResource_ip_address_pattern, s); 
     277                                boolean ip4 = Pattern.matches (NetworkResourceShape.NetworkResource_ipv4_address_pattern, s); 
     278                                boolean ip6 = Pattern.matches(NetworkResourceShape.NetworkResource_ipv6_address_pattern, s);  
     279                                 
     280                                if( ip4 || ip6 || match ) 
     281                                        updateStatus (); 
     282                                else 
    280283                                { 
    281284                                        String msg = getErrorMessage (); 
    282                                          
    283285                                        if (msg == null || !msg.equals (this.errorMessage)) 
    284286                                                updateStatus (this.errorMessage, false); 
    285287                                } 
    286                                 else 
    287                                         updateStatus(); 
    288288                        } 
    289289                } 
     
    306306                        modifyValue (s); 
    307307                         
    308                         if (s.length () == 0) 
    309                         { 
    310                                 updateStatus();                  
    311                         } 
    312                          
     308                        if (s.trim ().length () > 0 && !Pattern.matches (NetworkResourceShape.NetworkResource_ip_ports_pattern, s)) 
     309                                updateStatus(this.errorMessage, false); 
    313310                        else 
    314                         { 
    315                                 if (!Pattern.matches (NetworkResourceShape.NetworkResource_ip_ports_pattern, s)) 
    316                                         updateStatus(this.errorMessage, false); 
    317                          
    318                                 else 
    319                                         updateStatus(); 
    320                         } 
     311                                updateStatus(); 
    321312                } 
    322313        } 
     
    594585                        if ((getNetworkType().GetSysResourceState (SystemResourceTypes.ipsec) == SysResourceState.Yes || getNetworkType().GetSysResourceState (SystemResourceTypes.ipsec) == SysResourceState.Optional)) 
    595586                        { 
    596                                 if (localIPAddress.length () == 0) 
     587                                if (localIPAddress.trim ().length () == 0) 
    597588                                        super.updateStatus (Messages.NetworkResourcePropertyPage_bad_local_ip_address, false); 
    598589                        } 
     
    600591                        else if ((getNetworkType().GetSysResourceState (SystemResourceTypes.secmark) == SysResourceState.Yes || getNetworkType().GetSysResourceState (SystemResourceTypes.secmark) == SysResourceState.Optional)) 
    601592                        { 
    602                                 if (localDevice.length () == 0 && localIPAddress.length () == 0) 
     593                                if (localDevice.trim ().length () == 0 && localIPAddress.trim ().length () == 0) 
    603594                                        super.updateStatus (Messages.NetworkResourcePropertyPage_err_local_device_or_ip, false); 
    604595                        }                
     
    607598         
    608599        public Rdef getNetworkType() 
    609         { 
     600        {  
    610601                return (Rdef)((StructuredSelection) this.m_combo.getSelection ()).getFirstElement (); 
    611602        }