use of org.vcell.util.document.UserLoginInfo.DigestedPassword in project vcell by virtualcell.
the class LoginChecker method attemptLogin.
private static boolean attemptLogin(SiteInfo si, String user, String password) {
long start = 0;
try {
if (VERBOSE) {
start = System.currentTimeMillis();
}
String url = si.bootStrapUrl();
VCellBootstrap vcellBootstrap = (VCellBootstrap) java.rmi.Naming.lookup(url);
DigestedPassword dp = new UserLoginInfo.DigestedPassword(password);
UserLoginInfo uli = new UserLoginInfo(user, dp);
VCellConnection vcellConnection = vcellBootstrap.getVCellConnection(uli);
if (vcellConnection == null) {
if (VERBOSE) {
System.out.println("no connection on " + si + " in " + elapsed(start) + " seconds");
}
return false;
}
UserMetaDbServer dataServer = vcellConnection.getUserMetaDbServer();
@SuppressWarnings("unused") BioModelInfo[] bmi = dataServer.getBioModelInfos(true);
if (VERBOSE) {
System.out.println("success on " + si + " in " + elapsed(start) + " seconds");
}
return true;
} catch (MalformedURLException e) {
e.printStackTrace();
throw new Error("bad code");
} catch (Exception e) {
if (VERBOSE) {
System.out.println("failed in " + elapsed(start) + " seconds");
}
e.printStackTrace();
return false;
}
}
use of org.vcell.util.document.UserLoginInfo.DigestedPassword in project vcell by virtualcell.
the class SBMLExportTest method getConnection.
static VCellConnection getConnection(String siteName, String user, String password) {
Collection<SiteInfo> sites = LoginChecker.getSiteInfos(siteName);
for (SiteInfo si : sites) {
try {
String url = si.bootStrapUrl();
VCellBootstrap vcellBootstrap = (VCellBootstrap) java.rmi.Naming.lookup(url);
DigestedPassword dp = new UserLoginInfo.DigestedPassword(password);
UserLoginInfo uli = new UserLoginInfo(user, dp);
VCellConnection vcellConnection = vcellBootstrap.getVCellConnection(uli);
return vcellConnection;
} catch (Exception e) {
System.err.println(e.getMessage());
continue;
}
}
throw new RuntimeException("No connection for site " + siteName);
}
use of org.vcell.util.document.UserLoginInfo.DigestedPassword in project vcell by virtualcell.
the class UserVerifier method authenticateUser.
public User authenticateUser(String userid, char[] secret) {
DigestedPassword digestedPassword = UserLoginInfo.DigestedPassword.createAlreadyDigested(new String(secret));
AuthenticationInfo authInfo = useridMap.get(userid);
if (authInfo != null) {
if (authInfo.digestedPassword.equals(digestedPassword)) {
return authInfo.user;
}
}
if ((System.currentTimeMillis() - lastQueryTimestampMS) > MIN_QUERY_TIME_MS) {
synchronized (adminDbTopLevel) {
User user = null;
try {
user = adminDbTopLevel.getUser(userid, digestedPassword, true, false);
} catch (ObjectNotFoundException e) {
e.printStackTrace();
} catch (DataAccessException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
// refresh stored list of user infos (for authentication)
if (user != null) {
useridMap.put(userid, new AuthenticationInfo(user, digestedPassword));
}
lastQueryTimestampMS = System.currentTimeMillis();
return user;
}
} else {
return null;
}
}
use of org.vcell.util.document.UserLoginInfo.DigestedPassword in project vcell by virtualcell.
the class VCellClient method login.
public static void login(final RequestManager requestManager, final ClientServerInfo clientServerInfo, final DocumentWindowManager currWindowManager) {
final LoginManager loginManager = new LoginManager();
LoginDelegate loginDelegate = new LoginDelegate() {
public void login(final String userid, final UserLoginInfo.DigestedPassword digestedPassword) {
AsynchClientTask task1 = new AsynchClientTask("connect to server", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
ClientServerInfo newClientServerInfo = createClientServerInfo(clientServerInfo, userid, digestedPassword);
requestManager.connectToServer(currWindowManager, newClientServerInfo);
}
};
AsynchClientTask task2 = new AsynchClientTask("logging in", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
ConnectionStatus connectionStatus = requestManager.getConnectionStatus();
loginManager.close();
if (connectionStatus.getStatus() != ConnectionStatus.CONNECTED) {
VCellClient.login(requestManager, clientServerInfo, currWindowManager);
} else {
ErrorUtils.setLoginInfo(clientServerInfo.getUserLoginInfo());
}
}
};
ClientTaskDispatcher.dispatch(currWindowManager.getComponent(), new Hashtable<String, Object>(), new AsynchClientTask[] { task1, task2 });
}
public void registerRequest() {
loginManager.close();
try {
UserRegistrationManager.registrationOperationGUI(requestManager, currWindowManager, clientServerInfo, LoginManager.USERACTION_REGISTER, null);
} catch (UserCancelException e) {
// do nothing
} catch (Exception e) {
e.printStackTrace();
PopupGenerator.showErrorDialog(currWindowManager, "New user Registration error:\n" + e.getMessage());
}
}
public void lostPasswordRequest(String userid) {
try {
ClientServerInfo newClientServerInfo = createClientServerInfo(clientServerInfo, userid, null);
UserRegistrationManager.registrationOperationGUI(requestManager, currWindowManager, newClientServerInfo, LoginManager.USERACTION_LOSTPASSWORD, null);
} catch (UserCancelException e) {
// do nothing
} catch (Exception e) {
e.printStackTrace();
PopupGenerator.showErrorDialog(currWindowManager, "New user Registration error:\n" + e.getMessage());
}
}
public void userCancel() {
loginManager.close();
PopupGenerator.showInfoDialog(currWindowManager, "Note: The Login dialog can be accessed any time under the 'Server' main menu as 'Change User...'");
}
};
loginManager.showLoginDialog(currWindowManager.getComponent(), currWindowManager, loginDelegate);
}
use of org.vcell.util.document.UserLoginInfo.DigestedPassword in project vcell by virtualcell.
the class ClientFactory method createRemoteVCellConnectionFactory.
public static VCellConnectionFactory createRemoteVCellConnectionFactory(String host, int port, String userid, String password) throws Exception {
DigestedPassword digestedPassword = new DigestedPassword(password);
org.vcell.util.document.UserLoginInfo userLoginInfo = new org.vcell.util.document.UserLoginInfo(userid, digestedPassword);
VCellConnectionFactory vcConnFactory = new RemoteProxyVCellConnectionFactory(host, port, userLoginInfo);
return vcConnFactory;
}
Aggregations