Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion common/src/java/org/apache/hive/http/HttpServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ ServerConnector createAndAddChannelConnector(int queueSize, Builder b) {
if (!b.useSSL) {
connector = new ServerConnector(webServer, http);
} else {
SslContextFactory sslContextFactory = new SslContextFactory.Server();
SslContextFactory.Server sslContextFactory = new SslContextFactory.Server();
sslContextFactory.setKeyStorePath(b.keyStorePath);
sslContextFactory.setKeyStoreType(b.keyStoreType == null || b.keyStoreType.isEmpty() ?
KeyStore.getDefaultType(): b.keyStoreType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.eclipse.jetty.security.authentication.LoginAuthenticator;
import org.eclipse.jetty.server.Authentication;
import org.eclipse.jetty.server.UserIdentity;
import org.eclipse.jetty.util.B64Code;
import java.util.Base64;

import javax.security.sasl.AuthenticationException;
import javax.servlet.ServletRequest;
Expand All @@ -41,9 +41,9 @@
This class authenticates HS2 web UI via PAM. To authenticate use

* httpGet with header name "Authorization"
* and header value "Basic authB64Code"
* and header value "Basic authBase64Code"

where authB64Code is Base64 string for "login:password"
where authBase64Code is Base64 string for "login:password"
*/

public class PamAuthenticator extends LoginAuthenticator {
Expand Down Expand Up @@ -79,7 +79,8 @@ public Authentication validateRequest(ServletRequest req, ServletResponse res, b
String method = credentials.substring(0, space);
if ("basic".equalsIgnoreCase(method)) {
credentials = credentials.substring(space + 1);
credentials = B64Code.decode(credentials, StandardCharsets.ISO_8859_1);
byte[] decodedBytes = Base64.getDecoder().decode(credentials);
credentials = new String(decodedBytes, StandardCharsets.ISO_8859_1);
int i = credentials.indexOf(':');
if (i > 0) {
String username = credentials.substring(0, i);
Expand Down
4 changes: 4 additions & 0 deletions hcatalog/webhcat/svr/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,10 @@
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
</dependency>
</dependencies>
<build>
<resources>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
import com.sun.jersey.spi.container.servlet.ServletContainer;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
Expand All @@ -35,6 +36,7 @@
import org.apache.hadoop.security.authentication.server.AuthenticationFilter;
import org.apache.hadoop.security.authentication.server.KerberosAuthenticationHandler;
import org.apache.hadoop.hive.common.IPStackUtils;
import org.eclipse.jetty.util.resource.PathResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -204,9 +206,11 @@ public Server runServer(int port)
if (StringUtils.isEmpty(conf.jettyConfiguration())) {
server = new Server(port);
} else {
FileInputStream jettyConf = new FileInputStream(conf.jettyConfiguration());
XmlConfiguration configuration = new XmlConfiguration(jettyConf);
server = (Server)configuration.configure();
Path configPath = Paths.get(conf.jettyConfiguration());
PathResource jettyResource = new PathResource(configPath);

XmlConfiguration configuration = new XmlConfiguration(jettyResource);
server = (Server) configuration.configure();
}

ServletContextHandler root = new ServletContextHandler(server, "/");
Expand Down Expand Up @@ -289,7 +293,7 @@ private Connector createChannelConnector(Server server) {

if (conf.getBoolean(AppConfig.USE_SSL, false)) {
LOG.info("Using SSL for templeton.");
SslContextFactory sslContextFactory = new SslContextFactory.Server();
SslContextFactory.Server sslContextFactory = new SslContextFactory.Server();
sslContextFactory.setKeyStorePath(conf.get(AppConfig.KEY_STORE_PATH, DEFAULT_KEY_STORE_PATH));
sslContextFactory.setKeyStorePassword(conf.get(AppConfig.KEY_STORE_PASSWORD, DEFAULT_KEY_STORE_PASSWORD));
Set<String> excludedSSLProtocols = Sets.newHashSet(Splitter.on(",").trimResults().omitEmptyStrings()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,13 @@
import org.apache.http.StatusLine;
import org.apache.http.util.EntityUtils;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.util.B64Code;
import org.eclipse.jetty.util.StringUtil;
import java.util.Base64;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import java.nio.charset.StandardCharsets;
import com.fasterxml.jackson.databind.ObjectMapper;


Expand Down Expand Up @@ -812,9 +811,9 @@ private String sendAuthMethod(HttpRequestBase method, boolean enableAuth, boolea
}

private void setupAuthHeaders(final HttpRequestBase method) {
String authB64Code =
B64Code.encode(ADMIN_USER + ":" + ADMIN_PASSWORD, StringUtil.__ISO_8859_1);
method.setHeader(HttpHeader.AUTHORIZATION.asString(), "Basic " + authB64Code);
String credentials = ADMIN_USER + ":" + ADMIN_PASSWORD;
String authBase64Code = Base64.getEncoder().encodeToString(credentials.getBytes(StandardCharsets.ISO_8859_1));
method.setHeader(HttpHeader.AUTHORIZATION.asString(), "Basic " + authBase64Code);
}

private Map<String, String> getConfOverlay(final String instanceId) {
Expand Down
2 changes: 1 addition & 1 deletion itests/qtest-druid/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<hive.path.to.root>../..</hive.path.to.root>
<druid.curator.version>4.0.0</druid.curator.version>
<druid.jersey.version>1.19.3</druid.jersey.version>
<druid.jetty.version>9.4.57.v20241219</druid.jetty.version>
<druid.jetty.version>10.0.24</druid.jetty.version>
<druid.derby.version>10.11.1.1</druid.derby.version>
<druid.guava.version>16.0.1</druid.guava.version>
<druid.guice.version>4.1.0</druid.guice.version>
Expand Down
18 changes: 9 additions & 9 deletions packaging/src/license/licenses.xml
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-api</artifactId>
<version>9.4.57.v20241219</version>
<artifactId>websocket-jetty-api</artifactId>
<version>10.0.24</version>
<licenses>
<license>
<name>Apache Software License - Version 2.0</name>
Expand All @@ -313,8 +313,8 @@
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-client</artifactId>
<version>9.4.57.v20241219</version>
<artifactId>websocket-jetty-client</artifactId>
<version>10.0.24</version>
<licenses>
<license>
<name>Apache Software License - Version 2.0</name>
Expand All @@ -337,8 +337,8 @@
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-server</artifactId>
<version>9.4.57.v20241219</version>
<artifactId>websocket-jetty-server</artifactId>
<version>10.0.24</version>
<licenses>
<license>
<name>Apache Software License - Version 2.0</name>
Expand Down Expand Up @@ -507,7 +507,7 @@
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>9.4.57.v20241219</version>
<version>10.0.24</version>
<licenses>
<license>
<name>Apache Software License - Version 2.0</name>
Expand All @@ -531,7 +531,7 @@
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util-ajax</artifactId>
<version>9.4.57.v20241219</version>
<version>10.0.24</version>
<licenses>
<license>
<name>Apache Software License - Version 2.0</name>
Expand All @@ -543,7 +543,7 @@
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>9.4.57.v20241219</version>
<version>10.0.24</version>
<licenses>
<license>
<name>Apache Software License - Version 2.0</name>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
<javax-servlet.version>3.1.0</javax-servlet.version>
<javolution.version>5.5.1</javolution.version>
<jettison.version>1.5.4</jettison.version>
<jetty.version>9.4.57.v20241219</jetty.version>
<jetty.version>10.0.24</jetty.version>
<jersey.version>1.19.4</jersey.version>
<!-- HIVE-28992: only upgrade to newer than 3.25.0 if you tested the prompt -->
<jline.version>3.25.0</jline.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import org.apache.hadoop.hive.shims.ShimLoader;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.util.ExitUtil;
import org.apache.hive.service.ServiceUtils;
import org.apache.hive.service.auth.AuthType;
import org.apache.hive.service.auth.HiveAuthFactory;
import org.apache.hive.service.auth.saml.HiveSamlHttpServlet;
Expand All @@ -56,10 +55,8 @@
import org.apache.thrift.protocol.TProtocolFactory;
import org.apache.thrift.server.TServlet;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.security.ConstraintMapping;
import org.eclipse.jetty.security.ConstraintSecurityHandler;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.Server;
Expand Down Expand Up @@ -126,22 +123,18 @@ public void setThreadFactory(ThreadFactory threadFactory) {
conf.setResponseHeaderSize(responseHeaderSize);
conf.setSendServerVersion(false);
conf.setSendXPoweredBy(false);
final HttpConnectionFactory http = new HttpConnectionFactory(conf) {
public Connection newConnection(Connector connector, EndPoint endPoint) {
Connection connection = super.newConnection(connector, endPoint);
connection.addListener(new Connection.Listener() {
public void onOpened(Connection connection) {
openConnection();
}

public void onClosed(Connection connection) {
closeConnection();
}
});
return connection;
final HttpConnectionFactory http = new HttpConnectionFactory(conf);
http.addBean(new Connection.Listener() {
@Override
public void onOpened(Connection connection) {
openConnection();
}
};

@Override
public void onClosed(Connection connection) {
closeConnection();
}
});
boolean useSsl = hiveConf.getBoolVar(ConfVars.HIVE_SERVER2_USE_SSL);
String schemeName = useSsl ? "https" : "http";

Expand All @@ -163,7 +156,7 @@ public void onClosed(Connection connection) {
if (keyStoreAlgorithm.isEmpty()) {
keyStoreAlgorithm = KeyManagerFactory.getDefaultAlgorithm();
}
SslContextFactory sslContextFactory = new SslContextFactory.Server();
SslContextFactory.Server sslContextFactory = new SslContextFactory.Server();
String[] excludedProtocols = hiveConf.getVar(ConfVars.HIVE_SSL_PROTOCOL_BLACKLIST).split(",");
LOG.info("HTTP Server SSL: adding excluded protocols: " + Arrays.toString(excludedProtocols));
sslContextFactory.addExcludeProtocols(excludedProtocols);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpParams;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.util.B64Code;
import org.eclipse.jetty.util.StringUtil;

import java.util.Base64;
import java.nio.charset.StandardCharsets;

import java.util.List;
import java.util.Optional;
import org.junit.AfterClass;
Expand Down Expand Up @@ -89,8 +88,9 @@ public void testValidCredentialsWithAuthorizationHeader() throws Exception {
httpclient = builder.build();

HttpGet httpGet = new HttpGet("http://" + HOST + ":" + webUIPort + "/jmx");
String authB64Code = B64Code.encode(VALID_USER + ":" + VALID_PASS, StringUtil.__ISO_8859_1);
httpGet.setHeader(HttpHeader.AUTHORIZATION.asString(), "Basic " + authB64Code);
String credentials = VALID_USER + ":" + VALID_PASS;
String authBase64Code = Base64.getEncoder().encodeToString(credentials.getBytes(StandardCharsets.ISO_8859_1));
httpGet.setHeader(HttpHeader.AUTHORIZATION.asString(), "Basic " + authBase64Code);
httpclient.execute(httpGet);

Assert.assertTrue(isAuthorized(httpCookieStore.getCookies()));
Expand All @@ -110,8 +110,9 @@ public void testInvalidCredentialsWithInAuthorizationHeader() throws Exception {
httpclient = builder.build();

HttpGet httpGet = new HttpGet("http://" + HOST + ":" + webUIPort + "/jmx");
String authB64Code = B64Code.encode(INVALID_USER + ":" + INVALID_PASS, StringUtil.__ISO_8859_1);
httpGet.setHeader(HttpHeader.AUTHORIZATION.asString(), "Basic " + authB64Code);
String credentials = INVALID_USER + ":" + INVALID_PASS;
String authBase64Code = Base64.getEncoder().encodeToString(credentials.getBytes(StandardCharsets.ISO_8859_1));
httpGet.setHeader(HttpHeader.AUTHORIZATION.asString(), "Basic " + authBase64Code);
httpclient.execute(httpGet);

Assert.assertFalse(isAuthorized(httpCookieStore.getCookies()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
import org.apache.http.impl.client.HttpClients;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.server.UserIdentity;
import org.eclipse.jetty.util.B64Code;
import org.eclipse.jetty.util.StringUtil;

import java.nio.charset.StandardCharsets;
import java.util.Base64;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
Expand Down Expand Up @@ -90,8 +91,9 @@ public void testAuthorizedConnection() throws Exception {
httpclient = HttpClients.createDefault();

HttpGet httpGet = new HttpGet("http://" + host + ":" + webUIPort);
String authB64Code = B64Code.encode(username + ":" + password, StringUtil.__ISO_8859_1);
httpGet.setHeader(HttpHeader.AUTHORIZATION.asString(), "Basic " + authB64Code);
String credentials = username + ":" + password;
String authBase64Code = Base64.getEncoder().encodeToString(credentials.getBytes(StandardCharsets.ISO_8859_1));
httpGet.setHeader(HttpHeader.AUTHORIZATION.asString(), "Basic " + authBase64Code);
CloseableHttpResponse response = httpclient.execute(httpGet);
Assert.assertTrue(response.toString().contains(Integer.toString(HttpURLConnection.HTTP_OK)));

Expand All @@ -111,8 +113,9 @@ public void testIncorrectUser() throws Exception {
httpclient = HttpClients.createDefault();

HttpGet httpGet = new HttpGet("http://" + host + ":" + webUIPort);
String authB64Code = B64Code.encode(username + ":" + password, StringUtil.__ISO_8859_1);
httpGet.setHeader(HttpHeader.AUTHORIZATION.asString(), "Basic " + authB64Code);
String credentials = username + ":" + password;
String authBase64Code = Base64.getEncoder().encodeToString(credentials.getBytes(StandardCharsets.ISO_8859_1));
httpGet.setHeader(HttpHeader.AUTHORIZATION.asString(), "Basic " + authBase64Code);
CloseableHttpResponse response = httpclient.execute(httpGet);
Assert.assertTrue(response.toString().contains(Integer.toString(HttpURLConnection.HTTP_UNAUTHORIZED)));

Expand All @@ -132,8 +135,9 @@ public void testIncorrectPassword() throws Exception {
httpclient = HttpClients.createDefault();

HttpGet httpGet = new HttpGet("http://" + host + ":" + webUIPort);
String authB64Code = B64Code.encode(username + ":" + password, StringUtil.__ISO_8859_1);
httpGet.setHeader(HttpHeader.AUTHORIZATION.asString(), "Basic " + authB64Code);
String credentials = username + ":" + password;
String authBase64Code = Base64.getEncoder().encodeToString(credentials.getBytes(StandardCharsets.ISO_8859_1));
httpGet.setHeader(HttpHeader.AUTHORIZATION.asString(), "Basic " + authBase64Code);
CloseableHttpResponse response = httpclient.execute(httpGet);
Assert.assertTrue(response.toString().contains(Integer.toString(HttpURLConnection.HTTP_UNAUTHORIZED)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,14 @@

import org.eclipse.jetty.security.ConstraintMapping;
import org.eclipse.jetty.security.ConstraintSecurityHandler;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.server.HttpChannel;
import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.SslConnectionFactory;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.util.security.Constraint;
Expand Down Expand Up @@ -380,9 +382,10 @@ public void setThreadFactory(ThreadFactory threadFactory) {

final HttpConnectionFactory http = new HttpConnectionFactory(httpServerConf);

final SslContextFactory sslContextFactory = ServletSecurity.createSslContextFactory(conf);
final SslContextFactory.Server sslContextFactory = ServletSecurity.createSslContextFactory(conf);
if (sslContextFactory != null) {
connector = new ServerConnector(server, sslContextFactory, http);
connector = new ServerConnector(server, new SslConnectionFactory(sslContextFactory,
HttpVersion.HTTP_1_1.asString()), http);
} else {
connector = new ServerConnector(server, http);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ static void loginServerPrincipal(Configuration conf) throws IOException {
* @return null if no ssl in config, an instance otherwise
* @throws IOException if getting password fails
*/
static SslContextFactory createSslContextFactory(Configuration conf) throws IOException {
static SslContextFactory.Server createSslContextFactory(Configuration conf) throws IOException {
final boolean useSsl = MetastoreConf.getBoolVar(conf, MetastoreConf.ConfVars.USE_SSL);
if (!useSsl) {
return null;
Expand All @@ -359,7 +359,7 @@ static SslContextFactory createSslContextFactory(Configuration conf) throws IOEx
if (LOG.isInfoEnabled()) {
LOG.info("HTTP Server SSL: adding excluded protocols: {}", Arrays.toString(excludedProtocols));
}
SslContextFactory factory = new SslContextFactory.Server();
SslContextFactory.Server factory = new SslContextFactory.Server();
factory.addExcludeProtocols(excludedProtocols);
if (LOG.isInfoEnabled()) {
LOG.info("HTTP Server SSL: SslContextFactory.getExcludeProtocols = {}",
Expand Down
Loading