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

📄 executabletype.java

📁 这是linux下ssl vpn的实现程序
💻 JAVA
字号:
/*
 *  SSL-Explorer
 *
 *  Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License
 *  as published by the Free Software Foundation; either version 2 of
 *  the License, or (at your option) any later version.
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public
 *  License along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
			
package com.sslexplorer.extensions.types;

import java.io.IOException;
import java.util.Iterator;

import org.jdom.Element;
import org.jdom.JDOMException;

import com.sslexplorer.boot.Util;
import com.sslexplorer.extensions.ApplicationLauncherType;
import com.sslexplorer.extensions.ApplicationShortcutItem;
import com.sslexplorer.extensions.ExtensionDescriptor;

/**
 * Implementation of an
 * {@link com.sslexplorer.extensions.ApplicationLauncherType} that allows
 * launching of native applications installed the client machine using a running
 * VPN client.
 * <p>
 * The links provided by this type will launch the VPN client if it is not
 * currently running.
 * 
 * @author Brett Smith <a href="mailto: brett@3sp.com">&lt;brett@3sp.com&gt;</a>
 * @version $Revision: 1.10 $
 */
public class ExecutableType implements ApplicationLauncherType {

    final static String TYPE = "executable";
    
    /*
     * (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 {

        if (element.getName().equals(TYPE)) {
        	verifyExecutable(element);    
        }
        
    }

    public void verifyRequiredElements() throws JDOMException {

    }
    
    /*
     * (non-Javadoc)
     * 
     * @see com.sslexplorer.extensions.ApplicationLauncherType#getLink(com.sslexplorer.extensions.ApplicationShortcutItem,
     *      java.lang.String)
     */
    public String getLink(ApplicationShortcutItem shortcut, String referer) {
        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;
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.sslexplorer.extensions.ApplicationLauncherType#getOnClick(com.sslexplorer.extensions.ApplicationShortcutItem)
     */
    public String getOnClick(ApplicationShortcutItem shortcut) {
        return null;
    }

    private void verifyExecutable(Element element) throws JDOMException, IOException {
        for (Iterator it = element.getChildren().iterator(); it.hasNext();) {
            Element e = (Element) it.next();
            if (e.getName().equalsIgnoreCase("if")) {
                verifyExecutable(e);
            } else if (!e.getName().equalsIgnoreCase("arg") && !e.getName().equalsIgnoreCase("jvm")) {
                throw new JDOMException("Unexpected element <" + e.getName() + "> found in <executable>");
            }
        }

    }
    
    public boolean isHidden() {
        return false;
    }    
    
    public String getType() {
        return TYPE;
    }
}

⌨️ 快捷键说明

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