Package unibg.overencrypt.protocol

Examples of unibg.overencrypt.protocol.Response


            passphrase = SecurityAlgorithms.decryptAES(passphrase);
        } catch (Exception e) {
            // TODO ??
        }

        Response resp = client.sendAndWait(
                ClientPrimitives.OE_UPLMANAGER_FOLDER, path, owner,
                usersSelected, path, folderName);
        String folderIdGraph = resp.getValue("folderId");
        String acl = resp.getValue("acl");

        String relativePath = path.replace(Configuration.URL_WEBDAV_SERVER, "");
        String ownerPath = "/" + owner + relativePath + "/" + folderName;

        FileSystemUtils.deletePrivateFiles();

        new TokensResource(path).updateToken(owner, passphrase, acl);

        int aclType = 0;
        do {
            aclType = Integer.valueOf(client.sendAndWait(
                    ClientPrimitives.OE_FIRST_STEP_JSON, path, owner).getValue(
                    "result"));

            if (aclType == 1) {
                boolean firstStep = true;
                do {
                    firstStep = true;
                    do {
                        String json1 = client.sendAndWait(
                                ClientPrimitives.OE_JSON_UPLOAD, path, owner,
                                nextToken, String.valueOf(firstStep)).getValue(
                                "json");

                        if (json1.equals("{\"values\":[]}")) {
                            destinationACLReached = true;
                        } else {
                            FileSystemUtils.writePrivateFile("json.txt", json1);

                            String command = Configuration.EXECUTABLES_PATH
                            + "/wpes1_linux";
                            command += firstStep ? "new1" : "newn";
                            command += Configuration.LOCAL_PRIVATE_RESOURCES_PATH
                            + "/json.txt";
                            if (firstAesKey) {
                                command += Configuration.LOCAL_PRIVATE_RESOURCES_PATH
                                + "/AesKeyFin.txt";
                            }
                            command += firstStep ? passphrase
                                    : Configuration.LOCAL_PRIVATE_RESOURCES_PATH
                                    + "/AesKey.txt";
                            command += Configuration.LOCAL_PRIVATE_RESOURCES_PATH
                            + "/AesKey.txt";
                            command += folderIdGraph;
                            command += Configuration.LOCAL_PRIVATE_RESOURCES_PATH
                            + "/next.txt";
                            command += acl;

                            RunnerExecutables.execute(command);
                            firstStep = false;

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

                            nextToken = next;

                            destinationACLReached = Boolean
                            .valueOf(client
                                    .sendAndWait(
                                            ClientPrimitives.OE_FINISHED_UPLOAD_TOKEN,
                                            path, owner, next)
                                            .getValue("result"));

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

                            client.sendAndWait(
                                    ClientPrimitives.OE_PUT_TOKEN_DB, path,
                                    owner, jsonout);
                        }

                    } while (!destinationACLReached);

                    File aesKeyFile = new File(
                            Configuration.LOCAL_PRIVATE_RESOURCES_PATH
                                    + "/AesKey.txt");
                    if (firstAesKey && aesKeyFile.exists()) {
                        aesKeyFile.renameTo(new File(
                                Configuration.LOCAL_PRIVATE_RESOURCES_PATH
                                        + "/AesKeyFin.txt"));
                        firstAesKey = false;
                    }

                    result3 = Boolean.valueOf(client.sendAndWait(
                            ClientPrimitives.OE_MORE_USERS_ACL, path, owner)
                            .getValue("result"));
                } while (result3);
            } else if (aclType == 3) {
                String json2 = client.sendAndWait(
                        ClientPrimitives.OE_JSON_UPLOAD, path, owner, "",
                        String.valueOf(true)).getValue("json");
                FileSystemUtils.writePrivateFile("json.txt", json2);

                String command = Configuration.EXECUTABLES_PATH
                        + "/wpes1_linux";
                command += "new1";
                command += Configuration.LOCAL_PRIVATE_RESOURCES_PATH
                        + "/json.txt";
                if (firstAesKey) {
                    command += Configuration.LOCAL_PRIVATE_RESOURCES_PATH
                            + "/AesKeyFin.txt";
                }
                command += passphrase;
                command += Configuration.LOCAL_PRIVATE_RESOURCES_PATH
                        + "/AesKey.txt";
                command += folderIdGraph;
                command += Configuration.LOCAL_PRIVATE_RESOURCES_PATH
                        + "/next.txt";
                command += acl;

                RunnerExecutables.execute(command);
                firstAesKey = false;

                if (firstAesKey) {
                    File aesKeyFile = new File(
                            Configuration.LOCAL_PRIVATE_RESOURCES_PATH
                                    + "/AesKey.txt");
                    aesKeyFile.renameTo(new File(
                            Configuration.LOCAL_PRIVATE_RESOURCES_PATH
                                    + "/AesKeyFin.txt"));
                }

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

                client.sendAndWait(ClientPrimitives.OE_PUT_TOKEN_DB, path,
                        owner, jsonout);
            } else if (aclType == 2) {
                String act = "";
                String notes = "";

                Response resp2 = client.sendAndWait(
                        ClientPrimitives.OE_CURRENT_NOTE, path, owner);
                act = resp2.getValue("act");
                notes = resp2.getValue("notes");
                FileSystemUtils.writePrivateFile("NoteJson.txt", notes);

                String command[] = {
                        Configuration.EXECUTABLES_PATH + "/wpes1_linux",
                        "note",
View Full Code Here


        OverEncryptClient client = new OverEncryptClient();
        AuthenticationClient pinManagementClient = new AuthenticationClient();
        PermissionsClient permissionsClient = new PermissionsClient();

        Response resp = client.readResponse(path);
        logger.debug("Response:\n===\n" + resp.toString() + "===");

        if (resp.getPrimitive() == ServerPrimitives.OE_DHKEYPAIRS) {
            exitWithError(1, "The user hasn't chosen a passphrase yet. "
                    + "Use the '" + new GenerateKeysCommand().getKeyword()
                    + "' command to choose one.");
        }

        String userId = resp.getValue("userId");
        String passphrase = "";

        if (options.has("p") || options.has("passphrase")) {
            passphrase = (String) options.valueOf("p");
        } else {
            exitWithError(2, "No passphrase supplied. Please use " +
                    "the -p/--passphrase option to supply a valid passphrase.");
        }

        client.deleteResponse(path);
        while (resp.getPrimitive() == ServerPrimitives.OE_AUTHENTICATION) {
            resp = pinManagementClient.checkPin(path, userId, passphrase);
            logger.debug("Response:\n===\n" + resp.toString() + "===");
        }

        if (resp.getPrimitive() == ServerPrimitives.OE_UPDATE_ALL_PERMS) {
            permissionsClient.updateAllPermissions(resp.getValue("friends"),
                    resp.getValue("userInfos"), resp.getValue("friendsInfos"),
                    path, userId, passphrase);

            exitWithSuccess("User authenticated successfully.");
        } else {
            exitWithError(3, "Unable to authenticate user.");
View Full Code Here

        }

        OverEncryptClient client = new OverEncryptClient();
        AuthenticationClient pinManagementClient = new AuthenticationClient();

        Response resp = client.waitForResponse(path);
        String userId = resp.getValue("userId");
        logger.debug("Response:\n===\n" + resp.toString() + "===");

        if (resp.getPrimitive() == ServerPrimitives.OE_DHKEYPAIRS) {
            resp = pinManagementClient.generateKeyPairs(path, userId,
                    passphrase);
            logger.debug("Response:\n===\n" + resp.toString() + "===");

            if (resp.getPrimitive() == ServerPrimitives.OE_SUCCESSFUL) {
                exitWithSuccess("Keys generated successfully.");
            } else {
                exitWithError("Unable to generate keys.");
            }
        }
View Full Code Here

    @Override
    public void run(String[] args) {
        OptionSet options = new OptionParser().parse(args);
        String path = options.nonOptionArguments().get(1);

        Response response = new AuthenticationClient().logout(path);

        if (response.getPrimitive() == ServerPrimitives.OE_SUCCESSFUL) {
            exitWithSuccess("Logout successful. You can now unmount your "
                    + "WebDAV client.");
        } else {
            exitWithError("Logout failed.");
        }
View Full Code Here

    public void deleteResponse(String path) {
        client.delete(path + ".response");
    }

    public Response waitForResponse(String path) {
        Response resp = readResponse(path);
        deleteResponse(path);

        return resp;
    }
View Full Code Here

            .getLogger(AuthenticationClient.class);

    private OverEncryptClient client = new OverEncryptClient();

    public Response checkPin(String path, String userId, String pin) {
        Response resp = client.sendAndWait(ClientPrimitives.OE_PASSPHRASE,
                path, SecurityAlgorithms.doubleMd5(pin), userId);

        LocalPrivateResource lpr = new LocalPrivateResource();
        try {
            lpr.set("UserInfo", "userId", userId);
View Full Code Here

        logger.debug(userId);

        // lpr.delete();

        client.send(ClientPrimitives.OE_LOGOUT, path, userId);
        Response response = client.readResponse(path);

        return response;
    }
View Full Code Here

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

TOP

Related Classes of unibg.overencrypt.protocol.Response

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.