Package unibg.overencrypt.core

Examples of unibg.overencrypt.core.DBConnection


    }


    log.debug("WebDAV Server initialization");
    if( authenticationService == null ) {
      dbConnection = new DBConnection()//PostgreSQL connection
      ArrayList<AuthenticationHandler> authHandls = new ArrayList<AuthenticationHandler>();
      authHandls.add(new BasicAuthHandler());
      authenticationService = new AuthenticationService(authHandls);
      //TODO sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
      resourceFactory = new ResourcesManager();     
View Full Code Here


   * @param folderIdDB the folder id in database to delete
   * @param folderPath the folder path to delete
   * @param folderName the folder name to delete
   */
  public static void deleteFolder(String folderIdDB, String folderPath, String folderName) {
    DBConnection connection = new DBConnection();
    new File(folderPath + "/" + folderName).delete();
    Statement stmt = null;
    try {
      stmt = connection.getConnection().createStatement();
      stmt.executeUpdate("DELETE FROM filetable WHERE objectid = " + folderIdDB);
      stmt.close();
    } catch (SQLException sqlException) {
      LOGGER.error(sqlException.getMessage());
    }
    connection.closeConnection();
  }
View Full Code Here

    String pinHash = FileSystemUtils.getArgFromFile(request,"hash");
    LOGGER.debug("user id: "  + userId);
    LOGGER.debug("hash of pin: "  + pinHash);
    //Confronto tra hash del pin ed hash del pin salvato nel database

    DBConnection connection=new DBConnection();
    String sql = "SELECT  subjectid, name, surname, hashpwd from usertable where subjectid = '%s'";
    sql = String.format(sql, userId);
    ResultSet rset;
    boolean pinOk = false;
    try {
      rset = connection.getConnection().createStatement().executeQuery(sql);
      //User found
      if (rset.next()){
        LOGGER.debug("OK, user found, now check if pin and hash pin are the same..");
        if(rset.getString("hashpwd").equals(pinHash)){
          LOGGER.debug("YES, they're the same!!");
          pinOk = true;
        }else{
          LOGGER.debug("No, they aren't.");
          LOGGER.debug("Hash pin in db:       " + rset.getString("hashpwd"));
          LOGGER.debug("Hash pin from client: " + pinHash);         
        }
      }
    } catch (SQLException e) {
      LOGGER.error("SQL Exception while retriving pin hash of user: " + e.getMessage());
    }
   
    //Search if there is any .response in user folder
    File userRoot = new File(ServerConfiguration.getWebDAVrootPath() + "/" + userId);
    String[] files = userRoot.list();
    for (int i = 0; i < files.length; i++) {
      if (".response".equals(files[i])) {
        LOGGER.debug("---Delete request into user root path");
        new File(ServerConfiguration.getWebDAVrootPath() + "/" + userId + "/.response").delete();
      }
    }


    //Send confirm or retry
    if(pinOk){
      response = ServerUpdatePermissionsManager.sendUpdatePermissions(request.getParent(), userId);
      //response = ServerUpdatePermissionsManager.sendUpdatePermissionsResponseForOwneredFiles(request.getParent(), userId);
    }else{
      response = OverEncryptResponse.generateResponse(ServerPrimitives.OE_ERROR, request.getParent(), "PIN Check failed. Unmount WebDAV volume and try again");
      SessionManager.removeFromSession(userId);
    }
    connection.closeConnection();
    return response;
  }
View Full Code Here

TOP

Related Classes of unibg.overencrypt.core.DBConnection

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.