Repository: knox Updated Branches: refs/heads/master c25cd6825 -> 90d433997
KNOX-1168 - Adding few adapter classes (dispatch classes) for backward compatibility Project: http://git-wip-us.apache.org/repos/asf/knox/repo Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/90d43399 Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/90d43399 Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/90d43399 Branch: refs/heads/master Commit: 90d4339973870fbaa9c48eeae6896fefec95035d Parents: c25cd68 Author: Sandeep More <[email protected]> Authored: Wed Jan 24 18:27:46 2018 -0500 Committer: Sandeep More <[email protected]> Committed: Wed Jan 24 18:27:46 2018 -0500 ---------------------------------------------------------------------- gateway-adapter/pom.xml | 32 ++++ .../gateway/audit/log4j/layout/AuditLayout.java | 6 +- .../gateway/dispatch/DefaultDispatch.java | 147 +++++++++++++++++++ .../hadoop/gateway/dispatch/NiFiDispatch.java | 50 +++++++ .../hadoop/gateway/dispatch/NiFiHaDispatch.java | 54 +++++++ .../dispatch/PassAllHeadersDispatch.java | 37 +++++ .../PassAllHeadersNoEncodingDispatch.java | 28 ++++ .../hadoopauth/filter/HadoopAuthFilter.java | 31 ++++ .../hadoop/gateway/hbase/HBaseDispatch.java | 30 ++++ .../hdfs/dispatch/HdfsHttpClientDispatch.java | 46 ++++++ .../hdfs/dispatch/WebHdfsHaDispatch.java | 75 ++++++++++ .../hadoop/gateway/hive/HiveDispatch.java | 42 ++++++ .../hadoop/gateway/hive/HiveHaDispatch.java | 41 ++++++ .../jwt/filter/JWTFederationFilter.java | 53 +++++++ .../jwt/filter/SSOCookieFederationFilter.java | 77 ++++++++++ .../gateway/rm/dispatch/RMHaDispatch.java | 41 ++++++ .../gateway/rm/dispatch/RMUIHaDispatch.java | 41 ++++++ .../shirorealm/KnoxLdapContextFactory.java | 5 + .../gateway/shirorealm/KnoxLdapRealm.java | 5 + .../hadoop/gateway/shirorealm/KnoxPamRealm.java | 9 +- .../hadoop/gateway/storm/StormDispatch.java | 27 ++++ 21 files changed, 873 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/knox/blob/90d43399/gateway-adapter/pom.xml ---------------------------------------------------------------------- diff --git a/gateway-adapter/pom.xml b/gateway-adapter/pom.xml index 51fcadd..b44f9f0 100644 --- a/gateway-adapter/pom.xml +++ b/gateway-adapter/pom.xml @@ -64,6 +64,38 @@ <groupId>org.apache.knox</groupId> <artifactId>gateway-provider-security-shiro</artifactId> </dependency> + <dependency> + <groupId>org.apache.knox</groupId> + <artifactId>gateway-service-webhdfs</artifactId> + </dependency> + <dependency> + <groupId>org.apache.knox</groupId> + <artifactId>gateway-provider-security-jwt</artifactId> + </dependency> + <dependency> + <groupId>org.apache.knox</groupId> + <artifactId>gateway-provider-security-hadoopauth</artifactId> + </dependency> + <dependency> + <groupId>org.apache.knox</groupId> + <artifactId>gateway-service-hbase</artifactId> + </dependency> + <dependency> + <groupId>org.apache.knox</groupId> + <artifactId>gateway-service-hive</artifactId> + </dependency> + <dependency> + <groupId>org.apache.knox</groupId> + <artifactId>gateway-service-nifi</artifactId> + </dependency> + <dependency> + <groupId>org.apache.knox</groupId> + <artifactId>gateway-service-rm</artifactId> + </dependency> + <dependency> + <groupId>org.apache.knox</groupId> + <artifactId>gateway-service-storm</artifactId> + </dependency> </dependencies> </project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/knox/blob/90d43399/gateway-adapter/src/main/java/org/apache/hadoop/gateway/audit/log4j/layout/AuditLayout.java ---------------------------------------------------------------------- diff --git a/gateway-adapter/src/main/java/org/apache/hadoop/gateway/audit/log4j/layout/AuditLayout.java b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/audit/log4j/layout/AuditLayout.java index 612026f..6687d6f 100644 --- a/gateway-adapter/src/main/java/org/apache/hadoop/gateway/audit/log4j/layout/AuditLayout.java +++ b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/audit/log4j/layout/AuditLayout.java @@ -17,14 +17,16 @@ package org.apache.hadoop.gateway.audit.log4j.layout; * the License. */ -import org.apache.log4j.spi.LoggingEvent; - /** * An adapter class that delegate calls to {@link org.apache.knox.gateway.audit.log4j.layout.AuditLayout} * for backwards compatability with package structure. * + * This is class is deprecated and only used for backwards compatibility + * please use + * org.apache.knox.gateway.audit.log4j.layout.AuditLayout * @since 0.14.0 */ +@Deprecated public class AuditLayout extends org.apache.knox.gateway.audit.log4j.layout.AuditLayout { http://git-wip-us.apache.org/repos/asf/knox/blob/90d43399/gateway-adapter/src/main/java/org/apache/hadoop/gateway/dispatch/DefaultDispatch.java ---------------------------------------------------------------------- diff --git a/gateway-adapter/src/main/java/org/apache/hadoop/gateway/dispatch/DefaultDispatch.java b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/dispatch/DefaultDispatch.java new file mode 100644 index 0000000..0b52702 --- /dev/null +++ b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/dispatch/DefaultDispatch.java @@ -0,0 +1,147 @@ +package org.apache.hadoop.gateway.dispatch; + +import org.apache.http.HttpEntity; +import org.apache.http.HttpResponse; +import org.apache.http.client.methods.HttpUriRequest; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Set; + +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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. + */ +public class DefaultDispatch extends org.apache.knox.gateway.dispatch.DefaultDispatch { + @Override + public void init() { + super.init(); + } + + @Override + public void destroy() { + super.destroy(); + } + + @Override + protected int getReplayBufferSize() { + return super.getReplayBufferSize(); + } + + @Override + protected void setReplayBufferSize(int size) { + super.setReplayBufferSize(size); + } + + @Override + protected int getReplayBufferSizeInBytes() { + return super.getReplayBufferSizeInBytes(); + } + + @Override + protected void setReplayBufferSizeInBytes(int size) { + super.setReplayBufferSizeInBytes(size); + } + + @Override + protected void executeRequest(HttpUriRequest outboundRequest, + HttpServletRequest inboundRequest, HttpServletResponse outboundResponse) + throws IOException { + super.executeRequest(outboundRequest, inboundRequest, outboundResponse); + } + + @Override + protected HttpResponse executeOutboundRequest(HttpUriRequest outboundRequest) + throws IOException { + return super.executeOutboundRequest(outboundRequest); + } + + @Override + protected void writeOutboundResponse(HttpUriRequest outboundRequest, + HttpServletRequest inboundRequest, HttpServletResponse outboundResponse, + HttpResponse inboundResponse) throws IOException { + super.writeOutboundResponse(outboundRequest, inboundRequest, + outboundResponse, inboundResponse); + } + + @Override + protected void closeInboundResponse(HttpResponse response, InputStream stream) + throws IOException { + super.closeInboundResponse(response, stream); + } + + /** + * This method provides a hook for specialized credential propagation + * in subclasses. + * + * @param outboundRequest + */ + @Override + protected void addCredentialsToRequest(HttpUriRequest outboundRequest) { + super.addCredentialsToRequest(outboundRequest); + } + + @Override + protected HttpEntity createRequestEntity(HttpServletRequest request) + throws IOException { + return super.createRequestEntity(request); + } + + @Override + public void doGet(URI url, HttpServletRequest request, + HttpServletResponse response) throws IOException, URISyntaxException { + super.doGet(url, request, response); + } + + @Override + public void doOptions(URI url, HttpServletRequest request, + HttpServletResponse response) throws IOException, URISyntaxException { + super.doOptions(url, request, response); + } + + @Override + public void doPut(URI url, HttpServletRequest request, + HttpServletResponse response) throws IOException, URISyntaxException { + super.doPut(url, request, response); + } + + @Override + public void doPost(URI url, HttpServletRequest request, + HttpServletResponse response) throws IOException, URISyntaxException { + super.doPost(url, request, response); + } + + @Override + public void doDelete(URI url, HttpServletRequest request, + HttpServletResponse response) throws IOException, URISyntaxException { + super.doDelete(url, request, response); + } + + @Override + public void doHead(URI url, HttpServletRequest request, + HttpServletResponse response) throws IOException, URISyntaxException { + super.doHead(url, request, response); + } + + @Override + public Set<String> getOutboundResponseExcludeHeaders() { + return super.getOutboundResponseExcludeHeaders(); + } +} http://git-wip-us.apache.org/repos/asf/knox/blob/90d43399/gateway-adapter/src/main/java/org/apache/hadoop/gateway/dispatch/NiFiDispatch.java ---------------------------------------------------------------------- diff --git a/gateway-adapter/src/main/java/org/apache/hadoop/gateway/dispatch/NiFiDispatch.java b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/dispatch/NiFiDispatch.java new file mode 100644 index 0000000..face486 --- /dev/null +++ b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/dispatch/NiFiDispatch.java @@ -0,0 +1,50 @@ +package org.apache.hadoop.gateway.dispatch; + +import org.apache.http.HttpResponse; +import org.apache.http.client.methods.HttpUriRequest; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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. + */ +public class NiFiDispatch extends org.apache.knox.gateway.dispatch.NiFiDispatch { + @Override + protected void executeRequest(HttpUriRequest outboundRequest, + HttpServletRequest inboundRequest, HttpServletResponse outboundResponse) + throws IOException { + super.executeRequest(outboundRequest, inboundRequest, outboundResponse); + } + + /** + * Overridden to provide a spot to modify the outbound response before its stream is closed. + * + * @param outboundRequest + * @param inboundRequest + * @param outboundResponse + * @param inboundResponse + */ + @Override + protected void writeOutboundResponse(HttpUriRequest outboundRequest, + HttpServletRequest inboundRequest, HttpServletResponse outboundResponse, + HttpResponse inboundResponse) throws IOException { + super.writeOutboundResponse(outboundRequest, inboundRequest, + outboundResponse, inboundResponse); + } +} http://git-wip-us.apache.org/repos/asf/knox/blob/90d43399/gateway-adapter/src/main/java/org/apache/hadoop/gateway/dispatch/NiFiHaDispatch.java ---------------------------------------------------------------------- diff --git a/gateway-adapter/src/main/java/org/apache/hadoop/gateway/dispatch/NiFiHaDispatch.java b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/dispatch/NiFiHaDispatch.java new file mode 100644 index 0000000..5bf96d3 --- /dev/null +++ b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/dispatch/NiFiHaDispatch.java @@ -0,0 +1,54 @@ +package org.apache.hadoop.gateway.dispatch; + +import org.apache.http.HttpResponse; +import org.apache.http.client.methods.HttpUriRequest; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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. + */ +public class NiFiHaDispatch extends org.apache.knox.gateway.dispatch.NiFiHaDispatch { + public NiFiHaDispatch() { + super(); + } + + @Override + protected void executeRequest(HttpUriRequest outboundRequest, + HttpServletRequest inboundRequest, HttpServletResponse outboundResponse) + throws IOException { + super.executeRequest(outboundRequest, inboundRequest, outboundResponse); + } + + /** + * Overridden to provide a spot to modify the outbound response before its stream is closed. + * + * @param outboundRequest + * @param inboundRequest + * @param outboundResponse + * @param inboundResponse + */ + @Override + protected void writeOutboundResponse(HttpUriRequest outboundRequest, + HttpServletRequest inboundRequest, HttpServletResponse outboundResponse, + HttpResponse inboundResponse) throws IOException { + super.writeOutboundResponse(outboundRequest, inboundRequest, + outboundResponse, inboundResponse); + } +} http://git-wip-us.apache.org/repos/asf/knox/blob/90d43399/gateway-adapter/src/main/java/org/apache/hadoop/gateway/dispatch/PassAllHeadersDispatch.java ---------------------------------------------------------------------- diff --git a/gateway-adapter/src/main/java/org/apache/hadoop/gateway/dispatch/PassAllHeadersDispatch.java b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/dispatch/PassAllHeadersDispatch.java new file mode 100644 index 0000000..7d8847e --- /dev/null +++ b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/dispatch/PassAllHeadersDispatch.java @@ -0,0 +1,37 @@ +package org.apache.hadoop.gateway.dispatch; + +import java.util.Set; + +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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. + */ +public class PassAllHeadersDispatch extends org.apache.knox.gateway.dispatch.PassAllHeadersDispatch{ + @Override + public void init() { + super.init(); + } + + @Override + public Set<String> getOutboundResponseExcludeHeaders() { + return super.getOutboundResponseExcludeHeaders(); + } + + @Override + public Set<String> getOutboundRequestExcludeHeaders() { + return super.getOutboundRequestExcludeHeaders(); + } +} http://git-wip-us.apache.org/repos/asf/knox/blob/90d43399/gateway-adapter/src/main/java/org/apache/hadoop/gateway/dispatch/PassAllHeadersNoEncodingDispatch.java ---------------------------------------------------------------------- diff --git a/gateway-adapter/src/main/java/org/apache/hadoop/gateway/dispatch/PassAllHeadersNoEncodingDispatch.java b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/dispatch/PassAllHeadersNoEncodingDispatch.java new file mode 100644 index 0000000..d5f5633 --- /dev/null +++ b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/dispatch/PassAllHeadersNoEncodingDispatch.java @@ -0,0 +1,28 @@ +package org.apache.hadoop.gateway.dispatch; + +import javax.servlet.http.HttpServletRequest; +import java.net.URI; + +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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. + */ +public class PassAllHeadersNoEncodingDispatch extends org.apache.knox.gateway.dispatch.PassAllHeadersNoEncodingDispatch { + @Override + public URI getDispatchUrl(HttpServletRequest request) { + return super.getDispatchUrl(request); + } +} http://git-wip-us.apache.org/repos/asf/knox/blob/90d43399/gateway-adapter/src/main/java/org/apache/hadoop/gateway/hadoopauth/filter/HadoopAuthFilter.java ---------------------------------------------------------------------- diff --git a/gateway-adapter/src/main/java/org/apache/hadoop/gateway/hadoopauth/filter/HadoopAuthFilter.java b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/hadoopauth/filter/HadoopAuthFilter.java new file mode 100644 index 0000000..2ba4359 --- /dev/null +++ b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/hadoopauth/filter/HadoopAuthFilter.java @@ -0,0 +1,31 @@ +package org.apache.hadoop.gateway.hadoopauth.filter; + +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import java.util.Properties; + +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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. + */ +public class HadoopAuthFilter extends org.apache.knox.gateway.hadoopauth.filter.HadoopAuthFilter { + + @Override + protected Properties getConfiguration(String configPrefix, + FilterConfig filterConfig) throws ServletException { + return super.getConfiguration(configPrefix, filterConfig); + } +} http://git-wip-us.apache.org/repos/asf/knox/blob/90d43399/gateway-adapter/src/main/java/org/apache/hadoop/gateway/hbase/HBaseDispatch.java ---------------------------------------------------------------------- diff --git a/gateway-adapter/src/main/java/org/apache/hadoop/gateway/hbase/HBaseDispatch.java b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/hbase/HBaseDispatch.java new file mode 100644 index 0000000..327d3b1 --- /dev/null +++ b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/hbase/HBaseDispatch.java @@ -0,0 +1,30 @@ +package org.apache.hadoop.gateway.hbase; + +import javax.servlet.http.HttpServletRequest; +import java.net.URI; + +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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. + */ +@Deprecated +public class HBaseDispatch extends org.apache.knox.gateway.hbase.HBaseDispatch{ + + @Override + public URI getDispatchUrl(HttpServletRequest request) { + return super.getDispatchUrl(request); + } +} http://git-wip-us.apache.org/repos/asf/knox/blob/90d43399/gateway-adapter/src/main/java/org/apache/hadoop/gateway/hdfs/dispatch/HdfsHttpClientDispatch.java ---------------------------------------------------------------------- diff --git a/gateway-adapter/src/main/java/org/apache/hadoop/gateway/hdfs/dispatch/HdfsHttpClientDispatch.java b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/hdfs/dispatch/HdfsHttpClientDispatch.java new file mode 100644 index 0000000..8ba816a --- /dev/null +++ b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/hdfs/dispatch/HdfsHttpClientDispatch.java @@ -0,0 +1,46 @@ +package org.apache.hadoop.gateway.hdfs.dispatch; + +import org.apache.http.HttpEntity; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; + +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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. + */ +public class HdfsHttpClientDispatch extends org.apache.knox.gateway.hdfs.dispatch.HdfsHttpClientDispatch { + + public HdfsHttpClientDispatch() throws ServletException { + super(); + } + + //@Override + /** + * This method ensures that the request InputStream is not acquired + * prior to a dispatch to a component such as a namenode that doesn't + * the request body. The side effect of this is that the client does + * not get a 100 continue from Knox which will trigger the client to + * send the entire payload before redirect to the target component + * like a datanode and have to send it again. + */ + protected HttpEntity createRequestEntity(HttpServletRequest request) + throws IOException { + return super.createRequestEntity(request); + } + +} http://git-wip-us.apache.org/repos/asf/knox/blob/90d43399/gateway-adapter/src/main/java/org/apache/hadoop/gateway/hdfs/dispatch/WebHdfsHaDispatch.java ---------------------------------------------------------------------- diff --git a/gateway-adapter/src/main/java/org/apache/hadoop/gateway/hdfs/dispatch/WebHdfsHaDispatch.java b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/hdfs/dispatch/WebHdfsHaDispatch.java new file mode 100644 index 0000000..6393502 --- /dev/null +++ b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/hdfs/dispatch/WebHdfsHaDispatch.java @@ -0,0 +1,75 @@ +package org.apache.hadoop.gateway.hdfs.dispatch; + +import org.apache.http.HttpResponse; +import org.apache.http.client.methods.HttpUriRequest; +import org.apache.knox.gateway.ha.provider.HaProvider; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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. + */ +public class WebHdfsHaDispatch extends org.apache.knox.gateway.hdfs.dispatch.WebHdfsHaDispatch { + + /** + * @throws ServletException + */ + public WebHdfsHaDispatch() throws ServletException { + super(); + } + + @Override + public void init() { + super.init(); + } + + @Override + public HaProvider getHaProvider() { + return super.getHaProvider(); + } + + @Override + public void setHaProvider(HaProvider haProvider) { + super.setHaProvider(haProvider); + } + + @Override + protected void executeRequest(HttpUriRequest outboundRequest, + HttpServletRequest inboundRequest, HttpServletResponse outboundResponse) + throws IOException { + super.executeRequest(outboundRequest, inboundRequest, outboundResponse); + } + + /** + * Checks for specific outbound response codes/content to trigger a retry or failover + * + * @param outboundRequest + * @param inboundRequest + * @param outboundResponse + * @param inboundResponse + */ + @Override + protected void writeOutboundResponse(HttpUriRequest outboundRequest, + HttpServletRequest inboundRequest, HttpServletResponse outboundResponse, + HttpResponse inboundResponse) throws IOException { + super.writeOutboundResponse(outboundRequest, inboundRequest, + outboundResponse, inboundResponse); + } +} http://git-wip-us.apache.org/repos/asf/knox/blob/90d43399/gateway-adapter/src/main/java/org/apache/hadoop/gateway/hive/HiveDispatch.java ---------------------------------------------------------------------- diff --git a/gateway-adapter/src/main/java/org/apache/hadoop/gateway/hive/HiveDispatch.java b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/hive/HiveDispatch.java new file mode 100644 index 0000000..b26a2b8 --- /dev/null +++ b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/hive/HiveDispatch.java @@ -0,0 +1,42 @@ +package org.apache.hadoop.gateway.hive; + +import org.apache.http.client.methods.HttpUriRequest; + +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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. + */ +public class HiveDispatch extends org.apache.knox.gateway.hive.HiveDispatch{ + @Override + public void init() { + super.init(); + } + + @Override + protected void addCredentialsToRequest(HttpUriRequest request) { + super.addCredentialsToRequest(request); + } + + @Override + public void setBasicAuthPreemptive(boolean basicAuthPreemptive) { + super.setBasicAuthPreemptive(basicAuthPreemptive); + } + + @Override + public boolean isBasicAuthPreemptive() { + return super.isBasicAuthPreemptive(); + } +} http://git-wip-us.apache.org/repos/asf/knox/blob/90d43399/gateway-adapter/src/main/java/org/apache/hadoop/gateway/hive/HiveHaDispatch.java ---------------------------------------------------------------------- diff --git a/gateway-adapter/src/main/java/org/apache/hadoop/gateway/hive/HiveHaDispatch.java b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/hive/HiveHaDispatch.java new file mode 100644 index 0000000..daa0b63 --- /dev/null +++ b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/hive/HiveHaDispatch.java @@ -0,0 +1,41 @@ +package org.apache.hadoop.gateway.hive; + +import org.apache.http.client.methods.HttpUriRequest; + +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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. + */ +public class HiveHaDispatch extends org.apache.knox.gateway.hive.HiveHaDispatch{ + public HiveHaDispatch() { + super(); + } + + @Override + protected void addCredentialsToRequest(HttpUriRequest request) { + super.addCredentialsToRequest(request); + } + + @Override + public void setBasicAuthPreemptive(boolean basicAuthPreemptive) { + super.setBasicAuthPreemptive(basicAuthPreemptive); + } + + @Override + public boolean isBasicAuthPreemptive() { + return super.isBasicAuthPreemptive(); + } +} http://git-wip-us.apache.org/repos/asf/knox/blob/90d43399/gateway-adapter/src/main/java/org/apache/hadoop/gateway/provider/federation/jwt/filter/JWTFederationFilter.java ---------------------------------------------------------------------- diff --git a/gateway-adapter/src/main/java/org/apache/hadoop/gateway/provider/federation/jwt/filter/JWTFederationFilter.java b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/provider/federation/jwt/filter/JWTFederationFilter.java new file mode 100644 index 0000000..15cd5b1 --- /dev/null +++ b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/provider/federation/jwt/filter/JWTFederationFilter.java @@ -0,0 +1,53 @@ +package org.apache.hadoop.gateway.provider.federation.jwt.filter; + +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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. + */ +public class JWTFederationFilter extends org.apache.knox.gateway.provider.federation.jwt.filter.JWTFederationFilter { + + @Override + public void init(FilterConfig filterConfig) throws ServletException { + super.init(filterConfig); + } + + @Override + public void destroy() { + super.destroy(); + } + + @Override + public void doFilter(ServletRequest request, ServletResponse response, + FilterChain chain) throws IOException, ServletException { + super.doFilter(request, response, chain); + } + + @Override + protected void handleValidationError(HttpServletRequest request, + HttpServletResponse response, int status, String error) + throws IOException { + super.handleValidationError(request, response, status, error); + } +} http://git-wip-us.apache.org/repos/asf/knox/blob/90d43399/gateway-adapter/src/main/java/org/apache/hadoop/gateway/provider/federation/jwt/filter/SSOCookieFederationFilter.java ---------------------------------------------------------------------- diff --git a/gateway-adapter/src/main/java/org/apache/hadoop/gateway/provider/federation/jwt/filter/SSOCookieFederationFilter.java b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/provider/federation/jwt/filter/SSOCookieFederationFilter.java new file mode 100644 index 0000000..1e3735c --- /dev/null +++ b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/provider/federation/jwt/filter/SSOCookieFederationFilter.java @@ -0,0 +1,77 @@ +package org.apache.hadoop.gateway.provider.federation.jwt.filter; + +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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. + */ +public class SSOCookieFederationFilter extends org.apache.knox.gateway.provider.federation.jwt.filter.SSOCookieFederationFilter { + + @Override + public void init(FilterConfig filterConfig) throws ServletException { + super.init(filterConfig); + } + + @Override + public void destroy() { + super.destroy(); + } + + @Override + public void doFilter(ServletRequest request, ServletResponse response, + FilterChain chain) throws IOException, ServletException { + super.doFilter(request, response, chain); + } + + @Override + protected void handleValidationError(HttpServletRequest request, + HttpServletResponse response, int status, String error) + throws IOException { + super.handleValidationError(request, response, status, error); + } + + /** + * Encapsulate the acquisition of the JWT token from HTTP cookies within the + * request. + * + * @param req servlet request to get the JWT token from + * @return serialized JWT token + */ + @Override + protected String getJWTFromCookie(HttpServletRequest req) { + return super.getJWTFromCookie(req); + } + + /** + * Create the URL to be used for authentication of the user in the absence of + * a JWT token within the incoming request. + * + * @param request for getting the original request URL + * @return url to use as login url for redirect + */ + @Override + protected String constructLoginURL(HttpServletRequest request) { + return super.constructLoginURL(request); + } +} http://git-wip-us.apache.org/repos/asf/knox/blob/90d43399/gateway-adapter/src/main/java/org/apache/hadoop/gateway/rm/dispatch/RMHaDispatch.java ---------------------------------------------------------------------- diff --git a/gateway-adapter/src/main/java/org/apache/hadoop/gateway/rm/dispatch/RMHaDispatch.java b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/rm/dispatch/RMHaDispatch.java new file mode 100644 index 0000000..78ecddc --- /dev/null +++ b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/rm/dispatch/RMHaDispatch.java @@ -0,0 +1,41 @@ +package org.apache.hadoop.gateway.rm.dispatch; + +import org.apache.knox.gateway.ha.provider.HaProvider; + +import javax.servlet.ServletException; + +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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. + */ +public class RMHaDispatch extends org.apache.knox.gateway.rm.dispatch.RMHaDispatch { + /** + * @throws ServletException + */ + public RMHaDispatch() { + super(); + } + + @Override + public void setHaProvider(HaProvider haProvider) { + super.setHaProvider(haProvider); + } + + @Override + public void init() { + super.init(); + } +} http://git-wip-us.apache.org/repos/asf/knox/blob/90d43399/gateway-adapter/src/main/java/org/apache/hadoop/gateway/rm/dispatch/RMUIHaDispatch.java ---------------------------------------------------------------------- diff --git a/gateway-adapter/src/main/java/org/apache/hadoop/gateway/rm/dispatch/RMUIHaDispatch.java b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/rm/dispatch/RMUIHaDispatch.java new file mode 100644 index 0000000..1700139 --- /dev/null +++ b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/rm/dispatch/RMUIHaDispatch.java @@ -0,0 +1,41 @@ +package org.apache.hadoop.gateway.rm.dispatch; + +import org.apache.knox.gateway.ha.provider.HaProvider; + +import javax.servlet.ServletException; + +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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. + */ +public class RMUIHaDispatch extends org.apache.knox.gateway.rm.dispatch.RMUIHaDispatch { + /** + * @throws ServletException + */ + public RMUIHaDispatch() throws ServletException { + super(); + } + + @Override + public void setHaProvider(HaProvider haProvider) { + super.setHaProvider(haProvider); + } + + @Override + public void init() { + super.init(); + } +} http://git-wip-us.apache.org/repos/asf/knox/blob/90d43399/gateway-adapter/src/main/java/org/apache/hadoop/gateway/shirorealm/KnoxLdapContextFactory.java ---------------------------------------------------------------------- diff --git a/gateway-adapter/src/main/java/org/apache/hadoop/gateway/shirorealm/KnoxLdapContextFactory.java b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/shirorealm/KnoxLdapContextFactory.java index acc726f..c6d2cd4 100644 --- a/gateway-adapter/src/main/java/org/apache/hadoop/gateway/shirorealm/KnoxLdapContextFactory.java +++ b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/shirorealm/KnoxLdapContextFactory.java @@ -24,8 +24,13 @@ import java.util.Hashtable; /** * An adapter class that delegate calls to {@link org.apache.knox.gateway.shirorealm.KnoxLdapContextFactory} * for backwards compatability with package structure. + * + * This is class is deprecated and only used for backwards compatibility + * please use + * org.apache.knox.gateway.shirorealm.KnoxLdapContextFactory * @since 0.14.0 */ +@Deprecated public class KnoxLdapContextFactory extends org.apache.knox.gateway.shirorealm.KnoxLdapContextFactory { /** http://git-wip-us.apache.org/repos/asf/knox/blob/90d43399/gateway-adapter/src/main/java/org/apache/hadoop/gateway/shirorealm/KnoxLdapRealm.java ---------------------------------------------------------------------- diff --git a/gateway-adapter/src/main/java/org/apache/hadoop/gateway/shirorealm/KnoxLdapRealm.java b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/shirorealm/KnoxLdapRealm.java index 75204b0..a2efdb9 100644 --- a/gateway-adapter/src/main/java/org/apache/hadoop/gateway/shirorealm/KnoxLdapRealm.java +++ b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/shirorealm/KnoxLdapRealm.java @@ -31,8 +31,13 @@ import java.util.Map; /** * An adapter class that delegate calls to {@link org.apache.knox.gateway.shirorealm.KnoxLdapRealm} * for backwards compatability with package structure. + * + * This is class is deprecated and only used for backwards compatibility + * please use + * org.apache.knox.gateway.shirorealm.KnoxLdapRealm * @since 0.14.0 */ +@Deprecated public class KnoxLdapRealm extends org.apache.knox.gateway.shirorealm.KnoxLdapRealm { http://git-wip-us.apache.org/repos/asf/knox/blob/90d43399/gateway-adapter/src/main/java/org/apache/hadoop/gateway/shirorealm/KnoxPamRealm.java ---------------------------------------------------------------------- diff --git a/gateway-adapter/src/main/java/org/apache/hadoop/gateway/shirorealm/KnoxPamRealm.java b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/shirorealm/KnoxPamRealm.java index 245d9d5..912a593 100644 --- a/gateway-adapter/src/main/java/org/apache/hadoop/gateway/shirorealm/KnoxPamRealm.java +++ b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/shirorealm/KnoxPamRealm.java @@ -25,9 +25,14 @@ import org.apache.shiro.subject.PrincipalCollection; /** * An adapter class that delegate calls to {@link org.apache.knox.gateway.shirorealm.KnoxPamRealm} - * for backwards compatability with package structure. - * @since 0.14.0 + * for backwards compatibility with package structure. + * + * This is class is deprecated and only used for backwards compatibility + * please use + * org.apache.knox.gateway.shirorealm.KnoxPamRealm + * @since 1.0.0 */ +@Deprecated public class KnoxPamRealm extends org.apache.knox.gateway.shirorealm.KnoxPamRealm { http://git-wip-us.apache.org/repos/asf/knox/blob/90d43399/gateway-adapter/src/main/java/org/apache/hadoop/gateway/storm/StormDispatch.java ---------------------------------------------------------------------- diff --git a/gateway-adapter/src/main/java/org/apache/hadoop/gateway/storm/StormDispatch.java b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/storm/StormDispatch.java new file mode 100644 index 0000000..a262012 --- /dev/null +++ b/gateway-adapter/src/main/java/org/apache/hadoop/gateway/storm/StormDispatch.java @@ -0,0 +1,27 @@ +package org.apache.hadoop.gateway.storm; + +import java.util.Set; + +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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. + */ +public class StormDispatch extends org.apache.knox.gateway.storm.StormDispatch{ + @Override + public Set<String> getOutboundResponseExcludeHeaders() { + return super.getOutboundResponseExcludeHeaders(); + } +}
