Package unibg.overencrypt.client

Examples of unibg.overencrypt.client.TokensResource


        JOptionPane.showMessageDialog(null, "The folder is locked. Please, retry later", "Locked", JOptionPane.INFORMATION_MESSAGE);
        System.exit(0);
      }
    }
   
    TokensResource token = new TokensResource(filePath.substring(0, filePath.lastIndexOf("/")));
    TokenStruct tokenStruct = token.getTokens(filePath.substring(filePath.lastIndexOf("/") + 1));
    aclBEL = ClientTokensManager.getACLsFromToken(filePath, OperationType.DOWNLOAD, tokenStruct, inpd)[0];
    inpd.setVisible(true);

    inpd.setMessage("Starting upload file process..");
    // creating uploadManager for the current user
View Full Code Here


      ResponseManager.retrieveCommunication(path, ServerPrimitives.OE_SUCCESSFUL);
      inpd.setMessage("Upload completation... - Acl inserted in database");

    }

    TokensResource tokenFile = new TokensResource(path);
    tokenFile.saveTokens(folderName, folderIdDB, folderIdGraph, owner, String.valueOf(hasSEL), encAclBEL, encAclSEL);
    inpd.setMessage("Upload completation - File .tokens generated");

    if(ClientConfiguration.debug)
      JOptionPane.showMessageDialog(null, "file .tokens generated. ");
View Full Code Here

        System.exit(0);
      }
    }

    //Retrieve xml file .tokens in parent folder path
    TokensResource tokenFile = new TokensResource(grandParentPath);
    //Extract only contents of associated folder name
    token =  tokenFile.getTokens(folderName);
    LOGGER.debug("Token retrieved");
       
    //Retrieve decrypted ACL BEL & SEL throught .tokens file in parenth path
    String acls[] = ClientTokensManager.getACLsFromToken(path, OperationType.DOWNLOAD, token, inpd);
    inpd.setVisible(true);
View Full Code Here

    } catch (Exception e) {
      LOGGER.error("Error while retrieving user id from local private file - ",e);
    }

    //GET DECRYPTED ACL BEL & SEL
    TokensResource tokenFile = new TokensResource(path);
    TokenStruct token = tokenFile.getTokens(folderName);
    folderIdDB = token.folderIdDB;

    String[] acls = ClientTokensManager.getACLsFromToken(path, OperationType.EDIT, token);
   
    aclBEL = acls[0];
View Full Code Here

    String acl;
    String json = null;
    String jsout;
    boolean hasTokenHBELToCreate = false;

    TokensResource tokenFile = new TokensResource(path);
    TokenStruct token = tokenFile.getTokens(folderName);
    String aesKeyBEL = ClientTokensManager.getAESKeyFromToken(path, token, aclBEL, "BEL", false, inpd);

    LOGGER.debug("users: " + users);
    LOGGER.debug("userId: " + userId);
    LOGGER.debug("aclSEL: " + aclSEL);
    LOGGER.debug("aclBEL: " + aclBEL);
   
    if(ClientConfiguration.debug)
      JOptionPane.showMessageDialog(null, "debug");

    if(EditManager.setEditPermission(path, users, userId, aclSEL, aclBEL)) {
      returnValues = ResponseManager.retrieveCommunication(path, ServerPrimitives.OE_RETURN_EDITPERM, "newSEL", "addUser", "delUser");
      newSEL = returnValues[0];
      addUser = returnValues[1];
      delUser = returnValues[2];
    }

    if(!"nochange".equals(newSEL)) {
      if(EditManager.getTokenInfo(path, userId)) {
        returnValues = ResponseManager.retrieveCommunication(path, ServerPrimitives.OE_TOKEN_INFO, "idToken", "hasMoreTokens");
        idToken = returnValues[0];
        hasTokenHBELToCreate = Boolean.valueOf(returnValues[1]);
      }
      LOGGER.debug("idToken: " + idToken);
      LOGGER.debug("hasTokenHBELToCreate: " + hasTokenHBELToCreate);
      LOGGER.debug("addUser: " + addUser);
      LOGGER.debug("delUser: " + delUser);
     
      if(ClientConfiguration.debug)
        JOptionPane.showMessageDialog(null, "debug2");

      acl = aclBEL;
     
      while(hasTokenHBELToCreate) {
        if(ClientConfiguration.debug)
          JOptionPane.showMessageDialog(null, "hasTokenHBELtoCreate!");

        String tokenHBEL = "";
        if(EditManager.createJsonHBEL(path, userId)) {
          tokenHBEL = ResponseManager.retrieveCommunication(path, ServerPrimitives.OE_JSON_HBEL, "tokenHBEL")[0];
        }
        if(ClientConfiguration.debug)
          JOptionPane.showMessageDialog(null, "tokenHBEL: " + tokenHBEL);

        //HBEL Tokens creation
        FileSystemUtils.writePrivateFile("json.txt", tokenHBEL);
        String command[] = {
            ClientConfiguration.getEXECUTABLES_PATH() + "/wpes1_linux",
            "h",
            ClientConfiguration.getLOCAL_PRIVATE_RESOURCES_PATH() + "/" + aesKeyBEL,
            ClientConfiguration.getLOCAL_PRIVATE_RESOURCES_PATH() + "/json.txt",
            acl,
            idToken,
            passphrase
        };
        RunnerExecutables.execute(command);
        String jsonout = FileSystemUtils.readPrivateFile("jsonout.txt");
       
        if(ClientConfiguration.debug)
          JOptionPane.showMessageDialog(null, "Ora inserisce i token HBEL nel DB in tokentableencrypt. Controlla jsonout.txt per vedere cosa contiene");
         
        //Put new tokens HBEL in server DB
        if(EditManager.putToken(path, userId, jsonout)) {
          hasTokenHBELToCreate = Boolean.valueOf(ResponseManager.retrieveCommunication(path, ServerPrimitives.OE_TOKEN_INFO, "hasMoreTokens")[0]);
        }
        LOGGER.debug("hasTokenHBELToCreate: "  + hasTokenHBELToCreate);
        if(ClientConfiguration.debug)
          JOptionPane.showMessageDialog(null, "debug3");
         
        FileSystemUtils.deletePrivateFile("jsonout.txt");
      }
      //End HBEL tokens creation
      inpd.setMessage("HBEL tokens generated");
     
      if(ClientConfiguration.debug)
        JOptionPane.showMessageDialog(null, "HBEL tokens generated");

      FileSystemUtils.deletePrivateFile();
     
      //Update View Informations for added and deleted users
      if(!addUser.isEmpty()) {
        if(ClientConfiguration.debug)
          JOptionPane.showMessageDialog(null, "addUser process start");
       
        if(EditManager.getView(path, userId, userId + "-" + addUser, true)) {
          json = ResponseManager.retrieveCommunication(path, ServerPrimitives.OE_GET_VIEW, "json")[0];
        }
        FileSystemUtils.writePrivateFile("json.txt", json);
        LOGGER.debug("json: "  + json);
       
        if(ClientConfiguration.debug)
          JOptionPane.showMessageDialog(null, "debug");
       
        String command[] = {
            ClientConfiguration.getEXECUTABLES_PATH() + "/wpes1_linux",
            "addID",
            folderIdDB,
            ClientConfiguration.getLOCAL_PRIVATE_RESOURCES_PATH() + "/json.txt",
            ClientConfiguration.getLOCAL_PRIVATE_RESOURCES_PATH() + "/jsonout.txt",
            passphrase,
            userId
        };
        RunnerExecutables.execute(command);
        jsout = FileSystemUtils.readPrivateFile("jsonout.txt");
        if(ClientConfiguration.debug)
          JOptionPane.showMessageDialog(null, "leggi jsonout per vedere cosa inserirà in ViewInformations");
        if(EditManager.setView(userId, path, jsout)) {
          ResponseManager.retrieveCommunication(path, ServerPrimitives.OE_SUCCESSFUL);
        }
        FileSystemUtils.deletePrivateFile();
      }
      if(!delUser.isEmpty()) {
        if(ClientConfiguration.debug)
          JOptionPane.showMessageDialog(null, "delUser process start");

        if(EditManager.getView(path, userId, delUser, true)) {
          json = ResponseManager.retrieveCommunication(path, ServerPrimitives.OE_GET_VIEW, "json")[0];
        }
        FileSystemUtils.writePrivateFile("json.txt", json);
        LOGGER.debug("json: "  + json);
       
        if(ClientConfiguration.debug)
          JOptionPane.showMessageDialog(null, "debug");

        String command[] = {
            ClientConfiguration.getEXECUTABLES_PATH() + "/wpes1_linux",
            "remID",
            folderIdDB,
            ClientConfiguration.getLOCAL_PRIVATE_RESOURCES_PATH() + "/json.txt",
            ClientConfiguration.getLOCAL_PRIVATE_RESOURCES_PATH() + "/jsonout.txt",
            passphrase,
        };
        RunnerExecutables.execute(command);
        jsout = FileSystemUtils.readFile("jsonout.txt");
        if(ClientConfiguration.debug)
          JOptionPane.showMessageDialog(null, "leggi jsonout per vedere cosa inserirà in ViewInformations");
       
        if(EditManager.setView(userId, path, jsout)) {
          ResponseManager.retrieveCommunication(path, ServerPrimitives.OE_SUCCESSFUL);
        }
        FileSystemUtils.deletePrivateFile();
      }
     
     
      //If has SEL level decrypt and re-encrypt at SEL Level
      if(EditManager.selRequest(path, folderName, folderIdDB, userId,  users, aclSEL, Boolean.toString(token.hasSEL))) {
        ResponseManager.retrieveCommunication(path, ServerPrimitives.OE_SUCCESSFUL);
      }

      //Retrieve ViewInformations to encrypt acl to put into server db
      String viewInfos = "";
      if(EditManager.getView(path, userId, userId, true)) {
        viewInfos = ResponseManager.retrieveCommunication(path, ServerPrimitives.OE_GET_VIEW, "json")[0];
      }

      FileSystemUtils.writePrivateFile("viewInfos.txt", viewInfos);

      //run wpes1
      String command[] = {
          ClientConfiguration.getEXECUTABLES_PATH() + "/wpes1_linux",
          "eACLsel",
          folderIdDB,
          ClientConfiguration.getLOCAL_PRIVATE_RESOURCES_PATH() + "/viewInfos.txt",
          passphrase,
          "0-" + newSEL,
          ClientConfiguration.getLOCAL_PRIVATE_RESOURCES_PATH() + "/aclSEL.txt"
      };
      RunnerExecutables.execute(command);

      String newCryptedAclSEL = FileSystemUtils.readPrivateFile("aclSEL.txt");

      //SAVE IN .tokens
      //After a  permission editing also delta-SEL resources has SEL encrypt level
      tokenFile.editCryptedAcl(token.folderIdDB, newCryptedAclSEL);
      LOGGER.debug("New acl SEL saved in .tokens file");

      //SAVE IN SERVER DB
      if(EditManager.saveNewSEL(userId, path,folderIdDB,newCryptedAclSEL)){
        ResponseManager.retrieveCommunication(path, ServerPrimitives.OE_SUCCESSFUL);
View Full Code Here

        JOptionPane.showMessageDialog(null, "The folder is locked. Please, retry later", "Locked", JOptionPane.INFORMATION_MESSAGE);
        System.exit(0);
      }
    }
   
    TokensResource token = new TokensResource(path);
    TokenStruct tokenStruct = token.getTokens(folderName);
    owner = tokenStruct.ownerID;
   
    String acl = ClientTokensManager.getACLsFromToken(path, OperationType.EDIT, tokenStruct, inpd)[1];
    boolean requestDone = OverEncryptRequest.generateRequest(ClientPrimitives.OE_GET_USERNAMES, OverEncryptRequestType.CONTINUE, owner, path, owner, acl);
   
View Full Code Here

        System.exit(0);
      }
    }
   
   
    TokensResource tokenFile = new TokensResource(parentPath);
    TokenStruct token = tokenFile.getTokens(folderName);
    if(!token.hasSEL) {
      aclBEL = ClientTokensManager.getACLsFromToken(parentPath, OperationType.EDIT, token, inpd)[0];
      aclUsers = aclBEL;
    } else {
      aclSEL = ClientTokensManager.getACLsFromToken(parentPath, OperationType.EDIT, token, inpd)[1];
      aclUsers = aclSEL.substring(2, aclSEL.length());
    }
    inpd.setVisible(true);
    FileSystemUtils.deletePrivateFile();
    inpd.setMessage("Retieve folder informations...");
    if(EditManager.getView(parentPath, userId, aclUsers, true)) {
      json = ResponseManager.retrieveCommunication(parentPath, ServerPrimitives.OE_GET_VIEW, "json")[0];
    }
    FileSystemUtils.writePrivateFile("json.txt", json);
    String command[] = {
      ClientConfiguration.getEXECUTABLES_PATH() + "/wpes1_linux",
      "remID",
      token.folderIdDB,
      ClientConfiguration.getLOCAL_PRIVATE_RESOURCES_PATH() + "/json.txt",
      ClientConfiguration.getLOCAL_PRIVATE_RESOURCES_PATH() + "/jsonout.txt",
      passphrase
    };
    RunnerExecutables.execute(command);
    json = FileSystemUtils.readPrivateFile("jsonout.txt");
    if(EditManager.setView(userId, parentPath, json)) {
      ResponseManager.retrieveCommunication(parentPath, ServerPrimitives.OE_SUCCESSFUL);
    }
    inpd.setMessage("Folder deleting...");
    FileSystemUtils.deletePrivateFile();
    if(DeleteManager.deleteFolder(userId, parentPath, token.folderIdDB, folderName)) {
      ResponseManager.retrieveCommunication(parentPath, ServerPrimitives.OE_SUCCESSFUL);
    }
    tokenFile.deleteFolder(folderName);
    OverEncryptRequest.generateRequest(ClientPrimitives.OE_DELETE_FOLDER, OverEncryptRequestType.UNLOCK, userId, parentPath);
    inpd.dispose();
    JOptionPane.showMessageDialog(null, "Folder deleted");
  }
View Full Code Here

TOP

Related Classes of unibg.overencrypt.client.TokensResource

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.