本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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();
}
示例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;
}
}
示例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;
}
示例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));
}
示例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);
}