@Override public CommandProcessorResponse run(String command) { String[] args = command.split("\\s+"); if (args.length < 1) { return returnErrorResponse("Command arguments are empty."); } if (encryptionShim == null) { return returnErrorResponse("Hadoop encryption shim is not initialized."); } String action = args[0]; String params[] = Arrays.copyOfRange(args, 1, args.length); try { if (action.equalsIgnoreCase("create_key")) { createEncryptionKey(params); } else if (action.equalsIgnoreCase("create_zone")) { createEncryptionZone(params); } else if (action.equalsIgnoreCase("delete_key")) { deleteEncryptionKey(params); } else { return returnErrorResponse("Unknown command action: " + action); } } catch (Exception e) { return returnErrorResponse(e.getMessage()); } return new CommandProcessorResponse(0); }
/** * Deletes an encryption key using the parameters passed through the 'delete_key' action. * * @param params Parameters passed to the 'delete_key' command action. * @throws Exception If key deletion failed. */ private void deleteEncryptionKey(String[] params) throws Exception { CommandLine args = parseCommandArgs(DELETE_KEY_OPTIONS, params); String keyName = args.getOptionValue("keyName"); try { encryptionShim.deleteKey(keyName); } catch (IOException e) { throw new Exception("Cannot delete encryption key: " + e.getMessage()); } writeTestOutput("Encryption key deleted: '" + keyName + "'"); }
case CRYPTO: try { return new CryptoProcessor(SessionState.get().getHdfsEncryptionShim(), conf); } catch (HiveException e) { throw new SQLException("Fail to start the command processor due to the exception: ", e);
case CRYPTO: try { return new CryptoProcessor(SessionState.get().getHdfsEncryptionShim(), conf); } catch (HiveException e) { throw new SQLException("Fail to start the command processor due to the exception: ", e);
@Override public CommandProcessorResponse run(String command) throws CommandNeedRetryException { String[] args = command.split("\\s+"); if (args.length < 1) { return returnErrorResponse("Command arguments are empty."); } if (encryptionShim == null) { return returnErrorResponse("Hadoop encryption shim is not initialized."); } String action = args[0]; String params[] = Arrays.copyOfRange(args, 1, args.length); try { if (action.equalsIgnoreCase("create_key")) { createEncryptionKey(params); } else if (action.equalsIgnoreCase("create_zone")) { createEncryptionZone(params); } else if (action.equalsIgnoreCase("delete_key")) { deleteEncryptionKey(params); } else { return returnErrorResponse("Unknown command action: " + action); } } catch (Exception e) { return returnErrorResponse(e.getMessage()); } return new CommandProcessorResponse(0); }
/** * Creates an encryption key using the parameters passed through the 'create_key' action. * * @param params Parameters passed to the 'create_key' command action. * @throws Exception If key creation failed. */ private void createEncryptionKey(String[] params) throws Exception { CommandLine args = parseCommandArgs(CREATE_KEY_OPTIONS, params); String keyName = args.getOptionValue("keyName"); String bitLength = args.getOptionValue("bitLength", Integer.toString(DEFAULT_BIT_LENGTH)); try { encryptionShim.createKey(keyName, new Integer(bitLength)); } catch (Exception e) { throw new Exception("Cannot create encryption key: " + e.getMessage()); } writeTestOutput("Encryption key created: '" + keyName + "'"); }
case CRYPTO: try { return new CryptoProcessor(SessionState.get().getHdfsEncryptionShim(), conf); } catch (HiveException e) { throw new SQLException("Fail to start the command processor due to the exception: ", e);
@Override public CommandProcessorResponse run(String command) throws CommandNeedRetryException { String[] args = command.split("\\s+"); if (args.length < 1) { return returnErrorResponse("Command arguments are empty."); } if (encryptionShim == null) { return returnErrorResponse("Hadoop encryption shim is not initialized."); } String action = args[0]; String params[] = Arrays.copyOfRange(args, 1, args.length); try { if (action.equalsIgnoreCase("create_key")) { createEncryptionKey(params); } else if (action.equalsIgnoreCase("create_zone")) { createEncryptionZone(params); } else if (action.equalsIgnoreCase("delete_key")) { deleteEncryptionKey(params); } else { return returnErrorResponse("Unknown command action: " + action); } } catch (Exception e) { return returnErrorResponse(e.getMessage()); } return new CommandProcessorResponse(0); }
/** * Deletes an encryption key using the parameters passed through the 'delete_key' action. * * @param params Parameters passed to the 'delete_key' command action. * @throws Exception If key deletion failed. */ private void deleteEncryptionKey(String[] params) throws Exception { CommandLine args = parseCommandArgs(DELETE_KEY_OPTIONS, params); String keyName = args.getOptionValue("keyName"); try { encryptionShim.deleteKey(keyName); } catch (IOException e) { throw new Exception("Cannot delete encryption key: " + e.getMessage()); } writeTestOutput("Encryption key deleted: '" + keyName + "'"); } }
/** * Creates an encryption key using the parameters passed through the 'create_key' action. * * @param params Parameters passed to the 'create_key' command action. * @throws Exception If key creation failed. */ private void createEncryptionKey(String[] params) throws Exception { CommandLine args = parseCommandArgs(CREATE_KEY_OPTIONS, params); String keyName = args.getOptionValue("keyName"); String bitLength = args.getOptionValue("bitLength", Integer.toString(DEFAULT_BIT_LENGTH)); try { encryptionShim.createKey(keyName, new Integer(bitLength)); } catch (Exception e) { throw new Exception("Cannot create encryption key: " + e.getMessage()); } writeTestOutput("Encryption key created: '" + keyName + "'"); }
/** * Creates an encryption zone using the parameters passed through the 'create_zone' action. * * @param params Parameters passed to the 'create_zone' command action. * @throws Exception If zone creation failed. */ private void createEncryptionZone(String[] params) throws Exception { CommandLine args = parseCommandArgs(CREATE_ZONE_OPTIONS, params); String keyName = args.getOptionValue("keyName"); Path cryptoZone = new Path(args.getOptionValue("path")); if (cryptoZone == null) { throw new Exception("Cannot create encryption zone: Invalid path '" + args.getOptionValue("path") + "'"); } try { encryptionShim.createEncryptionZone(cryptoZone, keyName); } catch (IOException e) { throw new Exception("Cannot create encryption zone: " + e.getMessage()); } writeTestOutput("Encryption zone created: '" + cryptoZone + "' using key: '" + keyName + "'"); }
/** * Creates an encryption zone using the parameters passed through the 'create_zone' action. * * @param params Parameters passed to the 'create_zone' command action. * @throws Exception If zone creation failed. */ private void createEncryptionZone(String[] params) throws Exception { CommandLine args = parseCommandArgs(CREATE_ZONE_OPTIONS, params); String keyName = args.getOptionValue("keyName"); Path cryptoZone = new Path(args.getOptionValue("path")); if (cryptoZone == null) { throw new Exception("Cannot create encryption zone: Invalid path '" + args.getOptionValue("path") + "'"); } try { encryptionShim.createEncryptionZone(cryptoZone, keyName); } catch (IOException e) { throw new Exception("Cannot create encryption zone: " + e.getMessage()); } writeTestOutput("Encryption zone created: '" + cryptoZone + "' using key: '" + keyName + "'"); }
/** * Deletes an encryption key using the parameters passed through the 'delete_key' action. * * @param params Parameters passed to the 'delete_key' command action. * @throws Exception If key deletion failed. */ private void deleteEncryptionKey(String[] params) throws Exception { CommandLine args = parseCommandArgs(DELETE_KEY_OPTIONS, params); String keyName = args.getOptionValue("keyName"); try { encryptionShim.deleteKey(keyName); } catch (IOException e) { throw new Exception("Cannot delete encryption key: " + e.getMessage()); } writeTestOutput("Encryption key deleted: '" + keyName + "'"); } }
/** * Creates an encryption key using the parameters passed through the 'create_key' action. * * @param params Parameters passed to the 'create_key' command action. * @throws Exception If key creation failed. */ private void createEncryptionKey(String[] params) throws Exception { CommandLine args = parseCommandArgs(CREATE_KEY_OPTIONS, params); String keyName = args.getOptionValue("keyName"); String bitLength = args.getOptionValue("bitLength", Integer.toString(DEFAULT_BIT_LENGTH)); try { encryptionShim.createKey(keyName, new Integer(bitLength)); } catch (Exception e) { throw new Exception("Cannot create encryption key: " + e.getMessage()); } writeTestOutput("Encryption key created: '" + keyName + "'"); }
/** * Creates an encryption zone using the parameters passed through the 'create_zone' action. * * @param params Parameters passed to the 'create_zone' command action. * @throws Exception If zone creation failed. */ private void createEncryptionZone(String[] params) throws Exception { CommandLine args = parseCommandArgs(CREATE_ZONE_OPTIONS, params); String keyName = args.getOptionValue("keyName"); Path cryptoZone = new Path(args.getOptionValue("path")); if (cryptoZone == null) { throw new Exception("Cannot create encryption zone: Invalid path '" + args.getOptionValue("path") + "'"); } try { encryptionShim.createEncryptionZone(cryptoZone, keyName); } catch (IOException e) { throw new Exception("Cannot create encryption zone: " + e.getMessage()); } writeTestOutput("Encryption zone created: '" + cryptoZone + "' using key: '" + keyName + "'"); }