Package unibg.overencrypt.protocol

Examples of unibg.overencrypt.protocol.TokenStruct


            // TODO ??
        }

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

        String[] acls = tokenFile.getDecryptedACL(folderName,
                OperationType.EDIT);

        String aclBEL = acls[0];
        String aclSEL = acls[1];

        String acl;
        String json = null;
        String jsout;

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

        Response resp = client.sendAndWait(ClientPrimitives.OE_EDITPERM, path,
                users, userId, aclSEL, aclBEL);

        String newSEL = resp.getValue("newSel");
        String addUser = resp.getValue("addUser");
        String delUser = resp.getValue("delUser");

        if (!"nochange".equals(newSEL)) {
            Response tokenInfo = client.sendAndWait(
                    ClientPrimitives.OE_GET_TOKEN_INFO, path, userId);

            String idToken = tokenInfo.getValue("idToken");
            boolean hasMoreTokens = Boolean.valueOf(tokenInfo
                    .getValue("hasMoreTokens"));

            acl = aclBEL;

            while (hasMoreTokens) {
                String tokenHBEL = client.sendAndWait(
                        ClientPrimitives.OE_CREATE_JSON_HBEL, path, userId)
                        .getValue("tokenHBEL");

                // HBEL Tokens creation
                FileSystemUtils.writePrivateFile("json.txt", tokenHBEL);

                Executable exec = new Executable("wpes1_linux");
                exec.add("h");
                exec.add(Configuration.LOCAL_PRIVATE_RESOURCES_PATH + "/"
                        + aesKeyBEL);
                exec.add(Configuration.LOCAL_PRIVATE_RESOURCES_PATH
                        + "/json.txt");
                exec.add(acl);
                exec.add(idToken);
                exec.add(passphrase);
                exec.run();

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

                // Put new tokens HBEL in server DB
                hasMoreTokens = Boolean.valueOf(client.sendAndWait(
                        ClientPrimitives.OE_PUT_TOKEN_HBEL, path, userId,
                        jsonout).getValue("hasMoreTokens"));

                FileSystemUtils.deletePrivateFile("jsonout.txt");
            }
            // End HBEL tokens creation

            FileSystemUtils.deletePrivateFiles();

            // Update View Informations for added and deleted users
            if (!addUser.isEmpty()) {
                json = client.sendAndWait(ClientPrimitives.OE_VIEW_INFO, path,
                        userId, (userId + "-" + addUser), String.valueOf(true))
                        .getValue("json");
                FileSystemUtils.writePrivateFile("json.txt", json);

                Executable exec = new Executable("wpes1_linux");
                exec.add("addID");
                exec.add(folderIdDB);
                exec.add(Configuration.LOCAL_PRIVATE_RESOURCES_PATH
                        + "/json.txt");
                exec.add(Configuration.LOCAL_PRIVATE_RESOURCES_PATH
                        + "/jsonout.txt");
                exec.add(passphrase);
                exec.add(userId);
                exec.run();

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

                client.sendAndWait(ClientPrimitives.OE_SET_VIEW, path, jsout);

                FileSystemUtils.deletePrivateFiles();
            }

            if (!delUser.isEmpty()) {
                json = client.sendAndWait(ClientPrimitives.OE_VIEW_INFO, path,
                        userId, delUser, String.valueOf(true)).getValue("json");
                FileSystemUtils.writePrivateFile("json.txt", json);

                Executable exec = new Executable("wpes1_linux");
                exec.add("remID");
                exec.add(folderIdDB);
                exec.add(Configuration.LOCAL_PRIVATE_RESOURCES_PATH
                        + "/json.txt");
                exec.add(Configuration.LOCAL_PRIVATE_RESOURCES_PATH
                        + "/jsonout.txt");
                exec.add(passphrase);
                exec.run();
                jsout = FileSystemUtils.readFile("jsonout.txt");

                client.sendAndWait(ClientPrimitives.OE_SET_VIEW, path, jsout);
                FileSystemUtils.deletePrivateFiles();
            }

            // If has SEL level decrypt and re-encrypt at SEL Level
            client.sendAndWait(ClientPrimitives.OE_SEL_REQ, path, folderName,
                    folderIdDB, userId, users, aclSEL,
                    Boolean.toString(token.hasSEL()));

            // Retrieve ViewInformations to encrypt acl to put into server db
            String viewInfos = client.sendAndWait(
                    ClientPrimitives.OE_VIEW_INFO, path, userId, userId,
                    String.valueOf(true)).getValue("json");

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

            Executable exec = new Executable("wpes1_linux");
            exec.add("eACLsel");
            exec.add(folderIdDB);
            exec.add(Configuration.LOCAL_PRIVATE_RESOURCES_PATH
                    + "/viewInfos.txt");
            exec.add(passphrase);
            exec.add("0-" + newSEL);
            exec.add(Configuration.LOCAL_PRIVATE_RESOURCES_PATH + "/aclSEL.txt");
            exec.run();

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

            // SAVE IN .tokens
            // After a permission editing also delta-SEL resources has SEL
            // encrypt level
            tokenFile
                    .setEncryptedAcl(token.getFolderIdDB(), newEncryptedAclSEL);

            // SAVE IN SERVER DB
            client.sendAndWait(ClientPrimitives.OE_SAVE_NEW_SEL, path,
                    folderIdDB, newEncryptedAclSEL);
            FileSystemUtils.deletePrivateFiles();
View Full Code Here


        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

        String folderName = options.nonOptionArguments().get(2);

        logger.debug(folderName);

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

        String acl = tokenFile.getDecryptedACLSEL(folderName,
                OperationType.EDIT);

        logger.debug("acl: " + acl);

        String ownerId = token.getOwnerID();
        logger.debug("owner: " + ownerId);

        String usernames = new OverEncryptClient().sendAndWait(
                ClientPrimitives.OE_GET_USERNAMES, path, ownerId, acl).getValue(
                "usernames");
View Full Code Here

      }
    }
   
   
    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];
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.