📄 tunnelsform.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.tunnels.forms;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import org.apache.struts.action.ActionMapping;
import com.sslexplorer.core.CoreServlet;
import com.sslexplorer.forwarding.VPNListeningSocket;
import com.sslexplorer.policyframework.PolicyConstants;
import com.sslexplorer.policyframework.ResourceType;
import com.sslexplorer.policyframework.ResourceUtil;
import com.sslexplorer.policyframework.forms.AbstractResourcesForm;
import com.sslexplorer.security.SessionInfo;
import com.sslexplorer.security.SystemDatabase;
import com.sslexplorer.security.User;
import com.sslexplorer.security.VPNSession;
import com.sslexplorer.tunnels.TransportType;
import com.sslexplorer.tunnels.Tunnel;
import com.sslexplorer.tunnels.TunnelItemModel;
public class TunnelsForm extends AbstractResourcesForm {
String openTunnelLink;
String updateTunnelLink;
public TunnelsForm() {
super(new TunnelItemModel("tunnel"));
}
public String getOpenTunnelLink() {
return openTunnelLink;
}
public String getUpdateTunnelLink() {
return updateTunnelLink;
}
public List getTransportList() {
return TransportType.TRANSPORTS;
}
public List getTunnelTypeList() {
return TransportType.TYPES;
}
public void initialise(VPNSession vpnSession, SessionInfo session, User user, String defaultSortColumnId) throws Exception {
super.initialize(session.getHttpSession(), defaultSortColumnId);
SystemDatabase sdb = CoreServlet.getServlet().getSystemDatabase();
List tunnels = session.getNavigationContext() == SessionInfo.MANAGEMENT_CONSOLE_CONTEXT ? ResourceUtil
.filterManageableResources(sdb.getTunnels(), session.getUser()) : ResourceUtil.getGrantedResource(session, PolicyConstants.SSL_TUNNEL_RESOURCE_TYPE);
if (vpnSession != null) {
setOpenTunnelLink("http://localhost:" + vpnSession.getClientPort() + "/openTunnel");
setUpdateTunnelLink("http://localhost:" + vpnSession.getClientPort() + "/updateTunnel");
/*
* Display any tunnels that are in the database as well as any
* temporary tunnels determining which ones are open
*/
Collection listeningSockets = vpnSession.getListeningSockets();
for (Iterator it = tunnels.iterator(); it.hasNext();) {
Tunnel tunnel = (Tunnel) it.next();
if (tunnel != null && tunnel.getResourceId() != -1) {
VPNListeningSocket socket = null;
for (Iterator it2 = listeningSockets.iterator(); it2.hasNext() && socket == null;) {
VPNListeningSocket vpns = (VPNListeningSocket) it2.next();
if (vpns.getTunnel().getResourceId() == tunnel.getResourceId()) {
socket = vpns;
}
}
TunnelItem ti = null;
if (socket != null) {
ti = new TunnelItem(socket, vpnSession, CoreServlet.getServlet().getPolicyDatabase()
.getPoliciesAttachedToResource(tunnel));
} else {
ti = new TunnelItem(tunnel, vpnSession, CoreServlet.getServlet().getPolicyDatabase()
.getPoliciesAttachedToResource(tunnel));
}
ti.setFavoriteType(getFavoriteType(tunnel.getResourceId()));
getModel().addItem(ti);
}
}
} else {
Iterator i = tunnels.iterator();
while (i.hasNext()) {
Tunnel tunnel = (Tunnel) i.next();
if (tunnel != null){
TunnelItem ti = new TunnelItem(tunnel, CoreServlet.getServlet().getPolicyDatabase().getPoliciesAttachedToResource(
tunnel));
ti.setFavoriteType(getFavoriteType(ti.getTunnel().getResourceId()));
getModel().addItem(ti);
}
}
}
checkSort();
getPager().rebuild(getFilterText());
}
public void setOpenTunnelLink(String openTunnelLink) {
this.openTunnelLink = openTunnelLink;
}
public void setUpdateTunnelLink(String updateTunnelLink) {
this.updateTunnelLink = updateTunnelLink;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -