📄 webforwarditem.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.webforwards;
import java.awt.Rectangle;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import com.sslexplorer.boot.HostService;
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.RequiresSessionPasswordAbstractFavoriteItem;
import com.sslexplorer.security.VPNSession;
/**
* Wrapper to make a suitable struts bean for
* {@link com.sslexplorer.webforwards.WebForward} instances.
*
* @author Brett Smith <a href="mailto: brett@3sp.com"><brett@3sp.com></a>
* @author James D Robinson <a href="mailto:james@3sp.com"><james@3sp.com></a>
* @version $Revision$
*/
public class WebForwardItem extends RequiresSessionPasswordAbstractFavoriteItem {
// Private instance variables
private String selected;
private HostService sslexplorerHost;
/**
* 6 Construct a new web forward item wrapping a {@link WebForward}.
*
* @param webForward the web forward object
* @param sslexplorerHost the hostname of this SSL-Explorer server as the
* client sees it.
* @param policies list of policies
* @param requiresPassword requires password
*/
public WebForwardItem(WebForward webForward, HostService sslexplorerHost, List policies, boolean requiresPassword) {
/*
* TODO this needs to use ResourceItem and the actual resource object as /*
* per NetworkPlaceItem
*/
super(webForward, policies, requiresPassword);
this.sslexplorerHost = sslexplorerHost;
}
/**
* Get the host
*
* @return host
*/
public HostService getHost() {
return sslexplorerHost;
}
/**
* Get the URL required to 'launch' this web forward. The format of this
* will differ depending on the type. For example, Proxy </i> type will
* generate a URL pointing to the <code>getURL.do</code> action.
*
* @param referer the location this link was generated from
* @return link
*/
public String getLink(String referer) {
String refererLink = new DocumentOpenJavascriptLink(referer, "_self").toJavascript() + "windowRef.focus();";
if (this.getRequiresSessionPassword()) {
return "/promptForSessionPassword.do?forwardTo=" + Util.urlEncode("javascript: " + doPrepareLink().toJavascript() + refererLink);
} else {
return "javascript: " + doPrepareLink().toJavascript() + refererLink;
}
}
JavascriptLink doPrepareLink() {
WebForward webForward = (WebForward) this.getResource();
if (webForward != null) {
String uri = null;
if (webForward.getType() == WebForward.TYPE_REVERSE_PROXY) {
uri = "launchReverseProxy.do?id=" + webForward.getResourceId();
} else if (webForward.getType() == WebForward.TYPE_REPLACEMENT_PROXY) {
uri = "getURL.do?dest_url=" + Util.urlEncode(webForward.getDestinationURL()) + "&id=" + webForward.getResourceId();
} else {
uri = "launchTunneledSite.do?id=" + webForward.getResourceId();
}
return new WindowOpenJavascriptLink(uri, "wf_" + webForward.getResourceId(), new Rectangle(0, 0, 800, 600), true, true,
true, true);
}
return new WindowOpenJavascriptLink();
}
/**
* Get a descriptive name for the type of web forward this item represents.
*
* @return type name
*/
public String getTypeName() {
return ((WebForwardTypeItem) WebForwardTypes.WEB_FORWARD_TYPES.get(this.getWebForward().getType())).getName();
}
/**
* Set whether this item is selected
*
* @param selected
*/
public void setSelected(String selected) {
this.selected = selected;
}
/**
* Get if this item is selected
*
* @return selected
*/
public String getSelected() {
return selected;
}
/**
* Get the web forward
*
* @return
*/
public WebForward getWebForward() {
return (WebForward) this.getResource();
}
/*
* (non-Javadoc)
*
* @see com.sslexplorer.navigation.FavoriteItem#getOnClick()
*/
public String getOnClick() {
return "";
}
/*
* (non-Javadoc)
*
* @see com.sslexplorer.navigation.FavoriteItem#getTarget()
*/
public String getTarget() {
return "_blank";
}
/**
* Get the category for this web forward
*
* @return category
*/
public String getCategory() {
return ((WebForward) this.getResource()).getCategory();
}
/*
* (non-Javadoc)
*
* @see com.sslexplorer.table.TableItem#getColumnValue(int)
*/
public Object getColumnValue(int col) {
if (col < 2) {
return super.getColumnValue(col);
}
switch (col) {
case 2:
return getTypeName();
default:
return getCategory();
}
}
/*
* (non-Javadoc)
*
* @see com.sslexplorer.navigation.AbstractFavoriteItem#getFavoriteName()
*/
public String getFavoriteName() {
return getResource().getResourceName();
}
/*
* (non-Javadoc)
*
* @see com.sslexplorer.navigation.AbstractFavoriteItem#getFavoriteSubType()
*/
public String getFavoriteSubType() {
return getTypeName();
}
/*
* (non-Javadoc)
*
* @see com.sslexplorer.navigation.AbstractFavoriteItem#getSmallIconPath(javax.servlet.http.HttpServletRequest)
*/
public String getSmallIconPath(HttpServletRequest request) {
return CoreUtil.getThemePath(request.getSession()) + "/images/actions/runWebForward.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/runWebForwardLarge.gif";
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -