📄 relyingpartyadmin.java
字号:
/* * Copyright 2005,2006 WSO2, Inc. http://www.wso2.org * * 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;import org.apache.axis2.AxisFault;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.wso2.solutions.identity.IdentityProviderConstants;import org.wso2.solutions.identity.IdentityProviderException;import org.wso2.solutions.identity.i18n.Messages;import org.wso2.solutions.identity.persistence.IPPersistenceManager;import org.wso2.solutions.identity.persistence.dao.UserPersonalRelyingPartyDAO;import org.wso2.solutions.identity.persistence.dataobject.OpenIDUserRPDO;import org.wso2.solutions.identity.persistence.dataobject.RelyingPartyDO;import org.wso2.solutions.identity.persistence.dataobject.UserPersonalRelyingPartyIdentifier;import org.wso2.solutions.identity.persistence.dataobject.UserTrustedRPDO;public class RelyingPartyAdmin { private static Log log = LogFactory.getLog(RelyingPartyAdmin.class); Messages messages = Messages.getInstance(IdentityProviderConstants.RESOURCES); IPPersistenceManager dbMan; public RelyingPartyAdmin() throws IdentityProviderException { dbMan = IPPersistenceManager.getPersistanceManager(); } public void create(String rpName) throws AxisFault { try { RelyingPartyDO rp = new RelyingPartyDO(); rp.setHostName(rpName); dbMan.create(rp); } catch (IdentityProviderException e) { throw new AxisFault(e.getMessage(), e); } } public void create(RelyingPartyDO rp) throws AxisFault { try { dbMan.create(rp); } catch (IdentityProviderException e) { throw new AxisFault(e.getMessage(), e); } } public UserTrustedRPDO getPersonalRelyingParty(String alias, String user) throws AxisFault { return dbMan.getPersonalRelyingParty(user, alias); } public void create(UserTrustedRPDO rp) throws AxisFault { try { dbMan.create(rp); } catch (IdentityProviderException e) { throw new AxisFault(e.getMessage(), e); } } public void create(OpenIDUserRPDO rpdo) throws AxisFault { try { dbMan.create(rpdo); } catch (IdentityProviderException e) { throw new AxisFault(e.getMessage(), e); } } public void update(OpenIDUserRPDO rpdo) { dbMan.update(rpdo); } public RelyingPartyDO[] getAllRelyingPartyList() { return dbMan.getAllRelyingParties(); } public RelyingPartyDO getRelyingParty(String url) { return dbMan.getRelyingParty(url); } public void deleteRelyingParty(RelyingPartyDO rp) throws IdentityProviderException { log.info(messages.getMessage("deletedRp", new String[] { rp.getHostName() })); dbMan.delete(rp); //remove from keystore KeystoreUtilAdmin ksAdmin = new KeystoreUtilAdmin(); ksAdmin.deleteRelyingParty(rp.getHostName()); } public RelyingPartyDO findRelyingParty(Long id) { return (RelyingPartyDO) dbMan.getDataObject("RelyingPartyDO", id); } public UserTrustedRPDO[] getAllPersonalRelyingParties( String userId) { return dbMan.getAllPersonalRelyingParties(userId); } /** * Remove a personal relying party * @param user * @param hostName */ public void removePersonalRelyingParty(String user, String hostName) throws IdentityProviderException { UserTrustedRPDO rpDO = dbMan.getPersonalRelyingParty(user, hostName); dbMan.delete(rpDO); if(dbMan.getPersonalRelyingPartyByHostName(hostName).length==0){ KeystoreUtilAdmin ksAdmin = new KeystoreUtilAdmin(); ksAdmin.removeCertEntryFromUserTrustedRP(hostName); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -