📄 showaddrealmconfigurationaction.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 org.apache.struts2.StrutsStatics;import org.wso2.solutions.identity.admin.ui.UIConstants;import org.wso2.solutions.identity.persistence.IPPersistenceManager;import org.wso2.usermanager.config.RealmConfigParameterInfo;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpSession;import java.lang.reflect.Method;import java.util.ArrayList;import java.util.List;import com.opensymphony.xwork2.ActionContext;public class ShowAddRealmConfigurationAction extends ManagedAction { private static final long serialVersionUID = 9004883005928113131L; private List configProperties; private String realmClassName; public String execute() throws Exception { HttpServletRequest request = (HttpServletRequest) ActionContext .getContext().get(StrutsStatics.HTTP_REQUEST); this.realmClassName = request .getParameter(UIConstants.REALM_CLASS_NAME); HttpSession session = request.getSession(); if(this.realmClassName == null) { //Try the session, when returning from validation this.realmClassName = (String)session.getAttribute(UIConstants.REALM_CLASS_NAME); } session.setAttribute(UIConstants.REALM_CLASS_NAME, realmClassName); IPPersistenceManager db = IPPersistenceManager.getPersistanceManager(); String configClassName = db.getRealm(realmClassName) .getConfigClassName(); Class configClass = Class.forName(configClassName); Method[] methods = configClass.getDeclaredMethods(); this.configProperties = new ArrayList(); for (int i = 0; i < methods.length; i++) { final String name = methods[i].getName(); if (name.startsWith("set")) { ConfigProperty property = new ConfigProperty(); property.propertyName = name.substring(3, name.length()); RealmConfigParameterInfo info = (RealmConfigParameterInfo)methods[i].getAnnotation(RealmConfigParameterInfo.class); if(info != null){ property.isRequired = info.isRequired(); property.helpText = info.getHelpText(); } this.configProperties.add(property); } } session.setAttribute(UIConstants.REALM_CONFIG_PROPERTIES, this.configProperties); this.loadMessages(); return SUCCESS; } public List getConfigProperties() { return configProperties; } public class ConfigProperty{ private String propertyName; private boolean isRequired; private String helpText; public String getHelpText() { return helpText; } public boolean getIsRequired() { return isRequired; } public String getPropertyName() { return propertyName; } public void setHelpText(String helpText) { this.helpText = helpText; } public void setRequired(boolean isRequired) { this.isRequired = isRequired; } public void setPropertyName(String propertyName) { this.propertyName = propertyName; } } public String getRealmClassName() { return realmClassName; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -