cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eev...@apache.org
Subject svn commit: r921415 - /incubator/cassandra/trunk/src/java/org/apache/cassandra/cli/CliMain.java
Date Wed, 10 Mar 2010 15:58:26 GMT
Author: eevans
Date: Wed Mar 10 15:58:25 2010
New Revision: 921415

URL: http://svn.apache.org/viewvc?rev=921415&view=rev
Log:
cassandra-cli: login() should be optional until it's not

Patch by eevans

Modified:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/cli/CliMain.java

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/cli/CliMain.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/cli/CliMain.java?rev=921415&r1=921414&r2=921415&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/cli/CliMain.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/cli/CliMain.java Wed Mar 10 15:58:25
2010
@@ -97,33 +97,36 @@ public class CliMain
         thriftClient_ = cassandraClient;
         cliClient_ = new CliClient(css_, thriftClient_);
         
-        // Authenticate
-        Map<String, String> credentials = new HashMap<String, String>();
-        credentials.put(SimpleAuthenticator.USERNAME_KEY, css_.username);
-        credentials.put(SimpleAuthenticator.PASSWORD_KEY, css_.password);
-        AuthenticationRequest authRequest = new AuthenticationRequest(credentials);
-        try 
-        {
-            thriftClient_.login(css_.keyspace, authRequest);
-        } 
-        catch (AuthenticationException e) 
+        if ((css_.username != null) && (css_.password != null) && (css_.keyspace
!= null))
         {
-            css_.err.println("Exception during authentication to the cassandra node, " +
-            		"verify you are using correct credentials.");
-            return;
-        } 
-        catch (AuthorizationException e) 
-        {
-            css_.err.println("You are not authorized to use keyspace: " + css_.keyspace);
-            return;
-        } 
-        catch (TException e) 
-        {
-            if (css_.debug)
-                e.printStackTrace();
-            
-            css_.err.println("Login failure. Did you specify 'keyspace', 'username' and 'password'?");
-            return;
+            // Authenticate 
+            Map<String, String> credentials = new HashMap<String, String>();
+            credentials.put(SimpleAuthenticator.USERNAME_KEY, css_.username);
+            credentials.put(SimpleAuthenticator.PASSWORD_KEY, css_.password);
+            AuthenticationRequest authRequest = new AuthenticationRequest(credentials);
+            try 
+            {
+                thriftClient_.login(css_.keyspace, authRequest);
+            } 
+            catch (AuthenticationException e) 
+            {
+                css_.err.println("Exception during authentication to the cassandra node,
" +
+                		"verify you are using correct credentials.");
+                return;
+            } 
+            catch (AuthorizationException e) 
+            {
+                css_.err.println("You are not authorized to use keyspace: " + css_.keyspace);
+                return;
+            } 
+            catch (TException e) 
+            {
+                if (css_.debug)
+                    e.printStackTrace();
+                
+                css_.err.println("Login failure. Did you specify 'keyspace', 'username' and
'password'?");
+                return;
+            }
         }
         
         // Lookup the cluster name, this is to make it clear which cluster the user is connected
to



Mime
View raw message