📄 showmainaction.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.user.ui.action;import org.wso2.solutions.identity.IdentityConstants;import org.wso2.solutions.identity.IdentityProviderConstants;import org.wso2.solutions.identity.UserStore;import org.wso2.solutions.identity.admin.ClaimsAdmin;import org.wso2.solutions.identity.admin.ParameterAdmin;import org.wso2.solutions.identity.admin.RegisteredInfoCardInfoAdmin;import org.wso2.solutions.identity.admin.RelyingPartyAdmin;import org.wso2.solutions.identity.persistence.IPPersistenceManager;import org.wso2.solutions.identity.persistence.dataobject.ClaimDO;import org.wso2.solutions.identity.persistence.dataobject.OpenIDUserRPDO;import org.wso2.solutions.identity.persistence.dataobject.UserTrustedRPDO;import org.wso2.solutions.identity.user.ui.UIConstants;import org.wso2.solutions.identity.user.ui.UserProfile;import org.wso2.solutions.identity.users.IdentityDefaultRealm;import org.wso2.solutions.identity.users.IdentityUserStoreReader;import java.util.ArrayList;import java.util.Arrays;import java.util.Iterator;import java.util.List;import java.util.Map;import com.opensymphony.xwork2.ActionContext;public class ShowMainAction extends ManagedAction { private static final long serialVersionUID = -420264928772655254L; private List personalRPs; private List claims; private List registeredInformationCards; private List openIDUserRPs; private List profiles; private boolean enableOpenIDRegistration; private boolean allowUserRegistration; public boolean isAllowUserRegistration() { return allowUserRegistration; } public void setAllowUserRegistration(boolean allowUserRegistration) { this.allowUserRegistration = allowUserRegistration; } public String execute() throws Exception { RelyingPartyAdmin admin = new RelyingPartyAdmin(); Map session = ActionContext.getContext().getSession(); String user = (String) session.get(UIConstants.USER); ParameterAdmin paramAdmin = new ParameterAdmin(); this.enableOpenIDRegistration = paramAdmin .getParameter(IdentityProviderConstants.PARAM_NAME_ENABLE_OPENID_REGISTRATION) != null; this.allowUserRegistration = paramAdmin .getParameter(IdentityProviderConstants.PARAM_NAME_ALLOW_USER_REGISTRATION) != null; this.personalRPs = Arrays.asList((UserTrustedRPDO[]) admin .getAllPersonalRelyingParties(user)); ClaimsAdmin ClaimsAdmin = new ClaimsAdmin(); ClaimDO[] claimDOs = ClaimsAdmin.getAllMappedEnabledClaims(); this.claims = Arrays.asList((ClaimDO[]) claimDOs); RegisteredInfoCardInfoAdmin regCardInfoAdmin = new RegisteredInfoCardInfoAdmin(); this.registeredInformationCards = regCardInfoAdmin .getAllRegisteredInfoCards(user); if (enableOpenIDRegistration) { UserStore userStore = null; List propertyNames = null; Map mapValues = null; userStore = UserStore.getInstance(); propertyNames = new ArrayList(); propertyNames.add(IdentityConstants.CLAIM_OPENID); // Right now we don't have a single method in UserStore, which // returns // the value of a single claim so we use a List. mapValues = userStore.getClaimValues(user, propertyNames); if (mapValues != null && !mapValues.isEmpty()) { String openid = (String) mapValues .get(IdentityConstants.CLAIM_OPENID); if (openid != null && openid.trim().length() > 0) this.addInfoMessage("Your OpenID is: " + openid); else enableOpenIDRegistration = false; } IPPersistenceManager db = IPPersistenceManager .getPersistanceManager(); OpenIDUserRPDO[] rpdos = null; rpdos = db.getOpenIDUserRP(user); this.openIDUserRPs = Arrays.asList((OpenIDUserRPDO[]) rpdos); } if (allowUserRegistration) { IdentityDefaultRealm realm = null; IdentityUserStoreReader reader = null; IPPersistenceManager db = null; RelyingPartyAdmin rpAdmin = null; String defaultProfileName = null; List userProfiles = null; profiles = new ArrayList(); realm = (IdentityDefaultRealm) UserStore.getInstance().getRealm(); reader = realm.getIdentityUserStoreReader(); userProfiles = reader.getUserProfileNames(user); defaultProfileName = reader.getDefaultUserProfileName(user); for (Iterator iterator = userProfiles.iterator(); iterator .hasNext();) { String name = (String) iterator.next(); UserProfile userProfile = new UserProfile(); userProfile.setProfileName(name); if (name.equals(defaultProfileName)) { userProfile.setDefaultProfile(true); } else { userProfile.setDefaultProfile(false); } profiles.add(userProfile); } } this.loadMessages(); return SUCCESS; } public List getProfiles() { return profiles; } public void setProfiles(List profiles) { this.profiles = profiles; } public List getPersonalRPs() { return personalRPs; } public List getClaims() { return claims; } public List getRegisteredInformationCards() { return registeredInformationCards; } public boolean isEnableOpenIDRegistration() { return enableOpenIDRegistration; } public List getOpenIDUserRPs() { return openIDUserRPs; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -