最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Java Hadoop client library supports Basic Authentication - Stack Overflow

programmeradmin1浏览0评论

I have a Cloudera cluster under knox gateway with basic authentication (username/password). I want to access HDFS (SWebHDFS) through SSL (https) using Java Apache Hadoop client library (Apache Hadoop Client Aggregator » 3.4.1). Using swebhdfs scheme I can see that https is used, but I can't find a way to use basic authentication.

I can successfully use HTTP requests or Java HttpClient to access HDFS, but is it possible to apply basic authentication with the Java Hadoop client library?

Sample code

        Configuration conf = new Configuration();

        conf.set("fs.defaultFS", "swebhdfs://...");
        conf.setBoolean("dfs.webhdfs.enabled", true);
        conf.set("fs.webhdfs.impl", ".apache.hadoop.hdfs.web.SWebHdfsFileSystem");
        conf.set("hadoop.security.authentication", "simple");
        conf.set("dfs.http.policy", "HTTPS_ONLY");
        
        FileSystem fs = FileSystem.get(conf);
        fs.listStatus(new Path("/"));

With the above code I get the error Unexpected HTTP response: code=302 != 200, op=LISTSTATUS, message=Found This is because since basic authentication is not present and hadoop-jwt cokie doesn't exist, Knox tries to redirect to a Sign in form

发布评论

评论列表(0)

  1. 暂无评论