[ https://issues.apache.org/jira/browse/KNOX-3119?focusedWorklogId=965087&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-965087 ]
ASF GitHub Bot logged work on KNOX-3119: ---------------------------------------- Author: ASF GitHub Bot Created on: 07/Apr/25 15:44 Start Date: 07/Apr/25 15:44 Worklog Time Spent: 10m Work Description: lmccay commented on code in PR #1016: URL: https://github.com/apache/knox/pull/1016#discussion_r2031532007 ########## gateway-service-knoxtoken/src/main/java/org/apache/knox/gateway/service/knoxtoken/ServletContextWrapper.java: ########## @@ -0,0 +1,324 @@ +/* + * 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.knox.gateway.service.knoxtoken; + +import javax.servlet.Filter; +import javax.servlet.FilterRegistration; +import javax.servlet.RequestDispatcher; +import javax.servlet.Servlet; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.ServletRegistration; +import javax.servlet.SessionCookieConfig; +import javax.servlet.SessionTrackingMode; +import javax.servlet.descriptor.JspConfigDescriptor; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Collections; +import java.util.Enumeration; +import java.util.EventListener; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +class ServletContextWrapper implements ServletContext { + private ServletContext delegate; + private Map<String, String> defaultParams; + + ServletContextWrapper(ServletContext delegate) { + this.delegate = delegate; + defaultParams = new HashMap<>(); + } + + @Override + public String getContextPath() { + return delegate.getContextPath(); + } + + @Override + public ServletContext getContext(String uripath) { + return delegate.getContext(uripath); + } + + @Override + public int getMajorVersion() { + return delegate.getMajorVersion(); + } + + @Override + public int getMinorVersion() { + return delegate.getMinorVersion(); + } + + @Override + public int getEffectiveMajorVersion() { + return delegate.getEffectiveMajorVersion(); + } + + @Override + public int getEffectiveMinorVersion() { + return delegate.getEffectiveMinorVersion(); + } + + @Override + public String getMimeType(String file) { + return delegate.getMimeType(file); + } + + @Override + public Set<String> getResourcePaths(String path) { + return delegate.getResourcePaths(path); + } + + @Override + public URL getResource(String path) throws MalformedURLException { + return delegate.getResource(path); + } + + @Override + public InputStream getResourceAsStream(String path) { + return delegate.getResourceAsStream(path); + } + + @Override + public RequestDispatcher getRequestDispatcher(String path) { + return delegate.getRequestDispatcher(path); + } + + @Override + public RequestDispatcher getNamedDispatcher(String name) { + return delegate.getNamedDispatcher(name); + } + + @Override + public Servlet getServlet(String name) throws ServletException { + return delegate.getServlet(name); + } + + @Override + public Enumeration<Servlet> getServlets() { + return delegate.getServlets(); + } + + @Override + public Enumeration<String> getServletNames() { + return delegate.getServletNames(); + } + + @Override + public void log(String msg) { + delegate.log(msg); + } + + @Override + public void log(Exception exception, String msg) { + delegate.log(exception, msg); + } + + @Override + public void log(String message, Throwable throwable) { + delegate.log(message, throwable); + } + + @Override + public String getRealPath(String path) { + return delegate.getRealPath(path); + } + + @Override + public String getServerInfo() { + return delegate.getServerInfo(); + } + + @Override + public String getInitParameter(String name) { + String value = delegate.getInitParameter(name); + if (value == null) { + value = defaultParams.get(name); + } + return value; + } + + @Override + public Enumeration<String> getInitParameterNames() { + // Add all keys from the overriddenParams map + Set<String> combinedNames = new HashSet<>(defaultParams.keySet()); + + // Add all parameter names from the delegate context + Enumeration<String> delegateNames = delegate.getInitParameterNames(); + while (delegateNames.hasMoreElements()) { + combinedNames.add(delegateNames.nextElement()); Review Comment: Yes, dupes are fine. Messed up the test at first and looked like I was wrong but its okay. :) Issue Time Tracking ------------------- Worklog Id: (was: 965087) Time Spent: 1h 10m (was: 1h) > Tune defaults for config params in CLIENTID API > ----------------------------------------------- > > Key: KNOX-3119 > URL: https://issues.apache.org/jira/browse/KNOX-3119 > Project: Apache Knox > Issue Type: Improvement > Components: Server > Reporter: Larry McCay > Assignee: Larry McCay > Priority: Major > Fix For: 2.2.0 > > Time Spent: 1h 10m > Remaining Estimate: 0h > > There are a number of params that should be set by default for the CLIENTID > extension of the KNOXTOKEN API. This will reduce the likelihood of errors > based on having to explicitly configure these params which are either > required or the logical defaults. > 1. knox.token.exp.server-managed should be enabled by default this service if > based on passcode tokens and requires server state > 2. knox.token.ttl - should be -1 by default to not expire - fight me! :) > 3. knox.token.hash.key should be set by default as well. We need to check > whether this already exists via the AliasService and if not we should > generate it automatically or fail to deploy with appropriate error/exception. -- This message was sent by Atlassian Jira (v8.20.10#820010)