vukzeka commented on code in PR #222:
URL: https://github.com/apache/mina-sshd/pull/222#discussion_r871096735


##########
sshd-core/src/main/java/org/apache/sshd/certificate/OpenSshCertificateBuilder.java:
##########
@@ -267,4 +275,38 @@ public OpenSshCertificate sign(KeyPair caKeypair, String 
signatureAlgorithm) thr
 
         return cert;
     }
+
+    /**
+     * Validate if certificate options are correct
+     *
+     * @param options Options
+     */
+    private void validateOptions(List<OpenSshCertificate.CertificateOption> 
options) {
+        if (options != null && !options.isEmpty()) {
+            // check if any duplicates
+            Set<String> names = new HashSet<>();
+            Set<String> duplicates = options.stream().filter(option -> 
!names.add(option.getName()))
+                    .map(option -> option.getName())

Review Comment:
   Done



##########
sshd-core/src/main/java/org/apache/sshd/certificate/OpenSshCertificateBuilder.java:
##########
@@ -267,4 +275,38 @@ public OpenSshCertificate sign(KeyPair caKeypair, String 
signatureAlgorithm) thr
 
         return cert;
     }
+
+    /**
+     * Validate if certificate options are correct
+     *
+     * @param options Options
+     */
+    private void validateOptions(List<OpenSshCertificate.CertificateOption> 
options) {
+        if (options != null && !options.isEmpty()) {
+            // check if any duplicates
+            Set<String> names = new HashSet<>();
+            Set<String> duplicates = options.stream().filter(option -> 
!names.add(option.getName()))
+                    .map(option -> option.getName())
+                    .collect(Collectors.toSet());
+            if (!duplicates.isEmpty()) {
+                throw new IllegalArgumentException("Duplicate option: " + 
String.join(",", duplicates));

Review Comment:
   Done



-- 
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-unsubscr...@mina.apache.org

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


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

Reply via email to