deregisterclientaction.java
来自「这是linux下ssl vpn的实现程序」· Java 代码 · 共 100 行
JAVA
100 行
/*
* 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.security.actions;
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 org.jdom.Document;
import org.jdom.Element;
import com.sslexplorer.core.CoreEvent;
import com.sslexplorer.core.CoreEventConstants;
import com.sslexplorer.core.CoreServlet;
import com.sslexplorer.core.actions.XMLOutputAction;
import com.sslexplorer.security.VPNSession;
/**
* When a VPN client is stopped it must connect to the SSL Explorer and
* deregister itself by providing the VPN session ticket the user was allocated
* when the client was started. This will allow the VPN client status to be
* updated next time the page is updated.
*
* @author Brett Smith
* @version $Revision: 1.11 $
*/
public class DeregisterClientAction extends XMLOutputAction {
static Log log = LogFactory.getLog(DeregisterClientAction.class);
public DeregisterClientAction() {
}
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws Exception {
// Get the pending VPN session ticket
String ticket = request.getParameter("ticket");
// Check the values and send error if incorrect
if (ticket == null) {
log.error("The client failed to provide a ticket");
sendError("A VPN session ticket is requried", response);
} else {
log.error("Deregistering client VPN session for " + request.getRemoteHost());
// Everything looks good so deregister the client
VPNSession vpnSession = CoreServlet.getServlet().getLogonController().getVPNSessionByTicket(ticket);
if (vpnSession == null) {
// The ticket is invalid
log.error("SSL-Explorer Agent " + request.getRemoteHost() + " provided an invalid ticket");
sendError("SSL-Explorer Agent " + request.getRemoteHost() + " provided an invalid ticket", response);
} else {
try {
CoreServlet.getServlet().getLogonController().deregisterVPNClient(vpnSession);
if (log.isInfoEnabled())
log.info("SSL-Explorer Agent " + request.getRemoteHost() + " has been deregistered");
Element root = new Element("success");
Document doc = new Document(root);
sendDocument(doc, response);
}
catch(Exception e) {
log.error("Failed to de-register SSL-Explorer Agent.", e);
sendError(e.getMessage(), response);
}
}
}
// We have processed the output ourselves
return null;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?