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

Comparing projects/cms/source/server/uk/org/iscream/cms/server/clientinterface/TCPClientListener.java (file contents):
Revision 1.14 by tdb, Wed Mar 20 12:56:37 2002 UTC vs.
Revision 1.19 by tdb, Sun Aug 1 10:40:48 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.org.iscream.cms.server.clientinterface;
23  
24   //---IMPORTS---
25 < import uk.org.iscream.cms.server.util.*;
25 > import uk.org.iscream.cms.util.*;
26   import uk.org.iscream.cms.server.core.*;
27   import uk.org.iscream.cms.server.componentmanager.*;
28   import java.io.IOException;
# Line 56 | Line 76 | class TCPClientListener extends Thread {
76           * and then passing them off to handler processes to deal with.
77           */
78      public void run(){
79 <        // get our ACL from the configuration
80 <        ACL acl = null;
61 <        try {
62 <            String stringACL = ConfigurationProxy.getInstance().getProperty("ClientInterface", "ClientInterface.TCPControlChannelACL");
63 <            acl = new ACL(stringACL);
64 <        }
65 <        catch(PropertyNotFoundException e) {
66 <            _logger.write(toString(), Logger.WARNING, "No ACL found for ClientInterface (control channel listener): " + e);
67 <        }
79 >        // setup an empty ACL defaulting to ALLOW
80 >        ACL acl = new ACL(ACL.ALLOW);
81          
82          // get our port
83          int portNum;
# Line 84 | Line 97 | class TCPClientListener extends Thread {
97          boolean run = true;
98          try{
99                          // Setup the ServerSocket so that clients can connect
100 <                        // use an ACLServerSocket if we have an ACL
88 <                        if(acl != null) {
89 <                            listenPort = new ACLServerSocket(acl, portNum);
90 <                        }
91 <                        else {
92 <                listenPort = new ServerSocket(portNum);
93 <            }
100 >                        listenPort = new ACLServerSocket(acl, portNum);
101          }
102          catch(IOException e){
103          }
# Line 106 | Line 113 | class TCPClientListener extends Thread {
113                                                                                  +"port "+listenPort.getLocalPort());
114                  }
115                  // Loop round constantly until we decide to stop
116 +                ConfigurationProxy cp = ConfigurationProxy.getInstance();
117 +        String stringACL = "";
118 +        String newStringACL = "";
119          while(run){
120 +            // get hold of the ACL in the configuration
121 +            try {
122 +                newStringACL = cp.getProperty("ClientInterface", "ClientInterface.TCPControlChannelACL");
123 +            }
124 +            catch(PropertyNotFoundException e) {
125 +                // if we can't find it, we'll just use a null ACL
126 +                newStringACL = "";
127 +                _logger.write(toString(), Logger.WARNING, "No ACL found for ClientInterface (control channel listener), using empty ACL instead: " + e);
128 +            }
129 +            // check to see if the ACL has changed
130 +            if(!newStringACL.equals(stringACL)) {
131 +                _logger.write(toString(), Logger.SYSMSG, "Reloading Access Control List");
132 +                // clear the ACL
133 +                acl.clear();
134 +                // set the default to something sane
135 +                acl.setDefaultMode(ACL.ALLOW);
136 +                // add the new ACL (this may change the default)
137 +                acl.add(newStringACL);
138 +                stringACL = newStringACL;
139 +            }
140              Socket hostSocket=null;
141              try{
142                  _logger.write(toString(), Logger.SYSMSG, "Waiting for Connection");
# Line 137 | Line 167 | class TCPClientListener extends Thread {
167       * Overrides the {@link java.lang.Object#toString() Object.toString()}
168       * method to provide clean logging (every class should have this).
169       *
170 <     * This uses the uk.org.iscream.cms.server.util.NameFormat class
170 >     * This uses the uk.org.iscream.cms.util.NameFormat class
171       * to format the toString()
172       *
173       * @return the name of this class and its CVS revision

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines