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

📄 htmltype.java

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

import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdom.Element;
import org.jdom.JDOMException;

import com.sslexplorer.boot.ReplacementEngine;
import com.sslexplorer.boot.Replacer;
import com.sslexplorer.boot.Util;
import com.sslexplorer.extensions.ApplicationLauncherType;
import com.sslexplorer.extensions.ApplicationShortcut;
import com.sslexplorer.extensions.ApplicationShortcutItem;
import com.sslexplorer.extensions.ExtensionDescriptor;

/**
 * An implementation of an {@link com.sslexplorer.extensions.ApplicationLauncherType}
 * that allows launching of applications that may be embedded in a browser
 * such as Java applets and ActiveX controls.
 * <p>
 * If the application extension that supports this launcher has been marked
 * as <i>SSL-Explorer Aware</i>, this type will process and display the 
 * provided template page in a new browser window. If the application is
 * not SSL-Explorer Aware then the browser will first contact the VPN client
 * to set up any required tunnels before redirect back to the server to
 * process and display the templates.   
 * 
 * @author Brett Smith <a href="mailto: brett@3sp.com">&lt;brett@3sp.com&gt;</a>
 * @version $Revision: 1.12 $
 */
public class HtmlType implements ApplicationLauncherType {

    static Log log = LogFactory.getLog(HtmlType.class);
    
    final static String TYPE = "html";

    // Private instance variables
    private String template;
    private ExtensionDescriptor descriptor;
    private String window;
    private boolean sslExplorerAware;

    /* (non-Javadoc)
     * @see com.sslexplorer.extensions.ExtensionType#load(com.sslexplorer.extensions.ExtensionDescriptor, org.jdom.Element)
     */
    public void load(ExtensionDescriptor descriptor, Element element) throws JDOMException, IOException {
        this.descriptor = descriptor;
        if (element.getName().equals(TYPE)) {
            sslExplorerAware = "true".equalsIgnoreCase(element.getAttributeValue("sslexplorerAware"));
            window = element.getAttributeValue("window");
            template = element.getAttributeValue("template");
            if (template == null) {
                throw new JDOMException("The <html> tag requires the template attribute.");
            }
        }

    }

    public void verifyRequiredElements() throws JDOMException {

    }
    /**
     * Get the template name to use for HTML processing
     * 
     * @return template name
     */
    public String getTemplate() {
        return template;
    }

    /* (non-Javadoc)
     * @see com.sslexplorer.extensions.ApplicationLauncherType#getLink(com.sslexplorer.extensions.ApplicationShortcutItem, java.lang.String)
     */
    public String getLink(ApplicationShortcutItem shortcut, String referer) {
        if (!sslExplorerAware) {
            String redirect = "&path=" + Util.urlEncode(referer);
            String path = "http://localhost:" + shortcut.getClientPort() + "/launchApplication?name="
                            + shortcut.getExtensionDescriptor().getId() + "&id=" + shortcut.getResource().getResourceId() + redirect;
            if (shortcut.getClientPort() == -1) {
                path = "/launchVPNClient.do?returnTo=" + Util.urlEncode(path);
            }
            return path;
        } else {
            return "javascript: void()";
        }
    }

    /* (non-Javadoc)
     * @see com.sslexplorer.extensions.ApplicationLauncherType#getOnClick(com.sslexplorer.extensions.ApplicationShortcutItem)
     */
    public String getOnClick(final ApplicationShortcutItem shortcut) {
        String windowParsed = null;
        if (window != null) {
            ReplacementEngine engine = new ReplacementEngine();
            engine.addPattern("\\$\\{shortcut:[^}]*\\}", new Replacer() {
                public String getReplacement(Pattern pattern, Matcher matcher, String sequence) {
                    String match = matcher.group();
                    try {
                        String param = match.substring(11, match.length() - 1);
                        String val = (String) ((ApplicationShortcut)shortcut.getResource()).getParameters().get(param);
                        val = val == null ? "" : val;
                        return val;
                    } catch (Throwable t) {
                    }
                    return "";
                }
            }, null);
            windowParsed = engine.replace(window);
        }

        if (sslExplorerAware) {
            return "javascript:myRef = window.open('" + "/getHTMLApplication.do?id=" + shortcut.getResource().getResourceId()
                            + "&sslexplorer=' + escape(window.location.protocol + '//' + "
                            + "window.location.host + ':' + window.location.port)," + "'_blank'," +
                            // "'win_" +
                            // shortcut.getId() + String.valueOf((int)(
                            // Math.random() * 1000000d ))+ "'," +
                            "'" + (windowParsed == null ? "" : windowParsed) + "');myRef.focus(); return false;";
        } else {

            if (shortcut.getClientPort() == -1) {
                return null;
            } else {
                return "javascript:myRef = window.open('http://localhost:" + shortcut.getClientPort() + "/launchApplication?name="
                                + descriptor.getId() + "&id=" + shortcut.getResource().getResourceId() + "&path="
                                + Util.urlEncode("/getHTMLApplication.do?id=" + shortcut.getResource().getResourceId()) + "','win_" + shortcut.getResource().getResourceId()
                                + "','" + (windowParsed == null ? "" : windowParsed) + "');myRef.focus(); return false;";
            }

        }
    }
    
    public boolean isHidden() {
        return false;
    }    

    public String getType() {
        return TYPE;
    }    
}

⌨️ 快捷键说明

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