[ 
https://issues.apache.org/jira/browse/HADOOP-10604?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14036042#comment-14036042
 ] 

Uma Maheswara Rao G commented on HADOOP-10604:
----------------------------------------------

Please find my further comments on the latest patch.

CryptoFileSystemTestBase.java:

one cryption zone --> one encryption zone

{code}
FSDataOutputStream out = cryptoFS.create(file);
    int n = data.length/3;
    out.write(data, 0, n);
    out.close();
 {code}
 as practive close them in finally.

{code}
 @Test(timeout=120000)
 {code}
 Format off here


CryptoFileSystem.java:

seems like if we configure path{} as zone, we will allow it as empty keyid? we 
need to validate and refuse this?

underlyingfsschema -> underlyingfsscheme

{code}
for (String zone : zones.split(",")) {
        int kstart = zone.indexOf("{");
        int kend = zone.lastIndexOf("}");
        if (kstart < 0 || kend < 0) {
          throw new IOException("Key id has not configured for encryption " +
              "zone: " + zone);
        }
{code}
path can have ',', so splitting with , would create issues right?


My suggestion was like below:
{code}
  /** Get authority for CFS */
  private String getAuthority(URI underLyingURI) {
    String authority = encodeURIForCFSAuthority(underLyingURI);
    return authority;
  }

  private String encodeURIForCFSAuthority(URI underLyingURI) {
    String encodedUri = underLyingURI.getScheme() + "@";
    if (underLyingURI.getHost() != null) {
      encodedUri += underLyingURI.getHost();
      if (underLyingURI.getPort() != -1) {
        encodedUri += ":";
        encodedUri +=  underLyingURI.getPort();
      }
    }
    else {
      encodedUri += ":";
    }
    return encodedUri;
  }
 {code}

 we can even avoid getAuthority method, because getAuthority and passing uri 
gives the impression like, getting authority string from the passed uri


 When I try to run the test I am seeing the following
 {noformat}
 java.io.IOException: Bad configuration of hadoop.security.key.provider.path at 
jceks://file\tmp\560bda21-4b91-4acd-965d-12040b689b83/keystore.jceks
        at 
org.apache.hadoop.crypto.key.KeyProviderFactory.getProviders(KeyProviderFactory.java:70)
        at 
org.apache.hadoop.crypto.key.KeyShell$Command.getKeyProvider(KeyShell.java:193)
        at 
org.apache.hadoop.crypto.key.KeyShell$CreateCommand.validate(KeyShell.java:426)
        at org.apache.hadoop.crypto.key.KeyShell.run(KeyShell.java:66)
        at 
org.apache.hadoop.fs.CryptoFileSystemTestBase.initKeyStore(CryptoFileSystemTestBase.java:90)
        at 
org.apache.hadoop.fs.TestCryptoFileSystemDecoratingLocalFS.init(TestCryptoFileSystemDecoratingLocalFS.java:30)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at 
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
        at 
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at 
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
        at 
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
        at 
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
        at 
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
        at 
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.net.URISyntaxException: Illegal character in authority at index 
8: jceks://file\tmp\560bda21-4b91-4acd-965d-12040b689b83/keystore.jceks
        at java.net.URI$Parser.fail(Unknown Source)
        at java.net.URI$Parser.parseAuthority(Unknown Source)
        at java.net.URI$Parser.parseHierarchical(Unknown Source)
        at java.net.URI$Parser.parse(Unknown Source)
        at java.net.URI.<init>(Unknown Source)
        at 
org.apache.hadoop.crypto.key.KeyProviderFactory.getProviders(KeyProviderFactory.java:55)
{noformat}
I tried on windows and seems like \t create issue. 



> CryptoFileSystem decorator using xAttrs and KeyProvider
> -------------------------------------------------------
>
>                 Key: HADOOP-10604
>                 URL: https://issues.apache.org/jira/browse/HADOOP-10604
>             Project: Hadoop Common
>          Issue Type: Sub-task
>          Components: fs
>    Affects Versions: fs-encryption (HADOOP-10150 and HDFS-6134)
>            Reporter: Alejandro Abdelnur
>            Assignee: Yi Liu
>             Fix For: fs-encryption (HADOOP-10150 and HDFS-6134)
>
>         Attachments: HADOOP-10604.1.patch, HADOOP-10604.patch
>
>
> A FileSystem implementation that wraps an existing filesystem and provides 
> encryption. It will require the underlying filesystem to support xAttrs. It  
> will use the KeyProvider API to retrieve encryption keys.
> This is mostly the work in the patch HADOOP-10150 minus the crypto streams



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to