001package ca.bc.webarts.tools;
002
003import java.sql.*;
004import java.util.Date;
005import java.util.Hashtable;
006import java.io.IOException;
007import java.security.GeneralSecurityException;
008
009import ca.bc.webarts.tools.TomsCrypter;
010
011
012/**
013 *  Java WebAPP Login Helper App.
014 *
015 * @author    TGutwin
016 */
017public class LoginManager
018{
019
020  /**  A Class constant to signify an access level for a page or a wep app user.  */
021  public final static int SUPER_USER_ACCESS_LEVEL = 0;
022
023  /**  A Class constant to signify an access level for a page or a wep app user.  */
024  public final static int ADMIN_ACCESS_LEVEL = 1;
025
026  /**  A Class constant to signify an access level for a page or a wep app user.  */
027  public final static int AUTHORIZED_USER_ACCESS_LEVEL = 2;
028
029  /**  A Class constant to signify an access level for a page or a wep app user.  */
030  public final static int GUEST_ACCESS_LEVEL = 3;
031
032  /**  A holder for this clients System File Separator.  */
033  public final static String SYSTEM_FILE_SEPERATOR = java.io.File.separator;
034
035  /**  A holder for this clients System line termination separator.  */
036  public final static String SYSTEM_LINE_SEPERATOR =
037                                           System.getProperty("line.separator");
038  public final static String DEFAULT_COLUMN_DELIMITOR = "|";
039
040  private String columnDelimitor = DEFAULT_COLUMN_DELIMITOR;
041  private static String dbSchema = "EagleDB";
042  private String dbUser = "powereye";
043  private String dbPassword = "powereye";
044  private String dbDriverName = "org.apache.derby.jdbc.ClientDriver";
045  private String dbConnectString = "jdbc:derby:" + "/opt/jetty/baseDir/" + "EagleDB";  //"jdbc:derby://localhost:1527/EagleDB";;
046  private static String idPassTablename = dbSchema+".idpassword";
047  private Class jdbcDriver = Class.forName(dbDriverName);
048  private Connection con =
049            DriverManager.getConnection(dbConnectString, dbUser, dbPassword);
050
051  private static final String ENCRYPT_PASSPHRASE = "fyuF%h8dlQl0";
052  /**  Description of the Field */
053  private final static String SELECT_PASSWORD =
054      "SELECT login_password FROM "+idPassTablename+" WHERE login_id = ";
055
056  /**  Description of the Field */
057  private final static String QUOTE = "'";
058
059  /**  Description of the Field */
060  private Hashtable currentLogins;
061
062
063  /**
064   *  Constructor for the LoginManager object
065   *
066   * @exception  Exception  Description of the Exception
067   */
068  public LoginManager()  throws Exception
069  {
070    currentLogins = new Hashtable();
071  }
072
073
074  /** Main **/
075  public static void main (String [] args)
076  {
077    try
078    {
079      LoginManager instance = new LoginManager();
080      if (args.length >1)
081      {
082        if("-recover".equalsIgnoreCase(args[0]))
083        {
084          System.out.println(instance.recoverUserPassword(args[1]));
085        }
086        if("-reset".equalsIgnoreCase(args[0]))
087        {
088        }
089        if("-add".equalsIgnoreCase(args[0]))
090        {
091        }
092        if("-access".equalsIgnoreCase(args[0]))
093        {
094        }
095        if("-exists".equalsIgnoreCase(args[0]))
096        {
097        }
098      }
099    }
100      catch (Exception e)
101      {
102        System.out.println("Problem :");
103        e.printStackTrace();
104      }
105  }
106
107
108      /**
109   *  Description of the Method
110   *
111   * @param  credentials  Description of the Parameter
112   * @return              Description of the Return Value
113   */
114  public boolean alreadyLoggedIn(UserCredentials credentials)
115  {
116    boolean loggedIn = false;
117    String user = credentials.getUser();
118    if (currentLogins.containsKey(user))
119    {
120      LoginProfile aProfile =
121          (LoginProfile) currentLogins.get(user);
122      loggedIn = aProfile.isLoggedIn;
123    }
124    return loggedIn;
125  }
126
127
128  /**
129   *  Description of the Method
130   *
131   * @param  credentials  Description of the Parameter
132   * @return              Description of the Return Value
133   */
134  public boolean logout(UserCredentials credentials)
135  {
136    boolean loggedIn = false;
137    System.out.println("Attempting Logout for userid "+credentials.getUser());
138    String user = credentials.getUser();
139    if (currentLogins.containsKey(user))
140    {
141      currentLogins.remove(user);
142      LoginProfile aProfile =
143          (LoginProfile) currentLogins.get(user);
144      loggedIn = false;
145    }
146    return !loggedIn;
147  }
148
149
150  /**
151   *  Description of the Method
152   *
153   * @param  credentials       Description of the Parameter
154   * @return                   Description of the Return Value
155   * @exception  SQLException  Description of the Exception
156   */
157  public boolean validateLogin(UserCredentials credentials) throws SQLException
158  {
159    boolean extraDebug = true;
160    System.out.println("Attempting Login for userid "+credentials.getUser());
161    if (alreadyLoggedIn(credentials))
162    {
163      System.out.println("Already Logged In");
164      return true;
165    }
166
167    LoginProfile profile = new LoginProfile(credentials);
168    connect();
169    Statement s = con.createStatement();
170    String sql = SELECT_PASSWORD + QUOTE + credentials.getUser() + QUOTE;
171    System.out.println("SQL Query:\n"+sql);
172    ResultSet rs = s.executeQuery(sql);
173    while (rs.next())
174    {
175      try
176      {
177        // Create encrypter/decrypter class
178        TomsCrypter crypter = new TomsCrypter();
179
180        // Encrypt
181        String encrypted = crypter.encryptString(credentials.getPassword());
182
183        // Decrypt
184        //String decrypted = encrypter.decryptString(encrypted);
185        if (rs.getString(1).equals(encrypted))
186        {
187          System.out.println("Successful Login.");
188          if(extraDebug) System.out.println("user/pass "+credentials.getUser()+" / "+credentials.getPassword() +" / "+encrypted);
189          profile.isLoggedIn = true;
190          currentLogins.put(credentials.getUser(), profile);
191          break;
192        }
193        else
194        {
195          System.out.println("UNsuccessful Login.");
196          if(extraDebug) System.out.println("DB user/pass "+credentials.getUser()+" / "+crypter.decryptString(rs.getString(1))+" / "+rs.getString(1) );
197          System.out.println("entered user/pass "+credentials.getUser()+" / "+ credentials.getPassword() +" / "+encrypted);
198        }
199      }
200      catch (GeneralSecurityException gSecEx)
201      {
202        System.err.println(gSecEx.getMessage());
203      }
204      catch (Exception e)
205      {
206        System.out.println("Problem validating: "+credentials.getUser());
207        e.printStackTrace();
208      }
209    }
210
211    return profile.isLoggedIn;
212  }
213
214
215  /**
216   *  Description of the Method
217   *
218   * @param  credentials       Description of the Parameter
219   * @return                   Description of the Return Value
220   * @exception  SQLException  Description of the Exception
221   */
222  public boolean changePassword(UserCredentials credentials)
223    throws SQLException
224  {
225    System.out.println("Change Password for userid "+credentials.getUser());
226    boolean retVal = false;
227    logout(credentials);
228    if (validateLogin(credentials))
229    {
230      try
231      {
232        // Create encrypter/decrypter class
233        TomsCrypter crypter = new TomsCrypter();
234        // Encrypt
235        String encrypted = crypter.encryptString(credentials.getNewPassword());
236        System.out.println("  RESETing  user/pass "+credentials.getUser()+
237                                          " / "+credentials.getPassword() +
238                                          " to "+credentials.getNewPassword()+" / "+encrypted);
239        String chgPasswordSQL = "update "+idPassTablename+" set login_password='"+
240                                encrypted+ "' where login_id='"+
241                                credentials.getUser()+"'";
242        connect();
243        Statement s = con.createStatement();
244        s.executeUpdate(chgPasswordSQL);
245        logout(credentials);
246        credentials.setPassword(credentials.getNewPassword());
247        validateLogin(credentials);
248        retVal = true;
249      }
250      catch (GeneralSecurityException gSecEx)
251      {
252        System.err.println(gSecEx.getMessage());
253      }
254      catch (IOException e)
255      {
256        System.err.println(e.getMessage());
257      }
258    }
259    else
260    {
261      // user not a validated
262    }
263    return retVal;
264  }
265
266
267  /**
268   *   Resets the users password to the passed in string (Encrypted).
269   *
270   * @param  userId       The userId to reset
271   * @param  pass       The new password to use
272   * @return                   True if success
273   * @exception  SQLException  Description of the Exception
274   */
275  public boolean resetUserPassword(String userId, String pass)
276    throws SQLException
277  {
278    System.out.println("reseting password for userid "+userId);
279    boolean retVal = false;
280    if (userExists(userId))
281    {
282      try
283      {
284        System.out.println("Found User "+userId);
285        TomsCrypter crypter = new TomsCrypter();
286        String encrypted = crypter.encryptString(pass);
287        //System.out.println("Reseting password to  "+pass+"/"+encrypted);
288
289        // login_access - 0=su, 1=admin, 2=user, 3=guest
290        //account_status  - 0=enabled, 1=suspended
291        String resetPassSQL = "update "+idPassTablename+" set " +
292                                "login_password='" +encrypted+"' "+
293                                "where login_id='"+userId+"'";
294        connect();
295        Statement s = con.createStatement();
296        s.executeUpdate(resetPassSQL);
297        //System.out.println("User Database Updated ");
298        retVal = true;
299      }
300      catch (GeneralSecurityException gSecEx)
301      {
302        System.err.println(gSecEx.getMessage());
303      }
304      catch (IOException e)
305      {
306        System.err.println(e.getMessage());
307      }
308      catch (Throwable t)
309      {
310        t.printStackTrace();
311      }
312    }
313    else
314    {
315      System.out.println("userid "+userId +
316         " does NOT exist.");
317    }
318
319      return retVal;
320  }
321
322
323  /**
324   *  Resets the users password to their employee ID number.
325   *
326   * @param  userId       The userId to reset
327   * @return                   True if success
328   * @exception  SQLException  Description of the Exception
329   */
330  public boolean resetUserPassword(String userId)
331    throws SQLException
332  {
333    System.out.println("reseting password for userid "+userId);
334    boolean retVal = false;
335    String getUserSQL = "select id from "+idPassTablename+" where login_id='"+
336                        userId+"'";
337
338    // get the users Employee ID to use as the reset password
339    connect();
340    Statement s = con.createStatement();
341    ResultSet rs = s.executeQuery(getUserSQL);
342
343    if (rs.next())
344    {
345      try
346      {
347        String emplNum  = rs.getString(1);
348        String pass = "";
349        System.out.println("Found User "+userId);
350        TomsCrypter crypter = new TomsCrypter();
351        String encrypted = crypter.encryptString(emplNum);
352        //System.out.println("Reseting password to  "+pass+"/"+encrypted);
353
354        // login_access - 0=su, 1=admin, 2=user, 3=guest
355        //account_status  - 0=enabled, 1=suspended
356        String resetPassSQL = "update "+idPassTablename+" set " +
357                                "login_password='" +encrypted+"' "+
358                                "where login_id='"+userId+"'";
359        connect();
360        s = con.createStatement();
361        s.executeUpdate(resetPassSQL);
362        //System.out.println("User Database Updated ");
363        retVal = true;
364      }
365      catch (GeneralSecurityException gSecEx)
366      {
367        System.err.println(gSecEx.getMessage());
368      }
369      catch (IOException e)
370      {
371        System.err.println(e.getMessage());
372      }
373      catch (Throwable t)
374      {
375        t.printStackTrace();
376      }
377    }
378    else
379    {
380      System.out.println("userid "+userId +
381         " does NOT exist.");
382    }
383
384      return retVal;
385  }
386
387
388  /**
389   *  Returns a UserID's password.
390   *
391   * @param  credentials       Description of the Parameter
392   * @return                   Description of the Return Value
393   * @exception  SQLException  Description of the Exception
394   */
395  public String recoverUserPassword(String userId)
396  {
397    String retVal = "";
398    System.out.println("recvovering password for userid "+userId);
399    try
400    {
401      if (userExists(userId))
402      {
403        UserCredentials u = getUserID(userId);
404        String encryptedPass = u.getPassword();
405        TomsCrypter crypter = new TomsCrypter();
406        // DEcrypt
407        retVal = crypter.decryptString(encryptedPass);
408
409        System.out.println("pass="+retVal);
410      }
411      else
412      {
413        System.out.println("userid "+userId +
414           " does NOT exist.");
415      }
416    }
417    catch (GeneralSecurityException gSecEx)
418    {
419      System.err.println(gSecEx.getMessage());
420    }
421    catch (IOException e)
422    {
423      System.err.println(e.getMessage());
424    }
425    catch (SQLException sqlEx)
426    {
427      System.out.println("SQL CrapOut.");
428    }
429    return retVal;
430  }
431
432
433  /**
434   *  Description of the Method
435   *
436   * @param  credentials       Description of the Parameter
437   * @return                   Description of the Return Value
438   * @exception  SQLException  Description of the Exception
439   */
440  public boolean addUserID(UserCredentials credentials)
441    throws SQLException
442  {
443    System.out.println("Adding userid "+credentials.getUser());
444    boolean retVal = false;
445    if (!userExists(credentials.getUser()))
446    {
447      try
448      {
449        TomsCrypter crypter = new TomsCrypter();
450        String encrypted = crypter.encryptString(credentials.getNewPassword());
451
452        // login_access - 0=su, 1=admin, 2=user, 3=guest
453        //account_status  - 0=enabled, 1=suspended
454        String addUserSQL_FULL = "insert into "+idPassTablename+" (id,  login_id, " +
455                                "login_password, login_access, account_status) " +
456                                "VALUES ( "+credentials.getEmplId()+",'"+credentials.getUser()+
457                                "','"+encrypted+"', "+AUTHORIZED_USER_ACCESS_LEVEL+", 0)";
458        String addUserSQL = "insert into "+idPassTablename+" (login_id, " +
459                                "login_password, login_access, account_status) " +
460                                "VALUES ( '"+credentials.getUser()+
461                                "','"+encrypted+"', "+AUTHORIZED_USER_ACCESS_LEVEL+", 0)";
462        connect();
463        Statement s = con.createStatement();
464        s.executeUpdate(addUserSQL);
465        retVal = true;
466      }
467      catch (GeneralSecurityException gSecEx)
468      {
469        System.err.println(gSecEx.getMessage());
470      }
471      catch (IOException e)
472      {
473        System.err.println(e.getMessage());
474      }
475      catch (Throwable t)
476      {
477        t.printStackTrace();
478      }
479    }
480    else
481    {
482      System.out.println("userid "+credentials.getUser() +
483         " already exists " );
484    }
485
486      return retVal;
487  }
488
489
490
491
492  /**
493   *  Deletes a user from the DB.
494   *
495   * @param  credentials       The user object to delete
496   * @return                   true if success
497   * @exception  SQLException  Description of the Exception
498   */
499  public boolean deleteUserID(UserCredentials credentials)
500    throws SQLException
501  {
502    System.out.println("Delete userid "+credentials.getUser());
503    boolean retVal = false;
504    if (userExists(credentials.getUser()) && !credentials.getUser().equals("powereye") )
505    {
506      try
507      {
508        TomsCrypter crypter = new TomsCrypter();
509        String encrypted = crypter.encryptString(credentials.getNewPassword());
510
511        // login_access - 0=su, 1=admin, 2=user, 3=guest
512        //account_status  - 0=enabled, 1=suspended
513        String deleteUserSQL = "DELETE FROM "+idPassTablename+" where login_id='" +credentials.getUser()+"'";
514        connect();
515        Statement s = con.createStatement();
516        s.executeUpdate(deleteUserSQL);
517        retVal = true;
518      }
519      catch (GeneralSecurityException gSecEx)
520      {
521        System.err.println(gSecEx.getMessage());
522      }
523      catch (IOException e)
524      {
525        System.err.println(e.getMessage());
526      }
527      catch (Throwable t)
528      {
529        t.printStackTrace();
530      }
531    }
532    else
533    {
534      System.out.println("userid "+credentials.getUser() +
535         " does NOT exist or cannot be deleted" );
536    }
537
538      return retVal;
539  }
540
541
542  /**
543   *  Seeds the db with ids for all employees in the specified Department.
544   *
545   * @param  credentials       Description of the Parameter
546   * @return                   Description of the Return Value
547   * @exception  SQLException  Description of the Exception
548   */
549  public int seedLoginDB(int deptId)
550    throws SQLException
551  {
552    int retVal = 0;
553    String deptSQL = "Select empl.emplid,empl.last_name,empl.first_name from "+
554                     dbSchema+".employee empl where empl.department_id="+deptId+
555                     " order by empl.last_name";
556    UserCredentials credentials = null;
557    connect();
558    Statement s = con.createStatement();
559    ResultSet rs = s.executeQuery(deptSQL);
560    if (rs != null)
561    {
562      //rs.next();
563      while (rs.next())
564      {
565        try
566        {
567          credentials = new UserCredentials();
568          credentials.setEmplId(rs.getString(1));
569          credentials.setUser(rs.getString(3).substring(0,1).toLowerCase()+rs.getString(2).toLowerCase());
570          credentials.setPassword(credentials.getEmplId());
571          credentials.setNewPassword(credentials.getEmplId());
572          System.out.println("Seeding userid "+credentials.getUser());
573          if (!userExists(credentials.getUser()))
574          {
575            addUserID(credentials);
576            retVal++;
577          }
578          else
579          {
580            System.out.println("userid "+credentials.getUser() +
581               " already exists with emplID="+credentials.getEmplId() );
582          }
583        }
584        catch (Exception e)
585        {
586          //retVal = 3;
587        }
588      }
589    }
590    else
591    {
592      System.out.println("seedLoginDB:  Empty resultset for \n"+deptSQL);
593    }
594    return retVal;
595  }
596
597
598  public boolean userExists(String userId)
599  {
600    boolean retVal = false;
601    try
602    {
603      String getUserSQL = "select id, login_password from "+idPassTablename+" where login_id='"+
604                        userId+"'";
605      connect();
606      Statement s = con.createStatement();
607      ResultSet rs = s.executeQuery(getUserSQL);
608      if (rs.next()) retVal = true;
609      //retVal = (getUserID(userId) != null);
610    }
611    catch (Exception ex)
612    {
613      // leave the retVal as false
614    }
615
616    return retVal;
617  }
618
619
620  /**
621   *  Description of the Method
622   *
623   * @param  credentials       Description of the Parameter
624   * @return                   Description of the Return Value
625   * @exception  SQLException  Description of the Exception
626   */
627  public UserCredentials getUserID(String userId)
628    throws SQLException
629  {
630    System.out.println("retrieving userid "+userId +" credentials");
631    UserCredentials retVal = null;
632
633    // login_access - 0=su, 1=admin, 2=user, 3=guest
634    //account_status  - 0=enabled, 1=suspended
635    String getUserSQL = "select id, login_password from "+idPassTablename+" where login_id='"+
636                        userId+"'";
637    connect();
638    Statement s = con.createStatement();
639    ResultSet rs = s.executeQuery(getUserSQL);
640    while (rs.next())
641    {
642      try
643      {
644        TomsCrypter crypter = new TomsCrypter();
645        // DEcrypt
646        String decrypted = crypter.decryptString(rs.getString(2)); // seed with the emplId as the password
647        retVal = new UserCredentials();
648        retVal.setUser(userId);
649        retVal.setEmplId(rs.getString(1));
650        retVal.setPassword(decrypted);
651        break;
652      }
653      catch (GeneralSecurityException gSecEx)
654      {
655        System.err.println(gSecEx.getMessage());
656      }
657      catch (IOException e)
658      {
659        System.err.println(e.getMessage());
660      }
661      catch (Exception e)
662      {
663        retVal = null;
664      }
665    }
666    return retVal;
667  }
668
669
670  /**
671   *  Description of the Method
672   *
673   * @param  credentials       Description of the Parameter
674   * @return                   Description of the Return Value
675   * @exception  SQLException  Description of the Exception
676   */
677  public int getUserAccess(String userId)
678    throws SQLException
679  {
680    System.out.println("retrieving accessLevel for userid "+userId);
681    int retVal = GUEST_ACCESS_LEVEL;
682
683    // login_access - 0=su, 1=admin, 2=user, 3=guest
684    //account_status  - 0=enabled, 1=suspended
685    String getUserSQL = "select login_access from "+idPassTablename+" where login_id='"+
686                        userId+"'";
687    connect();
688    Statement s = con.createStatement();
689    ResultSet rs = s.executeQuery(getUserSQL);
690    while (rs.next())
691    {
692      try
693      {
694        retVal = rs.getInt(1);
695        break;
696      }
697      catch (Exception e)
698      {
699        retVal = GUEST_ACCESS_LEVEL;
700      }
701    }
702    return retVal;
703  }
704
705
706  /** Connects this classes JDBC connection. **/
707  private synchronized void connect() throws SQLException
708  {
709    if (con != null && !con.isClosed())
710    {
711      con.clearWarnings(); // this might throw an  SQLException
712    }
713    else
714    {
715      con = null;
716      con = DriverManager.getConnection(dbConnectString, dbUser, dbPassword);
717    }
718  }
719
720
721  /** Reconnects this classes JDBC connection closing an existing one if needed. **/
722  private synchronized void reConnect() throws SQLException
723  {
724    if (con != null && !con.isClosed())
725    {
726      con.commit();
727      con.close(); // this might throw an  SQLException
728    }
729    connect();
730  }
731
732
733  /**
734   *  Executes a SQL statement onto the JDBC accessed databased defined by the
735   *  class driver and connection string and connection.
736   *
737   * @param sql is the SQL to execute
738   * @return either the row count for INSERT, UPDATE, or DELETE statements, or 0 for SQL statements that return nothing
739   **/
740  private synchronized int queryUpdate(String sql)
741  {
742    int retVal = 0;
743    if (sql != null && !sql.equals(""))
744    {
745      try
746      {
747        connect();
748        Statement s = con.createStatement();
749        //System.out.println("SQL Query:\n"+sql);
750          if (sql.toUpperCase().startsWith("INSERT")
751              || sql.toUpperCase().startsWith("UPDATE")
752              || sql.toUpperCase().startsWith("REPLACE")
753              || sql.toUpperCase().startsWith("DELETE")
754              || sql.toUpperCase().startsWith("DROP")
755              || sql.toUpperCase().startsWith("CREATE")
756            )
757          {
758            retVal = s.executeUpdate(sql); // any query that returns nothing
759          }
760        s.close();
761        // leave the connection open
762      }
763      catch (SQLException e2)
764      {
765        // Exception when executing java.sql related commands, print error message to the console
766        System.out.println(e2.toString());
767      }
768      catch (Exception e3)
769      {
770        // other unexpected exception, print error message to the console
771        System.out.println(e3.toString());
772      }
773    }
774
775    return retVal;
776  }
777
778
779  /**
780   *  Executes a SQL statement onto the JDBC accessed databased defined by the
781   *  class driver and connection string and connection.
782   *  Only SQL that returns a RS. (returns null for INSERT,UPDATE,REPLACE,DELETE,DROP,CREATE )
783   *
784   * @param sql is the SQL to execute
785   * @return the ResultSet (null if error).
786   **/
787  private synchronized ResultSet queryResultSet(String sql)
788  {
789    ResultSet retVal = null;
790    if (sql != null && !sql.equals(""))
791    {
792      try
793      {
794        connect();
795        Statement s = con.createStatement();
796        //System.out.println("SQL Query:\n"+sql);
797          if (!(   sql.toUpperCase().startsWith("INSERT")
798                || sql.toUpperCase().startsWith("UPDATE")
799                || sql.toUpperCase().startsWith("REPLACE")
800                || sql.toUpperCase().startsWith("DELETE")
801                || sql.toUpperCase().startsWith("DROP")
802                || sql.toUpperCase().startsWith("CREATE")
803               )
804            )
805          {
806            retVal = s.executeQuery(sql);
807          }
808        s.close();
809        // leave the connection open
810      }
811      catch (SQLException e2)
812      {
813        // Exception when executing java.sql related commands, print error message to the console
814        System.out.println(e2.toString());
815      }
816      catch (Exception e3)
817      {
818        // other unexpected exception, print error message to the console
819        System.out.println(e3.toString());
820      }
821    }
822
823    return retVal;
824  }
825
826
827      /**
828   *  Description of the Class
829   *
830   * @author    TGutwin
831   */
832  private class LoginProfile extends UserCredentials
833  {
834    /**  Description of the Field */
835    boolean isLoggedIn = false;
836
837
838    /**
839     *  Constructor for the LoginProfile object
840     *
841     * @param  credentials  Description of the Parameter
842     */
843    public LoginProfile(UserCredentials credentials)
844    {
845      setUser(credentials.getUser());
846      setPassword(credentials.getPassword());
847      isLoggedIn = false;
848    }
849  }
850
851
852}
853