[ https://issues.apache.org/jira/browse/HDFS-17606?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17874964#comment-17874964 ]
ASF GitHub Bot commented on HDFS-17606: --------------------------------------- szetszwo commented on code in PR #7005: URL: https://github.com/apache/hadoop/pull/7005#discussion_r1722173386 ########## hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/protocol/datatransfer/sasl/TestCustomizedCallbackHandler.java: ########## @@ -60,4 +60,30 @@ public void testCustomizedCallbackHandler() throws Exception { MyCallbackHandler.class, CustomizedCallbackHandler.class); new SaslServerCallbackHandler(conf, String::toCharArray).handle(callbacks); } + + static class MyCallbackMethod { + public void handleCallback(List<Callback> callbacks, String name, char[] password) + throws UnsupportedCallbackException { + LOG.info("{}: handling {} for {}", getClass().getSimpleName(), callbacks, name); + } + } + + @Test + public void testCustomizedCallbackMethod() throws Exception { + final Configuration conf = new Configuration(); + final Callback[] callbacks = {new MyCallback()}; + + // without setting conf, expect UnsupportedCallbackException + try { + new SaslServerCallbackHandler(conf, String::toCharArray).handle(callbacks); + Assert.fail("Expected UnsupportedCallbackException for " + Arrays.asList(callbacks)); + } catch (UnsupportedCallbackException e) { + LOG.info("The failure is expected", e); + } + + // set conf and expect success + conf.setClass(HdfsClientConfigKeys.DFS_DATA_TRANSFER_SASL_CUSTOMIZEDCALLBACKHANDLER_CLASS_KEY, + MyCallbackMethod.class, Object.class); + new SaslServerCallbackHandler(conf, String::toCharArray).handle(callbacks); Review Comment: Sure, will add both. > Do not require implementing CustomizedCallbackHandler > ----------------------------------------------------- > > Key: HDFS-17606 > URL: https://issues.apache.org/jira/browse/HDFS-17606 > Project: Hadoop HDFS > Issue Type: Improvement > Components: security > Reporter: Tsz-wo Sze > Assignee: Tsz-wo Sze > Priority: Major > Labels: pull-request-available > > HDFS-17576 added a CustomizedCallbackHandler interface which declares the > following method: > {code} > void handleCallback(List<Callback> callbacks, String name, char[] password) > throws UnsupportedCallbackException, IOException; > {code} > This Jira is to allow an implementation to define the handleCallback method > without implementing the CustomizedCallbackHandler interface. It is to avoid > a security provider depending on the HDFS project. -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org