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

📄 infocarduserregistrationsubmitaction.java

📁 开源的OpenId的一个java实现
💻 JAVA
字号:
/* * Copyright 2004,2005 The Apache Software Foundation. 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 java.util.HashMap;import javax.servlet.http.HttpServletRequest;import org.apache.axiom.om.util.UUIDGenerator;import org.apache.struts2.StrutsStatics;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.ReportAdmin;import org.wso2.solutions.identity.openid.OpenIDProvider;import org.wso2.solutions.identity.openid.OpenIDUtil;import org.wso2.solutions.identity.persistence.dataobject.ActionDO;import org.wso2.solutions.identity.persistence.dataobject.ClaimDO;import org.wso2.solutions.identity.relyingparty.TokenVerifierConstants;import org.wso2.solutions.identity.util.IdentityUtil;import com.opensymphony.xwork2.ActionContext;public class InfoCardUserRegistrationSubmitAction extends ManagedAction {    private static final long serialVersionUID = -8132077631173378913L;    public String execute() throws Exception {        ActionContext context = ActionContext.getContext();        HttpServletRequest request = (HttpServletRequest) context                .get(StrutsStatics.HTTP_REQUEST);        String ppid = (String) request                .getAttribute(IdentityConstants.CLAIM_PPID);        if (ppid == null) {            this.addErrorMessage(getText("no_selector"));            return ERROR;        }        RegisteredInfoCardInfoAdmin admin = new RegisteredInfoCardInfoAdmin();        if (admin.isRegistedInformationCard(ppid)) {            this.addErrorMessage(getText("card_alredy_registered",                    new String[] { IdentityUtil.getPPIDDisplayValue(ppid) }));            return ERROR;        }        try {            UserStore store = UserStore.getInstance();            String userName = IdentityUtil.getPPIDDisplayValue(ppid);            store.getRealm().getUserStoreAdmin().addUser(userName,                    UUIDGenerator.getUUID());            ClaimsAdmin ClaimsAdmin = new ClaimsAdmin();            ClaimDO[] claimDOs = ClaimsAdmin.getAllMappedEnabledClaims();            HashMap props = new HashMap();            for (int i = 0; i < claimDOs.length; i++) {                if (request.getAttribute(claimDOs[i].getUri()) != null) {                    props.put(claimDOs[i].getUri(), (String) request                            .getAttribute(claimDOs[i].getUri()));                } else if (claimDOs[i].isRequired()) {                    // You will not get here - since the identity selector makes                    // sure all the required attributes are provided.                    this.addActionError("Required attribute missing");                    return ERROR;                }            }            ParameterAdmin paramAdmin = new ParameterAdmin();            boolean enableOpenIDRegistration = paramAdmin                    .getParameter(IdentityProviderConstants.PARAM_NAME_ENABLE_OPENID_REGISTRATION) != null;            String openid = null;            if (enableOpenIDRegistration) {                // We create an OpenID for all registering users                openid = OpenIDUtil.generateOpenID(userName);                props.put(IdentityConstants.CLAIM_OPENID, openid);            }            store.getRealm().getUserStoreAdmin().setUserProperties(userName,                    props);            String issuerInfo = (String) request                    .getAttribute(TokenVerifierConstants.ISSUER_INFO);            admin.registerNewInfoCardInformation(ppid, userName, issuerInfo);            ReportAdmin.record(userName, ActionDO.ACTION_USER_INFOCARD_SUBMIT,                    "PPID=" + ppid);            this.addInfoMessage(getText("user_successfully_added",                    new String[] { userName }));            if (enableOpenIDRegistration) {                this.addInfoMessage("Your OpenID is " + openid);            }        } catch (RuntimeException e) {            this.addActionError(e.getMessage());            return ERROR;        }        return SUCCESS;    }}

⌨️ 快捷键说明

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