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

📄 showuserstoreeditaction.java

📁 开源的OpenId的一个java实现
💻 JAVA
字号:
/* * Copyright 2005-2007 WSO2, Inc. (http://wso2.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.wso2.solutions.identity.admin.ui.action;import java.lang.reflect.Method;import java.util.ArrayList;import java.util.HashSet;import java.util.Iterator;import java.util.List;import java.util.Set;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpSession;import org.apache.struts2.StrutsStatics;import org.wso2.solutions.identity.IdentityProviderException;import org.wso2.solutions.identity.admin.RealmConfigAdmin;import org.wso2.solutions.identity.persistence.dataobject.RealmConfigurationDO;import org.wso2.solutions.identity.persistence.dataobject.RealmConfigurationPropertyDO;import org.wso2.usermanager.config.RealmConfigParameterInfo;import com.opensymphony.xwork2.ActionContext;public class ShowUserStoreEditAction        extends ManagedAction {    private static final long serialVersionUID = 8265273506039256750L;    private Set configProperties = null;    private String configName = null;    public String execute() throws Exception {        if (this.configName == null) {            return ERROR;        }        RealmConfigAdmin admin = new RealmConfigAdmin();        RealmConfigurationDO realm = admin.getRealmConfiguration(configName);        Set properties = realm.getConfigProperties();        Iterator ite = properties.iterator();        List reqNames = this.getRequiredList(realm.getRealm().getConfigClassName());        configProperties = new HashSet();        while (ite.hasNext()) {            RealmConfigurationPropertyDO configProp = (RealmConfigurationPropertyDO) ite                    .next();            ConfigProperty prop = new ConfigProperty();            if (reqNames.contains(configProp.getName())) {                prop.setIsRequired(true);            }            prop.setName(configProp.getName());            prop.setValue(configProp.getValue());            configProperties.add(prop);        }        return INPUT;    }    public String doUpdate() {        try {            HttpServletRequest request = (HttpServletRequest) ActionContext                    .getContext().get(StrutsStatics.HTTP_REQUEST);            String[] values = request.getParameterValues("configName");            configName = values[0];            RealmConfigAdmin admin = new RealmConfigAdmin();            RealmConfigurationDO realm = admin                    .getRealmConfiguration(configName);            configProperties = realm.getConfigProperties();            Iterator ite = configProperties.iterator();            while (ite.hasNext()) {                RealmConfigurationPropertyDO rdo = (RealmConfigurationPropertyDO) ite                        .next();                String name = rdo.getName();                values = request.getParameterValues(name);                rdo.setValue(values[0]);            }            admin.updateRealmConfigurationProperties(configProperties);        } catch (IdentityProviderException e) {            return ERROR;        }        return SUCCESS;    }    public String getConfigName() {        return configName;    }    public void setConfigName(String configName) {        this.configName = configName;    }    public Set getConfigProperties() {        return configProperties;    }    public void setConfigProperties(Set configProperties) {        this.configProperties = configProperties;    }    private List getRequiredList(String configClassName) throws Exception {        List requiredProps = new ArrayList();        Class configClass = Class.forName(configClassName);        Method[] methods = configClass.getDeclaredMethods();        for (int i = 0; i < methods.length; i++) {            final String name = methods[i].getName();            if (name.startsWith("set")) {                RealmConfigParameterInfo info = (RealmConfigParameterInfo) methods[i]                        .getAnnotation(RealmConfigParameterInfo.class);                if (info != null) {                    if (info.isRequired()) {                        requiredProps.add(name.substring(3));                    }                }            }        }        return requiredProps;    }    public class ConfigProperty {        private String name;        private boolean isRequired;        private String value;        public boolean getIsRequired() {            return isRequired;        }        public String getName() {            return name;        }        public void setName(String name) {            this.name = name;        }        public String getValue() {            return value;        }        public void setValue(String value) {            this.value = value;        }        public void setIsRequired(boolean isRequired) {            this.isRequired = isRequired;        }    }}

⌨️ 快捷键说明

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