📄 authenticationschemeform.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.forms;
import java.util.Iterator;
import javax.servlet.http.HttpServletRequest;
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.MultiSelectSelectionModel;
import com.sslexplorer.policyframework.PolicyConstants;
import com.sslexplorer.policyframework.Resource;
import com.sslexplorer.policyframework.forms.AbstractResourceForm;
import com.sslexplorer.security.AuthenticationModuleDefinition;
import com.sslexplorer.security.AuthenticationModuleManager;
import com.sslexplorer.security.AuthenticationSchemeSequence;
import com.sslexplorer.security.User;
/**
* Implementation of a {@link com.sslexplorer.policyframework.forms.AbstractResourceForm}
* that allows an administrator to edit an <i>Authentication Scheme</i>.
*
* @author Brett Smith <a href="mailto:brett@3sp.com"><brett@3sp.com></a>
* @version $Revision: 1.9 $
* @see com.sslexplorer.security.AuthenticationScheme
*/
public class AuthenticationSchemeForm extends AbstractResourceForm {
// Protected instnace variables
protected String selectedTab;
protected MultiSelectSelectionModel moduleModel;
protected PropertyList selectedModules;
/* (non-Javadoc)
* @see org.apache.struts.action.ActionForm#validate(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
*/
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
ActionErrors errs = super.validate(mapping, request);
if(isCommiting()) {
PropertyList l = 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;
}
/* (non-Javadoc)
* @see com.sslexplorer.policyframework.forms.AbstractResourceForm#applyToResource()
*/
public void applyToResource() throws Exception {
AuthenticationSchemeSequence seq = (AuthenticationSchemeSequence)getResource();
seq.clearModules();
for(Iterator i = getSelectedModulesList().iterator(); i.hasNext(); ) {
seq.addModule((String)i.next());
}
}
/* (non-Javadoc)
* @see com.sslexplorer.tabs.TabModel#getTabCount()
*/
public int getTabCount() {
return 3;
}
/* (non-Javadoc)
* @see com.sslexplorer.tabs.TabModel#getTabName(int)
*/
public String getTabName(int idx) {
switch (idx) {
case 0:
return "details";
case 1:
return "modules";
default:
return "policies";
}
}
/*
* (non-Javadoc)
*
* @see com.sslexplorer.tabs.TabModel#getSelectedTab()
*/
public String getSelectedTab() {
return selectedTab;
}
/*
* (non-Javadoc)
*
* @see com.sslexplorer.tabs.TabModel#setSelectedTab(java.lang.String)
*/
public void setSelectedTab(String selectedTab) {
this.selectedTab = selectedTab;
}
/* (non-Javadoc)
* @see com.sslexplorer.tabs.TabModel#getTabTitle(int)
*/
public String getTabTitle(int i) {
return null;
}
/* (non-Javadoc)
* @see com.sslexplorer.policyframework.forms.AbstractResourceForm#getResourceByName(java.lang.String)
*/
public Resource getResourceByName(String resourceName) throws Exception {
return PolicyConstants.AUTHENTICATION_SCHEMES_RESOURCE_TYPE.getResourceByName(resourceName);
}
/**
* 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;
}
/* (non-Javadoc)
* @see com.sslexplorer.tabs.TabModel#getTabBundle(int)
*/
public String getTabBundle(int idx) {
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);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -