Java 类org.apache.hadoop.security.ProviderUtils 实例源码

项目:hadoop-oss    文件:TestCredentialProviderFactory.java   
@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);
}
项目:hadoop-oss    文件:TestCredentialProviderFactory.java   
@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);
}
项目:hadoop    文件:TestCredentialProviderFactory.java   
@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);
}
项目:hadoop-oss    文件:ReEncryptionClientProvider.java   
public ReEncryptionClientProvider(URI uri, Configuration conf) throws IOException {
  setConf(conf);
  renUrl = createServiceURL(ProviderUtils.unnestUri(uri));
  if ("https".equalsIgnoreCase(new URL(renUrl).getProtocol())) {
    sslFactory = new SSLFactory(SSLFactory.Mode.CLIENT, conf);
    try {
      sslFactory.init();
    } catch (GeneralSecurityException ex) {
      throw new IOException(ex);
    }
  }
  int timeout = conf.getInt(TIMEOUT_ATTR, DEFAULT_TIMEOUT);
  authRetry = conf.getInt(AUTH_RETRY, DEFAULT_AUTH_RETRY);
  configurator = new TimeoutConnConfigurator(timeout, sslFactory);

  authToken = new DelegationTokenAuthenticatedURL.Token();
  UserGroupInformation.AuthenticationMethod authMethod =
      UserGroupInformation.getCurrentUser().getAuthenticationMethod();
  if (authMethod == UserGroupInformation.AuthenticationMethod.PROXY) {
    actualUgi = UserGroupInformation.getCurrentUser().getRealUser();
  } else if (authMethod == UserGroupInformation.AuthenticationMethod.TOKEN) {
    actualUgi = UserGroupInformation.getLoginUser();
  } else {
    actualUgi =UserGroupInformation.getCurrentUser();
  }
}
项目:hadoop    文件:TestCredentialProviderFactory.java   
@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);
}
项目:aliyun-oss-hadoop-fs    文件:TestS3Credentials.java   
@Test
public void testCredentialProvider() throws Exception {
  // set up conf to have a cred provider
  final Configuration conf = new Configuration();
  final File file = tempDir.newFile("test.jks");
  final URI jks = ProviderUtils.nestURIForLocalJavaKeyStoreProvider(
      file.toURI());
  conf.set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH,
      jks.toString());

  // add our creds to the provider
  final CredentialProvider provider =
      CredentialProviderFactory.getProviders(conf).get(0);
  provider.createCredentialEntry("fs.s3.awsSecretAccessKey",
      EXAMPLE_KEY.toCharArray());
  provider.flush();

  // make sure S3Creds can retrieve things.
  S3Credentials s3Credentials = new S3Credentials();
  conf.set("fs.s3.awsAccessKeyId", EXAMPLE_ID);
  s3Credentials.initialize(new URI("s3://foobar"), conf);
  assertEquals("Could not retrieve proper access key", EXAMPLE_ID,
      s3Credentials.getAccessKey());
  assertEquals("Could not retrieve proper secret", EXAMPLE_KEY,
      s3Credentials.getSecretAccessKey());
}
项目:aliyun-oss-hadoop-fs    文件:TestCredentialProviderFactory.java   
@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);
}
项目:aliyun-oss-hadoop-fs    文件:TestCredentialProviderFactory.java   
@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);
}
项目:big-c    文件:TestCredentialProviderFactory.java   
@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);
}
项目:big-c    文件:TestCredentialProviderFactory.java   
@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);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestCredentialProviderFactory.java   
@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);
}
项目:hops    文件:TestCredentialProviderFactory.java   
@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("rw-------"));
  assertTrue(file + " should exist", file.isFile());

  // check permission retention after explicit change
  fs.setPermission(path, new FsPermission("777"));
  checkPermissionRetention(conf, ourUrl, path);
}
项目:hops    文件:TestCredentialProviderFactory.java   
@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("rw-------"));
  assertTrue(file + " should exist", file.isFile());

  // check permission retention after explicit change
  fs.setPermission(path, new FsPermission("777"));
  checkPermissionRetention(conf, ourUrl, path);
}
项目:hadoop-oss    文件:AbstractJavaKeyStoreProvider.java   
protected void initFileSystem(URI keystoreUri, Configuration conf)
    throws IOException {
  path = ProviderUtils.unnestUri(keystoreUri);
  if (LOG.isDebugEnabled()) {
    LOG.debug("backing jks path initialized to " + path);
  }
}
项目:aliyun-oss-hadoop-fs    文件:AbstractJavaKeyStoreProvider.java   
protected void initFileSystem(URI keystoreUri, Configuration conf)
    throws IOException {
  path = ProviderUtils.unnestUri(keystoreUri);
  if (LOG.isDebugEnabled()) {
    LOG.debug("backing jks path initialized to " + path);
  }
}
项目:hops    文件:AbstractJavaKeyStoreProvider.java   
protected void initFileSystem(URI keystoreUri)
    throws IOException {
  path = ProviderUtils.unnestUri(keystoreUri);
  if (LOG.isDebugEnabled()) {
    LOG.debug("backing jks path initialized to " + path);
  }
}
项目:hops    文件:JavaKeyStoreProvider.java   
private JavaKeyStoreProvider(URI uri, Configuration conf) throws IOException {
  super(conf);
  this.uri = uri;
  path = ProviderUtils.unnestUri(uri);
  fs = path.getFileSystem(conf);
  locateKeystore();
  ReadWriteLock lock = new ReentrantReadWriteLock(true);
  readLock = lock.readLock();
  writeLock = lock.writeLock();
}
项目:hops    文件:TestKeyShell.java   
@Test
public void testStrict() throws Exception {
  outContent.reset();
  int rc = 0;
  KeyShell ks = new KeyShell();
  ks.setConf(new Configuration());
  final String[] args1 = {"create", "hello", "-provider", jceksProvider,
      "-strict"};
  rc = ks.run(args1);
  assertEquals(1, rc);
  assertTrue(outContent.toString()
      .contains(ProviderUtils.NO_PASSWORD_ERROR));
  assertTrue(outContent.toString()
      .contains(ProviderUtils.NO_PASSWORD_INSTRUCTIONS_DOC));
}
项目:hadoop-oss    文件:KMSClientProvider.java   
private static Path extractKMSPath(URI uri) throws MalformedURLException, IOException {
  return ProviderUtils.unnestUri(uri);
}
项目:hadoop-oss    文件:KMSPREClientProvider.java   
private static Path extractKMSPath(URI uri) throws MalformedURLException, IOException {
  return ProviderUtils.unnestUri(uri);
}
项目:hadoop    文件:AbstractJavaKeyStoreProvider.java   
protected void initFileSystem(URI keystoreUri, Configuration conf)
    throws IOException {
  path = ProviderUtils.unnestUri(keystoreUri);
}
项目:hadoop    文件:KMSClientProvider.java   
private static Path extractKMSPath(URI uri) throws MalformedURLException, IOException {
  return ProviderUtils.unnestUri(uri);
}
项目:aliyun-oss-hadoop-fs    文件:KMSClientProvider.java   
private static Path extractKMSPath(URI uri) throws MalformedURLException, IOException {
  return ProviderUtils.unnestUri(uri);
}
项目:big-c    文件:AbstractJavaKeyStoreProvider.java   
protected void initFileSystem(URI keystoreUri, Configuration conf)
    throws IOException {
  path = ProviderUtils.unnestUri(keystoreUri);
}
项目:big-c    文件:KMSClientProvider.java   
private static Path extractKMSPath(URI uri) throws MalformedURLException, IOException {
  return ProviderUtils.unnestUri(uri);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:KMSClientProvider.java   
private static Path extractKMSPath(URI uri) throws MalformedURLException, IOException {
  return ProviderUtils.unnestUri(uri);
}
项目:hops    文件:AbstractJavaKeyStoreProvider.java   
@Override
public boolean needsPassword() throws IOException {
  return (null == ProviderUtils.locatePassword(CREDENTIAL_PASSWORD_ENV_VAR,
      conf.get(CREDENTIAL_PASSWORD_FILE_KEY)));

}