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

📄 listuserattributecategoriesaction.java

📁 这是linux下ssl vpn的实现程序
💻 JAVA
字号:
package com.sslexplorer.ajax;

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

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.ajaxtags.helpers.AjaxXmlBuilder;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.util.MessageResources;

import com.sslexplorer.core.CoreServlet;
import com.sslexplorer.core.CoreUtil;
import com.sslexplorer.security.SessionInfo;
import com.sslexplorer.security.UserAttributeDefinition;


/**
 * Implementation of {@link com.sslexplorer.ajax.AbstractAjaxXMLAction}
 *  that returns an XML document containing all currently configured 
 *  <i>User Attribute Definition</i> categories.
 * <p>
 * A single request parameter is supported, <i>category</i> that will narrow
 * the results returned to those that begin with the supplied value.  
 * 
 * @author Brett Smith <a href="mailto: brett@3sp.com">&lt;brett@3sp.com&gt;</a>
 * @revision $Revision: 1.3 $
 */
public class ListUserAttributeCategoriesAction extends AbstractAjaxXMLAction {

    /* (non-Javadoc)
     * @see com.sslexplorer.core.actions.AuthenticatedAction#onExecute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
     */
    protected void onAjaxRequest(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                    HttpServletResponse response, AjaxXmlBuilder builder) throws Exception {
        List c = new ArrayList();
        List l = CoreServlet.getServlet().getUserDatabase().getUserAttributeDefinitions();
        String category = request.getParameter("category"); 
        for(Iterator i = l.iterator(); i.hasNext(); ) {
            UserAttributeDefinition def = (UserAttributeDefinition)i.next();
            String categoryLabel = def.getCategoryLabel();
            MessageResources mr = CoreUtil.getMessageResources(request.getSession(), def.getMessageResourcesKey());
            String s = mr == null ? null : mr.getMessage("userAttributeCategory." + def.getCategory() + ".title");
            if (s != null && !s.equals("")) {
                categoryLabel = s;
            } else {
                categoryLabel = categoryLabel == null || categoryLabel.equals("") ? "Attributes" : categoryLabel;
            }
            if(( category == null || category.equals("") || categoryLabel.toLowerCase().startsWith(category.toLowerCase()) ) && !c.contains(categoryLabel)) {
                c.add(categoryLabel);
            }
        }
        for(Iterator i = c.iterator(); i.hasNext(); ) {
            String n = (String)i.next();
            builder.addItem(n, n);
        }
    }

    /* (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 + -