Elffuss BraidHub

kikocis/java-driver public

c650795a337f · 3.4 KiBRawPermalink
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18package com.datastax.driver.auth;
19
20import com.datastax.driver.core.AuthProvider;
21import com.datastax.driver.core.Authenticator;
22import com.datastax.driver.core.exceptions.AuthenticationException;
23
24import java.net.InetSocketAddress;
25
26/**
27 * AuthProvider which supplies authenticator instances for clients to connect t
28 * DSE clusters secured with Kerberos
29 *
30 * The SASL protocol name defaults to "dse"; should you need to change that
31 * it can be overridden using the <code>dse.sasl.protocol</code> system property.
32 * <p>
33 * Keytab and ticket cache settings are specified using a standard JAAS
34 * configuration file. The location of the file can be set using the
35 * <code>java.security.auth.login.config</code> system property or by adding a
36 * <code>login.config.url.n</code> entry in the <code>java.security</code> properties
37 * file.
38 * <p>
39 * See <a href="http://docs.oracle.com/javase/1.4.2/docs/guide/security/jaas/tutorials/LoginConfigFile.html">http://docs.oracle.com/javase/1.4.2/docs/guide/security/jaas/tutorials/LoginConfigFile.html</a>
40 * for further details on the Login configuration file and
41 * <a href="http://docs.oracle.com/javase/6/docs/technotes/guides/security/jaas/tutorials/GeneralAcnOnly.html">http://docs.oracle.com/javase/6/docs/technotes/guides/security/jaas/tutorials/GeneralAcnOnly.html</a>
42 * for more on JAAS in general.
43 *
44 * <h1>Authentication using ticket cache</h1>
45 * Run <code>kinit</code> to obtain a ticket and populate the cache before
46 * connecting. JAAS config:
47
48 * <pre>
49 * DseClient {
50 * com.sun.security.auth.module.Krb5LoginModule required
51 * useTicketCache=true
52 * renewTGT=true;
53 * };
54 * </pre>
55 *
56 *
57 * <h1>Authentication using a keytab file</h1>
58 * To enable authentication using a keytab file, specify its location on disk.
59 * If your keytab contains more than one principal key, you should also specify
60 * which one to select.
61 *
62 * <pre>
63 * DseClient {
64 * com.sun.security.auth.module.Krb5LoginModule required
65 * useKeyTab=true
66 * keyTab="/path/to/file.keytab"
67 * principal="user@MYDOMAIN.COM";
68 * };
69 * </pre>
70 *
71 * To connect to clusters using internal authentication, use the standard method for
72 * setting credentials. eg:
73 *
74 * <pre>
75 * Cluster cluster = Cluster.builder()
76 * .addContactPoint(hostname)
77 * .withCredentials("username", "password")
78 * .build();
79 * </pre>
80 *
81 */
82public class DseAuthProvider implements AuthProvider
83{
84 @Override
85 public Authenticator newAuthenticator(InetSocketAddress host) throws AuthenticationException
86 {
87 return new KerberosAuthenticator(host);
88 }
89}