Package edu.wpi.cs.wpisuitetng

Examples of edu.wpi.cs.wpisuitetng.ManagerLayer


  /**
   * Ensure the Sessions are cleared after each Test.
   */
  public void tearDown()
  {
    ManagerLayer man = ManagerLayer.getInstance();
    SessionManager sessions = man.getSessions();
    UserManager users = man.getUsers();
   
    String ssid = this.sessions.createSession(this.u);
    users.deleteAll(this.sessions.getSession(ssid));
    sessions.clearSessions();
  }
View Full Code Here


   * Logs a user out given their sessionToken
   * @param sessionToken  a user's serialized Cookie
   */
  public void logout(String sessionToken)
  {
    ManagerLayer manager = ManagerLayer.getInstance();
    manager.getSessions().removeSession(sessionToken);
    logger.log(Level.INFO, "Session <" + sessionToken + "> logged out");
  }
View Full Code Here

    logger.log(Level.INFO, "Begin POST body parsing <" + postString + ">");
    String[] credentials = parsePost(postString); // [0] - username, [1] - password
    logger.log(Level.INFO, "End POST body parsing <" + postString + ">");
   
    // attempt to retrieve the User from the Manager layer
    ManagerLayer manager = ManagerLayer.getInstance();
    User[] u;
    try {
      System.out.println("DEBUG: Retrieve Login User");
      logger.log(Level.INFO, "Attempting to retrieve User...");
      u = manager.getUsers().getEntity(credentials[0]);
    } catch (NotFoundException e) {
      logger.log(Level.WARNING, "Login attempted with non-existant user <" + credentials[0] + ">");
      throw new AuthenticationException("The user \"" + credentials[0] + "\" could not be found. Please check if the username was spelled correctly.");
    }

    User user = u[0];
   
    // check password
    System.out.println("DEBUG: Authenticate Password");
    // password security
    logger.log(Level.INFO, "Authenticating password for User <" + credentials[0] + ">...");
    String hashedPassword = this.passwordHash.generateHash(credentials[1]);
    if(!user.matchPassword(hashedPassword))
    {
      logger.log(Level.WARNING, "Login attempted with bad password for User <" + credentials[0] + ">");
      throw new AuthenticationException("An invalid password was given. Please check the password and try again.");
    }
    logger.log(Level.INFO, "Password authentication Success! <" + credentials[0] + ">");
   
    // create a Session mapping in the ManagerLayer
    SessionManager sessions = manager.getSessions();
    String ssid = sessions.createSession(user);
    Session userSession = sessions.getSession(ssid);
   
    System.out.println("DEBUG: Create Session");
   
View Full Code Here

TOP

Related Classes of edu.wpi.cs.wpisuitetng.ManagerLayer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.