当前位置: 首页>>代码示例>>Java>>正文


Java XSString类代码示例

本文整理汇总了Java中org.opensaml.xml.schema.XSString的典型用法代码示例。如果您正苦于以下问题:Java XSString类的具体用法?Java XSString怎么用?Java XSString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


XSString类属于org.opensaml.xml.schema包,在下文中一共展示了XSString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createXSString

import org.opensaml.xml.schema.XSString; //导入依赖的package包/类
/**
 * Utility method for creating an OpenSAML object given its type and assigns the value.
 * 
 * @param clazz
 *          the class to create
 * @param value
 *          the string value to assign
 * @return the XML object or {@code null} if value is {@code null}
 */
private <T extends XSString> T createXSString(Class<T> clazz, String value) {
  if (value == null) {
    return null;
  }
  QName elementName = null;
  String localName = null;
  try {
    elementName = (QName) clazz.getDeclaredField("DEFAULT_ELEMENT_NAME").get(null);
    localName = (String) clazz.getDeclaredField("DEFAULT_ELEMENT_LOCAL_NAME").get(null);
  }
  catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException | SecurityException e) {
    throw new RuntimeException(e);
  }
  XMLObjectBuilder<?> builder = Configuration.getBuilderFactory().getBuilder(elementName);
  XMLObject object = builder.buildObject(new QName(this.getElementQName().getNamespaceURI(), localName, this.getElementQName().getPrefix()));
  T xsstring = clazz.cast(object);
  xsstring.setValue(value);
  return xsstring;
}
 
开发者ID:litsec,项目名称:eidas-opensaml,代码行数:29,代码来源:CurrentAddressStructuredTypeImpl.java

示例2: extractAttributeValueValue

import org.opensaml.xml.schema.XSString; //导入依赖的package包/类
/**
 * Extract the value of the first attributeValue within an SAML20 attribute
 * 
 * @param attribute
 *            The attribute
 * @return The text value of the attributeValue
 */
public static String extractAttributeValueValue(Attribute attribute) {
	for (int i = 0; i < attribute.getAttributeValues().size(); i++) {
		if (attribute.getAttributeValues().get(i) instanceof XSString) {
			XSString str = (XSString) attribute.getAttributeValues().get(i);
			if (AttributeValue.DEFAULT_ELEMENT_LOCAL_NAME.equals(str.getElementQName().getLocalPart())
					&& SAMLConstants.SAML20_NS.equals(str.getElementQName().getNamespaceURI())) {
				return str.getValue();
			}
		} else {
			XSAny ep = (XSAny) attribute.getAttributeValues().get(i);
			if (AttributeValue.DEFAULT_ELEMENT_LOCAL_NAME.equals(ep.getElementQName().getLocalPart())
					&& SAMLConstants.SAML20_NS.equals(ep.getElementQName().getNamespaceURI())) {
				if (ep.getUnknownXMLObjects().size() > 0) {
					StringBuilder res = new StringBuilder();
					for (XMLObject obj : ep.getUnknownXMLObjects()) {
						res.append(XMLHelper.nodeToString(SAMLUtil.marshallObject(obj)));
					}
					return res.toString();
				}
				return ep.getTextContent();
			}
		}
	}
	return null;
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:33,代码来源:AttributeUtil.java

示例3: buildAttributeStatement

import org.opensaml.xml.schema.XSString; //导入依赖的package包/类
/**
 * Build attribute statement section for a SAML Assertion
 *
 * @param pAttributeMap Map of attribute keys to values (currently strings only)
 * @return SAML Attribute Statement object for inclusion in a SAML Assertion
 */
private AttributeStatement buildAttributeStatement(Map<String, String> pAttributeMap) {
  AttributeStatement lAttributeStatement = null;
  if (pAttributeMap != null) {
    lAttributeStatement = new AttributeStatementBuilder().buildObject();

    for (Map.Entry<String, String> lAttributeEntry : pAttributeMap.entrySet()) {
      Attribute lAttribute = new AttributeBuilder().buildObject();
      lAttribute.setName(lAttributeEntry.getKey());

      // Currently just set all value as string type
      XSString lStringAttributeValue = (XSString) buildXMLObject(XSString.TYPE_NAME);
      lStringAttributeValue.setValue(lAttributeEntry.getValue());

      lAttribute.getAttributeValues().add(lStringAttributeValue);
      lAttributeStatement.getAttributes().add(lAttribute);
    }
  }
  return lAttributeStatement;
}
 
开发者ID:Fivium,项目名称:FOXopen,代码行数:26,代码来源:SAMLResponseCommand.java

示例4: buildAttributeStatement

import org.opensaml.xml.schema.XSString; //导入依赖的package包/类
/**
 * Build Attribute Statement
 *
 * @param claims
 * @return AttributeStatement
 */
private AttributeStatement buildAttributeStatement(Map<String, String> claims) {
    AttributeStatement attStmt = null;
    if (claims != null) {
        attStmt = new AttributeStatementBuilder().buildObject();
        Iterator<String> ite = claims.keySet().iterator();

        for (int i = 0; i < claims.size(); i++) {
            Attribute attrib = new AttributeBuilder().buildObject();
            String claimUri = ite.next();
            attrib.setName(claimUri);
            // look
            // https://wiki.shibboleth.net/confluence/display/OpenSAML/OSTwoUsrManJavaAnyTypes
            XSStringBuilder stringBuilder =
                    (XSStringBuilder) Configuration.getBuilderFactory()
                            .getBuilder(XSString.TYPE_NAME);
            XSString stringValue =
                    stringBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME,
                            XSString.TYPE_NAME);
            stringValue.setValue(claims.get(claimUri));
            attrib.getAttributeValues().add(stringValue);
            attStmt.getAttributes().add(attrib);
        }
    }
    return attStmt;
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:32,代码来源:SAMLResponseBuilder.java

示例5: createAttributeStatement

import org.opensaml.xml.schema.XSString; //导入依赖的package包/类
private AttributeStatement createAttributeStatement(HashMap<String, List<String>> attributes) {
	// create authenticationstatement object
	AttributeStatementBuilder attributeStatementBuilder = new AttributeStatementBuilder();
	AttributeStatement attributeStatement = attributeStatementBuilder.buildObject();
	
	AttributeBuilder attributeBuilder = new AttributeBuilder();
	if (attributes != null) {
		for (Map.Entry<String, List<String>> entry : attributes.entrySet()) {
			Attribute attribute = attributeBuilder.buildObject();
			attribute.setName(entry.getKey());
			
			for (String value : entry.getValue()) {
				XSStringBuilder stringBuilder = new XSStringBuilder();
				XSString attributeValue = stringBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, XSString.TYPE_NAME);
				attributeValue.setValue(value);
				attribute.getAttributeValues().add(attributeValue);
			}
			
			attributeStatement.getAttributes().add(attribute);
		}
	}
	
	return attributeStatement;
}
 
开发者ID:rackerlabs,项目名称:saml-generator,代码行数:25,代码来源:SamlAssertionProducer.java

示例6: buildAttributeStatement

import org.opensaml.xml.schema.XSString; //导入依赖的package包/类
private AttributeStatement buildAttributeStatement() {
    AttributeStatement attributeStatement = OpenSAMLUtils.buildSAMLObject(AttributeStatement.class);

    Attribute attributeUserName = OpenSAMLUtils.buildSAMLObject(Attribute.class);

    XSStringBuilder stringBuilder = (XSStringBuilder)Configuration.getBuilderFactory().getBuilder(XSString.TYPE_NAME);
    XSString userNameValue = stringBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, XSString.TYPE_NAME);
    userNameValue.setValue("bob");

    attributeUserName.getAttributeValues().add(userNameValue);
    attributeUserName.setName("username");
    attributeStatement.getAttributes().add(attributeUserName);

    Attribute attributeLevel = OpenSAMLUtils.buildSAMLObject(Attribute.class);
    XSString levelValue = stringBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, XSString.TYPE_NAME);
    levelValue.setValue("999999999");

    attributeLevel.getAttributeValues().add(levelValue);
    attributeLevel.setName("telephone");
    attributeStatement.getAttributes().add(attributeLevel);

    return attributeStatement;

}
 
开发者ID:rasmusson,项目名称:webprofile-ref-project,代码行数:25,代码来源:ArtifactResolutionServlet.java

示例7: buildAttributeStatement

import org.opensaml.xml.schema.XSString; //导入依赖的package包/类
private AttributeStatement buildAttributeStatement() throws IllegalAccessException {
	AttributeStatement attributeStatement = buildXMLObjectDefaultName(AttributeStatement.class);

	Attribute attributeUserName = buildXMLObjectDefaultName(Attribute.class);

	XSStringBuilder stringBuilder = (XSStringBuilder)Configuration.getBuilderFactory().getBuilder(XSString.TYPE_NAME);
	XSString userNameValue = stringBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, XSString.TYPE_NAME);
	userNameValue.setValue(MockIDPAuthnReq.userId);

	attributeUserName.getAttributeValues().add(userNameValue);
	attributeUserName.setName("uid");
	attributeStatement.getAttributes().add(attributeUserName);

	Attribute attributeLevel = buildXMLObjectDefaultName(Attribute.class);
	XSString levelValue = stringBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, XSString.TYPE_NAME);
	levelValue.setValue(MockIDPAuthnReq.secLevel);

	attributeLevel.getAttributeValues().add(levelValue);
	attributeLevel.setName("SecurityLevel");
	attributeStatement.getAttributes().add(attributeLevel);

	return attributeStatement;

}
 
开发者ID:rasmusson,项目名称:MockIDP,代码行数:25,代码来源:MockIDPArtifactResolve.java

示例8: newAttributeValue

import org.opensaml.xml.schema.XSString; //导入依赖的package包/类
private XSString newAttributeValue(final Object value) {
    final XSString stringValue = this.attrValueBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, XSString.TYPE_NAME);
    if (value instanceof String) {
        stringValue.setValue((String) value);
    } else {
        stringValue.setValue(value.toString());
    }
    return stringValue;
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:10,代码来源:Saml10SuccessResponseView.java

示例9: processChildElement

import org.opensaml.xml.schema.XSString; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentXMLObject, XMLObject childXMLObject)
        throws UnmarshallingException {
    Fault fault = (Fault) parentXMLObject;
    
    if(childXMLObject instanceof XSQName){
        fault.setCode((FaultCode) childXMLObject);
    }else if(childXMLObject instanceof XSString){
        fault.setMessage((FaultString) childXMLObject);
    }else if(childXMLObject instanceof XSURI){
        fault.setActor((FaultActor) childXMLObject);
    }else if(childXMLObject instanceof Detail){
        fault.setDetail((Detail) childXMLObject);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:FaultUnmarshaller.java

示例10: processChildElement

import org.opensaml.xml.schema.XSString; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentXMLObject, XMLObject childXMLObject)
        throws UnmarshallingException {
    if (childXMLObject instanceof XSString) {
        DefaultsType defaultType = (DefaultsType) parentXMLObject;
        defaultType.setXPathVersion((XSString) childXMLObject);
    } else {
        super.processChildElement(parentXMLObject, childXMLObject);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:DefaultsTypeUnmarshaller.java

示例11: toSwedishEidString

import org.opensaml.xml.schema.XSString; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public String toSwedishEidString() {
  StringBuilder sb = new StringBuilder();

  List<XMLObject> children = this.getOrderedChildren();
  for (XMLObject child : children) {
    if (child instanceof XSString) {
      final String value = ((XSString) child).getValue();
      if (value.trim().isEmpty()) {
        continue;
      }
      if (sb.length() > 0) {
        sb.append(';');
      }
      try {
        sb.append(child.getElementQName().getLocalPart())
          .append('=')
          .append(URLEncoder.encode(value, "UTF-8").replaceAll("\\+", "%20"));
      }
      catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e);
      }
    }
  }

  return sb.toString();
}
 
开发者ID:litsec,项目名称:eidas-opensaml,代码行数:29,代码来源:CurrentAddressTypeImpl.java

示例12: getString

import org.opensaml.xml.schema.XSString; //导入依赖的package包/类
private String getString(XMLObject xmlValue) {
    if (xmlValue instanceof XSString) {
        return ((XSString) xmlValue).getValue();
    } else if (xmlValue instanceof XSAny) {
        return ((XSAny) xmlValue).getTextContent();
    } else {
        return null;
    }
}
 
开发者ID:ulisesbocchio,项目名称:spring-boot-security-saml-samples,代码行数:10,代码来源:SAMLUserDetails.java

示例13: extractAttributeValueValues

import org.opensaml.xml.schema.XSString; //导入依赖的package包/类
/**
 * Extract all attribute values within an SAML20 attribute
 * 
 * @param attribute The attribute
 * @return A list containing the text value of each attributeValue
 */
public static List<String> extractAttributeValueValues(Attribute attribute) {
	List<String> values = new ArrayList<String>();
	for (int i = 0; i < attribute.getAttributeValues().size(); i++) {
		if (attribute.getAttributeValues().get(i) instanceof XSString) {
			XSString str = (XSString) attribute.getAttributeValues().get(i);
			if (AttributeValue.DEFAULT_ELEMENT_LOCAL_NAME.equals(str.getElementQName().getLocalPart())
					&& SAMLConstants.SAML20_NS.equals(str.getElementQName().getNamespaceURI())) {
				values.add(str.getValue());
			}
		} else {
			XSAny ep = (XSAny) attribute.getAttributeValues().get(i);
			if (AttributeValue.DEFAULT_ELEMENT_LOCAL_NAME.equals(ep.getElementQName().getLocalPart())
					&& SAMLConstants.SAML20_NS.equals(ep.getElementQName().getNamespaceURI())) {
				if (ep.getUnknownXMLObjects().size() > 0) {
					StringBuilder res = new StringBuilder();
					for (XMLObject obj : ep.getUnknownXMLObjects()) {
						res.append(XMLHelper.nodeToString(SAMLUtil.marshallObject(obj)));
					}
					values.add(res.toString());
				}
				values.add(ep.getTextContent());
			}
		}
	}
	return values;
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:33,代码来源:AttributeUtil.java

示例14: populateRequiredData

import org.opensaml.xml.schema.XSString; //导入依赖的package包/类
/** {@inheritDoc} */
protected void populateRequiredData() {
    super.populateRequiredData();

    Attribute attribute = (Attribute) target;
    
    XSStringBuilder attributeValueBuilder = (XSStringBuilder) builderFactory.getBuilder(XSString.TYPE_NAME);
    attribute.getAttributeValues().add(attributeValueBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME));
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:10,代码来源:AttributeSchemaTest.java

示例15: testChildElementsMarshall

import org.opensaml.xml.schema.XSString; //导入依赖的package包/类
/** {@inheritDoc} */
public void testChildElementsMarshall(){
    Attribute attribute = (Attribute) buildXMLObject(qname);

    XSStringBuilder attributeValueBuilder = (XSStringBuilder) builderFactory.getBuilder(XSString.TYPE_NAME);
    
    attribute.getAttributeValues().add(attributeValueBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, XSString.TYPE_NAME)); 
    attribute.getAttributeValues().add(attributeValueBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, XSString.TYPE_NAME)); 
    attribute.getAttributeValues().add(attributeValueBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, XSString.TYPE_NAME)); 
    attribute.getAttributeValues().add(attributeValueBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, XSString.TYPE_NAME)); 

    assertEquals(expectedChildElementsDOM, attribute);
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:14,代码来源:AttributeTest.java


注:本文中的org.opensaml.xml.schema.XSString类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。