org.apache.hadoop.security.ProviderUtils Java Examples

The following examples show how to use org.apache.hadoop.security.ProviderUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestCredentialProviderFactory.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #2
Source File: TestCredentialProviderFactory.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #3
Source File: TestCredentialProviderFactory.java    From big-c with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #4
Source File: TestCredentialProviderFactory.java    From big-c with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #5
Source File: TestCredentialProvider.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnnestUri() throws Exception {
  assertEquals(new Path("hdfs://nn.example.com/my/path"),
      ProviderUtils.unnestUri(new URI("myscheme://[email protected]/my/path")));
  assertEquals(new Path("hdfs://nn/my/path?foo=bar&baz=bat#yyy"),
      ProviderUtils.unnestUri(new URI("myscheme://hdfs@nn/my/path?foo=bar&baz=bat#yyy")));
  assertEquals(new Path("inner://[email protected]/my/path"),
      ProviderUtils.unnestUri(new URI("outer://inner@[email protected]/my/path")));
  assertEquals(new Path("user:///"),
      ProviderUtils.unnestUri(new URI("outer://user/")));
}
 
Example #6
Source File: TestKeyProvider.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnnestUri() throws Exception {
  assertEquals(new Path("hdfs://nn.example.com/my/path"),
      ProviderUtils.unnestUri(new URI("myscheme://[email protected]/my/path")));
  assertEquals(new Path("hdfs://nn/my/path?foo=bar&baz=bat#yyy"),
      ProviderUtils.unnestUri(new URI("myscheme://hdfs@nn/my/path?foo=bar&baz=bat#yyy")));
  assertEquals(new Path("inner://[email protected]/my/path"),
      ProviderUtils.unnestUri(new URI("outer://inner@[email protected]/my/path")));
  assertEquals(new Path("user:///"),
      ProviderUtils.unnestUri(new URI("outer://user/")));
}
 
Example #7
Source File: TestCredentialProvider.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnnestUri() throws Exception {
  assertEquals(new Path("hdfs://nn.example.com/my/path"),
      ProviderUtils.unnestUri(new URI("myscheme://[email protected]/my/path")));
  assertEquals(new Path("hdfs://nn/my/path?foo=bar&baz=bat#yyy"),
      ProviderUtils.unnestUri(new URI("myscheme://hdfs@nn/my/path?foo=bar&baz=bat#yyy")));
  assertEquals(new Path("inner://[email protected]/my/path"),
      ProviderUtils.unnestUri(new URI("outer://inner@[email protected]/my/path")));
  assertEquals(new Path("user:///"),
      ProviderUtils.unnestUri(new URI("outer://user/")));
}
 
Example #8
Source File: TestKeyProvider.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnnestUri() throws Exception {
  assertEquals(new Path("hdfs://nn.example.com/my/path"),
      ProviderUtils.unnestUri(new URI("myscheme://[email protected]/my/path")));
  assertEquals(new Path("hdfs://nn/my/path?foo=bar&baz=bat#yyy"),
      ProviderUtils.unnestUri(new URI("myscheme://hdfs@nn/my/path?foo=bar&baz=bat#yyy")));
  assertEquals(new Path("inner://[email protected]/my/path"),
      ProviderUtils.unnestUri(new URI("outer://inner@[email protected]/my/path")));
  assertEquals(new Path("user:///"),
      ProviderUtils.unnestUri(new URI("outer://user/")));
}
 
Example #9
Source File: AbstractJavaKeyStoreProvider.java    From hadoop with Apache License 2.0 4 votes vote down vote up
protected void initFileSystem(URI keystoreUri, Configuration conf)
    throws IOException {
  path = ProviderUtils.unnestUri(keystoreUri);
}
 
Example #10
Source File: KMSClientProvider.java    From hadoop with Apache License 2.0 4 votes vote down vote up
private static Path extractKMSPath(URI uri) throws MalformedURLException, IOException {
  return ProviderUtils.unnestUri(uri);
}
 
Example #11
Source File: AbstractJavaKeyStoreProvider.java    From big-c with Apache License 2.0 4 votes vote down vote up
protected void initFileSystem(URI keystoreUri, Configuration conf)
    throws IOException {
  path = ProviderUtils.unnestUri(keystoreUri);
}
 
Example #12
Source File: KMSClientProvider.java    From big-c with Apache License 2.0 4 votes vote down vote up
private static Path extractKMSPath(URI uri) throws MalformedURLException, IOException {
  return ProviderUtils.unnestUri(uri);
}
 
Example #13
Source File: KmsKeyMgr.java    From ranger with Apache License 2.0 4 votes vote down vote up
private static Path extractKMSPath(URI uri) throws MalformedURLException,IOException {
	return ProviderUtils.unnestUri(uri);
}
 
Example #14
Source File: KMSClient.java    From ranger with Apache License 2.0 4 votes vote down vote up
private static Path extractKMSPath(URI uri) throws MalformedURLException,
		IOException {
	return ProviderUtils.unnestUri(uri);
}