@Test public void testJksProvider() throws Exception { Configuration conf = new Configuration(); final Path jksPath = new Path(tmpDir.toString(), "test.jks"); final String ourUrl = JavaKeyStoreProvider.SCHEME_NAME + "://file" + jksPath.toUri(); File file = new File(tmpDir, "test.jks"); file.delete(); conf.set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH, ourUrl); checkSpecificProvider(conf, ourUrl); Path path = ProviderUtils.unnestUri(new URI(ourUrl)); FileSystem fs = path.getFileSystem(conf); FileStatus s = fs.getFileStatus(path); assertTrue(s.getPermission().toString().equals("rwx------")); assertTrue(file + " should exist", file.isFile()); // check permission retention after explicit change fs.setPermission(path, new FsPermission("777")); checkPermissionRetention(conf, ourUrl, path); }
@Test public void testUserProvider() throws Exception { Configuration conf = new Configuration(); final String ourUrl = UserProvider.SCHEME_NAME + ":///"; conf.set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH, ourUrl); checkSpecificProvider(conf, ourUrl); // see if the credentials are actually in the UGI Credentials credentials = UserGroupInformation.getCurrentUser().getCredentials(); assertArrayEquals(new byte[]{'1', '2', '3'}, credentials.getSecretKey(new Text("pass2"))); }
CredentialProvider provider = CredentialProviderFactory.getProviders(conf).get(0); char[] passwd = generatePassword(16);
@Test public void testUserProvider() throws Exception { Configuration conf = new Configuration(); final String ourUrl = UserProvider.SCHEME_NAME + ":///"; conf.set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH, ourUrl); checkSpecificProvider(conf, ourUrl); // see if the credentials are actually in the UGI Credentials credentials = UserGroupInformation.getCurrentUser().getCredentials(); assertArrayEquals(new byte[]{'1', '2', '3'}, credentials.getSecretKey(new Text("pass2"))); }
CredentialProvider provider = CredentialProviderFactory.getProviders(conf).get(0); char[] passwd = generatePassword(16);
@Test public void testJksProvider() throws Exception { Configuration conf = new Configuration(); final Path jksPath = new Path(tmpDir.toString(), "test.jks"); final String ourUrl = JavaKeyStoreProvider.SCHEME_NAME + "://file" + jksPath.toUri(); File file = new File(tmpDir, "test.jks"); file.delete(); conf.set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH, ourUrl); checkSpecificProvider(conf, ourUrl); Path path = ProviderUtils.unnestUri(new URI(ourUrl)); FileSystem fs = path.getFileSystem(conf); FileStatus s = fs.getFileStatus(path); assertTrue(s.getPermission().toString().equals("rwx------")); assertTrue(file + " should exist", file.isFile()); // check permission retention after explicit change fs.setPermission(path, new FsPermission("777")); checkPermissionRetention(conf, ourUrl, path); }
@Test public void testLocalJksProvider() throws Exception { Configuration conf = new Configuration(); final Path jksPath = new Path(tmpDir.toString(), "test.jks"); final String ourUrl = LocalJavaKeyStoreProvider.SCHEME_NAME + "://file" + jksPath.toUri(); File file = new File(tmpDir, "test.jks"); file.delete(); conf.set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH, ourUrl); checkSpecificProvider(conf, ourUrl); Path path = ProviderUtils.unnestUri(new URI(ourUrl)); FileSystem fs = path.getFileSystem(conf); FileStatus s = fs.getFileStatus(path); assertTrue("Unexpected permissions: " + s.getPermission().toString(), s.getPermission().toString().equals("rwx------")); assertTrue(file + " should exist", file.isFile()); // check permission retention after explicit change fs.setPermission(path, new FsPermission("777")); checkPermissionRetention(conf, ourUrl, path); }
@Test public void testLocalJksProvider() throws Exception { Configuration conf = new Configuration(); final Path jksPath = new Path(tmpDir.toString(), "test.jks"); final String ourUrl = LocalJavaKeyStoreProvider.SCHEME_NAME + "://file" + jksPath.toUri(); File file = new File(tmpDir, "test.jks"); file.delete(); conf.set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH, ourUrl); checkSpecificProvider(conf, ourUrl); Path path = ProviderUtils.unnestUri(new URI(ourUrl)); FileSystem fs = path.getFileSystem(conf); FileStatus s = fs.getFileStatus(path); assertTrue("Unexpected permissions: " + s.getPermission().toString(), s.getPermission().toString().equals("rwx------")); assertTrue(file + " should exist", file.isFile()); // check permission retention after explicit change fs.setPermission(path, new FsPermission("777")); checkPermissionRetention(conf, ourUrl, path); }