Java Code Examples for org.apache.hadoop.security.ProviderUtils

The following examples show how to use org.apache.hadoop.security.ProviderUtils. These examples are extracted from open source projects. 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 Project: hadoop   Source File: TestCredentialProviderFactory.java    License: 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 Project: hadoop   Source File: TestCredentialProviderFactory.java    License: 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 Project: big-c   Source File: TestCredentialProviderFactory.java    License: 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 Project: big-c   Source File: TestCredentialProviderFactory.java    License: 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 Project: hadoop   Source File: TestCredentialProvider.java    License: 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://[email protected]/my/path?foo=bar&baz=bat#yyy")));
  assertEquals(new Path("inner://[email protected]/my/path"),
      ProviderUtils.unnestUri(new URI("outer://[email protected]@nn1.example.com/my/path")));
  assertEquals(new Path("user:///"),
      ProviderUtils.unnestUri(new URI("outer://user/")));
}
 
Example 6
Source Project: hadoop   Source File: TestKeyProvider.java    License: 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://[email protected]/my/path?foo=bar&baz=bat#yyy")));
  assertEquals(new Path("inner://[email protected]/my/path"),
      ProviderUtils.unnestUri(new URI("outer://[email protected]@nn1.example.com/my/path")));
  assertEquals(new Path("user:///"),
      ProviderUtils.unnestUri(new URI("outer://user/")));
}
 
Example 7
Source Project: big-c   Source File: TestCredentialProvider.java    License: 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://[email protected]/my/path?foo=bar&baz=bat#yyy")));
  assertEquals(new Path("inner://[email protected]/my/path"),
      ProviderUtils.unnestUri(new URI("outer://[email protected]@nn1.example.com/my/path")));
  assertEquals(new Path("user:///"),
      ProviderUtils.unnestUri(new URI("outer://user/")));
}
 
Example 8
Source Project: big-c   Source File: TestKeyProvider.java    License: 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://[email protected]/my/path?foo=bar&baz=bat#yyy")));
  assertEquals(new Path("inner://[email protected]/my/path"),
      ProviderUtils.unnestUri(new URI("outer://[email protected]@nn1.example.com/my/path")));
  assertEquals(new Path("user:///"),
      ProviderUtils.unnestUri(new URI("outer://user/")));
}
 
Example 9
Source Project: hadoop   Source File: AbstractJavaKeyStoreProvider.java    License: 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 Project: hadoop   Source File: KMSClientProvider.java    License: 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 Project: big-c   Source File: AbstractJavaKeyStoreProvider.java    License: 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 Project: big-c   Source File: KMSClientProvider.java    License: 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 Project: ranger   Source File: KmsKeyMgr.java    License: 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 Project: ranger   Source File: KMSClient.java    License: Apache License 2.0 4 votes vote down vote up
private static Path extractKMSPath(URI uri) throws MalformedURLException,
		IOException {
	return ProviderUtils.unnestUri(uri);
}