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

📄 geturlaction.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.replacementproxy.actions;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.sslexplorer.boot.Util;
import com.sslexplorer.core.CoreAttributeConstants;
import com.sslexplorer.core.CoreEvent;
import com.sslexplorer.core.CoreEventConstants;
import com.sslexplorer.core.CoreServlet;
import com.sslexplorer.core.actions.AuthenticatedAction;
import com.sslexplorer.policyframework.Policy;
import com.sslexplorer.policyframework.ResourceAccessEvent;
import com.sslexplorer.policyframework.ResourceUtil;
import com.sslexplorer.security.Constants;
import com.sslexplorer.security.SessionInfo;
import com.sslexplorer.util.TicketGenerator;
import com.sslexplorer.webforwards.AbstractAuthenticatingWebForward;
import com.sslexplorer.webforwards.ReplacementProxyWebForward;
import com.sslexplorer.webforwards.WebForward;
import com.sslexplorer.webforwards.WebForwardTypeItem;
import com.sslexplorer.webforwards.WebForwardTypes;

/**
 * Implementation of {@link com.sslexplorer.core.actions.AuthenticatedAction}
 * that is the entry point for <i>Replacement Proxy Web Forward</i>.
 * 
 * @author Brett Smith <a href="mailto: brett@3sp.com">&lt;brett@3sp.com&gt;</a>
 * @version $Revision: 1.6 $
 */
public class GetURLAction extends AuthenticatedAction {

    static boolean debug = "true".equalsIgnoreCase(System.getProperty("sslexplorer.debugReplacementProxyTraffic"));
    static HashMap caches = new HashMap();
    static Log log = LogFactory.getLog(GetURLAction.class);

    /*
     * (non-Javadoc)
     * 
     * @see com.sslexplorer.core.actions.AuthenticatedAction#isIgnoreSessionLock()
     */
    protected boolean isIgnoreSessionLock() {
        return true;
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.sslexplorer.core.actions.AuthenticatedAction#onExecute(org.apache.struts.action.ActionMapping,
     *      org.apache.struts.action.ActionForm,
     *      javax.servlet.http.HttpServletRequest,
     *      javax.servlet.http.HttpServletResponse)
     */
    public ActionForward onExecute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {
        // Setup the Replacement proxy
        String destinationURL = request.getParameter("dest_url");
        int id = Integer.parseInt(request.getParameter("id"));
        if (destinationURL != null) {
            String uniqueTicket = TicketGenerator.getInstance().generateUniqueTicket("SPT", 10).toUpperCase();
            SessionInfo session = this.getSessionInfo();
            WebForward wf = CoreServlet.getServlet().getSystemDatabase().getWebForward(id);
            AbstractAuthenticatingWebForward abstractAuthenticatingWebForward = (AbstractAuthenticatingWebForward) wf;
            ReplacementProxyWebForward f = (ReplacementProxyWebForward) wf;

            ResourceUtil.checkResourceAccessRights(wf, session);

            if (wf != null) {
                if (session.getHttpSession().getAttribute(Constants.REFERALS) == null) {
                    session.getHttpSession().setAttribute(Constants.REFERALS, new HashMap());
                }
                Map referals = (Map) session.getHttpSession().getAttribute(Constants.REFERALS);
                referals.put(uniqueTicket, wf);

                response.sendRedirect("/replacementProxyEngine?sslex_ticket=" + uniqueTicket + "&sslex_url="
                                + Util.urlEncode(wf.getDestinationURL())
                                + (!f.getFormType().equals(WebForwardTypes.FORM_SUBMIT_NONE) ? "&launched=true" : ""));

            } else
                response.sendError(500, "Invalid web forward");
        } else {
            response.sendError(500, "Invalid request");
        }

        return null;
    }

    public int getNavigationContext(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
        return SessionInfo.MANAGEMENT_CONSOLE_CONTEXT | SessionInfo.USER_CONSOLE_CONTEXT;
    }

}

⌨️ 快捷键说明

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