微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

org.apache.catalina.Globals的实例源码

项目:lazycat    文件AccessLogValve.java   
@Override
public void addElement(StringBuilder buf,Date date,Request request,Response response,long time) {
    // Don't need to flush since trigger for log message is after the
    // response has been committed
    long length = response.getBytesWritten(false);
    if (length <= 0) {
        // Protect against nulls and unexpected types as these values
        // may be set by untrusted applications
        Object start = request.getAttribute(Globals.SENDFILE_FILE_START_ATTR);
        if (start instanceof Long) {
            Object end = request.getAttribute(Globals.SENDFILE_FILE_END_ATTR);
            if (end instanceof Long) {
                length = ((Long) end).longValue() - ((Long) start).longValue();
            }
        }
    }
    if (length <= 0 && conversion) {
        buf.append('-');
    } else {
        buf.append(length);
    }
}
项目:tomcat7    文件AuthenticatorBase.java   
/**
 * Look for the X509 certificate chain in the Request under the key
 * <code>javax.servlet.request.X509Certificate</code>. If not found,trigger
 * extracting the certificate chain from the Coyote request.
 *
 * @param request   Request to be processed
 *
 * @return          The X509 certificate chain if found,<code>null</code>
 *                  otherwise.
 */
protected X509Certificate[] getRequestCertificates(final Request request)
        throws IllegalStateException {

    X509Certificate certs[] =
            (X509Certificate[]) request.getAttribute(Globals.CERTIFICATES_ATTR);

    if ((certs == null) || (certs.length < 1)) {
        try {
            request.getCoyoteRequest().action(ActionCode.REQ_SSL_CERTIFICATE,null);
            certs = (X509Certificate[]) request.getAttribute(Globals.CERTIFICATES_ATTR);
        } catch (IllegalStateException ise) {
            // Request body was too large for save buffer
            // Return null which will trigger an auth failure
        }
    }

    return certs;
}
项目:tomcat7    文件DefaultServlet.java   
private File validateGlobalXsltFile() {

    File result = null;
    String base = System.getProperty(Globals.CATALINA_BASE_PROP);

    if (base != null) {
        File baseConf = new File(base,"conf");
        result = validateGlobalXsltFile(baseConf);
    }

    if (result == null) {
        String home = System.getProperty(Globals.CATALINA_HOME_PROP);
        if (home != null && !home.equals(base)) {
            File homeConf = new File(home,"conf");
            result = validateGlobalXsltFile(homeConf);
        }
    }

    return result;
}
项目:tomcat7    文件ReplicatedContext.java   
/**
 * Start this component and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
 *
 * @exception LifecycleException if this component detects a Fatal error
 *  that prevents this component from being used
 */
@Override
protected synchronized void startInternal() throws LifecycleException {

    try {
        CatalinaCluster catclust = (CatalinaCluster)this.getCluster();
        if (this.context == null) this.context = new ReplApplContext(this);
        if ( catclust != null ) {
            ReplicatedMap<String,Object> map =
                    new ReplicatedMap<String,Object>(this,catclust.getChannel(),DEFAULT_REPL_TIMEOUT,getName(),getClassLoaders());
            map.setChannelSendOptions(mapSendOptions);
            ((ReplApplContext)this.context).setAttributeMap(map);
            if (getAltDDName() != null) context.setAttribute(Globals.ALT_DD_ATTR,getAltDDName());
        }
        super.startInternal();
    }  catch ( Exception x ) {
        log.error("Unable to start ReplicatedContext",x);
        throw new LifecycleException("Failed to start ReplicatedContext",x);
    }
}
项目:tomcat7    文件WebappClassLoaderBase.java   
@Override
public boolean check(Permission permission) {
    if (!Globals.IS_Security_ENABLED) {
        return true;
    }
    Policy currentPolicy = Policy.getPolicy();
    if (currentPolicy != null) {
        ResourceEntry entry = findResourceInternal("/","/",false);
        if (entry != null) {
            CodeSource cs = new CodeSource(
                    entry.codeBase,(java.security.cert.Certificate[]) null);
            PermissionCollection pc = currentPolicy.getPermissions(cs);
            if (pc.implies(permission)) {
                return true;
            }
        }
    }
    return false;
}
项目:lazycat    文件ApplicationContext.java   
/**
 * Return the value of the specified initialization parameter,or
 * <code>null</code> if this parameter does not exist.
 *
 * @param name
 *            Name of the initialization parameter to retrieve
 */
@Override
public String getinitParameter(final String name) {
    // Special handling for XML settings as the context setting must
    // always override anything that might have been set by an application.
    if (Globals.JASPER_XML_VALIDATION_TLD_INIT_ParaM.equals(name) && context.getTldValidation()) {
        return "true";
    }
    if (Globals.JASPER_XML_VALIDATION_INIT_ParaM.equals(name) && context.getXmlValidation()) {
        return "true";
    }
    if (Globals.JASPER_XML_BLOCK_EXTERNAL_INIT_ParaM.equals(name)) {
        if (!context.getXmlBlockExternal()) {
            // System admin has explicitly changed the default
            return "false";
        }
    }
    return parameters.get(name);
}
项目:apache-tomcat-7.0.73-with-comment    文件DefaultServlet.java   
private File validateGlobalXsltFile() {

    File result = null;
    String base = System.getProperty(Globals.CATALINA_BASE_PROP);

    if (base != null) {
        File baseConf = new File(base,"conf");
            result = validateGlobalXsltFile(homeConf);
        }
    }

    return result;
}
项目:tomcat7    文件Bootstrap.java   
/**
 * 设置catalina.home属性,如果用户未设置则使用当前的工作目录
 * Set the <code>catalina.home</code> System property to the current
 * working directory if it has not been set.
 */
private void setCatalinaHome() {

    if (System.getProperty(Globals.CATALINA_HOME_PROP) != null)
        return;
    File bootstrapJar =
        new File(System.getProperty("user.dir"),"bootstrap.jar");
    if (bootstrapJar.exists()) {
        try {
            System.setProperty
                (Globals.CATALINA_HOME_PROP,(new File(System.getProperty("user.dir"),".."))
                 .getCanonicalPath());
        } catch (Exception e) {
            // Ignore
            System.setProperty(Globals.CATALINA_HOME_PROP,System.getProperty("user.dir"));
        }
    } else {
        System.setProperty(Globals.CATALINA_HOME_PROP,System.getProperty("user.dir"));
    }

}
项目:lams    文件ErrorReportValve.java   
/**
 * Invoke the next Valve in the sequence. When the invoke returns,check
 * the response state,and output an error report is necessary.
 *
 * @param request The servlet request to be processed
 * @param response The servlet response to be created
 *
 * @exception IOException if an input/output error occurs
 * @exception servletexception if a servlet error occurs
 */
public void invoke(Request request,Response response)
    throws IOException,servletexception {

    // Perform the request
    getNext().invoke(request,response);

    Throwable throwable =
        (Throwable) request.getAttribute(Globals.EXCEPTION_ATTR);

    if (response.isCommitted()) {
        return;
    }

    if (throwable != null) {

        // The response is an error
        response.setError();

        // Reset the response (if possible)
        try {
            response.reset();
        } catch (IllegalStateException e) {
            ;
        }

        response.sendError
            (HttpServletResponse.SC_INTERNAL_SERVER_ERROR);

    }

    response.setSuspended(false);

    try {
        report(request,response,throwable);
    } catch (Throwable tt) {
        ;
    }

}
项目:lams    文件Applicationdispatcher.java   
/**
 * Forward this request and response to another resource for processing.
 * Any runtime exception,IOException,or servletexception thrown by the
 * called servlet will be propogated to the caller.
 *
 * @param request The servlet request to be forwarded
 * @param response The servlet response to be forwarded
 *
 * @exception IOException if an input/output error occurs
 * @exception servletexception if a servlet exception occurs
 */
public void forward(ServletRequest request,ServletResponse response)
    throws servletexception,IOException
{
    if (Globals.IS_Security_ENABLED) {
        try {
            PrivilegedForward dp = new PrivilegedForward(request,response);
            AccessController.doPrivileged(dp);
        } catch (PrivilegedActionException pe) {
            Exception e = pe.getException();
            if (e instanceof servletexception)
                throw (servletexception) e;
            throw (IOException) e;
        }
    } else {
        doForward(request,response);
    }
}
项目:tomcat7    文件AccessLogValve.java   
@Override
public void addElement(StringBuilder buf,long time) {
    // Don't need to flush since trigger for log message is after the
    // response has been committed
    long length = response.getBytesWritten(false);
    if (length <= 0) {
        // Protect against nulls and unexpected types as these values
        // may be set by untrusted applications
        Object start = request.getAttribute(
                Globals.SENDFILE_FILE_START_ATTR);
        if (start instanceof Long) {
            Object end = request.getAttribute(
                    Globals.SENDFILE_FILE_END_ATTR);
            if (end instanceof Long) {
                length = ((Long) end).longValue() -
                        ((Long) start).longValue();
            }
        }
    }
    if (length <= 0 && conversion) {
        buf.append('-');
    } else {
        buf.append(length);
    }
}
项目:lazycat    文件ApplicationHttpRequest.java   
/**
 * Override the <code>setAttribute()</code> method of the wrapped request.
 *
 * @param name
 *            Name of the attribute to set
 * @param value
 *            Value of the attribute to set
 */
@Override
public void setAttribute(String name,Object value) {

    if (name.equals(Globals.disPATCHER_TYPE_ATTR)) {
        dispatcherType = (dispatcherType) value;
        return;
    } else if (name.equals(Globals.disPATCHER_REQUEST_PATH_ATTR)) {
        requestdispatcherPath = value;
        return;
    }

    if (!setSpecial(name,value)) {
        getRequest().setAttribute(name,value);
    }

}
项目:tomcat7    文件Introspection.java   
/**
 * Obtain the declared methods for a class taking account of any security
 * manager that may be configured.
 */
public static Method[] getDeclaredMethods(final Class<?> clazz) {
    Method[] methods = null;
    if (Globals.IS_Security_ENABLED) {
        methods = AccessController.doPrivileged(
                new PrivilegedAction<Method[]>(){
            @Override
            public Method[] run(){
                return clazz.getDeclaredMethods();
            }
        });
    } else {
        methods = clazz.getDeclaredMethods();
    }
    return methods;
}
项目:tomcat7    文件ApplicationContextFacade.java   
@Override
public URL getResource(String path)
    throws MalformedURLException {
    if (Globals.IS_Security_ENABLED) {
        try {
            return (URL) invokeMethod(context,"getResource",new Object[]{path});
        } catch(Throwable t) {
            ExceptionUtils.handleThrowable(t);
            if (t instanceof MalformedURLException){
                throw (MalformedURLException)t;
            }
            return null;
        }
    } else {
        return context.getResource(path);
    }
}
项目:tomcat7    文件ApplicationContext.java   
/**
 * Return the value of the specified initialization parameter,or
 * <code>null</code> if this parameter does not exist.
 *
 * @param name Name of the initialization parameter to retrieve
 */
@Override
public String getinitParameter(final String name) {
    // Special handling for XML settings as the context setting must
    // always override anything that might have been set by an application.
    if (Globals.JASPER_XML_VALIDATION_TLD_INIT_ParaM.equals(name) &&
            context.getTldValidation()) {
        return "true";
    }
    if (Globals.JASPER_XML_VALIDATION_INIT_ParaM.equals(name) &&
            context.getXmlValidation()) {
        return "true";
    }
    if (Globals.JASPER_XML_BLOCK_EXTERNAL_INIT_ParaM.equals(name)) {
        if (!context.getXmlBlockExternal()) {
            // System admin has explicitly changed the default
            return "false";
        }
    }
    return parameters.get(name);
}
项目:tomcat7    文件ApplicationContext.java   
/**
 * Return the names of the context's initialization parameters,or an
 * empty enumeration if the context has no initialization parameters.
 */
@Override
public Enumeration<String> getinitParameterNames() {
    Set<String> names = new HashSet<String>();
    names.addAll(parameters.keySet());
    // Special handling for XML settings as these attributes will always be
    // available if they have been set on the context
    if (context.getTldValidation()) {
        names.add(Globals.JASPER_XML_VALIDATION_TLD_INIT_ParaM);
    }
    if (context.getXmlValidation()) {
        names.add(Globals.JASPER_XML_VALIDATION_INIT_ParaM);
    }
    if (!context.getXmlBlockExternal()) {
        names.add(Globals.JASPER_XML_BLOCK_EXTERNAL_INIT_ParaM);
    }
    return Collections.enumeration(names);
}
项目:tomcat7    文件ApplicationContext.java   
@Override
public ClassLoader getClassLoader() {
    ClassLoader result = context.getLoader().getClassLoader();
    if (Globals.IS_Security_ENABLED) {
        ClassLoader tccl = Thread.currentThread().getContextClassLoader();
        ClassLoader parent = result;
        while (parent != null) {
            if (parent == tccl) {
                break;
            }
            parent = parent.getParent();
        }
        if (parent == null) {
            System.getSecurityManager().checkPermission(
                    new RuntimePermission("getClassLoader"));
        }
    }

    return result;
}
项目:tomcat7    文件Applicationdispatcher.java   
/**
 * Forward this request and response to another resource for processing.
 * Any runtime exception,or servletexception thrown by the
 * called servlet will be propagated to the caller.
 *
 * @param request The servlet request to be forwarded
 * @param response The servlet response to be forwarded
 *
 * @exception IOException if an input/output error occurs
 * @exception servletexception if a servlet exception occurs
 */
@Override
public void forward(ServletRequest request,response);
    }
}
项目:tomcat7    文件Applicationdispatcher.java   
/**
 * Include the response from another resource in the current response.
 * Any runtime exception,or servletexception thrown by the
 * called servlet will be propagated to the caller.
 *
 * @param request The servlet request that is including this one
 * @param response The servlet response to be appended to
 *
 * @exception IOException if an input/output error occurs
 * @exception servletexception if a servlet exception occurs
 */
@Override
public void include(ServletRequest request,IOException
{
    if (Globals.IS_Security_ENABLED) {
        try {
            PrivilegedInclude dp = new PrivilegedInclude(request,response);
            AccessController.doPrivileged(dp);
        } catch (PrivilegedActionException pe) {
            Exception e = pe.getException();

            if (e instanceof servletexception)
                throw (servletexception) e;
            throw (IOException) e;
        }
    } else {
        doInclude(request,response);
    }
}
项目:tomcat7    文件Applicationdispatcher.java   
@Override
public void dispatch(ServletRequest request,ServletResponse response)
        throws servletexception,IOException {
    if (Globals.IS_Security_ENABLED) {
        try {
            Privilegeddispatch dp = new Privilegeddispatch(request,response);
            AccessController.doPrivileged(dp);
        } catch (PrivilegedActionException pe) {
            Exception e = pe.getException();

            if (e instanceof servletexception)
                throw (servletexception) e;
            throw (IOException) e;
        }
    } else {
        dodispatch(request,response);
    }
}
项目:apache-tomcat-7.0.73-with-comment    文件ReplicatedContext.java   
/**
 * Start this component and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
 *
 * @exception LifecycleException if this component detects a Fatal error
 *  that prevents this component from being used
 */
@Override
protected synchronized void startInternal() throws LifecycleException {

    try {
        CatalinaCluster catclust = (CatalinaCluster)this.getCluster();
        if (this.context == null) this.context = new ReplApplContext(this);
        if ( catclust != null ) {
            ReplicatedMap<String,x);
    }
}
项目:lazycat    文件DefaultServlet.java   
private File validateGlobalXsltFile() {

        File result = null;
        String base = System.getProperty(Globals.CATALINA_BASE_PROP);

        if (base != null) {
            File baseConf = new File(base,"conf");
            result = validateGlobalXsltFile(baseConf);
        }

        if (result == null) {
            String home = System.getProperty(Globals.CATALINA_HOME_PROP);
            if (home != null && !home.equals(base)) {
                File homeConf = new File(home,"conf");
                result = validateGlobalXsltFile(homeConf);
            }
        }

        return result;
    }
项目:apache-tomcat-7.0.73-with-comment    文件ResponseFacade.java   
@Override
public void setDateHeader(String name,long date) {

    if (isCommitted()) {
        return;
    }

    if(Globals.IS_Security_ENABLED) {
        AccessController.doPrivileged(new DateHeaderPrivilegedAction
                                         (name,date,false));
    } else {
        response.setDateHeader(name,date);
    }

}
项目:tomcat7    文件SecurityUtil.java   
/**
 * Return the <code>SecurityManager</code> only if Security is enabled AND
 * package protection mechanism is enabled.
 */
public static boolean isPackageProtectionEnabled(){
    if (packageDeFinitionEnabled && Globals.IS_Security_ENABLED){
        return true;
    }
    return false;
}
项目:tomcat7    文件ReplicatedContext.java   
@Override
public ServletContext getServletContext() {
    if (context == null) {
        context = new ReplApplContext(this);
        if (getAltDDName() != null)
            context.setAttribute(Globals.ALT_DD_ATTR,getAltDDName());
    }

    return ((ReplApplContext)context).getFacade();

}
项目:apache-tomcat-7.0.73-with-comment    文件PersistentValve.java   
private void bind(Context context) {
    // Bind the context CL to the current thread
    if (clBindrequired && context.getLoader() != null) {
        if (Globals.IS_Security_ENABLED) {
            PrivilegedAction<Void> pa =
                    new PrivilegedSetTccl(context.getLoader().getClassLoader());
            AccessController.doPrivileged(pa);                
        } else {
            Thread.currentThread().setContextClassLoader(context.getLoader().getClassLoader());
        }
    }
}
项目:apache-tomcat-7.0.73-with-comment    文件ApplicationFilterChain.java   
/**
 * Process the event,using the security manager if the option is enabled.
 * 
 * @param event the event to process
 * 
 * @exception IOException if an input/output error occurs
 * @exception servletexception if a servlet exception occurs
 */
@Override
public void doFilterEvent(CometEvent event)
    throws IOException,servletexception {

    if( Globals.IS_Security_ENABLED ) {
        final CometEvent ev = event;
        try {
            java.security.AccessController.doPrivileged(
                new java.security.PrivilegedExceptionAction<Void>() {
                    @Override
                    public Void run() 
                        throws servletexception,IOException {
                        internalDoFilterEvent(ev);
                        return null;
                    }
                }
            );
        } catch( PrivilegedActionException pe) {
            Exception e = pe.getException();
            if (e instanceof servletexception)
                throw (servletexception) e;
            else if (e instanceof IOException)
                throw (IOException) e;
            else if (e instanceof RuntimeException)
                throw (RuntimeException) e;
            else
                throw new servletexception(e.getMessage(),e);
        }
    } else {
        internalDoFilterEvent(event);
    }
}
项目:apache-tomcat-7.0.73-with-comment    文件Tomcat.java   
protected void initBaseDir() {
    String catalinaHome = System.getProperty(Globals.CATALINA_HOME_PROP);
    if (basedir == null) {
        basedir = System.getProperty(Globals.CATALINA_BASE_PROP);
    }
    if (basedir == null) {
        basedir = catalinaHome;
    }
    if (basedir == null) {
        // Create a temp dir.
        basedir = System.getProperty("user.dir") + 
            "/tomcat." + port;
        File home = new File(basedir);
        home.mkdir();
        if (!home.isAbsolute()) {
            try {
                basedir = home.getCanonicalPath();
            } catch (IOException e) {
                basedir = home.getAbsolutePath();
            }
        }
    }
    if (catalinaHome == null) {
        System.setProperty(Globals.CATALINA_HOME_PROP,basedir);
    }
    System.setProperty(Globals.CATALINA_BASE_PROP,basedir);
}
项目:apache-tomcat-7.0.73-with-comment    文件Applicationdispatcher.java   
private void dodispatch(ServletRequest request,IOException {

    // Set up to handle the specified request and response
    State state = new State(request,false);

    // Create a wrapped response to use for this request
    wrapResponse(state);

    ApplicationHttpRequest wrequest =
        (ApplicationHttpRequest) wrapRequest(state);

    if (queryString != null) {
        wrequest.setQueryParams(queryString);
    }

    wrequest.setAttribute(Globals.disPATCHER_TYPE_ATTR,dispatcherType.ASYNC);
    wrequest.setAttribute(Globals.disPATCHER_REQUEST_PATH_ATTR,getCombinedpath());

    wrequest.setcontextpath(context.getPath());
    wrequest.setRequestURI(requestURI);
    wrequest.setServletPath(servletPath);
    wrequest.setPathInfo(pathInfo);
    if (queryString != null) {
        wrequest.setQueryString(queryString);
        wrequest.setQueryParams(queryString);
    }

    invoke(state.outerRequest,state.outerResponse,state);
}
项目:tomcat7    文件Bootstrap.java   
/**
 * 通过系统属性取替换对应的占位参数${}
 * 查找${位置,然后查找} 的位置,截取中间内容去替换,不支持嵌套的${}.
 *
 *
 * System property replacement in the given string.
 * 
 * @param str The original string
 * @return the modified string
 */
protected String replace(String str) {
    // Implementation is copied from ClassLoaderLogManager.replace(),// but added special processing for catalina.home and catalina.base.
    String result = str;
    int pos_start = str.indexOf("${");
    if (pos_start >= 0) {
        StringBuilder builder = new StringBuilder();
        int pos_end = -1;
        while (pos_start >= 0) {
            builder.append(str,pos_end + 1,pos_start);
            pos_end = str.indexOf('}',pos_start + 2);
            if (pos_end < 0) {
                pos_end = pos_start - 1;
                break;
            }
            String propName = str.substring(pos_start + 2,pos_end);
            String replacement;
            if (propName.length() == 0) {
                replacement = null;
            } else if (Globals.CATALINA_HOME_PROP.equals(propName)) {
                replacement = getCatalinaHome();
            } else if (Globals.CATALINA_BASE_PROP.equals(propName)) {
                replacement = getCatalinaBase();
            } else {
                replacement = System.getProperty(propName);
            }
            if (replacement != null) {
                builder.append(replacement);
            } else {
                builder.append(str,pos_start,pos_end + 1);
            }
            pos_start = str.indexOf("${",pos_end + 1);
        }
        builder.append(str,str.length());
        result = builder.toString();
    }
    return result;
}
项目:apache-tomcat-7.0.73-with-comment    文件StandardContext.java   
/**
 * Return a File object representing the base directory for the
 * entire servlet container (i.e. the Engine container if present).
 */
protected File engineBase() {
    String base=System.getProperty(Globals.CATALINA_BASE_PROP);
    if( base == null ) {
        StandardEngine eng=(StandardEngine)this.getParent().getParent();
        base=eng.getBaseDir();
    }
    return (new File(base));
}
项目:tomcat7    文件Bootstrap.java   
/**
 * Set the <code>catalina.base</code> System property to the current
 * working directory if it has not been set.
 */
private void setCatalinaBase() {

    if (System.getProperty(Globals.CATALINA_BASE_PROP) != null)
        return;
    if (System.getProperty(Globals.CATALINA_HOME_PROP) != null)
        System.setProperty(Globals.CATALINA_BASE_PROP,System.getProperty(Globals.CATALINA_HOME_PROP));
    else
        System.setProperty(Globals.CATALINA_BASE_PROP,System.getProperty("user.dir"));

}
项目:tomcat7    文件ResponseFacade.java   
@Override
public void setDateHeader(String name,date);
    }

}
项目:lazycat    文件SSIFilter.java   
@Override
public void doFilter(ServletRequest request,ServletResponse response,FilterChain chain)
        throws IOException,servletexception {
    // cast once
    HttpServletRequest req = (HttpServletRequest) request;
    HttpServletResponse res = (HttpServletResponse) response;

    // indicate that we're in SSI processing
    req.setAttribute(Globals.SSI_FLAG_ATTR,"true");

    // setup to capture output
    ByteArrayServletoutputStream basos = new ByteArrayServletoutputStream();
    ResponseIncludeWrapper responseIncludeWrapper = new ResponseIncludeWrapper(config.getServletContext(),req,res,basos);

    // process remainder of filter chain
    chain.doFilter(req,responseIncludeWrapper);

    // we can't assume the chain flushed its output
    responseIncludeWrapper.flushOutputStreamOrWriter();
    byte[] bytes = basos.toByteArray();

    // get content type
    String contentType = responseIncludeWrapper.getContentType();

    // is this an allowed type for SSI processing?
    if (contentTypeRegEx.matcher(contentType).matches()) {
        String encoding = res.getCharacterEncoding();

        // set up SSI processing
        SSIExternalResolver ssiExternalResolver = new SSIServletExternalResolver(config.getServletContext(),isVirtualWebappRelative,debug,encoding);
        SSIProcessor ssiProcessor = new SSIProcessor(ssiExternalResolver,allowExec);

        // prepare readers/writers
        Reader reader = new InputStreamReader(new ByteArrayInputStream(bytes),encoding);
        ByteArrayOutputStream ssIoUt = new ByteArrayOutputStream();
        PrintWriter writer = new PrintWriter(new OutputStreamWriter(ssIoUt,encoding));

        // do SSI processing
        long lastModified = ssiProcessor.process(reader,responseIncludeWrapper.getLastModified(),writer);

        // set output bytes
        writer.flush();
        bytes = ssIoUt.toByteArray();

        // override headers
        if (expires != null) {
            res.setDateHeader("expires",(new java.util.Date()).getTime() + expires.longValue() * 1000);
        }
        if (lastModified > 0) {
            res.setDateHeader("last-modified",lastModified);
        }
        res.setContentLength(bytes.length);

        Matcher shtmlMatcher = shtmlRegEx.matcher(responseIncludeWrapper.getContentType());
        if (shtmlMatcher.matches()) {
            // Convert shtml mime type to ordinary html mime type but
            // preserve
            // encoding,if any.
            String enc = shtmlMatcher.group(1);
            res.setContentType("text/html" + ((enc != null) ? enc : ""));
        }
    }

    // write output
    OutputStream out = null;
    try {
        out = res.getoutputStream();
    } catch (IllegalStateException e) {
        // Ignore,will try to use a writer
    }
    if (out == null) {
        res.getWriter().write(new String(bytes));
    } else {
        out.write(bytes);
    }
}
项目:tomcat7    文件Request.java   
/**
 * Test if a given name is one of the special Servlet-spec SSL attributes.
 */
static boolean isSSLAttribute(String name) {
    return Globals.CERTIFICATES_ATTR.equals(name) ||
        Globals.CIPHER_SUITE_ATTR.equals(name) ||
        Globals.KEY_SIZE_ATTR.equals(name)  ||
        Globals.SSL_SESSION_ID_ATTR.equals(name) ||
        Globals.SSL_SESSION_ID_TOMCAT_ATTR.equals(name) ||
        Globals.SSL_SESSION_MGR_ATTR.equals(name);
}
项目:apache-tomcat-7.0.73-with-comment    文件RequestFacade.java   
@Override
public Enumeration<String> getAttributeNames() {

    if (request == null) {
        throw new IllegalStateException(
                        sm.getString("requestFacade.nullRequest"));
    }

    if (Globals.IS_Security_ENABLED){
        return AccessController.doPrivileged(
            new GetAttributePrivilegedAction());
    } else {
        return request.getAttributeNames();
    }
}
项目:tomcat7    文件RequestFacade.java   
@Override
public String getCharacterEncoding() {

    if (request == null) {
        throw new IllegalStateException(
                        sm.getString("requestFacade.nullRequest"));
    }

    if (Globals.IS_Security_ENABLED){
        return AccessController.doPrivileged(
            new GetCharacterEncodingPrivilegedAction());
    } else {
        return request.getCharacterEncoding();
    }
}
项目:apache-tomcat-7.0.73-with-comment    文件ApplicationHttpRequest.java   
/**
 * Override the <code>getAttribute()</code> method of the wrapped request.
 *
 * @param name Name of the attribute to retrieve
 */
@Override
public Object getAttribute(String name) {

    if (name.equals(Globals.disPATCHER_TYPE_ATTR)) {
        return dispatcherType;
    } else if (name.equals(Globals.disPATCHER_REQUEST_PATH_ATTR)) {
        if ( requestdispatcherPath != null ){
            return requestdispatcherPath.toString();
        } else {
            return null;   
        }
    }

    int pos = getSpecial(name);
    if (pos == -1) {
        return getRequest().getAttribute(name);
    } else {
        if ((specialAttributes[pos] == null) 
            && (specialAttributes[5] == null) && (pos >= 5)) {
            // If it's a forward special attribute,and null,it means this
            // is an include,so we check the wrapped request since 
            // the request Could have been forwarded before the include
            return getRequest().getAttribute(name);
        } else {
            return specialAttributes[pos];
        }
    }

}
项目:lazycat    文件ContextConfig.java   
protected String getBaseDir() {
    Container engineC = context.getParent().getParent();
    if (engineC instanceof StandardEngine) {
        return ((StandardEngine) engineC).getBaseDir();
    }
    return System.getProperty(Globals.CATALINA_BASE_PROP);
}
项目:apache-tomcat-7.0.73-with-comment    文件FailedRequestFilter.java   
private boolean isGoodRequest(ServletRequest request) {
    // Trigger parsing of parameters
    request.getParameter("none");
    // Detect failure
    if (request.getAttribute(Globals.ParaMETER_PARSE_Failed_ATTR) != null) {
        return false;
    }
    return true;
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。