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

📄 athenticationschemeselectionform.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.security.authwizard.forms;

import javax.servlet.ServletRequest;
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.input.MultiSelectDataSource;
import com.sslexplorer.input.MultiSelectSelectionModel;
import com.sslexplorer.security.AuthenticationModuleDefinition;
import com.sslexplorer.security.AuthenticationModuleManager;
import com.sslexplorer.security.ModulesDataSource;
import com.sslexplorer.wizard.AbstractWizardSequence;
import com.sslexplorer.wizard.forms.DefaultWizardForm;

public class AthenticationSchemeSelectionForm extends DefaultWizardForm {

    final static Log log = LogFactory.getLog(AthenticationSchemeSelectionForm.class);

    public static final String ATTR_SELECTED_MODULES = "selectedModules";

    // TODO sampleAttributes attributes should be defined here.
    protected MultiSelectSelectionModel moduleModel;
    protected PropertyList selectedModules;

    /**
     * Constructor
     */
    public AthenticationSchemeSelectionForm() {
        super(true, true, "/WEB-INF/jsp/content/security/authwizard/athenticationSchemeSelection.jspf", "resourceName", true,
                        false, "athenticationSchemeSelection", "security", "authwizard.athenticationSchemeSelection", 2);
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.sslexplorer.wizard.forms.AbstractWizardForm#init(com.sslexplorer.wizard.AbstractWizardSequence,
     *      javax.servlet.http.HttpServletRequest)
     */
    public void init(AbstractWizardSequence sequence, HttpServletRequest request) throws Exception {
        super.init(sequence, request);
        this.selectedModules = ((PropertyList) sequence.getAttribute(ATTR_SELECTED_MODULES, new PropertyList()));
        MultiSelectDataSource modules = new ModulesDataSource(request.getSession(), "security");
        this.moduleModel = new MultiSelectSelectionModel(modules, selectedModules);
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.sslexplorer.wizard.forms.AbstractWizardForm#apply(com.sslexplorer.wizard.AbstractWizardSequence)
     */
    public void apply(AbstractWizardSequence sequence) throws Exception {
        super.apply(sequence);
        sequence.putAttribute(ATTR_SELECTED_MODULES, this.selectedModules);
    }

    /**
     * Get the module model
     * 
     * @return the module model.
     */
    public MultiSelectSelectionModel getModuleModel() {
        return moduleModel;
    }

    /**
     * Set the module model
     * 
     * @param moduleModel model to set.
     */
    public void setModuleModel(MultiSelectSelectionModel moduleModel) {
        this.moduleModel = moduleModel;
    }

    /**
     * Get the selected modules as a list
     * 
     * @return selected modules list
     */
    public PropertyList getSelectedModulesList() {
        return selectedModules;
    }

    /**
     * Get the selected modules as a string suitable for the multi select
     * components
     * 
     * @return selected modules as string
     */
    public String getSelectedModules() {
        return selectedModules.getAsTextFieldText();
    }

    /**
     * Set the selected modules as a string from the multi select components
     * 
     * @param selectedModules selected modules as string
     */
    public void setSelectedModules(String selectedModules) {
        this.selectedModules.setAsTextFieldText(selectedModules);
    }

    /**
     * Set the selected modules list
     * 
     * @param selectedModules selected modules list
     */
    public void setSelectedModulesList(PropertyList selectedModules) {
        this.selectedModules = selectedModules;
    }

    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        ActionErrors errs = new ActionErrors();
        if (this.isCommiting()) {
            PropertyList l = this.getSelectedModulesList();
            if (l.size() < 1) {
                errs.add(Globals.ERROR_KEY, new ActionMessage("editAuthenticationScheme.error.noModulesSelected"));
            } else {
                AuthenticationModuleDefinition def = AuthenticationModuleManager.getInstance().getModuleDefinition(
                                l.get(0).toString());
                if (!def.getPrimary()) {
                    errs.add(Globals.ERROR_KEY, new ActionMessage("editAuthenticationScheme.error.firstModuleNotPrimary"));
                }
            }
        }
        return errs;
    }

}

⌨️ 快捷键说明

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