cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eev...@apache.org
Subject svn commit: r1068061 - /cassandra/trunk/drivers/java/src/org/apache/cassandra/cql/driver/Connection.java
Date Mon, 07 Feb 2011 19:20:04 GMT
Author: eevans
Date: Mon Feb  7 19:20:04 2011
New Revision: 1068061

URL: http://svn.apache.org/viewvc?rev=1068061&view=rev
Log:
authentication for Java CQL driver

Patch by Vivek Mishra and eevans for CASSANDRA-1708

Modified:
    cassandra/trunk/drivers/java/src/org/apache/cassandra/cql/driver/Connection.java

Modified: cassandra/trunk/drivers/java/src/org/apache/cassandra/cql/driver/Connection.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/drivers/java/src/org/apache/cassandra/cql/driver/Connection.java?rev=1068061&r1=1068060&r2=1068061&view=diff
==============================================================================
--- cassandra/trunk/drivers/java/src/org/apache/cassandra/cql/driver/Connection.java (original)
+++ cassandra/trunk/drivers/java/src/org/apache/cassandra/cql/driver/Connection.java Mon Feb
 7 19:20:04 2011
@@ -21,6 +21,12 @@
 
 package org.apache.cassandra.cql.driver;
 
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.cassandra.thrift.AuthenticationException;
+import org.apache.cassandra.thrift.AuthenticationRequest;
+import org.apache.cassandra.thrift.AuthorizationException;
 import org.apache.cassandra.thrift.Cassandra;
 import org.apache.cassandra.thrift.Compression;
 import org.apache.cassandra.thrift.CqlResult;
@@ -71,6 +77,26 @@ public class Connection
         logger.info("Connected to {}:{}", hostName, portNo);
     }
     
+
+    /**
+     * Create a new <code>Connection</code> instance.
+     * 
+     * @param hostName hostname or IP address of the remote host
+     * @param portNo TCP port number
+     * @throws AuthorizationException if authorization fails
+     * @throws AuthenticationException for authentication failures
+     * @throws TException on errors encountered issuing the request(s) 
+     */
+    public Connection(String hostName, int portNo, String userName, String password)
+    throws AuthenticationException, AuthorizationException, TException
+    {
+        this(hostName, portNo);
+        
+        Map<String, String> credentials = new HashMap<String, String>();
+        AuthenticationRequest areq = new AuthenticationRequest(credentials);
+        client.login(areq) ;
+    }
+    
     /**
      * Execute a CQL query.
      * 



Mime
View raw message