Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2016-2017] [Payara Foundation and/or its affiliates]
package com.sun.enterprise.web;
import com.sun.enterprise.config.serverbeans.Application;
import com.sun.enterprise.config.serverbeans.ConfigBeansUtilities;
import com.sun.enterprise.config.serverbeans.ServerTags;
import com.sun.enterprise.container.common.spi.util.JavaEEIOUtils;
import com.sun.enterprise.deployment.*;
import org.glassfish.web.deployment.annotation.handlers.ServletSecurityHandler;
import com.sun.enterprise.deployment.runtime.web.SunWebApp;
import com.sun.enterprise.deployment.web.*;
import com.sun.enterprise.security.integration.RealmInitializer;
import com.sun.enterprise.universal.GFBase64Decoder;
import com.sun.enterprise.universal.GFBase64Encoder;
import com.sun.enterprise.util.StringUtils;
import com.sun.enterprise.web.deploy.LoginConfigDecorator;
import com.sun.enterprise.web.pwc.PwcWebModule;
import com.sun.enterprise.web.session.PersistenceType;
import com.sun.enterprise.web.session.SessionCookieConfig;
import com.sun.web.security.RealmAdapter;
import org.apache.catalina.*;
import org.apache.catalina.Valve;
import org.apache.catalina.core.*;
import org.apache.catalina.deploy.FilterMaps;
import org.apache.catalina.loader.WebappLoader;
import org.apache.catalina.servlets.DefaultServlet;
import org.apache.catalina.session.StandardManager;
import org.apache.jasper.servlet.JspServlet;
import org.glassfish.api.deployment.DeploymentContext;
import org.glassfish.embeddable.web.Context;
import org.glassfish.embeddable.web.config.FormLoginConfig;
import org.glassfish.embeddable.web.config.LoginConfig;
import org.glassfish.embeddable.web.config.SecurityConfig;
import org.glassfish.embeddable.web.config.TransportGuarantee;
import org.glassfish.hk2.classmodel.reflect.Types;
import org.glassfish.internal.api.ServerContext;
import org.glassfish.logging.annotation.LogMessageInfo;
import org.glassfish.security.common.Role;
import org.glassfish.web.admin.monitor.ServletProbeProvider;
import org.glassfish.web.admin.monitor.SessionProbeProvider;
import org.glassfish.web.admin.monitor.WebModuleProbeProvider;
import org.glassfish.web.deployment.descriptor.*;
import org.glassfish.web.deployment.runtime.SessionConfig;
import org.glassfish.web.deployment.runtime.*;
import org.glassfish.web.loader.ServletContainerInitializerUtil;
import org.glassfish.web.valve.GlassFishValve;
import org.glassfish.hk2.api.ServiceLocator;
import org.jvnet.hk2.config.types.Property;
import javax.annotation.security.DeclareRoles;
import javax.annotation.security.RunAs;
import javax.servlet.*;
import javax.servlet.Servlet;
import javax.servlet.http.HttpUpgradeHandler;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.ServletSecurity;
import javax.servlet.http.HttpSession;
import java.io.*;
import java.lang.ClassLoader;
import java.lang.Object;
import java.lang.String;
import java.lang.reflect.Method;
import java.net.*;
import java.text.MessageFormat;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Class representing a web module for use by the Application Server.
*/
public class WebModule extends PwcWebModule implements Context {
// ----------------------------------------------------- Class Variables
private static final Logger logger = WebContainer.logger;
protected static final ResourceBundle rb = logger.getResourceBundle();
@LogMessageInfo(
message = "Unable to create custom ObjectInputStream",
level = "SEVERE",
cause = "An exception occurred during creating ObjectInputStream",
action = "Check the Exception for error")
public static final String CREATE_CUSTOM_OBJECT_INTPUT_STREAM_ERROR = "AS-WEB-GLUE-00222";
@LogMessageInfo(
message = "Unable to create custom ObjectOutputStream",
level = "SEVERE",
cause = "An exception occurred during creating ObjectOutputStream",
action = "Check the Exception for error")
public static final String CREATE_CUSTOM_BOJECT_OUTPUT_STREAM_ERROR = "AS-WEB-GLUE-00223";
@LogMessageInfo(
message = "The default-locale attribute of locale-charset-info element is being ignored",
level = "WARNING")
public static final String DEFAULT_LOCALE_DEPRECATED = "AS-WEB-GLUE-00224";
@LogMessageInfo(
message = "Realm {0} is not an instance of {1}, and will be ignored",
level = "SEVERE",
cause = "Realm {0} is not an instance of {1}",
action = "Check the Realm")
public static final String IGNORE_INVALID_REALM = "AS-WEB-GLUE-00225";
@LogMessageInfo(
message = "Web module [{0}] has a property with missing name or value",
level = "WARNING")
public static final String NULL_WEB_MODULE_PROPERTY = "AS-WEB-GLUE-00226";
@LogMessageInfo(
message = "Object of type {0} is not a valve",
level = "WARNING")
public static final String VALVE_CLASS_NAME_NO_VALVE = "AS-WEB-GLUE-00227";
@LogMessageInfo(
message = "Unable to add valve to web module {0}",
level = "WARNING")
public static final String VALVE_MISSING_NAME = "AS-WEB-GLUE-00228";
@LogMessageInfo(
message = "Unable to add valve with name {0} to web module {1}",
level = "WARNING")
public static final String VALVE_MISSING_CLASS_NAME = "AS-WEB-GLUE-00229";
@LogMessageInfo(
message = "No method {0}(java.lang.String) defined on valve {1} of web module {2}",
level = "SEVERE",
cause = "A matching method is not found",
action = "Check the method name")
public static final String VALVE_SPECIFIED_METHOD_MISSING = "AS-WEB-GLUE-00230";
@LogMessageInfo(
message = "Exception during execution of method {0} on valve {1} of web module {2}",
level = "SEVERE",
cause = "An exception occurred during method execution",
action = "Check the Exception for error")
public static final String VALVE_SETTER_CAUSED_EXCEPTION = "AS-WEB-GLUE-00231";
@LogMessageInfo(
message = "Valve {0} of web module {1} has a property without any name",
level = "SEVERE",
cause = "The valve is missing property name",
action = "Check the property name")
public static final String VALVE_MISSING_PROPERTY_NAME = "AS-WEB-GLUE-00232";
@LogMessageInfo(
message = "Unable to add listener of type {0} to web module {1}",
level = "WARNING")
public static final String INVALID_LISTENER = "AS-WEB-GLUE-00233";
@LogMessageInfo(
message = "Unable to load extension class {0} from web module {1}",
level = "WARNING")
public static final String UNABLE_TO_LOAD_EXTENSION = "AS-WEB-GLUE-00234";
@LogMessageInfo(
message = "Null property name or value for alternate docbase",
level = "WARNING")
public static final String ALTERNATE_DOC_BASE_NULL_PROPERTY_NAME_VALVE = "AS-WEB-GLUE-00235";
@LogMessageInfo(
message = "Alternate docbase property value {0} is missing a URL pattern or docbase",
level = "WARNING")
public static final String ALTERNATE_DOC_BASE_MISSING_PATH_OR_URL_PATTERN = "AS-WEB-GLUE-00236";
@LogMessageInfo(
message = "URL pattern {0} for alternate docbase is invalid",
level = "WARNING")
public static final String ALTERNATE_DOC_BASE_ILLEGAL_URL_PATTERN = "AS-WEB-GLUE-00237";
@LogMessageInfo(
message = "Failed to parse sun-web.xml singleThreadedServletPoolSize property value ({0}) of web module deployed at {1}, using default ({2})",
level = "WARNING")
public static final String INVALID_SERVLET_POOL_SIZE = "AS-WEB-GLUE-00238";
@LogMessageInfo(
message = "Enabled session ID reuse for web module {0} deployed on virtual server {1}",
level = "WARNING")
public static final String SESSION_IDS_REUSED = "AS-WEB-GLUE-00239";
@LogMessageInfo(
message = "Using alternate deployment descriptor {0} for web module {1}",
level = "FINE")
public static final String ALT_DD_NAME = "AS-WEB-GLUE-00240";
@LogMessageInfo(
message = "Ignoring invalid property {0} = {1}",
level = "WARNING")
public static final String INVALID_PROPERTY = "AS-WEB-GLUE-00241";
@LogMessageInfo(
message = "Unable to save sessions for web module {0} during redeployment",
level = "WARNING")
public static final String UNABLE_TO_SAVE_SESSIONS_DURING_REDEPLOY = "AS-WEB-GLUE-00242";
@LogMessageInfo(
message = "Unable to restore sessions for web module [{0}] from previous deployment",
level = "WARNING")
public static final String UNABLE_TO_RESTORE_SESSIONS_DURING_REDEPLOY = "AS-WEB-GLUE-00243";
@LogMessageInfo(
message = "Webservice based application, requires Metro to be installed. Run updatecenter client located in bin folder to install Metro",
level = "WARNING")
public static final String MISSING_METRO = "AS-WEB-GLUE-00244";
@LogMessageInfo(
message = "WebModule[{0}]: Setting delegate to {1}",
level = "FINE")
public static final String SETTING_DELEGATE = "AS-WEB-GLUE-00245";
@LogMessageInfo(
message = "WebModule[{0}]: Adding {1} to the classpath",
level = "FINE")
public static final String ADDING_CLASSPATH = "AS-WEB-GLUE-00246";
@LogMessageInfo(
message = "extra-class-path component {0} is not a valid pathname",
level = "SEVERE",
cause = "A MalformedURLException occurred",
action = "Check the extra-class-path component")
public static final String CLASSPATH_ERROR = "AS-WEB-GLUE-00247";
@LogMessageInfo(
message = "class-loader attribute dynamic-reload-interval in sun-web.xml not supported",
level = "WARNING")
public static final String DYNAMIC_RELOAD_INTERVAL = "AS-WEB-GLUE-00248";
@LogMessageInfo(
message = "IN WebContainer>>ConfigureSessionManager before builder factory FINAL_PERSISTENCE-TYPE IS = {0} FINAL_PERSISTENCE_FREQUENCY IS = {1} FINAL_PERSISTENCE_SCOPE IS = {2}",
level = "FINEST")
public static final String CONFIGURE_SESSION_MANAGER = "AS-WEB-GLUE-00249";
@LogMessageInfo(
message = "PersistenceStrategyBuilder class = {0}",
level = "FINEST")
public static final String PERSISTENCE_STRATEGY_BUILDER = "AS-WEB-GLUE-00250";
@LogMessageInfo(
message = "Property [{0}] is not yet supported",
level = "INFO")
public static final String PROP_NOT_YET_SUPPORTED = "AS-WEB-GLUE-00251";
@LogMessageInfo(
message = "WebModule[{0}] configure cookie properties {1}",
level = "FINE")
public static final String CONFIGURE_COOKIE_PROPERTIES = "AS-WEB-GLUE-00252";
@LogMessageInfo(
message = "Unable to add listener of type: {0}, because it does not implement any of the required ServletContextListener, ServletContextAttributeListener, ServletRequestListener, ServletRequestAttributeListener, HttpSessionListener, or HttpSessionAttributeListener interfaces",
level = "WARNING")
public static final String INVALID_LISTENER_TYPE = "AS-WEB-GLUE-00253";
private static final String ALTERNATE_FROM = "from=";
private static final String ALTERNATE_DOCBASE = "dir=";
private static final GFBase64Encoder gfEncoder = new GFBase64Encoder();
private static final GFBase64Decoder gfDecoder = new GFBase64Decoder();
private static final String WS_SERVLET_CONTEXT_LISTENER =
"com.sun.xml.ws.transport.http.servlet.WSServletContextListener";
// ----------------------------------------------------- Instance Variables
// Object containing sun-web.xml information
private SunWebAppImpl iasBean = null;
//locale-charset-info tag from sun-web.xml
private LocaleCharsetMap[] _lcMap = null;
/**
* Is the default-web.xml parsed?
*/
private boolean hasBeenXmlConfigured = false;
private WebContainer webContainer;
private final Map adHocPaths;
private boolean hasAdHocPaths;
private final Map adHocSubtrees;
private boolean hasAdHocSubtrees;
private StandardPipeline adHocPipeline;
// File encoding of static resources
private String fileEncoding;
/**
* Cached findXXX results
*/
protected Object[] cachedFinds;
private Application bean;
private WebBundleDescriptor webBundleDescriptor;
private boolean hasStarted = false;
private String compEnvId = null;
private ServerContext serverContext = null;
private ServletProbeProvider servletProbeProvider = null;
private SessionProbeProvider sessionProbeProvider = null;
private WebModuleProbeProvider webModuleProbeProvider = null;
private JavaEEIOUtils javaEEIOUtils;
// The id of the parent container (i.e., virtual server) on which this
// web module was deployed
private String vsId;
private String monitoringNodeName;
private WebModuleConfig wmInfo;
// true if standalone WAR, false if embedded in EAR file
private boolean isStandalone = true;
private ServiceLocator services;
/**
* Constructor.
*/
public WebModule() {
this(null);
}
public WebModule(ServiceLocator services) {
super();
this.services = services;
this.adHocPaths = new HashMap();
this.adHocSubtrees = new HashMap();
this.adHocPipeline = new StandardPipeline(this);
this.adHocPipeline.setBasic(new AdHocContextValve(this));
notifyContainerListeners = false;
}
/**
* set the sun-web.xml config bean
*/
public void setIasWebAppConfigBean(SunWebAppImpl iasBean) {
this.iasBean = iasBean;
}
/**
* gets the sun-web.xml config bean
*/
public SunWebAppImpl getIasWebAppConfigBean() {
return iasBean;
}
/**
* Gets the web container in which this web module was loaded.
*
* @return the web container in which this web module was loaded
*/
public WebContainer getWebContainer() {
return webContainer;
}
/**
* Sets the web container in which this web module was loaded.
*
*/
public void setWebContainer(WebContainer webContainer) {
this.webContainer = webContainer;
this.servletProbeProvider = webContainer.getServletProbeProvider();
this.sessionProbeProvider = webContainer.getSessionProbeProvider();
this.webModuleProbeProvider =
webContainer.getWebModuleProbeProvider();
this.javaEEIOUtils =
webContainer.getJavaEEIOUtils();
}
public void setWebModuleConfig(WebModuleConfig wmInfo) {
this.wmInfo = wmInfo;
}
public WebModuleConfig getWebModuleConfig() {
return wmInfo;
}
void setMonitoringNodeName(String monitoringNodeName) {
this.monitoringNodeName = monitoringNodeName;
}
public String getMonitoringNodeName() {
return monitoringNodeName;
}
/**
* Sets the parameter encoding (i18n) info from sun-web.xml.
*/
public void setI18nInfo() {
if (iasBean == null) {
return;
}
if (iasBean.isParameterEncoding()) {
formHintField = iasBean.getAttributeValue(
SunWebApp.PARAMETER_ENCODING,
SunWebApp.FORM_HINT_FIELD);
defaultCharset = iasBean.getAttributeValue(
SunWebApp.PARAMETER_ENCODING,
SunWebApp.DEFAULT_CHARSET);
}
LocaleCharsetInfo lcinfo = iasBean.getLocaleCharsetInfo();
if (lcinfo != null) {
if (lcinfo.getAttributeValue(
LocaleCharsetInfo.DEFAULT_LOCALE) != null) {
logger.warning(DEFAULT_LOCALE_DEPRECATED);
}
/*
* subelem of takes precedence
* over that of
*/
if (lcinfo.isParameterEncoding()
&& !iasBean.isParameterEncoding()) {
formHintField = lcinfo.getAttributeValue(
LocaleCharsetInfo.PARAMETER_ENCODING,
LocaleCharsetInfo.FORM_HINT_FIELD);
defaultCharset = lcinfo.getAttributeValue(
LocaleCharsetInfo.PARAMETER_ENCODING,
LocaleCharsetInfo.DEFAULT_CHARSET);
}
_lcMap = lcinfo.getLocaleCharsetMap();
}
}
/**
* return locale-charset-map
*/
public LocaleCharsetMap[] getLocaleCharsetMap() {
return _lcMap;
}
/**
* Returns true if this web module specifies a locale-charset-map in its
* sun-web.xml, false otherwise.
*
* @return true if this web module specifies a locale-charset-map in its
* sun-web.xml, false otherwise
*/
@Override
public boolean hasLocaleToCharsetMapping() {
LocaleCharsetMap[] locCharsetMap = getLocaleCharsetMap();
return (locCharsetMap != null && locCharsetMap.length > 0);
}
/**
* Matches the given request locales against the charsets specified in
* the locale-charset-map of this web module's sun-web.xml, and returns
* the first matching charset.
*
* @param locales Request locales
*
* @return First matching charset, or null if this web module does not
* specify any locale-charset-map in its sun-web.xml, or no match was
* found
*/
@Override
public String mapLocalesToCharset(Enumeration locales) {
String encoding = null;
LocaleCharsetMap[] locCharsetMap = getLocaleCharsetMap();
if (locCharsetMap != null && locCharsetMap.length > 0) {
/*
* Check to see if there is a match between the request
* locales (in preference order) and the locales in the
* locale-charset-map.
*/
boolean matchFound = false;
while (locales.hasMoreElements() && !matchFound) {
Locale reqLoc = (Locale) locales.nextElement();
for (int i=0; itrue when the default-web.xml has been read for
* this module.
*/
public void setXmlConfigured(boolean hasBeenXmlConfigured){
this.hasBeenXmlConfigured = hasBeenXmlConfigured;
}
/**
* Return true if the default=web.xml has been read for
* this module.
*/
public boolean hasBeenXmlConfigured(){
return hasBeenXmlConfigured;
}
/**
* Cache the result of doing findXX on this object
* NOTE: this method MUST be used only when loading/using
* the content of default-web.xml
*/
public void setCachedFindOperation(Object[] cachedFinds){
this.cachedFinds = cachedFinds;
}
/**
* Return the cached result of doing findXX on this object
* NOTE: this method MUST be used only when loading/using
* the content of default-web.xml
*/
public Object[] getCachedFindOperation(){
return cachedFinds;
}
@Override
public void setRealm(Realm realm) {
if ((realm != null) && !(realm instanceof RealmAdapter)) {
logger.log(Level.SEVERE, IGNORE_INVALID_REALM,
new Object[] { realm.getClass().getName(),
RealmAdapter.class.getName() });
} else {
super.setRealm(realm);
}
}
/**
* Starts this web module.
*/
@Override
public synchronized void start() throws LifecycleException {
// Get interestList of ServletContainerInitializers present, if any.
List