Elffuss BraidHub

kikocis/java-driver public

Merge branch '2.0' into 2.1
Changesetbe0906c620fd8a58866609cdaa2e75437a16cd5f9e972c032fc678a41c894d56
Authorolim7t <omichallat+github@gmail.com> · 2016-01-26 18:36 +01:00
Committerolim7t <omichallat+github@gmail.com> · 2016-01-26 18:36 +01:00
Parents430ca1214a5d, 68d7d54014b4

Browse the files at this changeset

7 files changed

modified driver-dist/pom.xml +0 −6
@@ -41,12 +41,6 @@
4141 <version>${project.parent.version}</version>
4242 </dependency>
4343
44- <dependency>
45- <groupId>com.datastax.cassandra</groupId>
46- <artifactId>cassandra-driver-dse</artifactId>
47- <version>${project.parent.version}</version>
48- </dependency>
49-
5044 <dependency>
5145 <groupId>com.datastax.cassandra</groupId>
5246 <artifactId>cassandra-driver-mapping</artifactId>
modified driver-dist/src/assembly/binary-tarball.xml +0 −1
@@ -26,7 +26,6 @@
2626 <useAllReactorProjects>true</useAllReactorProjects>
2727 <includes>
2828 <include>com.datastax.cassandra:cassandra-driver-core</include>
29- <include>com.datastax.cassandra:cassandra-driver-dse</include>
3029 <include>com.datastax.cassandra:cassandra-driver-mapping</include>
3130 </includes>
3231 <binaries>
deleted driver-dse/pom.xml +0 −90
@@ -1,90 +0,0 @@
1-<!--
2-
3- Copyright (C) 2012-2015 DataStax Inc.
4-
5- Licensed under the Apache License, Version 2.0 (the "License");
6- you may not use this file except in compliance with the License.
7- You may obtain a copy of the License at
8-
9- http://www.apache.org/licenses/LICENSE-2.0
10-
11- Unless required by applicable law or agreed to in writing, software
12- distributed under the License is distributed on an "AS IS" BASIS,
13- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14- See the License for the specific language governing permissions and
15- limitations under the License.
16-
17--->
18-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
19- <modelVersion>4.0.0</modelVersion>
20- <parent>
21- <groupId>com.datastax.cassandra</groupId>
22- <artifactId>cassandra-driver-parent</artifactId>
23- <version>2.1.10-SNAPSHOT</version>
24- </parent>
25- <artifactId>cassandra-driver-dse</artifactId>
26- <packaging>bundle</packaging>
27- <name>DataStax Java Driver for Apache Cassandra - DataStax Enterprise Module</name>
28- <description>Extensions to the CQL driver for use with DataStax Enterprise.</description>
29- <url>https://github.com/datastax/java-driver</url>
30-
31- <properties>
32- <main.basedir>${project.parent.basedir}</main.basedir>
33- </properties>
34-
35- <dependencies>
36- <dependency>
37- <groupId>com.datastax.cassandra</groupId>
38- <artifactId>cassandra-driver-core</artifactId>
39- <version>${project.parent.version}</version>
40- </dependency>
41- </dependencies>
42-
43- <build>
44- <plugins>
45- <plugin>
46- <groupId>org.apache.felix</groupId>
47- <artifactId>maven-bundle-plugin</artifactId>
48- <extensions>true</extensions>
49- <version>2.4.0</version>
50- <configuration>
51- <instructions>
52- <Bundle-SymbolicName>com.datastax.driver.dse</Bundle-SymbolicName>
53- <Bundle-Version>${project.version}</Bundle-Version>
54- <_include>-osgi.bnd</_include>
55- </instructions>
56- <supportedProjectTypes>
57- <supportedProjectType>jar</supportedProjectType>
58- <supportedProjectType>bundle</supportedProjectType>
59- <supportedProjectType>pom</supportedProjectType>
60- </supportedProjectTypes>
61- </configuration>
62- </plugin>
63- </plugins>
64- </build>
65-
66- <licenses>
67- <license>
68- <name>Apache 2</name>
69- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
70- <distribution>repo</distribution>
71- <comments>Apache License Version 2.0</comments>
72- </license>
73- </licenses>
74-
75- <scm>
76- <connection>scm:git:git@github.com:datastax/java-driver.git</connection>
77- <developerConnection>scm:git:git@github.com:datastax/java-driver.git</developerConnection>
78- <url>https://github.com/datastax/java-driver</url>
79- <tag>HEAD</tag>
80- </scm>
81-
82- <developers>
83- <developer>
84- <name>Various</name>
85- <organization>DataStax</organization>
86- </developer>
87- </developers>
88-
89-</project>
90-
deleted driver-dse/src/main/java/com/datastax/driver/auth/DseAuthProvider.java +0 −84
@@ -1,84 +0,0 @@
1-/*
2- * Copyright (C) 2012-2015 DataStax Inc.
3- *
4- * Licensed under the Apache License, Version 2.0 (the "License");
5- * you may not use this file except in compliance with the License.
6- * You may obtain a copy of the License at
7- *
8- * http://www.apache.org/licenses/LICENSE-2.0
9- *
10- * Unless required by applicable law or agreed to in writing, software
11- * distributed under the License is distributed on an "AS IS" BASIS,
12- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13- * See the License for the specific language governing permissions and
14- * limitations under the License.
15- */
16-package com.datastax.driver.auth;
17-
18-import com.datastax.driver.core.AuthProvider;
19-import com.datastax.driver.core.Authenticator;
20-import com.datastax.driver.core.exceptions.AuthenticationException;
21-
22-import java.net.InetSocketAddress;
23-
24-/**
25- * AuthProvider which supplies authenticator instances for clients to connect t
26- * DSE clusters secured with Kerberos
27- * <p/>
28- * The SASL protocol name defaults to "dse"; should you need to change that
29- * it can be overridden using the <code>dse.sasl.protocol</code> system property.
30- * <p/>
31- * Keytab and ticket cache settings are specified using a standard JAAS
32- * configuration file. The location of the file can be set using the
33- * <code>java.security.auth.login.config</code> system property or by adding a
34- * <code>login.config.url.n</code> entry in the <code>java.security</code> properties
35- * file.
36- * <p/>
37- * See the following documents for further details on the
38- * <a href="https://docs.oracle.com/javase/6/docs/technotes/guides/security/jgss/tutorials/LoginConfigFile.html">JAAS Login Configuration File</a> and the
39- * <a href="http://docs.oracle.com/javase/6/docs/technotes/guides/security/jaas/tutorials/GeneralAcnOnly.html">JAAS Authentication Tutorial</a>
40- * for more on JAAS in general.
41- * <p/>
42- * <h1>Authentication using ticket cache</h1>
43- * Run <code>kinit</code> to obtain a ticket and populate the cache before
44- * connecting. JAAS config:
45- * <p/>
46- * <pre>
47- * DseClient {
48- * com.sun.security.auth.module.Krb5LoginModule required
49- * useTicketCache=true
50- * renewTGT=true;
51- * };
52- * </pre>
53- * <p/>
54- * <p/>
55- * <h1>Authentication using a keytab file</h1>
56- * To enable authentication using a keytab file, specify its location on disk.
57- * If your keytab contains more than one principal key, you should also specify
58- * which one to select.
59- * <p/>
60- * <pre>
61- * DseClient {
62- * com.sun.security.auth.module.Krb5LoginModule required
63- * useKeyTab=true
64- * keyTab="/path/to/file.keytab"
65- * principal="user@MYDOMAIN.COM";
66- * };
67- * </pre>
68- * <p/>
69- * To connect to clusters using internal authentication, use the standard method for
70- * setting credentials. eg:
71- * <p/>
72- * <pre>
73- * Cluster cluster = Cluster.builder()
74- * .addContactPoint(hostname)
75- * .withCredentials("username", "password")
76- * .build();
77- * </pre>
78- */
79-public class DseAuthProvider implements AuthProvider {
80- @Override
81- public Authenticator newAuthenticator(InetSocketAddress host) throws AuthenticationException {
82- return new KerberosAuthenticator(host);
83- }
84-}
deleted driver-dse/src/main/java/com/datastax/driver/auth/KerberosAuthenticator.java +0 −89
@@ -1,89 +0,0 @@
1-/*
2- * Copyright (C) 2012-2015 DataStax Inc.
3- *
4- * Licensed under the Apache License, Version 2.0 (the "License");
5- * you may not use this file except in compliance with the License.
6- * You may obtain a copy of the License at
7- *
8- * http://www.apache.org/licenses/LICENSE-2.0
9- *
10- * Unless required by applicable law or agreed to in writing, software
11- * distributed under the License is distributed on an "AS IS" BASIS,
12- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13- * See the License for the specific language governing permissions and
14- * limitations under the License.
15- */
16-package com.datastax.driver.auth;
17-
18-import com.datastax.driver.core.Authenticator;
19-import org.slf4j.Logger;
20-import org.slf4j.LoggerFactory;
21-
22-import javax.security.auth.Subject;
23-import javax.security.auth.login.LoginContext;
24-import javax.security.auth.login.LoginException;
25-import java.net.InetSocketAddress;
26-
27-/**
28- * Responsible for authenticating with secured DSE services using Kerberos
29- * over GSSAPI &amp; SASL. The actual SASL negotiation is delegated to a
30- * PrivilegedSaslClient which performs the priviledged actions on behalf
31- * of the logged in user.
32- */
33-public class KerberosAuthenticator implements Authenticator {
34- private static final Logger logger = LoggerFactory.getLogger(KerberosAuthenticator.class);
35-
36- public static final String JAAS_CONFIG_ENTRY = "DseClient";
37- public static final String[] SUPPORTED_MECHANISMS = new String[]{"GSSAPI"};
38- public static final String SASL_PROTOCOL_NAME = "dse";
39- public static final String SASL_PROTOCOL_NAME_PROPERTY = "dse.sasl.protocol";
40-
41- private final PrivilegedSaslClient saslClient;
42-
43- public KerberosAuthenticator(InetSocketAddress host) {
44- saslClient = new PrivilegedSaslClient(loginSubject(),
45- SUPPORTED_MECHANISMS,
46- null,
47- System.getProperty(SASL_PROTOCOL_NAME_PROPERTY, SASL_PROTOCOL_NAME),
48- host.getAddress().getCanonicalHostName(),
49- PrivilegedSaslClient.DEFAULT_PROPERTIES,
50- null);
51- }
52-
53- private Subject loginSubject() {
54- Subject subject = new Subject();
55- try {
56- LoginContext login = new LoginContext(JAAS_CONFIG_ENTRY, subject);
57- login.login();
58- return subject;
59- } catch (LoginException e) {
60- throw new RuntimeException(e);
61- }
62- }
63-
64- @Override
65- public byte[] initialResponse() {
66- return saslClient.getInitialResponse();
67- }
68-
69- @Override
70- public byte[] evaluateChallenge(byte[] challenge) {
71- byte[] response = saslClient.evaluateChallenge(challenge);
72- if (response == null) {
73- // If we generate a null response, then authentication has completed (if
74- // not, warn), and return without sending a response back to the server.
75- logger.trace("Response to server is null: authentication should now be complete.");
76- if (!saslClient.isComplete()) {
77- String error = "Client generated a null sasl response, but authentication is not complete.";
78- logger.error(error);
79- throw new RuntimeException(error);
80- }
81- }
82- return response;
83- }
84-
85- @Override
86- public void onAuthenticationSuccess(byte[] token) {
87- // no-op
88- }
89-}
deleted driver-dse/src/main/java/com/datastax/driver/auth/PrivilegedSaslClient.java +0 −144
@@ -1,144 +0,0 @@
1-/*
2- * Copyright (C) 2012-2015 DataStax Inc.
3- *
4- * Licensed under the Apache License, Version 2.0 (the "License");
5- * you may not use this file except in compliance with the License.
6- * You may obtain a copy of the License at
7- *
8- * http://www.apache.org/licenses/LICENSE-2.0
9- *
10- * Unless required by applicable law or agreed to in writing, software
11- * distributed under the License is distributed on an "AS IS" BASIS,
12- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13- * See the License for the specific language governing permissions and
14- * limitations under the License.
15- */
16-package com.datastax.driver.auth;
17-
18-import org.slf4j.Logger;
19-import org.slf4j.LoggerFactory;
20-
21-import javax.security.auth.Subject;
22-import javax.security.auth.callback.CallbackHandler;
23-import javax.security.sasl.Sasl;
24-import javax.security.sasl.SaslClient;
25-import javax.security.sasl.SaslException;
26-import java.security.PrivilegedAction;
27-import java.util.HashMap;
28-import java.util.Map;
29-
30-/**
31- * Wrapper around {@code SaslClient}, which performs necessary parts of
32- * the authentication protocol as {@code PrivilegedAction}s with the
33- * assumed identity of the {@code Subject} supplied in the constructor.
34- */
35-public class PrivilegedSaslClient {
36- private static final Logger logger = LoggerFactory.getLogger(PrivilegedSaslClient.class);
37-
38- public static final Map<String, String> DEFAULT_PROPERTIES = new HashMap<String, String>() {{
39- put(Sasl.SERVER_AUTH, "true");
40- put(Sasl.QOP, "auth");
41- }};
42- private static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
43-
44- /**
45- * Used to respond to server challenges with SASL tokens
46- * represented as byte arrays.
47- */
48- private final SaslClient saslClient;
49-
50- /**
51- * The identity we intend to use when we authenticate with the server
52- */
53- private Subject clientIdentity;
54-
55- public PrivilegedSaslClient(final Subject clientIdentity,
56- final String[] mechanisms,
57- final String authzId,
58- final String protocol,
59- final String hostname,
60- final Map<String, String> properties,
61- final CallbackHandler callbackHandler) {
62- logger.trace("Initalising SASL client");
63- this.clientIdentity = clientIdentity;
64- saslClient = Subject.doAs(this.clientIdentity, new PrivilegedAction<SaslClient>() {
65- @Override
66- public javax.security.sasl.SaslClient run() {
67- try {
68- return Sasl.createSaslClient(
69- mechanisms,
70- authzId,
71- protocol,
72- hostname,
73- properties,
74- callbackHandler);
75- } catch (Exception e) {
76- logger.error("Error initialising SASL client", e);
77- throw new RuntimeException(e);
78- }
79- }
80- });
81- logger.trace("SASL client initialised");
82- }
83-
84-
85- /**
86- * Generate an initial token to start the SASL handshake with server.
87- *
88- * @return SaslTokenRequestMessage message to be sent to server.
89- */
90- public byte[] getInitialResponse() {
91- logger.trace("Initialising SASL handshake from client");
92- byte[] initialResponse = null;
93- if (saslClient.hasInitialResponse()) {
94- initialResponse = Subject.doAs(clientIdentity, new PrivilegedAction<byte[]>() {
95- @Override
96- public byte[] run() {
97- try {
98- return saslClient.evaluateChallenge(EMPTY_BYTE_ARRAY);
99- } catch (Exception e) {
100- throw new RuntimeException(e);
101- }
102- }
103- });
104- }
105- return initialResponse;
106- }
107-
108- /**
109- * Respond to server's SASL token
110- *
111- * @param challenge contains server's SASL token
112- * @return client's response SASL token, which will be null if authentication is complete
113- */
114- public byte[] evaluateChallenge(final byte[] challenge) {
115- logger.trace("Evaluating SASL server token");
116- if (saslClient.isComplete()) {
117- return null;
118- }
119- byte[] retval = Subject.doAs(clientIdentity, new PrivilegedAction<byte[]>() {
120- @Override
121- public byte[] run() {
122- try {
123- logger.trace("SASL client evaluating challenge");
124- byte[] retval = saslClient.evaluateChallenge(challenge);
125- logger.trace("SASL client is complete = " + saslClient.isComplete());
126- return retval;
127- } catch (SaslException e) {
128- logger.error("Failed to generate response to SASL server's token:", e);
129- throw new RuntimeException(e);
130- }
131- }
132- });
133- return retval;
134- }
135-
136- /**
137- * Is the SASL negotiation with the server complete
138- *
139- * @return true iff SASL authentication has successfully completed
140- */
141- public boolean isComplete() {
142- return saslClient.isComplete();
143- }
144-}
modified pom.xml +0 −1
@@ -37,7 +37,6 @@
3737 <module>driver-core</module>
3838 <module>driver-mapping</module>
3939 <module>driver-examples</module>
40- <module>driver-dse</module>
4140 <module>driver-dist</module>
4241 </modules>
4342