52 |
|
* and then passing them off to other processes to deal with. |
53 |
|
*/ |
54 |
|
public void run(){ |
55 |
< |
// get our ACL from the configuration |
56 |
< |
ACL acl = null; |
57 |
< |
try { |
58 |
< |
String stringACL = ConfigurationProxy.getInstance().getProperty("FilterManager." + FilterManager.NAME, "FilterManager.ACL"); |
59 |
< |
acl = new ACL(stringACL); |
60 |
< |
} |
61 |
< |
catch(PropertyNotFoundException e) { |
62 |
< |
_logger.write(toString(), Logger.WARNING, "No ACL found for FilterManager: " + e); |
63 |
< |
} |
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 |
62 |
|
// Work out the port we want |
63 |
|
int listenPort = Integer.parseInt(ConfigurationProxy.getInstance().getProperty("FilterManager." + FilterManager.NAME, "FilterManager.listenPort")); |
64 |
|
// Setup the ServerSocket so that clients can connect |
65 |
< |
// use an ACLServerSocket if we have an ACL |
73 |
< |
if(acl != null) { |
74 |
< |
listenSocket = new ACLServerSocket(acl, listenPort); |
75 |
< |
} |
76 |
< |
else { |
77 |
< |
listenSocket = new ServerSocket(listenPort); |
78 |
< |
} |
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"); |