Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
8b56400
Add new module and add v11 thrift protocol
AngersZhuuuu Oct 22, 2019
e30f686
add pom lincense
AngersZhuuuu Oct 23, 2019
4a50bc9
update code folder name
AngersZhuuuu Oct 23, 2019
7ffdc3b
all like hive
AngersZhuuuu Oct 23, 2019
b74d5e0
remove py/cpp/r/php
AngersZhuuuu Oct 23, 2019
fc2648f
Maven generate thrift source code
wangyum Oct 24, 2019
5365dcf
org.apache.thrift.tools:maven-thrift-plugin -> org.apache.thrift:thri…
wangyum Oct 25, 2019
95d8137
save some basic code
AngersZhuuuu Oct 26, 2019
4dc5c7e
Merge pull request #2 from wangyum/SPARK-29108
AngersZhuuuu Oct 27, 2019
24ce6d4
Merge branch 'SPARK-29018-V11' of https://github.com/AngersZhuuuu/spa…
AngersZhuuuu Oct 27, 2019
5efe8cb
Revert "save some basic code"
AngersZhuuuu Oct 27, 2019
6f7d48a
Update TCLIService.thrift
AngersZhuuuu Oct 27, 2019
cf24306
Add basic data
AngersZhuuuu Oct 27, 2019
24fce6b
save code
AngersZhuuuu Oct 28, 2019
bc36bdf
change
AngersZhuuuu Oct 28, 2019
c438673
format code
AngersZhuuuu Oct 28, 2019
a7ec8b0
format code
AngersZhuuuu Oct 29, 2019
5cf7eb0
Update SparkSQLEnv.scala
AngersZhuuuu Oct 29, 2019
0023bcb
fix logger conflict
AngersZhuuuu Oct 29, 2019
723450b
fix scala style
AngersZhuuuu Oct 29, 2019
3eb7672
start with execution hive
AngersZhuuuu Oct 29, 2019
5aa4d9d
format code add file header
AngersZhuuuu Oct 29, 2019
782d36b
FOR BUILD spark-thriftserver
AngersZhuuuu Oct 29, 2019
f2b5346
add UT class
AngersZhuuuu Oct 29, 2019
a14a9e9
fix UT case, remove can't supported UT
AngersZhuuuu Oct 29, 2019
e1bb6e1
fix for UT
AngersZhuuuu Oct 29, 2019
74fb240
fix UT
AngersZhuuuu Oct 29, 2019
2f90ed9
fix for UT
AngersZhuuuu Oct 30, 2019
cd92f3f
fix return error
AngersZhuuuu Oct 30, 2019
60dc24f
fix client convert row map
AngersZhuuuu Oct 30, 2019
409a1a3
add UT of TCLIServiceClient
AngersZhuuuu Oct 31, 2019
5771a9b
fix java code style
AngersZhuuuu Oct 31, 2019
77578c3
add processGlobalInitFile
AngersZhuuuu Oct 31, 2019
4f7cbac
Update ThriftServerSessionImpl.scala
AngersZhuuuu Oct 31, 2019
d93ab72
Keep type in scala and remove unused type
AngersZhuuuu Oct 31, 2019
ac9ad54
basic service to java
AngersZhuuuu Oct 31, 2019
795ada1
Handle to java
AngersZhuuuu Oct 31, 2019
63076d3
Operation Type State Status to java
AngersZhuuuu Oct 31, 2019
000443a
Fetch type and orientation to java
AngersZhuuuu Oct 31, 2019
5de2bf9
PatternOrIdentifier to java
AngersZhuuuu Oct 31, 2019
a6b0ed1
Interface to Java
AngersZhuuuu Oct 31, 2019
2e6d221
fix bug
AngersZhuuuu Nov 1, 2019
158b298
remove setApplicationName
AngersZhuuuu Nov 1, 2019
745ca60
Session Basic Class to java
AngersZhuuuu Nov 1, 2019
f62e577
auth and thrift service to java
AngersZhuuuu Nov 1, 2019
5fae842
Update ColumnBasedSet.scala
AngersZhuuuu Nov 1, 2019
fe39db0
Update RowBasedSet.scala
AngersZhuuuu Nov 1, 2019
1c303ba
Update type map
AngersZhuuuu Nov 1, 2019
9a32af8
make RowSetFactory clean
AngersZhuuuu Nov 1, 2019
287c6be
update
AngersZhuuuu Nov 2, 2019
f6a7736
format code
AngersZhuuuu Nov 2, 2019
f8b7351
add thrift file
AngersZhuuuu Nov 6, 2019
272ba3c
not check current java code now
AngersZhuuuu Nov 6, 2019
0de3191
remove import jdk.tools dependency
AngersZhuuuu Nov 6, 2019
6374f42
follow comment
AngersZhuuuu Nov 6, 2019
f464773
Merge branch 'master' into SPARK-29018-V11-STEP4-ADD-TEST
AngersZhuuuu Nov 7, 2019
13da926
fix for `mvn install`
AngersZhuuuu Nov 7, 2019
d0de49f
fix for `mvn install`
AngersZhuuuu Nov 7, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add basic data
  • Loading branch information
AngersZhuuuu committed Oct 27, 2019
commit cf243064c7ea317c2c0406bfd691844c209d5c1e
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.spark.sql.thriftserver.auth;

import javax.security.sasl.AuthenticationException;

/**
* This authentication provider allows any combination of username and password.
*/
public class AnonymousAuthenticationProviderImpl implements PasswdAuthenticationProvider {

@Override
public void Authenticate(String user, String password) throws AuthenticationException {
// no-op authentication
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.spark.sql.thriftserver.auth;

import javax.security.sasl.AuthenticationException;

/**
* This class helps select a {@link PasswdAuthenticationProvider} for a given {@code AuthMethod}.
*/
public final class AuthenticationProviderFactory {

public enum AuthMethods {
LDAP("LDAP"),
PAM("PAM"),
CUSTOM("CUSTOM"),
NONE("NONE");

private final String authMethod;

AuthMethods(String authMethod) {
this.authMethod = authMethod;
}

public String getAuthMethod() {
return authMethod;
}

public static AuthMethods getValidAuthMethod(String authMethodStr)
throws AuthenticationException {
for (AuthMethods auth : AuthMethods.values()) {
if (authMethodStr.equals(auth.getAuthMethod())) {
return auth;
}
}
throw new AuthenticationException("Not a valid authentication method");
}
}

private AuthenticationProviderFactory() {
}

public static PasswdAuthenticationProvider getAuthenticationProvider(AuthMethods authMethod)
throws AuthenticationException {
if (authMethod == AuthMethods.LDAP) {
return new LdapAuthenticationProviderImpl();
} else if (authMethod == AuthMethods.PAM) {
return new PamAuthenticationProviderImpl();
} else if (authMethod == AuthMethods.CUSTOM) {
return new CustomAuthenticationProviderImpl();
} else if (authMethod == AuthMethods.NONE) {
return new AnonymousAuthenticationProviderImpl();
} else {
throw new AuthenticationException("Unsupported authentication method");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.spark.sql.thriftserver.auth;

import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.util.ReflectionUtils;

import javax.security.sasl.AuthenticationException;

/**
* This authentication provider implements the {@code CUSTOM} authentication. It allows a {@link
* PasswdAuthenticationProvider} to be specified at configuration time which may additionally
* implement {@link org.apache.hadoop.conf.Configurable Configurable} to grab Hive's {@link
* org.apache.hadoop.conf.Configuration Configuration}.
*/
public class CustomAuthenticationProviderImpl implements PasswdAuthenticationProvider {

private final PasswdAuthenticationProvider customProvider;

@SuppressWarnings("unchecked")
CustomAuthenticationProviderImpl() {
HiveConf conf = new HiveConf();
Class<? extends PasswdAuthenticationProvider> customHandlerClass =
(Class<? extends PasswdAuthenticationProvider>) conf.getClass(
HiveConf.ConfVars.HIVE_SERVER2_CUSTOM_AUTHENTICATION_CLASS.varname,
PasswdAuthenticationProvider.class);
customProvider = ReflectionUtils.newInstance(customHandlerClass, conf);
}

@Override
public void Authenticate(String user, String password) throws AuthenticationException {
customProvider.Authenticate(user, password);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License. See accompanying LICENSE file.
*/

package org.apache.spark.sql.thriftserver.auth;

public class HttpAuthenticationException extends Exception {

private static final long serialVersionUID = 0;

/**
* @param cause original exception
*/
public HttpAuthenticationException(Throwable cause) {
super(cause);
}

/**
* @param msg exception message
*/
public HttpAuthenticationException(String msg) {
super(msg);
}

/**
* @param msg exception message
* @param cause original exception
*/
public HttpAuthenticationException(String msg, Throwable cause) {
super(msg, cause);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.spark.sql.thriftserver.auth;

import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.spark.sql.thriftserver.ServiceUtils;

import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.directory.InitialDirContext;
import javax.security.sasl.AuthenticationException;
import java.util.Hashtable;

public class LdapAuthenticationProviderImpl implements PasswdAuthenticationProvider {

private final String ldapURL;
private final String baseDN;
private final String ldapDomain;

LdapAuthenticationProviderImpl() {
HiveConf conf = new HiveConf();
ldapURL = conf.getVar(HiveConf.ConfVars.HIVE_SERVER2_PLAIN_LDAP_URL);
baseDN = conf.getVar(HiveConf.ConfVars.HIVE_SERVER2_PLAIN_LDAP_BASEDN);
ldapDomain = conf.getVar(HiveConf.ConfVars.HIVE_SERVER2_PLAIN_LDAP_DOMAIN);
}

@Override
public void Authenticate(String user, String password) throws AuthenticationException {

Hashtable<String, Object> env = new Hashtable<String, Object>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, ldapURL);

// If the domain is available in the config, then append it unless domain is
// already part of the username. LDAP providers like Active Directory use a
// fully qualified user name like [email protected].
if (!hasDomain(user) && ldapDomain != null) {
user = user + "@" + ldapDomain;
}

if (password == null || password.isEmpty() || password.getBytes()[0] == 0) {
throw new AuthenticationException("Error validating LDAP user:" +
" a null or blank password has been provided");
}

// setup the security principal
String bindDN;
if (baseDN == null) {
bindDN = user;
} else {
bindDN = "uid=" + user + "," + baseDN;
}
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, bindDN);
env.put(Context.SECURITY_CREDENTIALS, password);

try {
// Create initial context
Context ctx = new InitialDirContext(env);
ctx.close();
} catch (NamingException e) {
throw new AuthenticationException("Error validating LDAP user", e);
}
}

private boolean hasDomain(String userName) {
return (ServiceUtils.indexOfDomainMatch(userName) > 0);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.spark.sql.thriftserver.auth;

import net.sf.jpam.Pam;
import org.apache.hadoop.hive.conf.HiveConf;

import javax.security.sasl.AuthenticationException;

public class PamAuthenticationProviderImpl implements PasswdAuthenticationProvider {

private final String pamServiceNames;

PamAuthenticationProviderImpl() {
HiveConf conf = new HiveConf();
pamServiceNames = conf.getVar(HiveConf.ConfVars.HIVE_SERVER2_PAM_SERVICES);
}

@Override
public void Authenticate(String user, String password) throws AuthenticationException {

if (pamServiceNames == null || pamServiceNames.trim().isEmpty()) {
throw new AuthenticationException("No PAM services are set.");
}

String[] pamServices = pamServiceNames.split(",");
for (String pamService : pamServices) {
Pam pam = new Pam(pamService);
boolean isAuthenticated = pam.authenticateSuccessful(user, password);
if (!isAuthenticated) {
throw new AuthenticationException(
"Error authenticating with the PAM service: " + pamService);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.spark.sql.thriftserver.auth;

import javax.security.sasl.AuthenticationException;

public interface PasswdAuthenticationProvider {

/**
* The Authenticate method is called by the HiveServer2 authentication layer
* to authenticate users for their requests.
* If a user is to be granted, return nothing/throw nothing.
* When a user is to be disallowed, throw an appropriate {@link AuthenticationException}.
*
* For an example implementation, see {@link LdapAuthenticationProviderImpl}.
*
* @param user The username received over the connection request
* @param password The password received over the connection request
*
* @throws AuthenticationException When a user is found to be
* invalid by the implementation
*/
void Authenticate(String user, String password) throws AuthenticationException;
}
Loading