Database Reference
In-Depth Information
NOTE
In 0.6, there was no login operation provided by the Thrift API, so if you've gotten used to starting the
CLI and then connecting in a separate operation, that won't work if you are requiring authentication. A
login operation was added in 0.7.
NOTE
In 0.7, authenticators have been split into an IAuthenticator (which handles authentication) and
IAuthority (which handles authorization). The SimpleAuthenticator class has had authorization
split out into SimpleAuthority . SimpleAuthenticator reads only passwd.properties, and Sim-
pleAuthority reads only access.properties.
Programmatic Authentication
If you have set up authentication on your keyspace, your client application code will need to log
in. You can use Example 6-2 as a guide.
Example6-2.Programmatic authentication to a keyspace
package com.cassandraguide.config;
import java.util.HashMap;
import java.util.Map;
import org.apache.cassandra.thrift.AccessLevel;
import org.apache.cassandra.thrift.AuthenticationRequest;
import org.apache.cassandra.thrift.Cassandra;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TFramedTransport;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;
/**
* How to connect if you've set up SimpleAuthenticator
*/
public class AuthExample {
public static void main(String[] args) throws Exception {
TTransport tr = new TSocket("localhost", 9160);
TFramedTransport tf = new TFramedTransport(tr);
Search WWH ::




Custom Search