Package ca.carleton.gcrc.auth.common.impl

Examples of ca.carleton.gcrc.auth.common.impl.UserAndPassword


 
  public User authenticate(String username, String password) throws Exception {

    String sqlQuery = "SELECT "+sqlQueryColumns+" FROM users WHERE email=?;";
   
    UserAndPassword userAndPassword = null;
    try {
      PreparedStatement preparedStmt = connection.prepareStatement(sqlQuery);
      preparedStmt.setString(1, username);

      userAndPassword = executeStatementToUser(preparedStmt);
    } catch (Exception sqle) {
      throw new Exception("SQL query failed - query: "+sqlQuery,sqle);
    }

    // Check password
    String dbPassword = userAndPassword.getPassword();
    if( null != dbPassword && false == dbPassword.equals(password) ) {
      throw new Exception("Password mismatch");
    }
   
    return userAndPassword;
View Full Code Here


      if( true == rs.next() ) {
        throw new Exception("Result set had more than one result");
      }
     
      // Return user
      UserAndPassword user = new UserAndPassword();
      user.setId(userId);
      user.setUser(email);
      user.setDisplayName(displayName);
      user.setPassword(dbPassword);
      if( 0 == groupId ) {
        user.setAnonymous(true);
      } else if( 1 == groupId ) {
        user.setAdmin(true);
      }
      Vector<Integer> groups = new Vector<Integer>();
      groups.add( new Integer(groupId) );
      user.setGroups(groups);
      return user;
     
    } else {
      // indicates an update count or no results - this must be no results
      throw new Exception("Query returned no results");
View Full Code Here

TOP

Related Classes of ca.carleton.gcrc.auth.common.impl.UserAndPassword

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.