You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by GitBox <gi...@apache.org> on 2022/05/26 17:29:47 UTC

[GitHub] [mina-sshd] lgoldstein commented on a diff in pull request #213: [SSHD-1254] Client side implementation of host bound pubkey auth

lgoldstein commented on code in PR #213:
URL: https://github.com/apache/mina-sshd/pull/213#discussion_r882909068


##########
sshd-common/src/main/java/org/apache/sshd/common/kex/extension/parser/HostBoundPubkeyAuthentication.java:
##########
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sshd.common.kex.extension.parser;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+
+import org.apache.sshd.common.util.buffer.Buffer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class HostBoundPubkeyAuthentication extends AbstractKexExtensionParser<Integer> {
+
+    public static final String NAME = "publickey-hostbound@openssh.com";
+
+    public static final String AUTH_NAME = "publickey-hostbound-v00@openssh.com";
+
+    public static final HostBoundPubkeyAuthentication INSTANCE = new HostBoundPubkeyAuthentication();
+
+    private static final Logger LOG = LoggerFactory.getLogger(HostBoundPubkeyAuthentication.class);
+
+    public HostBoundPubkeyAuthentication() {
+        super(NAME);
+    }
+
+    @Override
+    public Integer parseExtension(Buffer buffer) throws IOException {
+        return parseExtension(buffer.array(), buffer.rpos(), buffer.available());
+    }
+
+    @Override
+    public Integer parseExtension(byte[] data, int off, int len) throws IOException {
+        return parseExtension((len <= 0) ? "" : new String(data, off, len, StandardCharsets.UTF_8));

Review Comment:
   If `len <= 0` then can return *null* here instead of relying on the called code to throw an exception. It is not a good idea to do code flow control with exception.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org