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

📄 propertiesaction.java

📁 这是linux下ssl vpn的实现程序
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
 *  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.properties.actions;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

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.Globals;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;

import com.sslexplorer.boot.PropertyDefinition;
import com.sslexplorer.boot.Util;
import com.sslexplorer.core.CoreServlet;
import com.sslexplorer.core.CoreUtil;
import com.sslexplorer.core.PropertyUtil;
import com.sslexplorer.core.actions.AuthenticatedDispatchAction;
import com.sslexplorer.policyframework.PolicyConstants;
import com.sslexplorer.policyframework.PolicyUtil;
import com.sslexplorer.policyframework.ResourceUtil;
import com.sslexplorer.properties.PropertyDefinitionCategory;
import com.sslexplorer.properties.PropertyItem;
import com.sslexplorer.properties.PropertyProfile;
import com.sslexplorer.properties.forms.DefaultPropertiesForm;
import com.sslexplorer.properties.forms.PropertiesForm;
import com.sslexplorer.security.Constants;
import com.sslexplorer.security.SessionInfo;
import com.sslexplorer.security.User;

public class PropertiesAction extends AuthenticatedDispatchAction {
    static Log log = LogFactory.getLog(PropertiesAction.class);

    public PropertiesAction() {
        super();
    }

    public ActionForward reset(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {
        DefaultPropertiesForm f = (DefaultPropertiesForm) form;
        f.clearValues();
        User user = isSetupMode() ? null : CoreServlet.getServlet().getLogonController().getUser((HttpServletRequest) request);
        rebuildItems(f.getParentCategory(), f, request, user);
        return mapping.findForward("display");
    }

    public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                    HttpServletResponse response) throws Exception {
        String profileScope = Constants.SCOPE_PERSONAL;
        String forwardTo = null;
        boolean redirect = false;
        int selectedCategory = -1;
        int parentCategory = -1;
        if (request.getParameter("parentCategory") != null) {
            parentCategory = Integer.parseInt(request.getParameter("parentCategory"));
        }
        int profile = -1;
        DefaultPropertiesForm pf = (DefaultPropertiesForm) form;
        pf.clearValues();
        SessionInfo session = CoreServlet.getServlet().getLogonController().getSessionInfo((HttpServletRequest) request);
        // Parse the request parameters
        if (request.getParameter("selectedPropertyProfile") != null) {
            profile = Integer.parseInt(request.getParameter("selectedPropertyProfile"));
        }
        if (request.getParameter("scope") != null) {
            profileScope = request.getParameter("scope");
        }
        if (request.getParameter("forwardTo") != null) {
            forwardTo = request.getParameter("forwardTo");
        }
        if (request.getParameter("redirect") != null) {
            redirect = "true".equalsIgnoreCase(request.getParameter("redirect"));
        }
        if (request.getParameter("selectedCategory") != null) {
            if ("changeSelectedCategory".equalsIgnoreCase(pf.getActionTarget())) {
                selectedCategory = pf.getNewSelectedCategory();
            } else {
                selectedCategory = Integer.parseInt(request.getParameter("selectedCategory"));
            }
        }
        // Now try the struts supplied action mapping parameter
        if (mapping.getParameter() != null && !mapping.getParameter().equals("")) {
            String[] parms = mapping.getParameter().split(",");
            if (parms.length > 0) {
                profileScope = parms[0];
                // Setup scoped properties only ever exist in profile 0
                if (profileScope.equals(Constants.SCOPE_SETUP)) {
                    profile = 0;
                }
            }
            if (parms.length > 1) {
                parentCategory = Integer.parseInt(parms[1]);
            }
            if (parms.length > 2) {
                forwardTo = parms[2];
            }
            if (parms.length > 3) {
                redirect = "true".equalsIgnoreCase(parms[3]);
            }
            if (parms.length > 4) {
                profile = Integer.parseInt(parms[4]);
            }
        }
        // If the profile still isnt known, use the current one
        if (profile == -1) {
            if (request.getSession().getAttribute(Constants.SELECTED_PROFILE) != null) {
                profile = ((PropertyProfile) request.getSession().getAttribute(Constants.SELECTED_PROFILE)).getResourceId();
            } else {
                profile = 0;
            }
        }
        PropertyProfile selectedPropertyProfile = CoreServlet.getServlet().getPropertyDatabase().getPropertyProfile(profile);
        if (selectedPropertyProfile == null) {
            selectedPropertyProfile = CoreServlet.getServlet().getPropertyDatabase().getPropertyProfile(session.getUser().getPrincipalName(),
                "Default");
            if (selectedPropertyProfile == null) {
                selectedPropertyProfile = CoreServlet.getServlet().getPropertyDatabase().getPropertyProfile(null, "Default");
            }
        }
        
//        // 
//        if (profileScope.equals(Constants.SCOPE_SETUP)) {
//            PolicyUtil.checkPermission(PolicyConstants.SYSTEM_CONFIGURATION_RESOURCE_TYPE,
//                PolicyConstants.PERM_CHANGE, request);
//        }
//        else if (profileScope.equals(Constants.SCOPE_GLOBAL)) {
//            ResourceUtil.checkResourceManagementRights(selectedPropertyProfile, session, PolicyConstants.PERM_CHANGE);
//        }
//        else if (profileScope.equals(Constants.SCOPE_GLOBAL)) {
//            ResourceUtil.checkResourceManagementRights(selectedPropertyProfile, session, PolicyConstants.PERM_CHANGE);
//        }
        // 
        // Get the property profiles
        List propertyProfiles = (List)request.getSession().getAttribute(Constants.PROFILES);
        if (selectedPropertyProfile == null) {
            for (Iterator i = propertyProfiles.iterator(); i.hasNext();) {
                selectedPropertyProfile = (PropertyProfile) i.next();
                if (selectedPropertyProfile.getResourceName().equals("Default")) {
                    break;
                }
            }
        }
        // Intialize the form
        pf.setProfileScope(profileScope);
        pf.setForwardTo(forwardTo);
        pf.setUpdateAction(mapping.getPath() + ".do");
        pf.setPropertyProfiles(propertyProfiles);
        pf.setSelectedPropertyProfile(selectedPropertyProfile.getResourceId());
        pf.setRedirect(redirect);

⌨️ 快捷键说明

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