@Test public void testScriptPathNotSpecified() throws Exception { if (!Shell.WINDOWS) { return; } ShellDecryptionKeyProvider provider = new ShellDecryptionKeyProvider(); Configuration conf = new Configuration(); String account = "testacct"; String key = "key"; conf.set(SimpleKeyProvider.KEY_ACCOUNT_KEY_PREFIX + account, key); try { provider.getStorageAccountKey(account, conf); Assert .fail("fs.azure.shellkeyprovider.script is not specified, we should throw"); } catch (KeyProviderException e) { LOG.info("Received an expected exception: " + e.getMessage()); } }
@Override public String getStorageAccountKey(String accountName, Configuration conf) throws KeyProviderException { String envelope = super.getStorageAccountKey(accountName, conf); final String command = conf.get(KEY_ACCOUNT_SHELLKEYPROVIDER_SCRIPT); if (command == null) { throw new KeyProviderException( "Script path is not specified via fs.azure.shellkeyprovider.script"); } String[] cmd = command.split(" "); String[] cmdWithEnvelope = Arrays.copyOf(cmd, cmd.length + 1); cmdWithEnvelope[cmdWithEnvelope.length - 1] = envelope; String decryptedKey = null; try { decryptedKey = Shell.execCommand(cmdWithEnvelope); } catch (IOException ex) { throw new KeyProviderException(ex); } return decryptedKey.trim(); }
ShellDecryptionKeyProvider extends SimpleKeyProvider { @Override public String getStorageAccountKey(String accountName, Configuration conf) throws KeyProviderException { String envelope = super.getStorageAccountKey(accountName, conf); final String command = conf.get(KEY_ACCOUNT_SHELLKEYPROVIDER_SCRIPT); if (command == null) { throw new KeyProviderException( "Script path is not specified via fs.azure.shellkeyprovider.script"); } String[] cmd = command.split(" "); String[] cmdWithEnvelope = Arrays.copyOf(cmd, cmd.length + 1); cmdWithEnvelope[cmdWithEnvelope.length - 1] = envelope; String decryptedKey = null; try { decryptedKey = Shell.execCommand(cmdWithEnvelope); } catch (IOException ex) { throw new KeyProviderException(ex); } return decryptedKey.trim(); } }
ShellDecryptionKeyProvider extends SimpleKeyProvider { @Override public String getStorageAccountKey(String accountName, Configuration conf) throws KeyProviderException { String envelope = super.getStorageAccountKey(accountName, conf); final String command = conf.get(KEY_ACCOUNT_SHELLKEYPROVIDER_SCRIPT); if (command == null) { throw new KeyProviderException( "Script path is not specified via fs.azure.shellkeyprovider.script"); } String[] cmd = command.split(" "); String[] cmdWithEnvelope = Arrays.copyOf(cmd, cmd.length + 1); cmdWithEnvelope[cmdWithEnvelope.length - 1] = envelope; String decryptedKey = null; try { decryptedKey = Shell.execCommand(cmdWithEnvelope); } catch (IOException ex) { throw new KeyProviderException(ex); } return decryptedKey.trim(); }  }
ShellDecryptionKeyProvider extends SimpleKeyProvider { @Override public String getStorageAccountKey(String accountName, Configuration conf) throws KeyProviderException { String envelope = super.getStorageAccountKey(accountName, conf); final String command = conf.get(KEY_ACCOUNT_SHELLKEYPROVIDER_SCRIPT); if (command == null) { throw new KeyProviderException( "Script path is not specified via fs.azure.shellkeyprovider.script"); } String[] cmd = command.split(" "); String[] cmdWithEnvelope = Arrays.copyOf(cmd, cmd.length + 1); cmdWithEnvelope[cmdWithEnvelope.length - 1] = envelope; String decryptedKey = null; try { decryptedKey = Shell.execCommand(cmdWithEnvelope); } catch (IOException ex) { throw new KeyProviderException(ex); } return decryptedKey.trim(); }  @Override String getStorageAccountKey(String accountName, Configuration conf); }
ShellDecryptionKeyProvider extends SimpleKeyProvider { @Override public String getStorageAccountKey(String accountName, Configuration conf) throws KeyProviderException { String envelope = super.getStorageAccountKey(accountName, conf); final String command = conf.get(KEY_ACCOUNT_SHELLKEYPROVIDER_SCRIPT); if (command == null) { throw new KeyProviderException( "Script path is not specified via fs.azure.shellkeyprovider.script"); } String[] cmd = command.split(" "); String[] cmdWithEnvelope = Arrays.copyOf(cmd, cmd.length + 1); cmdWithEnvelope[cmdWithEnvelope.length - 1] = envelope; String decryptedKey = null; try { decryptedKey = Shell.execCommand(cmdWithEnvelope); } catch (IOException ex) { throw new KeyProviderException(ex); } return decryptedKey.trim(); }  @Override String getStorageAccountKey(String accountName, Configuration conf);  }