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.org.iscream.clientinterface; |
21 |
> |
package uk.org.iscream.cms.server.clientinterface; |
22 |
|
|
23 |
|
//---IMPORTS--- |
24 |
< |
import uk.org.iscream.util.*; |
25 |
< |
import uk.org.iscream.core.*; |
26 |
< |
import uk.org.iscream.componentmanager.*; |
24 |
> |
import uk.org.iscream.cms.server.util.*; |
25 |
> |
import uk.org.iscream.cms.server.core.*; |
26 |
> |
import uk.org.iscream.cms.server.componentmanager.*; |
27 |
|
import java.io.IOException; |
28 |
|
import java.net.Socket; |
29 |
|
import java.net.ServerSocket; |
75 |
|
* and then passing them off to handler processes to deal with. |
76 |
|
*/ |
77 |
|
public void run(){ |
78 |
+ |
// setup an empty ACL defaulting to ALLOW |
79 |
+ |
ACL acl = new ACL(ACL.ALLOW); |
80 |
+ |
|
81 |
|
// get our port |
82 |
|
int portNum; |
83 |
|
try { |
96 |
|
boolean run = true; |
97 |
|
try{ |
98 |
|
// Setup the ServerSocket so that clients can connect |
99 |
< |
listenPort = new ServerSocket(portNum); |
99 |
> |
listenPort = new ACLServerSocket(acl, portNum); |
100 |
|
} |
101 |
|
catch(IOException e){ |
102 |
|
} |
112 |
|
+"port "+listenPort.getLocalPort()); |
113 |
|
} |
114 |
|
// Loop round constantly until we decide to stop |
115 |
+ |
ConfigurationProxy cp = ConfigurationProxy.getInstance(); |
116 |
+ |
String stringACL = ""; |
117 |
+ |
String newStringACL = ""; |
118 |
|
while(run){ |
119 |
+ |
// get hold of the ACL in the configuration |
120 |
+ |
try { |
121 |
+ |
newStringACL = cp.getProperty("ClientInterface", "ClientInterface.TCPControlChannelACL"); |
122 |
+ |
} |
123 |
+ |
catch(PropertyNotFoundException e) { |
124 |
+ |
// if we can't find it, we'll just use a null ACL |
125 |
+ |
newStringACL = ""; |
126 |
+ |
_logger.write(toString(), Logger.WARNING, "No ACL found for ClientInterface (control channel listener), using empty ACL instead: " + e); |
127 |
+ |
} |
128 |
+ |
// check to see if the ACL has changed |
129 |
+ |
if(!newStringACL.equals(stringACL)) { |
130 |
+ |
_logger.write(toString(), Logger.SYSMSG, "Reloading Access Control List"); |
131 |
+ |
// clear the ACL |
132 |
+ |
acl.clear(); |
133 |
+ |
// set the default to something sane |
134 |
+ |
acl.setDefaultMode(ACL.ALLOW); |
135 |
+ |
// add the new ACL (this may change the default) |
136 |
+ |
acl.add(newStringACL); |
137 |
+ |
stringACL = newStringACL; |
138 |
+ |
} |
139 |
|
Socket hostSocket=null; |
140 |
|
try{ |
141 |
|
_logger.write(toString(), Logger.SYSMSG, "Waiting for Connection"); |
166 |
|
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
167 |
|
* method to provide clean logging (every class should have this). |
168 |
|
* |
169 |
< |
* This uses the uk.org.iscream.util.NameFormat class |
169 |
> |
* This uses the uk.org.iscream.cms.server.util.NameFormat class |
170 |
|
* to format the toString() |
171 |
|
* |
172 |
|
* @return the name of this class and its CVS revision |