📄 showauthenticationschemesdispatchaction.java
字号:
ActionMessages mesgs = new ActionMessages();
if (defaultScheme == id) {
List allSchemes = CoreServlet.getServlet().getSystemDatabase().getAuthenticationSchemeSequences();
// Look for the next enabled scheme
int nextEnabled = -1;
for (Iterator i = allSchemes.iterator(); i.hasNext();) {
AuthenticationSchemeSequence oseq = (AuthenticationSchemeSequence) i.next();
if (!oseq.equals(seq) && oseq.getEnabled()) {
nextEnabled = oseq.getResourceId();
}
}
if (nextEnabled == -1) {
mesgs.add(Globals.ERROR_KEY, new ActionMessage("authenticationSchemes.error.mustHaveOneEnabledScheme"));
saveErrors(request, mesgs);
return list(mapping, form, request, response);
} else {
PropertyUtil.getPropertyUtil().setProperty(0, null, "authenticationScheme.default", String.valueOf(nextEnabled),
getSessionInfo());
}
}
doRemove(mapping, form, request, response);
PolicyUtil.detachResourceFromPolicyList(seq, getSessionInfo());
CoreServlet.getServlet().getSystemDatabase().deleteAuthenticationSchemeSequence(id);
mesgs.add(Globals.MESSAGE_KEY, new ActionMessage("authenticationSchemes.message.schemeDeleted", seq.getResourceName()));
saveMessages(request, mesgs);
return mapping.findForward("refresh");
}
/**
* Disable the selected authentication scheme.
*
* @param mapping mapping
* @param form form
* @param request request
* @param response response
* @return forward
* @throws Exception on any error
*/
public ActionForward disable(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws Exception {
PolicyUtil.checkPermission(PolicyConstants.AUTHENTICATION_SCHEMES_RESOURCE_TYPE, PolicyConstants.PERM_EDIT_AND_ASSIGN,
request);
AuthenticationSchemesForm schemesForm = (AuthenticationSchemesForm) form;
int id = schemesForm.getSelectedResource();
int defaultScheme = CoreServlet.getServlet().getPropertyDatabase().getPropertyInt(0, null, "authenticationScheme.default");
AuthenticationSchemeSequence seq = CoreServlet.getServlet().getSystemDatabase().getAuthenticationSchemeSequence(id);
if (seq == null) {
throw new Exception("No scheme with Id of " + id + ".");
}
ActionMessages mesgs = new ActionMessages();
List authSchemes = CoreServlet.getServlet().getSystemDatabase().getAuthenticationSchemeSequences();
int enabled = 0;
for (Iterator i = authSchemes.iterator(); i.hasNext();) {
AuthenticationSchemeSequence oseq = (AuthenticationSchemeSequence) i.next();
if (oseq.getResourceId() == id && !oseq.getEnabled()) {
throw new Exception("Scheme already disabled.");
}
if (oseq.getEnabled()) {
enabled++;
}
}
if (enabled == 1) {
mesgs.add(Globals.ERROR_KEY, new ActionMessage("authenticationSchemes.error.cantDisableLastEnabledScheme"));
saveErrors(request, mesgs);
return list(mapping, form, request, response);
}
if (defaultScheme == id) {
mesgs.add(Globals.ERROR_KEY, new ActionMessage("authenticationSchemes.error.cantDisableDefaultScheme"));
saveErrors(request, mesgs);
return list(mapping, form, request, response);
}
seq.setEnabled(false);
CoreServlet.getServlet().getSystemDatabase().updateAuthenticationSchemeSequence(seq);
mesgs.add(Globals.MESSAGE_KEY, new ActionMessage("authenticationSchemes.message.schemeDisabled", seq.getResourceName()));
saveMessages(request, mesgs);
return list(mapping, form, request, response);
}
/**
* Enable the selected authentication scheme.
*
* @param mapping mapping
* @param form form
* @param request request
* @param response response
* @return forward
* @throws Exception on any error
*/
public ActionForward enable(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws Exception {
PolicyUtil.checkPermission(PolicyConstants.AUTHENTICATION_SCHEMES_RESOURCE_TYPE, PolicyConstants.PERM_EDIT_AND_ASSIGN,
request);
AuthenticationSchemesForm schemesForm = (AuthenticationSchemesForm) form;
int id = schemesForm.getSelectedResource();
AuthenticationSchemeSequence seq = CoreServlet.getServlet().getSystemDatabase().getAuthenticationSchemeSequence(id);
if (seq == null) {
throw new Exception("No scheme with Id of " + id + ".");
}
if (seq.getEnabled()) {
throw new Exception("Alreadty enabled.");
}
ActionMessages mesgs = new ActionMessages();
seq.setEnabled(true);
CoreServlet.getServlet().getSystemDatabase().updateAuthenticationSchemeSequence(seq);
mesgs.add(Globals.MESSAGE_KEY, new ActionMessage("authenticationSchemes.message.schemeEnabled", seq.getResourceName()));
saveMessages(request, mesgs);
return list(mapping, form, request, response);
}
/**
* Edit the selected authentication scheme.
*
* @param mapping mapping
* @param form form
* @param request request
* @param response response
* @return forward
* @throws Exception on any error
*/
public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws Exception {
PolicyUtil.checkPermissions(PolicyConstants.AUTHENTICATION_SCHEMES_RESOURCE_TYPE, new Permission[] {
PolicyConstants.PERM_EDIT_AND_ASSIGN, PolicyConstants.PERM_CREATE_EDIT_AND_ASSIGN,
PolicyConstants.PERM_ASSIGN }, request);
AuthenticationSchemesForm schemesForm = (AuthenticationSchemesForm) form;
int id = schemesForm.getSelectedResource();
AuthenticationSchemeSequence seq = CoreServlet.getServlet().getSystemDatabase().getAuthenticationSchemeSequence(id);
if (seq == null) {
throw new Exception("No scheme with Id of " + id + ".");
}
if (seq.isSystemScheme()) {
throw new Exception("Cannot remove system schemes.");
}
request.getSession().setAttribute(
Constants.EDITING_RESOURCE,
CoreServlet.getServlet().getSystemDatabase().getAuthenticationSchemeSequence(
((AuthenticationSchemesForm) form).getSelectedResource()));
return mapping.findForward("edit");
}
/**
* List the authentication schemes configured.
*
* @param mapping mapping
* @param form form
* @param request request
* @param response response
* @return forward
* @throws Exception on any error
*/
public ActionForward list(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws Exception {
AuthenticationSchemesForm schemesForm = (AuthenticationSchemesForm) form;
List schemes = CoreServlet.getServlet().getSystemDatabase().getAuthenticationSchemeSequences();
schemesForm.initialize(request.getSession(), schemes);
Util.noCache(response);
return mapping.findForward("display");
}
/*
* (non-Javadoc)
*
* @see com.sslexplorer.core.actions.CoreAction#getNavigationContext(org.apache.struts.action.ActionMapping,
* org.apache.struts.action.ActionForm,
* javax.servlet.http.HttpServletRequest,
* javax.servlet.http.HttpServletResponse)
*/
public int getNavigationContext(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
return SessionInfo.MANAGEMENT_CONSOLE_CONTEXT;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -