ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/server/uk/org/iscream/cms/server/filtermanager/HostListener.java
(Generate patch)

Comparing projects/cms/source/server/uk/org/iscream/cms/server/filtermanager/HostListener.java (file contents):
Revision 1.7 by tdb, Tue Mar 13 13:40:26 2001 UTC vs.
Revision 1.16 by tdb, Sun Aug 1 10:41:05 2004 UTC

# Line 1 | Line 1
1 + /*
2 + * i-scream central monitoring system
3 + * http://www.i-scream.org
4 + * Copyright (C) 2000-2002 i-scream
5 + *
6 + * This program is free software; you can redistribute it and/or
7 + * modify it under the terms of the GNU General Public License
8 + * as published by the Free Software Foundation; either version 2
9 + * of the License, or (at your option) any later version.
10 + *
11 + * This program is distributed in the hope that it will be useful,
12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 + * GNU General Public License for more details.
15 + *
16 + * You should have received a copy of the GNU General Public License
17 + * along with this program; if not, write to the Free Software
18 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19 + */
20 +
21   //---PACKAGE DECLARATION---
22 < package uk.ac.ukc.iscream.filtermanager;
22 > package uk.org.iscream.cms.server.filtermanager;
23  
24   //---IMPORTS---
25 < import uk.ac.ukc.iscream.core.*;
26 < import uk.ac.ukc.iscream.componentmanager.*;
27 < import uk.ac.ukc.iscream.filter.*;
28 < import uk.ac.ukc.iscream.util.*;
25 > import uk.org.iscream.cms.server.core.*;
26 > import uk.org.iscream.cms.server.componentmanager.*;
27 > import uk.org.iscream.cms.server.filter.*;
28 > import uk.org.iscream.cms.util.*;
29   import java.net.*;
30   import java.io.*;
31  
# Line 52 | Line 72 | class HostListener extends Thread {
72           * and then passing them off to other processes to deal with.
73           */
74      public void run(){
75 +        // setup an empty ACL defaulting to ALLOW
76 +        ACL acl = new ACL(ACL.ALLOW);
77 +        
78          ServerSocket listenSocket=null;
79                  // We use this boolean so we can break out of the while loop if we want
80          boolean run = true;
81          try{
82              // Work out the port we want
83 <            int listenPort = Integer.parseInt(ConfigurationProxy.getInstance().getProperty("FilterManager", "FilterManager.listenPort"));
83 >            int listenPort = Integer.parseInt(ConfigurationProxy.getInstance().getProperty("FilterManager." + FilterManager.NAME, "FilterManager.listenPort"));
84                          // Setup the ServerSocket so that clients can connect
85 <            listenSocket = new ServerSocket(listenPort);
85 >                        listenSocket = new ACLServerSocket(acl, listenPort);
86              _logger.write(toString(), Logger.SYSMSG, "Server listening on "
87                                                                                  +InetAddress.getLocalHost().getHostName()
88                                                                                  +"/"+InetAddress.getLocalHost().getHostAddress()
# Line 84 | Line 107 | class HostListener extends Thread {
107          }
108  
109                  // Loop round constantly until we decide to stop
110 +                ConfigurationProxy cp = ConfigurationProxy.getInstance();
111 +        String stringACL = "";
112 +        String newStringACL = "";
113          while(run){
114 +            // get hold of the ACL in the configuration
115 +            try {
116 +                newStringACL = cp.getProperty("FilterManager." + FilterManager.NAME, "FilterManager.ACL");
117 +            }
118 +            catch(PropertyNotFoundException e) {
119 +                // if we can't find it, we'll just use a null ACL
120 +                newStringACL = "";
121 +                _logger.write(toString(), Logger.WARNING, "No ACL found for FilterManager, using empty ACL instead: " + e);
122 +            }
123 +            // check to see if the ACL has changed
124 +            if(!newStringACL.equals(stringACL)) {
125 +                _logger.write(toString(), Logger.SYSMSG, "Reloading Access Control List");
126 +                // clear the ACL
127 +                acl.clear();
128 +                // set the default to something sane
129 +                acl.setDefaultMode(ACL.ALLOW);
130 +                // add the new ACL (this may change the default)
131 +                acl.add(newStringACL);
132 +                stringACL = newStringACL;
133 +            }
134              Socket hostSocket=null;
135              try{
136                  _logger.write(toString(), Logger.SYSMSG, "Waiting for Connection");
# Line 116 | Line 162 | class HostListener extends Thread {
162       * Overrides the {@link java.lang.Object#toString() Object.toString()}
163       * method to provide clean logging (every class should have this).
164       *
165 <     * This uses the uk.ac.ukc.iscream.util.NameFormat class
165 >     * This uses the uk.org.iscream.cms.util.NameFormat class
166       * to format the toString()
167       *
168       * @return the name of this class and its CVS revision

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines