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

📄 propertyprofileform.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.properties.forms;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.Globals;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

import com.sslexplorer.boot.PropertyList;
import com.sslexplorer.core.CoreServlet;
import com.sslexplorer.input.MultiSelectSelectionModel;
import com.sslexplorer.policyframework.Resource;
import com.sslexplorer.policyframework.ResourceUtil;
import com.sslexplorer.policyframework.forms.AbstractResourceForm;
import com.sslexplorer.properties.PropertyProfile;
import com.sslexplorer.security.Constants;
import com.sslexplorer.security.User;

public class PropertyProfileForm extends AbstractResourceForm {
    static Log log = LogFactory.getLog(PropertyProfileForm.class);
    private List propertyProfiles;
    private int selectedPropertyProfile;
    private String scope;
    private String selectedTab = "details";

    public String getUpdateAction() {
        return getEditing() ? (Constants.SCOPE_GLOBAL.equals(getPropertyScope()) ? "/editGlobalPropertyProfile.do"
                        : "/editPropertyProfile.do")
                        : (Constants.SCOPE_GLOBAL.equals(getPropertyScope()) ? "/createGlobalPropertyProfile.do"
                                        : "/createPropertyProfile.do");
    }

    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        ActionErrors errs = super.validate(mapping, request);
        if (isCommiting()) {
            if (getResourceName().equalsIgnoreCase("default")
                            && (!getEditing() || (getEditing() && !getResource().getResourceName().equalsIgnoreCase("default")))) {
                errs.add(Globals.ERROR_KEY, new ActionMessage("error.createProfile.cantUseNameDefault"));
                setResourceName("");
            }
        }
        return errs;
    }

    public List getPropertyProfiles() {
        return propertyProfiles;
    }

    public void setSelectedPropertyProfile(int selectedPropertyProfile) {
        this.selectedPropertyProfile = selectedPropertyProfile;
    }

    public int getSelectedPropertyProfile() {
        return selectedPropertyProfile;
    }

    public String getPropertyScope() {
        return scope;
    }

    public void setPropertyScope(String scope) {
        this.scope = scope;
    }

    public void setPropertyProfiles(List propertyProfiles) {
        this.propertyProfiles = propertyProfiles;
    }

    public Resource getResourceByName(String name) throws Exception {
        String username = Constants.SCOPE_GLOBAL.equals(getPropertyScope()) ? null : getUser().getPrincipalName();
        return CoreServlet.getServlet().getPropertyDatabase()
            .getPropertyProfile(username, name);
    }

    public int getTabCount() {
        return getPropertyScope().equals(Constants.SCOPE_PERSONAL) ? 1 : 2;
    }

    public String getTabName(int idx) {
        switch (idx) {
            case 0:
                return "details";
            default:
                return "policies";
        }
    }

    public String getTabTitle(int idx) {
        
        // Get from resources
        return null;
    }

    public void initialise(User user, Resource resource, boolean editing, MultiSelectSelectionModel policyModel,
                    PropertyList selectedPolicies, User owner) throws Exception {
        super.initialise(user, resource, editing, policyModel, selectedPolicies, owner);
        propertyProfiles = CoreServlet.getServlet().getPropertyDatabase().getPropertyProfiles(
            owner == null ? null : owner.getPrincipalName(), true);
        if(owner != null) {
            propertyProfiles = ResourceUtil.filterResources(owner, propertyProfiles, owner == null ? true : false);
        }
        if (resource != null) {
            selectedPropertyProfile = ((PropertyProfile) resource).getResourceId();
        } else {
            selectedPropertyProfile = 0;
        }
    }

    public String getSelectedTab() {
        return selectedTab;
    }

    public void setSelectedTab(String selectedTab) {
        this.selectedTab = selectedTab;
    }

    public void applyToResource() throws Exception {
    }

    /* (non-Javadoc)
     * @see com.sslexplorer.tabs.TabModel#getTabBundle(int)
     */
    public String getTabBundle(int idx) {
        return null;
    }
}

⌨️ 快捷键说明

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