private ConfigTO createConfigTO() throws StorageException, CipherException { ConfigTO configTO = options.getConfigTO(); if (options.getStrategy() == ConnectOptionsStrategy.CONNECTION_TO) { return configTO; } else if (options.getStrategy() == ConnectOptionsStrategy.CONNECTION_LINK) { return createConfigTOFromLink(configTO, options.getConnectLink(), options.getPassword()); } else { throw new RuntimeException("Unhandled connect strategy: " + options.getStrategy()); } }
@Override public ConnectOperationOptions parseOptions(String[] operationArgs) throws Exception { ConnectOperationOptions operationOptions = new ConnectOperationOptions(); String connectLink = (String) nonOptionArgs.get(0); operationOptions.setStrategy(ConnectOptionsStrategy.CONNECTION_LINK); operationOptions.setConnectLink(connectLink); operationOptions.setStrategy(ConnectOptionsStrategy.CONNECTION_TO); operationOptions.setConnectLink(null); operationOptions.setLocalDir(localDir); operationOptions.setConfigTO(configTO); operationOptions.setDaemon(options.has(optionAddDaemon)); operationOptions.setPassword(validateAndGetPassword(options, optionPassword));
transferManager = createTransferManagerFromNullConfig(options.getConfigTO()); File appDir = createAppDirs(options.getLocalDir()); if (options.isDaemon()) { try { boolean addedToDaemonConfig = DaemonConfigHelper.addFolder(options.getLocalDir()); result.setAddedToDaemon(addedToDaemonConfig);
@Override public int execute(String[] operationArgs) throws Exception { boolean retryNeeded = true; boolean performOperation = true; ConnectOperationOptions operationOptions = parseOptions(operationArgs); while (retryNeeded && performOperation) { ConnectOperationResult operationResult = new ConnectOperation(operationOptions, this).execute(); printResults(operationResult); retryNeeded = operationResult.getResultCode() != ConnectResultCode.OK && operationResult.getResultCode() != ConnectResultCode.NOK_DECRYPT_ERROR; if (retryNeeded) { performOperation = isInteractive && askRetryConnection(); if (performOperation) { updateTransferSettings(operationOptions.getConfigTO().getTransferSettings()); } } } return 0; }
private String getOrAskPassword() { if (options.getPassword() == null) { if (listener == null) { throw new RuntimeException("Repository file is encrypted, but password cannot be queried (no listener)."); } return listener.onUserPassword(null, "Master Password: "); } else { return options.getPassword(); } }
@Override public Response handleRequest(final ManagementRequest request) { final ConnectManagementRequest concreteRequest = (ConnectManagementRequest) request; logger.log(Level.SEVERE, "Executing ConnectOperation for folder " + concreteRequest.getOptions().getLocalDir() + " ..."); }, "ConRq/" + concreteRequest.getOptions().getLocalDir().getName());