diff src/ch/ethz/ssh2/auth/ServerAuthenticationManager.java @ 307:071eccdff8ea ganymed

fix java formatting
author Carl Byington <carl@five-ten-sg.com>
date Wed, 30 Jul 2014 14:16:58 -0700
parents d2b303406d63
children
line wrap: on
line diff
--- a/src/ch/ethz/ssh2/auth/ServerAuthenticationManager.java	Wed Jul 30 12:09:51 2014 -0700
+++ b/src/ch/ethz/ssh2/auth/ServerAuthenticationManager.java	Wed Jul 30 14:16:58 2014 -0700
@@ -29,25 +29,22 @@
     }
 
     private void sendresult(AuthenticationResult result) throws IOException {
-        if(AuthenticationResult.SUCCESS == result) {
+        if (AuthenticationResult.SUCCESS == result) {
             PacketUserauthSuccess pus = new PacketUserauthSuccess();
             state.tm.sendAsynchronousMessage(pus.getPayload());
-
             state.tm.removeMessageHandler(this);
             state.tm.registerMessageHandler(this, 50, 79);
-
             state.cm = new ChannelManager(state);
-
             state.flag_auth_completed = true;
-
         }
         else {
             Set<String> remaining_methods = new HashSet<String>();
 
-            if(state.cb_auth != null) {
+            if (state.cb_auth != null) {
                 remaining_methods.addAll(Arrays.asList(
-                        state.cb_auth.getRemainingAuthMethods(state.conn)));
+                                             state.cb_auth.getRemainingAuthMethods(state.conn)));
             }
+
             PacketUserauthFailure puf = new PacketUserauthFailure(remaining_methods,
                     AuthenticationResult.PARTIAL_SUCCESS == result);
             state.tm.sendAsynchronousMessage(puf.getPayload());
@@ -60,68 +57,63 @@
 
     public void handleMessage(byte[] msg) throws IOException {
         /* Ignore all authentication messages after successful auth */
-
-        if(state.flag_auth_completed) {
+        if (state.flag_auth_completed) {
             return;
         }
 
-        if(!state.flag_auth_serviceRequested) {
-			/* Must be PacketServiceRequest */
-
+        if (!state.flag_auth_serviceRequested) {
+            /* Must be PacketServiceRequest */
             PacketServiceRequest psr = new PacketServiceRequest(msg);
 
-            if(!"ssh-userauth".equals(psr.getServiceName())) {
+            if (!"ssh-userauth".equals(psr.getServiceName())) {
                 throw new IOException("SSH protocol error, expected ssh-userauth service request");
             }
 
             PacketServiceAccept psa = new PacketServiceAccept("ssh-userauth");
             state.tm.sendAsynchronousMessage(psa.getPayload());
-
             String banner = state.cb_auth.initAuthentication(state.conn);
 
-            if(banner != null) {
+            if (banner != null) {
                 PacketUserauthBanner pub = new PacketUserauthBanner(banner);
                 state.tm.sendAsynchronousMessage(pub.getPayload());
             }
 
             state.flag_auth_serviceRequested = true;
-
             return;
         }
 
         ServerAuthenticationCallback cb = state.cb_auth;
-
         TypesReader tr = new TypesReader(msg);
         int packet_type = tr.readByte();
 
-        if(packet_type == Packets.SSH_MSG_USERAUTH_REQUEST) {
+        if (packet_type == Packets.SSH_MSG_USERAUTH_REQUEST) {
             String username = tr.readString("UTF-8");
             String service = tr.readString();
             String method = tr.readString();
 
-            if(!"ssh-connection".equals(service)) {
+            if (!"ssh-connection".equals(service)) {
                 sendresult(AuthenticationResult.FAILURE);
                 return;
             }
 
-            if("none".equals(method)) {
-                if(cb != null) {
+            if ("none".equals(method)) {
+                if (cb != null) {
                     sendresult(cb.authenticateWithNone(state.conn, username));
                     return;
                 }
             }
 
-            if("password".equals(method)) {
+            if ("password".equals(method)) {
                 boolean flag_change_pass = tr.readBoolean();
 
-                if(flag_change_pass) {
+                if (flag_change_pass) {
                     sendresult(AuthenticationResult.FAILURE);
                     return;
                 }
 
                 String password = tr.readString("UTF-8");
 
-                if(cb != null) {
+                if (cb != null) {
                     sendresult(cb.authenticateWithPassword(state.conn, username, password));
                     return;
                 }
@@ -130,6 +122,7 @@
             sendresult(AuthenticationResult.FAILURE);
             return;
         }
+
         throw new PacketTypeException(packet_type);
     }
 }