⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 davservlet.java

📁 这是linux下ssl vpn的实现程序
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* ========================================================================== *
 * Copyright (C) 2004-2005 Pier Fumagalli <http://www.betaversion.org/~pier/> *
 *                            All rights reserved.                            *
 * ========================================================================== *
 *                                                                            *
 * Licensed 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 com.sslexplorer.vfs.webdav;

import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionBindingListener;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.Globals;
import org.apache.struts.action.ActionMessages;

import sun.tools.tree.AddExpression;

import com.sslexplorer.boot.Util;
import com.sslexplorer.core.BundleActionMessage;
import com.sslexplorer.core.CoreServlet;
import com.sslexplorer.core.CoreUtil;
import com.sslexplorer.properties.PropertyProfile;
import com.sslexplorer.security.Constants;
import com.sslexplorer.security.InvalidTicketException;
import com.sslexplorer.security.SessionInfo;
import com.sslexplorer.security.User;

/**
 * <p>
 * A very simple servlet capable of processing very simple <a
 * href="http://www.rfc-editor.org/rfc/rfc2518.txt">WebDAV</a> requests.
 * </p>
 * 
 * <p>
 * Modifications made to integrate with Commons-VFS and SSL-Explorer.
 * </p>
 * 
 * @author <a href="http://www.betaversion.org/~pier/">Pier Fumagalli</a>
 * @author <a href="http://3sp.com/">Brett Smith</a>
 * 
 */
public class DAVServlet implements Servlet, DAVListener {

    final static Log log = LogFactory.getLog(DAVServlet.class);

    /**
     * <p>
     * The session attribute in which the {@link DAVProcessor} is stored
     */
    private static String PROCESSOR_ATTR = "davServlet.processor";

    /**
     * <p>
     * The session attribute in which the {@link SessionInvalidateListener} is
     * stored
     */
    private static String SESSION_INVALIDATE_LISTENER_ATTR = "davServlet.sessionInvalidateListener";

    /**
     * <p>
     * The version of this servlet.
     * </p>
     */
    private static String SIGNATURE = DAVUtilities.getProperty("servlet.signature") + '/' + DAVUtilities.getProperty("version");
    /**
     * <p>
     * The version of this servlet.
     * </p>
     */
    private static String INFORMATION = DAVUtilities.getProperty("servlet.information") + " version "
                    + DAVUtilities.getProperty("version");
    /**
     * <p>
     * The {@link ServletContext} associated with this instance.
     * </p>
     */
    private ServletContext context = null;
    /**
     * <p>
     * The {@link ServletConfig} associated with this instance.
     * </p>
     */
    private ServletConfig config = null;
    /**
     * <p>
     * A list of processors in use.
     * </p>
     */
    private static List processors = new ArrayList();

    /**
     * <p>
     * Create a new {@link DAVServlet} instance.
     * </p>
     */
    public DAVServlet() {
        super();
    }

    /**
     * <p>
     * Initialize this {@link Servlet} instance.
     * </p>
     * 
     * <p>
     * The only initialization parameter required by this servlet is the &quot;<code>rootPath</code>&quot;
     * parameter specifying the path of the repository root (either absolute or
     * relative to the configured {@link ServletContext}.
     * </p>
     * 
     * <p>
     * If the specified root is relative, it will be considered to be relative
     * to the {@link ServletContext} deployment path.
     * </p>
     * 
     * <p>
     * In any case, the specified root must ultimately point to an existing
     * directory on a locally-accessible file system.
     * </p>
     * 
     * <p>
     * When set to <code>true</code>, an optional parameter called
     * <code>xmlOnly</code> will force this {@link DAVServlet} to use an
     * {@link XMLRepository} instead of the default {@link DAVRepository}.
     * </p>
     * 
     * <p>
     * Finally, when set to <code>true</code>, the optional parameter
     * <code>debugEnabled</code> will enable logging of method invocation and
     * events in the repository.
     * </p>
     */
    public void init(ServletConfig config) throws ServletException {
        /* Remember the configuration instance */
        this.context = config.getServletContext();
        this.config = config;

    }

    /**
     * <p>
     * Detroy this {@link Servlet} instance.
     * </p>
     */
    public void destroy() {
        for (Iterator i = processors.iterator(); i.hasNext();) {
            ((DAVProcessor) i.next()).getRepository().removeListener(this);
        }
    }

    /**
     * <p>
     * Return the {@link ServletConfig} associated with this instance.
     * </p>
     */
    public ServletConfig getServletConfig() {
        return (this.config);
    }

    /**
     * <p>
     * Return the {@link ServletContext} associated with this instance.
     * </p>
     */
    public ServletContext getServletContext() {
        return (this.context);
    }

    /**
     * <p>
     * Return a informative {@link String} about this servlet.
     * </p>
     */
    public String getServletInfo() {
        return INFORMATION;
    }

    public static DAVSession updateDAVSession(HttpServletRequest request, String resourcePath) {
        // This provides a key on which the store can lookup up webdav session
        // ids

        request.getSession().setAttribute("com.sslexplorer.vfs.webdav.DAVMethod", request.getSession().getId());
        DAVSession webdavSession = DAVSessionStore.getInstance().getSession(request.getSession().getId());
        if (webdavSession == null) {
            webdavSession = new DAVSession(request.getSession().getId());
            DAVSessionStore.getInstance().addSession(webdavSession);
        }
        PropertyProfile profile = (PropertyProfile) request.getSession().getAttribute(Constants.SELECTED_PROFILE);
        if (profile != null) {
            webdavSession.setAttribute(DAVSession.ATTR_PROFILE, profile);
        }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -