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

📄 networkplaceitem.java

📁 这是linux下ssl vpn的实现程序
💻 JAVA
字号:
package com.sslexplorer.vfs;

import java.awt.Rectangle;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import com.sslexplorer.boot.Util;
import com.sslexplorer.core.CoreUtil;
import com.sslexplorer.core.DocumentOpenJavascriptLink;
import com.sslexplorer.core.JavascriptLink;
import com.sslexplorer.core.WindowOpenJavascriptLink;
import com.sslexplorer.navigation.AbstractFavoriteItem;
import com.sslexplorer.navigation.RequiresSessionPasswordAbstractFavoriteItem;
import com.sslexplorer.security.Constants;
import com.sslexplorer.vfs.utils.URI;
import com.sslexplorer.vfs.webdav.DAVUtilities;
import com.sslexplorer.webforwards.WebForward;

/**
 * <p>
 * Implementation of {@link com.sslexplorer.navigation.AbstractFavoriteItem} to
 * display the network places in a sortable table.
 * 
 * @author James D Robinson <a href="mailto:james@3sp.com">&lt;james@3sp.com&gt;</a>
 * 
 */
public class NetworkPlaceItem extends RequiresSessionPasswordAbstractFavoriteItem {

    /**
     * Default window width for popup
     */
    public final static int WINDOW_WIDTH = 790;

    /**
     * Default window width for popup
     */
    public final static int WINDOW_HEIGHT = 480;

    // Private instance variables

    private String mountPath;

    /**
     * Constructor
     * 
     * @param networkPlace The network place represented by the
     *        NetworkPlaceItem.
     * @param mountPath The DAVMount path.
     * @param policies The policies for the resource.
     */
    public NetworkPlaceItem(NetworkPlace networkPlace, String mountPath, List policies, boolean requiresSessionPassword) {
        super(networkPlace, policies, requiresSessionPassword);
        this.mountPath = mountPath;
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.sslexplorer.navigation.FavoriteItem#getOnClick()
     */
    public String getOnClick() {
        return "";
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.sslexplorer.navigation.FavoriteItem#getLink(java.lang.String)
     */
    public String getLink(String referer) {
        String refererLink =  new DocumentOpenJavascriptLink(referer, "_self").toJavascript();
        if (this.getRequiresSessionPassword()) {
            return "/promptForSessionPassword.do?forwardTo=" + Util.urlEncode("javascript: " + doPrepareLink().toJavascript() + refererLink);
        } else {
            return "javascript: " + doPrepareLink().toJavascript() + refererLink;
        }
    }

    private JavascriptLink doPrepareLink() {
        return new WindowOpenJavascriptLink("fileSystem.do?actionTarget=list&path=" + Util.urlEncode(mountPath) + "&resourceId="
                        + getResource().getResourceId(), "vfs_" + getResource().getResourceId() + "_" + System.currentTimeMillis(),
                        new Rectangle(20, 20, WINDOW_WIDTH, WINDOW_HEIGHT), true, false, false, true);
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.sslexplorer.navigation.FavoriteItem#getTarget()
     */
    public String getTarget() {
        return "_blank";
    }

    /**
     * Get the web folder path
     * 
     * @return webfolder path.
     */
    public String getWebFolderPath() {
        return "/fs/" + mountPath;
    }
    
    /**
     * Get the path that prompts for session password then launches webfolder
     * 
     * @param referer
     * @return prompt then web folder path
     */
    public String getPromptThenWebFolderPath(String referer, HttpSession session) {
        String host = (String)session.getAttribute(Constants.HOST);
        if (this.getRequiresSessionPassword()) {
            return "/promptForSessionPassword.do?forwardTo=" + referer + 
                "&target=_blank&folder=" +
                Util.urlEncode(host + getWebFolderPath() + "?ticket=" + 
                    (String) session.getAttribute(Constants.WEB_FOLDER_LAUNCH_TICKET));
        } else {
            // dealt with in jsp
            return "";
        }
    }

    /**
     * @return The DAVMount path
     */
    public String getMountPath() {
        return mountPath;
    }

    /**
     * @param mountPath The DAVMount path.
     */
    public void setMountPath(String mountPath) {
        this.mountPath = mountPath;
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.sslexplorer.navigation.FavoriteItem#getName()
     */
    public String getFavoriteName() {
        return getResource().getResourceName();
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.sslexplorer.navigation.AbstractFavoriteItem#getFavoriteSubType()
     */
    public String getFavoriteSubType() {
        try {
            return new URI(((NetworkPlace) getResource()).getUri()).getScheme().toUpperCase();
        } catch (Exception e) {
            return "";
        }
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.sslexplorer.navigation.AbstractFavoriteItem#getSmallIconPath(javax.servlet.http.HttpServletRequest)
     */
    public String getSmallIconPath(HttpServletRequest request) {
        return CoreUtil.getThemePath(request.getSession()) + "/images/actions/runNetworkPlace.gif";
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.sslexplorer.navigation.AbstractFavoriteItem#getLargeIconPath(javax.servlet.http.HttpServletRequest)
     */
    public String getLargeIconPath(HttpServletRequest request) {
        return CoreUtil.getThemePath(request.getSession()) + "/images/actions/runNetworkPlaceLarge.gif";
    }
}

⌨️ 快捷键说明

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