james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject cvs commit: james-server/src/java/org/apache/james/transport/matchers AbstractNetworkMatcher.java
Date Sat, 04 Oct 2003 05:06:41 GMT
noel        2003/10/03 22:06:41

  Modified:    src/java/org/apache/james/transport/matchers Tag:
                        branch_2_1_fcs AbstractNetworkMatcher.java
  Log:
  Handle case where no networks are provided, rather than NPE
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.1.2.2   +18 -12    james-server/src/java/org/apache/james/transport/matchers/AbstractNetworkMatcher.java
  
  Index: AbstractNetworkMatcher.java
  ===================================================================
  RCS file: /home/cvs/james-server/src/java/org/apache/james/transport/matchers/AbstractNetworkMatcher.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- AbstractNetworkMatcher.java	6 Jun 2003 23:52:49 -0000	1.1.2.1
  +++ AbstractNetworkMatcher.java	4 Oct 2003 05:06:41 -0000	1.1.2.2
  @@ -92,27 +92,33 @@
       private NetMatcher authorizedNetworks = null;
   
       public void init() throws MessagingException {
  -        authorizedNetworks = new NetMatcher() {
  -            protected void log(String s) {
  -                AbstractNetworkMatcher.this.log(s);
  -            }
  -        };
  -        authorizedNetworks.initInetNetworks(allowedNetworks());
  -        log("Authorized addresses: " + authorizedNetworks.toString());
  +        Collection nets = allowedNetworks();
  +        if (nets != null) {
  +            authorizedNetworks = new NetMatcher() {
  +                protected void log(String s) {
  +                    AbstractNetworkMatcher.this.log(s);
  +                }
  +            };
  +            authorizedNetworks.initInetNetworks(allowedNetworks());
  +            log("Authorized addresses: " + authorizedNetworks.toString());
  +        }
       }
   
       protected Collection allowedNetworks() {
  -        StringTokenizer st = new StringTokenizer(getCondition(), ", ", false);
  -        Collection networks = new java.util.ArrayList();
  -        while (st.hasMoreTokens()) networks.add(st.nextToken());
  +        Collection networks = null;
  +        if (getCondition() != null) {
  +            StringTokenizer st = new StringTokenizer(getCondition(), ", ", false);
  +            networks = new java.util.ArrayList();
  +            while (st.hasMoreTokens()) networks.add(st.nextToken());
  +        }
           return networks;
       }
   
       protected boolean matchNetwork(java.net.InetAddress addr) {
  -        return authorizedNetworks.matchInetNetwork(addr);
  +        return authorizedNetworks == null ? false : authorizedNetworks.matchInetNetwork(addr);
       }
   
       protected boolean matchNetwork(String addr) {
  -        return authorizedNetworks.matchInetNetwork(addr);
  +        return authorizedNetworks == null ? false : authorizedNetworks.matchInetNetwork(addr);
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message