Package unibg.overencrypt.protocol

Examples of unibg.overencrypt.protocol.TokenStruct


   *
   * @param folderName the folder name of .tokens file
   * @return data structure of token
   */
  public TokenStruct getTokens(String folderName){
    TokenStruct token = null;

    Element root = xmlDocument.getRootElement();
    @SuppressWarnings("unchecked")
    List<Element> children = root.getChildren("Folder");
    if( children != null){
      for (Iterator<Element> iterator = children.iterator(); iterator.hasNext();) {
        Element element = (Element) iterator.next();
        if(element.getChildText("folderName").equals(folderName)){
          token = new TokenStruct();
          token.folderIdDB = element.getChildText("folderIdDB");
          token.folderIdGraph = element.getChildText("folderIdGraph");
          token.folderName = element.getChildText("folderName");
          token.ownerID = element.getChildText("ownerID");
          token.cryptedAclBEL = element.getChildText("cryptedAclBEL");
View Full Code Here


              LOGGER.debug("La map contiene questa path locked relativa all'utente: " + lockedPath);
              File temp = new File(lockedPath);
              if (temp.getParent().equals(ServerConfiguration.getWebDAVrootPath() + "/" + file.getName())) {
                TokensResource tokenResource = new TokensResource(file.getPath());
                LOGGER.debug("il token che ora vado a controllare ha path: " + file.getPath() + "/.tokens");
                TokenStruct token = tokenResource.getTokens(temp.getName());
                if (token != null) {
                  pathToReturn = ServerConfiguration.getWebDAVrootPath() + "/" + file.getName() + "/.tokens";                   
                  LOGGER.debug("Ci siamo - la path che ritorna è: " + pathToReturn);
                  pathFound = true;
                  break;
View Full Code Here

        folderName = folderName.substring(folderName.lastIndexOf('/') + 1);

        logger.debug(folderName);

        TokensResource tokenFile = new TokensResource(grandParentPath);
        TokenStruct token = tokenFile.getTokens(folderName);

        String acls[] = tokenFile.getDecryptedACL(folderName,
                OperationType.DOWNLOAD);
        String aclBEL = acls[0];
        String aclSEL = acls[1];

        String[] splittedSELACL = aclSEL.split("-");
        if (splittedSELACL.length > 2
                && splittedSELACL[1].equals(splittedSELACL[2])) {
            aclSEL = "0-" + splittedSELACL[1];
        }

        String tempEncryptedFilePath = Configuration.LOCAL_TMP_PATH + "/enc_"
                + fileName;
        WebDAVClient client = new ApacheWebDAVClient();
        client.download(path + fileName, tempEncryptedFilePath);

        String aesBELFileName = tokenFile.getAESKey(folderName, aclBEL, "BEL",
                false);

        String dsaKey = new OverEncryptClient().sendAndWait(
                ClientPrimitives.OE_GET_DSA_JSON, path, "Download",
                token.getOwnerID(), userID).getValue("dsa");
        String dsaFileName = "DSAKey.txt";
        FileSystemUtils.writePrivateFile(dsaFileName, dsaKey);

        logger.debug(destinationPath);

        Executable exec = new Executable("wpes2_linux");
        if (token.hasSEL()) {
            exec.add("dSELBEL");
        } else {
            exec.add("dBEL");
        }
        exec.add(Configuration.LOCAL_PRIVATE_RESOURCES_PATH + "/"
                + dsaFileName);
        exec.add(Configuration.LOCAL_PRIVATE_RESOURCES_PATH + "/"
                + aesBELFileName);
        if (token.hasSEL()) {
            exec.add(Configuration.LOCAL_PRIVATE_RESOURCES_PATH + "/"
                    + tokenFile.getAESKey(folderName, aclSEL, "SEL", false));
        }
        exec.add(tempEncryptedFilePath);
View Full Code Here

   *
   * @param folderName the folder name of .tokens file
   * @return data structure of token
   */
  public TokenStruct getTokens(String folderName){
    TokenStruct token = null;

    Element root = xmlDocument.getRootElement();
    @SuppressWarnings("unchecked")
    List<Element> children = root.getChildren("Folder");
    if( children != null){
      for (Iterator<Element> iterator = children.iterator(); iterator.hasNext();) {
        Element element = (Element) iterator.next();
        if(element.getChildText("folderName").equals(folderName)){
          token = new TokenStruct();
          token.folderIdDB = element.getChildText("folderIdDB");
          token.folderIdGraph = element.getChildText("folderIdGraph");
          token.folderName = element.getChildText("folderName");
          token.ownerID = element.getChildText("ownerID");
          token.cryptedAclBEL = element.getChildText("cryptedAclBEL");
View Full Code Here

        client.sendAndWait(ClientPrimitives.OE_PUT_ACL, path, encAclSEL,
                encAclBEL);

        TokensResource tokenFile = new TokensResource(path);

        TokenStruct tokens = new TokenStruct();
        tokens.setFolderIdDB(folderIdDB);
        tokens.setFolderName(folderName);
        tokens.setFolderIdGraph(folderIdGraph);
        tokens.setOwnerID(owner);
        tokens.setSEL(hasSEL);
        tokens.setEncryptedAclBEL(encAclBEL);
        tokens.setEncryptedAclSEL(encAclSEL);

        tokenFile.addTokens(tokens);

        FileSystemUtils.deletePrivateFiles();
View Full Code Here

        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

                remoteFolder.length() - 1);
        remoteFolderName = remoteFolderName.substring(remoteFolderName
                .lastIndexOf('/') + 1);

        TokensResource tokenFile = new TokensResource(remoteParentFolder);
        TokenStruct token = tokenFile.getTokens(remoteFolderName);
        String aclBEL = tokenFile.getDecryptedACLBEL(remoteFolderName,
                OperationType.DOWNLOAD);

        OverEncryptClient client = new OverEncryptClient();

        client.sendAndWait(ClientPrimitives.OE_UPLMANAGER_FILE, remoteFolder,
                aclBEL, userId);

        String dsaKey = client.sendAndWait(ClientPrimitives.OE_GET_DSA_JSON,
                remoteFolder, "Upload", userId, userId).getValue("dsa");
        String dsaFileName = "DSAKey.txt";
        FileSystemUtils.writePrivateFile(dsaFileName, dsaKey);

        String aesFileName = tokenFile.getAESKey(remoteFolderName, aclBEL,
                "BEL", true);

        Executable exec = new Executable("wpes2_linux");
        exec.add("eBEL");
        exec.add(Configuration.LOCAL_PRIVATE_RESOURCES_PATH + "/" + dsaFileName);
        exec.add(Configuration.LOCAL_PRIVATE_RESOURCES_PATH + "/" + aesFileName);
        exec.add(localFolder + "/" + fileName);
        exec.add(Configuration.LOCAL_TMP_PATH + "/" + fileName);
        exec.add(passphrase);
        exec.run();

        String localFilePath = Configuration.LOCAL_TMP_PATH + "/" + fileName;

        WebDAVClient davClient = new ApacheWebDAVClient();
        davClient.upload(localFilePath, remoteFolder + fileName);

        new File(localFilePath).delete();

        String[] splitted = aclBEL.split("-");
        String users = "";
        for (int i = 0; i < splitted.length; i++) {
            if (!splitted[i].equals(userId)) {
                users += splitted[i];
            }
        }
        users = userId + "," + users;

        if (token.hasSEL()) {
            client.sendAndWait(ClientPrimitives.OE_ENCRYPT_SEL, remoteFolder,
                    userId, fileName, users);
        }

        // TODO Aggiornare i riferimenti alle risorse condivise e i permessi
View Full Code Here

        } catch (Exception e) {
            // TODO Error
        }

        TokensResource tokenFile = new TokensResource(parentPath);
        TokenStruct token = tokenFile.getTokens(folderName);

        if (!token.hasSEL()) {
            String aclSEL = tokenFile.getDecryptedACLBEL(folderName,
                    OperationType.EDIT);
            aclUsers = aclSEL.substring(2, aclSEL.length());
        } else {
            aclUsers = tokenFile.getDecryptedACLSEL(folderName,
                    OperationType.EDIT);
        }

        FileSystemUtils.deletePrivateFiles();

        json = client.sendAndWait(ClientPrimitives.OE_VIEW_INFO, parentPath,
                userId, aclUsers, String.valueOf(true)).getValue("json");

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

        String command[] = { Configuration.EXECUTABLES_PATH + "/wpes1_linux",
                "remID", token.getFolderIdDB(),
                Configuration.LOCAL_PRIVATE_RESOURCES_PATH + "/json.txt",
                Configuration.LOCAL_PRIVATE_RESOURCES_PATH + "/jsonout.txt",
                passphrase };
        RunnerExecutables.execute(command);

        json = FileSystemUtils.readPrivateFile("jsonout.txt");

        client.sendAndWait(ClientPrimitives.OE_SET_VIEW, parentPath, json);

        FileSystemUtils.deletePrivateFiles();

        client.sendAndWait(ClientPrimitives.OE_DELETE_FOLDER, parentPath,
                token.getFolderIdDB(), folderName);

        tokenFile.deleteFolder(folderName);
    }
View Full Code Here

      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 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);
View Full Code Here

TOP

Related Classes of unibg.overencrypt.protocol.TokenStruct

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.