public void execute() throws IOException { if (alias.equals("-help")) { doHelp(); return; } warnIfTransientProvider(); getOut().println("Deleting credential: " + alias + " from CredentialProvider: " + provider.toString()); if (cont) { try { provider.deleteCredentialEntry(alias); getOut().println("Credential " + alias + " has been successfully deleted."); provider.flush(); printProviderWritten(); } catch (IOException e) { getOut().println("Credential " + alias + " has NOT been deleted."); throw e; } } }
public void execute() throws IOException, NoSuchAlgorithmException { if (alias.equals("-help")) { doHelp(); return; } warnIfTransientProvider(); try { char[] credential = null; if (value != null) { // testing only credential = value.toCharArray(); } else { credential = promptForCredential(); } provider.createCredentialEntry(alias, credential); provider.flush(); getOut().println(alias + " has been successfully created."); printProviderWritten(); } catch (InvalidParameterException e) { getOut().println("Credential " + alias + " has NOT been created. " + e.getMessage()); throw e; } catch (IOException e) { getOut().println("Credential " + alias + " has NOT been created. " + e.getMessage()); throw e; } }
public void execute() throws IOException { warnIfTransientProvider(); out.println("Deleting credential: " + alias + " from CredentialProvider: " + provider.toString()); if (cont) { try { provider.deleteCredentialEntry(alias); out.println(alias + " has been successfully deleted."); provider.flush(); printProviderWritten(); } catch (IOException e) { out.println(alias + " has NOT been deleted."); throw e; } } }
public void execute() throws IOException { warnIfTransientProvider(); out.println("Deleting credential: " + alias + " from CredentialProvider: " + provider.toString()); if (cont) { try { provider.deleteCredentialEntry(alias); out.println(alias + " has been successfully deleted."); provider.flush(); printProviderWritten(); } catch (IOException e) { out.println(alias + " has NOT been deleted."); throw e; } } }
public void execute() throws IOException { warnIfTransientProvider(); out.println("Deleting credential: " + alias + " from CredentialProvider: " + provider.toString()); if (cont) { try { provider.deleteCredentialEntry(alias); out.println("Credential " + alias + " has been successfully deleted."); provider.flush(); printProviderWritten(); } catch (IOException e) { out.println("Credential " + alias + " has NOT been deleted."); throw e; } } }
public void execute() throws IOException { warnIfTransientProvider(); out.println("Deleting credential: " + alias + " from CredentialProvider: " + provider.toString()); if (cont) { try { provider.deleteCredentialEntry(alias); out.println(alias + " has been successfully deleted."); provider.flush(); printProviderWritten(); } catch (IOException e) { out.println(alias + " has NOT been deleted."); throw e; } } }
public void execute() throws IOException, NoSuchAlgorithmException { warnIfTransientProvider(); try { char[] credential = null; if (value != null) { // testing only credential = value.toCharArray(); } else { credential = promptForCredential(); } provider.createCredentialEntry(alias, credential); out.println(alias + " has been successfully created."); provider.flush(); printProviderWritten(); } catch (InvalidParameterException e) { out.println(alias + " has NOT been created. " + e.getMessage()); throw e; } catch (IOException e) { out.println(alias + " has NOT been created. " + e.getMessage()); throw e; } }
public void execute() throws IOException, NoSuchAlgorithmException { warnIfTransientProvider(); try { char[] credential = null; if (value != null) { // testing only credential = value.toCharArray(); } else { credential = promptForCredential(); } provider.createCredentialEntry(alias, credential); out.println(alias + " has been successfully created."); provider.flush(); printProviderWritten(); } catch (InvalidParameterException e) { out.println(alias + " has NOT been created. " + e.getMessage()); throw e; } catch (IOException e) { out.println(alias + " has NOT been created. " + e.getMessage()); throw e; } }
public void execute() throws IOException, NoSuchAlgorithmException { warnIfTransientProvider(); try { char[] credential = null; if (value != null) { // testing only credential = value.toCharArray(); } else { credential = promptForCredential(); } provider.createCredentialEntry(alias, credential); out.println(alias + " has been successfully created."); provider.flush(); printProviderWritten(); } catch (InvalidParameterException e) { out.println(alias + " has NOT been created. " + e.getMessage()); throw e; } catch (IOException e) { out.println(alias + " has NOT been created. " + e.getMessage()); throw e; } }
public void execute() throws IOException, NoSuchAlgorithmException { warnIfTransientProvider(); try { char[] credential = null; if (value != null) { // testing only credential = value.toCharArray(); } else { credential = promptForCredential(); } provider.createCredentialEntry(alias, credential); provider.flush(); out.println(alias + " has been successfully created."); printProviderWritten(); } catch (InvalidParameterException e) { out.println("Credential " + alias + " has NOT been created. " + e.getMessage()); throw e; } catch (IOException e) { out.println("Credential " + alias + " has NOT been created. " + e.getMessage()); throw e; } }
void provisionAccountKey( final Configuration conf, String account, String key) throws Exception { // add our creds to the provider final CredentialProvider provider = CredentialProviderFactory.getProviders(conf).get(0); provider.createCredentialEntry( SimpleKeyProvider.KEY_ACCOUNT_KEY_PREFIX + account, key.toCharArray()); provider.flush(); }
public static void main(String[] args) throws IOException { // prompt for the provider name CredentialProvider provider = getCredentialProvider(textDevice); if(provider != null) { char[] cred; for (String key : KEYS) { cred = getPassword(textDevice, key); // create a credential entry and store it boolean overwrite = true; if (provider.getCredentialEntry(key) != null) { String choice = textDevice.readLine("Entry for %s already exists. Overwrite? (y/n) [y]:", key); overwrite = StringUtils.isEmpty(choice) || choice.equalsIgnoreCase("y"); if (overwrite) { provider.deleteCredentialEntry(key); provider.flush(); provider.createCredentialEntry(key, cred); provider.flush(); textDevice.printf("Entry for %s was overwritten with the new value.\n", key); } else { textDevice.printf("Entry for %s was not overwritten.\n", key); } } else { provider.createCredentialEntry(key, cred); provider.flush(); } } } }
@BeforeClass public static void setup() throws Exception { conf = new Configuration(false); final String ourUrl = UserProvider.SCHEME_NAME + ":///"; conf.set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH, ourUrl); CredentialProvider provider = CredentialProviderFactory.getProviders(conf).get(0); provider.createCredentialEntry(ServerConfig. SENTRY_STORE_JDBC_PASS, passwd); provider.flush(); dataDir = new File(Files.createTempDir(), "sentry_policy_db"); conf.set(ServerConfig.SENTRY_VERIFY_SCHEM_VERSION, "false"); conf.set(ServerConfig.SENTRY_STORE_JDBC_URL, "jdbc:derby:;databaseName=" + dataDir.getPath() + ";create=true"); conf.set(ServerConfig.SENTRY_STORE_JDBC_PASS, "dummy"); conf.setStrings(ServerConfig.ADMIN_GROUPS, adminGroups); conf.set(ServerConfig.SENTRY_STORE_GROUP_MAPPING, ServerConfig.SENTRY_STORE_LOCAL_GROUP_MAPPING); policyFilePath = new File(dataDir, "local_policy_file.ini"); conf.set(ServerConfig.SENTRY_STORE_GROUP_MAPPING_RESOURCE, policyFilePath.getPath()); sentryStore = new SentryStore(conf); }
@BeforeClass public static void setup() throws Exception { conf = new Configuration(true); final String ourUrl = UserProvider.SCHEME_NAME + ":///"; conf.set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH, ourUrl); // THis should be a UserGroupInformation provider CredentialProvider provider = CredentialProviderFactory.getProviders(conf).get(0); // The user credentials are stored as a static variable by UserGrouoInformation provider. // We need to only set the password the first time, an attempt to set it for the second // time fails with an exception. if(provider.getCredentialEntry(ServerConfig.SENTRY_STORE_JDBC_PASS) == null) { provider.createCredentialEntry(ServerConfig.SENTRY_STORE_JDBC_PASS, passwd); provider.flush(); } dataDir = new File(Files.createTempDir(), "sentry_policy_db"); conf.set(ServerConfig.SENTRY_VERIFY_SCHEM_VERSION, "false"); conf.set(ServerConfig.SENTRY_STORE_JDBC_URL, "jdbc:derby:;databaseName=" + dataDir.getPath() + ";create=true"); conf.set(ServerConfig.SENTRY_STORE_JDBC_PASS, "dummy"); conf.setStrings(ServerConfig.ADMIN_GROUPS, adminGroups); conf.set(ServerConfig.SENTRY_STORE_GROUP_MAPPING, ServerConfig.SENTRY_STORE_LOCAL_GROUP_MAPPING); policyFilePath = new File(dataDir, "local_policy_file.ini"); conf.set(ServerConfig.SENTRY_STORE_GROUP_MAPPING_RESOURCE, policyFilePath.getPath()); conf.setInt(ServerConfig.SENTRY_STORE_TRANSACTION_RETRY, 10); }
provider.flush(); } catch (Exception e) { e.printStackTrace();
provider.flush();
provider.flush(); } catch (Exception e) { e.printStackTrace();
provider.flush(); } catch (Exception e) { e.printStackTrace();
public void checkPermissionRetention(Configuration conf, String ourUrl, Path path) throws Exception { CredentialProvider provider = CredentialProviderFactory.getProviders(conf).get(0); // let's add a new credential and flush and check that permissions are still set to 777 char[] cred = new char[32]; for(int i =0; i < cred.length; ++i) { cred[i] = (char) i; } // create a new key try { provider.createCredentialEntry("key5", cred); } catch (Exception e) { e.printStackTrace(); throw e; } provider.flush(); // get a new instance of the provider to ensure it was saved correctly provider = CredentialProviderFactory.getProviders(conf).get(0); assertArrayEquals(cred, provider.getCredentialEntry("key5").getCredential()); FileSystem fs = path.getFileSystem(conf); FileStatus s = fs.getFileStatus(path); assertTrue("Permissions should have been retained from the preexisting " + "keystore.", s.getPermission().toString().equals("rwxrwxrwx")); } }
public void checkPermissionRetention(Configuration conf, String ourUrl, Path path) throws Exception { CredentialProvider provider = CredentialProviderFactory.getProviders(conf).get(0); // let's add a new credential and flush and check that permissions are still set to 777 char[] cred = new char[32]; for(int i =0; i < cred.length; ++i) { cred[i] = (char) i; } // create a new key try { provider.createCredentialEntry("key5", cred); } catch (Exception e) { e.printStackTrace(); throw e; } provider.flush(); // get a new instance of the provider to ensure it was saved correctly provider = CredentialProviderFactory.getProviders(conf).get(0); assertArrayEquals(cred, provider.getCredentialEntry("key5").getCredential()); FileSystem fs = path.getFileSystem(conf); FileStatus s = fs.getFileStatus(path); assertTrue("Permissions should have been retained from the preexisting " + "keystore.", s.getPermission().toString().equals("rwxrwxrwx")); } }