ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/catalina/util/SessionConfig.java

Path
ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/catalina/util/SessionConfig.java
Status
scanned
Type
file
Name
SessionConfig.java
Extension
.java
Programming language
Java
Mime type
text/plain
File type
ASCII text, with CRLF line terminators
Tag

      
    
Rootfs path

      
    
Size
4181 (4.1 KB)
MD5
bff22f659f4490016dbab0a2a6429e2e
SHA1
46683a451e20d6e10f09bd78a8cdb4d717d72042
SHA256
ec0fd87ee03fa22434ad290f7148d9f8ae2086338415996608215b612a30db23
SHA512

      
    
SHA1_git
8f036196b0a6cbff57afe7063f363d66e9099f50
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
SessionConfig.java | 4.1 KB |

/* * 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.catalina.util; import jakarta.servlet.SessionCookieConfig; import org.apache.catalina.Context; public class SessionConfig { private static final String DEFAULT_SESSION_COOKIE_NAME = "JSESSIONID"; private static final String DEFAULT_SESSION_PARAMETER_NAME = "jsessionid"; /** * Determine the name to use for the session cookie for the provided context. * * @param context The context * * @return the cookie name for the context */ public static String getSessionCookieName(Context context) { return getConfiguredSessionCookieName(context, DEFAULT_SESSION_COOKIE_NAME); } /** * Determine the name to use for the session path parameter for the provided context. * * @param context The context * * @return the parameter name for the session */ public static String getSessionUriParamName(Context context) { return getConfiguredSessionCookieName(context, DEFAULT_SESSION_PARAMETER_NAME); } private static String getConfiguredSessionCookieName(Context context, String defaultName) { // Priority is: // 1. Cookie name defined in context // 2. Cookie name configured for app // 3. Default defined by spec if (context != null) { String cookieName = context.getSessionCookieName(); if (cookieName != null && !cookieName.isEmpty()) { return cookieName; } SessionCookieConfig scc = context.getServletContext().getSessionCookieConfig(); cookieName = scc.getName(); if (cookieName != null && !cookieName.isEmpty()) { return cookieName; } } return defaultName; } /** * Determine the value to use for the session cookie path for the provided context. * * @param context The context * * @return the parameter name for the session */ public static String getSessionCookiePath(Context context) { SessionCookieConfig scc = context.getServletContext().getSessionCookieConfig(); String contextPath = context.getSessionCookiePath(); if (contextPath == null || contextPath.isEmpty()) { contextPath = scc.getPath(); } if (contextPath == null || contextPath.isEmpty()) { contextPath = context.getEncodedPath(); } if (context.getSessionCookiePathUsesTrailingSlash()) { // Handle special case of ROOT context where cookies require a path of // '/' but the servlet spec uses an empty string // Also ensure the cookies for a context with a path of /foo don't get // sent for requests with a path of /foobar if (!contextPath.endsWith("/")) { contextPath = contextPath + "/"; } } else { // Only handle special case of ROOT context where cookies require a // path of '/' but the servlet spec uses an empty string if (contextPath.isEmpty()) { contextPath = "/"; } } return contextPath; } private SessionConfig() { // Utility class. Hide default constructor. } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
28.2
Copyrights

      
    
Holders

      
    
Authors

      
    
License detections License expression License expression SPDX
apache_2_0-4bde3f57-78aa-4201-96bf-531cba09e7de apache-2.0 Apache-2.0
URL Start line End line
http://www.apache.org/licenses/LICENSE-2.0 9 9