1 |
|
//---PACKAGE DECLARATION--- |
2 |
< |
package uk.org.iscream.filtermanager; |
2 |
> |
package uk.org.iscream.cms.server.filtermanager; |
3 |
|
|
4 |
|
//---IMPORTS--- |
5 |
< |
import uk.org.iscream.core.*; |
6 |
< |
import uk.org.iscream.componentmanager.*; |
7 |
< |
import uk.org.iscream.filter.*; |
8 |
< |
import uk.org.iscream.util.*; |
5 |
> |
import uk.org.iscream.cms.server.core.*; |
6 |
> |
import uk.org.iscream.cms.server.componentmanager.*; |
7 |
> |
import uk.org.iscream.cms.server.filter.*; |
8 |
> |
import uk.org.iscream.cms.server.util.*; |
9 |
|
import java.net.*; |
10 |
|
import java.io.*; |
11 |
|
|
52 |
|
* and then passing them off to other processes to deal with. |
53 |
|
*/ |
54 |
|
public void run(){ |
55 |
+ |
// setup an empty ACL defaulting to ALLOW |
56 |
+ |
ACL acl = new ACL(ACL.ALLOW); |
57 |
+ |
|
58 |
|
ServerSocket listenSocket=null; |
59 |
|
// We use this boolean so we can break out of the while loop if we want |
60 |
|
boolean run = true; |
61 |
|
try{ |
62 |
|
// Work out the port we want |
63 |
< |
int listenPort = Integer.parseInt(ConfigurationProxy.getInstance().getProperty("FilterManager", "FilterManager.listenPort")); |
63 |
> |
int listenPort = Integer.parseInt(ConfigurationProxy.getInstance().getProperty("FilterManager." + FilterManager.NAME, "FilterManager.listenPort")); |
64 |
|
// Setup the ServerSocket so that clients can connect |
65 |
< |
listenSocket = new ServerSocket(listenPort); |
65 |
> |
listenSocket = new ACLServerSocket(acl, listenPort); |
66 |
|
_logger.write(toString(), Logger.SYSMSG, "Server listening on " |
67 |
|
+InetAddress.getLocalHost().getHostName() |
68 |
|
+"/"+InetAddress.getLocalHost().getHostAddress() |
87 |
|
} |
88 |
|
|
89 |
|
// Loop round constantly until we decide to stop |
90 |
+ |
ConfigurationProxy cp = ConfigurationProxy.getInstance(); |
91 |
+ |
String stringACL = ""; |
92 |
+ |
String newStringACL = ""; |
93 |
|
while(run){ |
94 |
+ |
// get hold of the ACL in the configuration |
95 |
+ |
try { |
96 |
+ |
newStringACL = cp.getProperty("FilterManager." + FilterManager.NAME, "FilterManager.ACL"); |
97 |
+ |
} |
98 |
+ |
catch(PropertyNotFoundException e) { |
99 |
+ |
// if we can't find it, we'll just use a null ACL |
100 |
+ |
newStringACL = ""; |
101 |
+ |
_logger.write(toString(), Logger.WARNING, "No ACL found for FilterManager, using empty ACL instead: " + e); |
102 |
+ |
} |
103 |
+ |
// check to see if the ACL has changed |
104 |
+ |
if(!newStringACL.equals(stringACL)) { |
105 |
+ |
_logger.write(toString(), Logger.SYSMSG, "Reloading Access Control List"); |
106 |
+ |
// clear the ACL |
107 |
+ |
acl.clear(); |
108 |
+ |
// set the default to something sane |
109 |
+ |
acl.setDefaultMode(ACL.ALLOW); |
110 |
+ |
// add the new ACL (this may change the default) |
111 |
+ |
acl.add(newStringACL); |
112 |
+ |
stringACL = newStringACL; |
113 |
+ |
} |
114 |
|
Socket hostSocket=null; |
115 |
|
try{ |
116 |
|
_logger.write(toString(), Logger.SYSMSG, "Waiting for Connection"); |
142 |
|
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
143 |
|
* method to provide clean logging (every class should have this). |
144 |
|
* |
145 |
< |
* This uses the uk.org.iscream.util.NameFormat class |
145 |
> |
* This uses the uk.org.iscream.cms.server.util.NameFormat class |
146 |
|
* to format the toString() |
147 |
|
* |
148 |
|
* @return the name of this class and its CVS revision |