Search in sources :

Example 1 with DigestedPassword

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;
    }
}
Also used : VCellConnection(cbit.vcell.server.VCellConnection) UserMetaDbServer(cbit.vcell.server.UserMetaDbServer) MalformedURLException(java.net.MalformedURLException) VCellBootstrap(cbit.vcell.server.VCellBootstrap) BioModelInfo(org.vcell.util.document.BioModelInfo) DigestedPassword(org.vcell.util.document.UserLoginInfo.DigestedPassword) MalformedURLException(java.net.MalformedURLException) UserLoginInfo(org.vcell.util.document.UserLoginInfo)

Example 2 with DigestedPassword

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);
}
Also used : VCellConnection(cbit.vcell.server.VCellConnection) SiteInfo(cbit.vcell.message.server.console.LoginChecker.SiteInfo) VCellBootstrap(cbit.vcell.server.VCellBootstrap) BigString(org.vcell.util.BigString) DigestedPassword(org.vcell.util.document.UserLoginInfo.DigestedPassword) UserLoginInfo(org.vcell.util.document.UserLoginInfo) RemoteProxyException(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) SBMLException(org.sbml.jsbml.SBMLException) XMLStreamException(javax.xml.stream.XMLStreamException) XmlParseException(cbit.vcell.xml.XmlParseException)

Example 3 with DigestedPassword

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;
    }
}
Also used : User(org.vcell.util.document.User) UnverifiedUser(org.vcell.rest.users.UnverifiedUser) SQLException(java.sql.SQLException) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) DigestedPassword(org.vcell.util.document.UserLoginInfo.DigestedPassword) DataAccessException(org.vcell.util.DataAccessException)

Example 4 with DigestedPassword

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);
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) LoginManager(cbit.vcell.desktop.LoginManager) Hashtable(java.util.Hashtable) ClientServerInfo(cbit.vcell.client.server.ClientServerInfo) UserCancelException(org.vcell.util.UserCancelException) LoginDelegate(cbit.vcell.desktop.LoginDelegate) DigestedPassword(org.vcell.util.document.UserLoginInfo.DigestedPassword) ConnectionStatus(cbit.vcell.client.server.ConnectionStatus) UserCancelException(org.vcell.util.UserCancelException)

Example 5 with DigestedPassword

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;
}
Also used : RemoteProxyVCellConnectionFactory(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory) DigestedPassword(org.vcell.util.document.UserLoginInfo.DigestedPassword) VCellConnectionFactory(cbit.vcell.server.VCellConnectionFactory) RemoteProxyVCellConnectionFactory(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory)

Aggregations

DigestedPassword (org.vcell.util.document.UserLoginInfo.DigestedPassword)15 UserLoginInfo (org.vcell.util.document.UserLoginInfo)7 VCellBootstrap (cbit.vcell.server.VCellBootstrap)5 VCellConnection (cbit.vcell.server.VCellConnection)5 IOException (java.io.IOException)5 BigString (org.vcell.util.BigString)5 VCSimulationIdentifier (cbit.vcell.solver.VCSimulationIdentifier)4 SQLException (java.sql.SQLException)4 DataAccessException (org.vcell.util.DataAccessException)4 MessageEvent (cbit.rmi.event.MessageEvent)3 ClientServerInfo (cbit.vcell.client.server.ClientServerInfo)3 SimulationStatusPersistent (cbit.vcell.server.SimulationStatusPersistent)3 Simulation (cbit.vcell.solver.Simulation)3 Date (java.util.Date)3 BioModelInfo (org.vcell.util.document.BioModelInfo)3 KeyValue (org.vcell.util.document.KeyValue)3 BioModel (cbit.vcell.biomodel.BioModel)2 ClientServerManager (cbit.vcell.client.server.ClientServerManager)2 InteractiveContextDefaultProvider (cbit.vcell.client.server.ClientServerManager.InteractiveContextDefaultProvider)2 SimulationContext (cbit.vcell.mapping.SimulationContext)2