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