Repository: karaf
Updated Branches:
  refs/heads/master f75ade9f2 -> f7ea3e0cb


Reformat ServerKeyVerifierImpl


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/f7ea3e0c
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/f7ea3e0c
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/f7ea3e0c

Branch: refs/heads/master
Commit: f7ea3e0cb3b6d07953c3fea828cb453405d8c6db
Parents: 0bde580
Author: Christian Schneider <[email protected]>
Authored: Tue Aug 1 14:51:15 2017 +0200
Committer: Christian Schneider <[email protected]>
Committed: Wed Aug 2 10:14:10 2017 +0200

----------------------------------------------------------------------
 .../karaf/shell/ssh/ServerKeyVerifierImpl.java  | 105 +++++++++----------
 1 file changed, 52 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/f7ea3e0c/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ServerKeyVerifierImpl.java
----------------------------------------------------------------------
diff --git 
a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ServerKeyVerifierImpl.java 
b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ServerKeyVerifierImpl.java
index 0d471b4..9cd3494 100644
--- 
a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ServerKeyVerifierImpl.java
+++ 
b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ServerKeyVerifierImpl.java
@@ -32,7 +32,7 @@ public class ServerKeyVerifierImpl implements 
ServerKeyVerifier {
        private final boolean quiet;
 
     private final static String keyChangedMessage =
-                       " 
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ \n" +
+                    " 
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ \n" +
                     " @    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!    
  @ \n" +
                     " 
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ \n" +
                     "IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!\n" +
@@ -44,60 +44,59 @@ public class ServerKeyVerifierImpl implements 
ServerKeyVerifier {
                     "RSA host key has changed and you have requested strict 
checking.\n" +
                     "Host key verification failed.";
 
-       public ServerKeyVerifierImpl(KnownHostsManager knownHostsManager, 
boolean quiet) {
-               this.knownHostsManager = knownHostsManager;
-               this.quiet = quiet;
-       }
-
-       @Override
-       public boolean verifyServerKey(ClientSession sshClientSession,
-                       SocketAddress remoteAddress, PublicKey serverKey) {
-               PublicKey knownKey;
-               try {
-                       knownKey = knownHostsManager.getKnownKey(remoteAddress, 
serverKey.getAlgorithm());
-               } catch (InvalidKeySpecException e) {
-                       System.err.println("Invalid key stored for host " + 
remoteAddress + ". Terminating session.");
-                       return false;
-               }
-               if (knownKey == null) {
-                       boolean confirm;
-                       if (!quiet) {
-                               System.out.println("Connecting to unknown 
server. Add this server to known hosts ? (y/n)");
-                               confirm = getConfirmation();
-                       } else {
-                               System.out.println("Connecting to unknown 
server. Automatically adding to known hosts.");
-                               confirm = true;
-                       }
-                       if (confirm) {
-                               
knownHostsManager.storeKeyForHost(remoteAddress, serverKey);
-                               System.out.println("Storing the server key in 
known_hosts.");
-                       } else {
-                               System.out.println("Aborting connection");
-                       }
-                       return confirm;
-               }
-               
-               boolean verifed = (knownKey.equals(serverKey));
-               if (!verifed) {
-                       System.err.println("Server key for host " + 
remoteAddress + " does not match the stored key !! Terminating session.");
-            System.err.println(keyChangedMessage);
-               }
-               return verifed;
-       }
+    public ServerKeyVerifierImpl(KnownHostsManager knownHostsManager, boolean 
quiet) {
+        this.knownHostsManager = knownHostsManager;
+        this.quiet = quiet;
+    }
 
-       private boolean getConfirmation() {
-               int ch;
-               try {
-                       do {
-                               ch = System.in.read();
-                       } while (ch != 'y' && ch != 'n');
-               } catch (IOException e) {
-                       throw new RuntimeException(e);
-               }
-               boolean confirm = ch == 'y';
-               return confirm;
-       }
+    @Override
+    public boolean verifyServerKey(ClientSession sshClientSession, 
SocketAddress remoteAddress,
+                                   PublicKey serverKey) {
+        PublicKey knownKey;
+        try {
+            knownKey = knownHostsManager.getKnownKey(remoteAddress, 
serverKey.getAlgorithm());
+        } catch (InvalidKeySpecException e) {
+            System.err.println("Invalid key stored for host " + remoteAddress 
+ ". Terminating session.");
+            return false;
+        }
+        if (knownKey == null) {
+            boolean confirm;
+            if (!quiet) {
+                System.out.println("Connecting to unknown server. Add this 
server to known hosts ? (y/n)");
+                confirm = getConfirmation();
+            } else {
+                System.out.println("Connecting to unknown server. 
Automatically adding to known hosts.");
+                confirm = true;
+            }
+            if (confirm) {
+                knownHostsManager.storeKeyForHost(remoteAddress, serverKey);
+                System.out.println("Storing the server key in known_hosts.");
+            } else {
+                System.out.println("Aborting connection");
+            }
+            return confirm;
+        }
 
+        boolean verifed = (knownKey.equals(serverKey));
+        if (!verifed) {
+            System.err.println("Server key for host " + remoteAddress
+                               + " does not match the stored key !! 
Terminating session.");
+            System.err.println(keyChangedMessage);
+        }
+        return verifed;
+    }
 
+    private boolean getConfirmation() {
+        int ch;
+        try {
+            do {
+                ch = System.in.read();
+            } while (ch != 'y' && ch != 'n');
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+        boolean confirm = ch == 'y';
+        return confirm;
+    }
 
 }

Reply via email to