📄 initialclaimsprocessor.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;import org.apache.axiom.om.OMElement;import org.apache.axiom.om.impl.builder.StAXOMBuilder;import org.wso2.solutions.identity.persistence.dataobject.ClaimDO;import org.wso2.solutions.identity.persistence.dataobject.DialectDO;import javax.xml.namespace.QName;import java.util.ArrayList;import java.util.Iterator;/** * This processes the list of initial claims given to the identity provider at * the initial start up. */public class InitialClaimsProcessor { public final static String LN_CLAIMS = "Claims"; public final static String LN_CLAIM_TYPE = "ClaimType"; public final static String LN_DISPLAY_TAG = "DisplayTag"; public final static String LN_DESCRIPTION = "Description"; public final static String LN_OPENID_TAG = "OpenIDTag"; public final static String ATTR_DIALECT = "Dialect"; public final static String ATTR_DIALECT_INFO = "DialectInfo"; public final static String ATTR_URI = "Uri"; private ArrayList claimList = new ArrayList(); private ArrayList dialectList = new ArrayList(); public void process(OMElement initialClaims) throws IdentityProviderException { Iterator claims = initialClaims .getChildrenWithName(new QName(LN_CLAIMS)); while (claims.hasNext()) { OMElement claimsElement = (OMElement) claims.next(); String dialectUri = claimsElement.getAttributeValue(new QName( ATTR_DIALECT)); if (dialectUri != null && dialectUri.length() != 0) { String dialectInfo = claimsElement.getAttributeValue(new QName( ATTR_DIALECT_INFO)); DialectDO dialect = new DialectDO(); dialect.setDialectUri(dialectUri); dialect.setDialectInfo(dialectInfo); Iterator claimTypes = claimsElement .getChildrenWithName(new QName(LN_CLAIM_TYPE)); while (claimTypes.hasNext()) { OMElement claimTypeElem = (OMElement) claimTypes.next(); String claimUri = claimTypeElem .getAttributeValue(new QName(ATTR_URI)); if (claimUri != null && claimUri.length() != 0) { OMElement dnElem = claimTypeElem .getFirstChildWithName(new QName(LN_DISPLAY_TAG)); String displayTag = null; if (dnElem != null) { displayTag = dnElem.getText(); } OMElement descElem = claimTypeElem .getFirstChildWithName(new QName(LN_DISPLAY_TAG)); String description = null; if (dnElem != null) { description = descElem.getText(); } // Claims which are supported by OpenID will have a OpenIDTag. OMElement openIDElem = claimTypeElem .getFirstChildWithName(new QName(LN_OPENID_TAG)); String openIDTag = null; if (openIDElem != null) { openIDTag = openIDElem.getText(); } ClaimDO claimDO = new ClaimDO(); claimDO.setUri(claimUri); claimDO.setDisplayTag(displayTag); claimDO.setDescription(description); claimDO.setOpenIDTag(openIDTag); claimDO.setDialect(dialect); this.claimList.add(claimDO); } else { throw new IdentityProviderException(LN_CLAIM_TYPE + " element MUST contain a " + ATTR_URI + " uri value"); } } this.dialectList.add(dialect); } else { throw new IdentityProviderException(LN_CLAIMS + " element MUST contain a " + ATTR_DIALECT + " uri value"); } } } public void process(String filePath) throws IdentityProviderException { try { StAXOMBuilder builder = new StAXOMBuilder(filePath); OMElement elem = builder.getDocumentElement(); this.process(elem); } catch (Exception e) { throw new IdentityProviderException(e.getMessage(), e); } } public ArrayList getClaimList() { return claimList; } public ArrayList getDialectList() { return dialectList; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -