Revision 527
Added by bojilova over 23 years ago
AuthMcat.java | ||
---|---|---|
23 | 23 |
import java.util.Vector; |
24 | 24 |
import java.rmi.*; |
25 | 25 |
import SrbJavaGlueInterface; |
26 |
import RMIControllerInterface; |
|
27 | 26 |
import java.util.PropertyResourceBundle; |
28 | 27 |
|
29 | 28 |
/** |
... | ... | |
45 | 44 |
// JNI (Java Native Interface) routines for SRB |
46 | 45 |
static String srbHost; |
47 | 46 |
static String srbPort; |
48 |
static String RMIhost; |
|
49 |
static RMIControllerInterface rmicon; |
|
47 |
static String srbDomain; |
|
50 | 48 |
static SrbJavaGlueInterface srbJG; |
51 | 49 |
static { |
52 | 50 |
try { |
... | ... | |
57 | 55 |
PropertyResourceBundle.getBundle("edu.ucsb.nceas.metacat.srbProps"); |
58 | 56 |
srbHost = (String)SRBProps.handleGetObject("host"); |
59 | 57 |
srbPort = (String)SRBProps.handleGetObject("port"); |
58 |
srbDomain = (String)SRBProps.handleGetObject("domain"); |
|
60 | 59 |
// should handle missing RMIhost name here |
61 |
RMIhost = (String)SRBProps.handleGetObject("RMIhost"); |
|
62 |
String name = "//" + RMIhost + "/RMIController"; |
|
63 |
rmicon = (RMIControllerInterface)Naming.lookup(name); |
|
64 |
name = "//" + RMIhost + "/SrbJavaGlue"; |
|
60 |
String name = "//" + srbHost + "/SrbJavaGlue"; |
|
65 | 61 |
srbJG = (SrbJavaGlueInterface)Naming.lookup(name); |
66 | 62 |
} catch (Exception e) { |
67 | 63 |
System.err.println("AuthMcat static: " + e.getMessage()); |
... | ... | |
226 | 222 |
private int srbConnect(String username, String password) |
227 | 223 |
throws RemoteException { |
228 | 224 |
|
229 |
int srbconn = 0; |
|
225 |
synchronized(this) { |
|
226 |
int srbconn = 0; |
|
230 | 227 |
|
231 |
// look up for SRBJavaGlue |
|
232 |
try { |
|
233 |
String name = "//" + RMIhost + "/SrbJavaGlue"; |
|
234 |
srbJG = (SrbJavaGlueInterface)Naming.lookup(name); |
|
235 |
} catch (Exception e) { |
|
228 |
// try SRB RMI Connection |
|
229 |
// integer value of the SBR Connection ID is returned only |
|
236 | 230 |
try { |
237 |
rmicon.restart(); |
|
238 |
} catch (Exception rmie) {} |
|
239 |
// The SRB server is not running or it is busy now |
|
240 |
throw new |
|
241 |
RemoteException("AuthMcat look up for SrbJavaGlue failed"); |
|
242 |
} |
|
231 |
String name = "//" + srbHost + "/SrbJavaGlue"; |
|
232 |
srbJG = (SrbJavaGlueInterface)Naming.lookup(name); |
|
233 |
srbconn=srbJG.clConnectJ(srbHost,srbPort,password,username,srbDomain); |
|
234 |
} catch (Exception e) { |
|
235 |
throw new |
|
236 |
RemoteException("AuthMcat.srbConnect():" + e.getMessage()); |
|
237 |
} |
|
243 | 238 |
|
244 |
// try SRB RMI Connection |
|
245 |
// integer value of the SBR Connection ID is returned only |
|
246 |
try { |
|
247 |
srbconn = srbJG.rmiConnectJ( srbHost, srbPort, password, username ); |
|
248 |
} catch (RemoteException e) { |
|
249 |
try { |
|
250 |
rmicon.restart(); |
|
251 |
} catch (Exception rmie) {} |
|
252 |
throw new RemoteException("AuthMcat.userAuth() - " + |
|
253 |
"Error on rmiConnectJ(): " + e.getMessage()); |
|
254 |
} |
|
255 |
|
|
256 |
// check if successfull |
|
257 |
if ( srbconn == 0 ) { |
|
258 |
throw new |
|
259 |
RemoteException("The SRB Server is not running or it is busy now"); |
|
260 |
} else if ( srbconn < 0 ) { |
|
261 |
try { |
|
262 |
rmicon.restart(); |
|
263 |
} catch (Exception rmie) {} |
|
264 |
if ( srbconn == -1003 ) { |
|
239 |
// check if successfull |
|
240 |
if ( srbconn == 0 ) { |
|
265 | 241 |
throw new |
266 |
RemoteException("SrbJavaGlue.c: Connection to srbMaster failed."); |
|
242 |
RemoteException("The SRB Server is not running or it is busy now"); |
|
243 |
} else if ( srbconn < 0 ) { |
|
244 |
return srbconn; |
|
267 | 245 |
} |
268 |
return srbconn; |
|
269 |
} |
|
270 | 246 |
|
271 |
return srbconn; |
|
247 |
return srbconn;
|
|
272 | 248 |
|
249 |
} // end of synchronized(this) |
|
273 | 250 |
} |
274 | 251 |
|
275 | 252 |
/** |
... | ... | |
278 | 255 |
private void srbDisconnect(int srbconn) throws RemoteException |
279 | 256 |
{ |
280 | 257 |
try { |
281 |
int err = srbJG.rmiFinishJ( srbconn );
|
|
258 |
int err = srbJG.clFinishJ( srbconn );
|
|
282 | 259 |
} catch (RemoteException e) {} |
283 | 260 |
|
284 | 261 |
} |
... | ... | |
442 | 419 |
|
443 | 420 |
boolean isValid = false; |
444 | 421 |
try { |
445 |
// isValid = authservice.authenticate(user, password);
|
|
422 |
isValid = authservice.authenticate(user, password); |
|
446 | 423 |
if (isValid) { |
447 | 424 |
System.out.println("Authentication successful for: " + user ); |
448 | 425 |
System.out.println(" "); |
Also available in: Unified diff
changes for using SRB v1.1.8 at LTER, NM