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


Java XSString类代码示例

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


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

示例1: createXSString

import org.opensaml.core.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<? extends XMLObject> builder = XMLObjectProviderRegistrySupport.getBuilderFactory().getBuilder(elementName);
  Object 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: getStringValues

import org.opensaml.core.xml.schema.XSString; //导入依赖的package包/类
/**
 * Gets string values from the list of mdui objects.
 *
 * @param items the items
 * @return the string values
 */
private Collection<String> getStringValues(final List<?> items) {
    final List<String> list = new ArrayList<>();
    for (final Object d : items) {
        if (d instanceof XSURI) {
            list.add(((XSURI) d).getValue());
        } else if (d instanceof XSString) {
            list.add(((XSString) d).getValue());
        }
    }
    return list;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:18,代码来源:SimpleMetadataUIInfo.java

示例3: newAttributeValue

import org.opensaml.core.xml.schema.XSString; //导入依赖的package包/类
/**
 * New attribute value.
 *
 * @param value the value
 * @param elementName the element name
 * @return the xS string
 */
protected final XSString newAttributeValue(final Object value, final QName elementName) {
    final XSStringBuilder attrValueBuilder = new XSStringBuilder();
    final XSString stringValue = attrValueBuilder.buildObject(elementName, XSString.TYPE_NAME);
    if (value instanceof String) {
        stringValue.setValue((String) value);
    } else {
        stringValue.setValue(value.toString());
    }
    return stringValue;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:18,代码来源:AbstractSamlObjectBuilder.java

示例4: newAttributeValue

import org.opensaml.core.xml.schema.XSString; //导入依赖的package包/类
/**
 * New attribute value.
 *
 * @param value       the value
 * @param elementName the element name
 * @return the xS string
 */
protected XSString newAttributeValue(final Object value, final QName elementName) {
    final XSStringBuilder attrValueBuilder = new XSStringBuilder();
    final XSString stringValue = attrValueBuilder.buildObject(elementName, XSString.TYPE_NAME);
    if (value instanceof String) {
        stringValue.setValue((String) value);
    } else {
        stringValue.setValue(value.toString());
    }
    return stringValue;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:18,代码来源:AbstractSamlObjectBuilder.java

示例5: getStringValues

import org.opensaml.core.xml.schema.XSString; //导入依赖的package包/类
/**
 * Gets string values from the list of mdui objects.
 *
 * @param items the items
 * @return the string values
 */
private static Collection<String> getStringValues(final List<?> items) {
    final List<String> list = new ArrayList<>();
    items.forEach(d -> {
        if (d instanceof XSURI) {
            list.add(((XSURI) d).getValue());
        } else if (d instanceof XSString) {
            list.add(((XSString) d).getValue());
        }
    });
    return list;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:18,代码来源:SamlMetadataUIInfo.java

示例6: logAssertionAttributes

import org.opensaml.core.xml.schema.XSString; //导入依赖的package包/类
private void logAssertionAttributes(Assertion assertion) {
    for (Attribute attribute : assertion.getAttributeStatements().get(0).getAttributes()) {
        logger.info("Attribute name: " + attribute.getName());
        for (XMLObject attributeValue : attribute.getAttributeValues()) {
            logger.info("Attribute value: " + ((XSString) attributeValue).getValue());
        }
    }
}
 
开发者ID:sunrongxin7666,项目名称:OpenSAML-ref-project-demo-v3,代码行数:9,代码来源:ConsumerServlet.java

示例7: toSwedishEidString

import org.opensaml.core.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

示例8: getCertificateNames

import org.opensaml.core.xml.schema.XSString; //导入依赖的package包/类
private List<String> getCertificateNames(Map<UsageType, List<KeyDescriptor>> keysByUsage, UsageType keyUsage) {
    return keysByUsage.get(keyUsage).stream()
                .flatMap(kd -> kd.getKeyInfo().getKeyNames().stream())
                .map(XSString::getValue)
                .collect(Collectors.toList());
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:7,代码来源:MatchingServiceAdapterMetadataAppRuleTest.java

示例9: marshallElementContent

import org.opensaml.core.xml.schema.XSString; //导入依赖的package包/类
/**
 * The element content of a {@code CurrentAddressType} is the Base64-encoding of the serialized value of the
 * {@code CurrentAddressStructuredType}. So ... we have to get there by iterating over our child elements.
 */
@Override
protected void marshallElementContent(XMLObject xmlObject, Element domElement) throws MarshallingException {

  // Find out if the our namespace already has been defined, and if so, get the prefix.
  //
  final String namespace = CurrentAddressType.TYPE_NAME.getNamespaceURI();
  Optional<String> _prefix = xmlObject.getNamespaceManager()
    .getNamespaces()
    .stream()
    .filter(n -> namespace.equals(n.getNamespaceURI()))
    .map(n -> n.getNamespacePrefix())
    .findFirst();
  String prefix = _prefix.isPresent() ? _prefix.get() : CurrentAddressType.TYPE_NAME.getPrefix();
  
  StringBuilder sb = new StringBuilder();

  final List<XMLObject> childXMLObjects = xmlObject.getOrderedChildren();
  if (childXMLObjects != null && childXMLObjects.size() > 0) {
    for (final XMLObject childXMLObject : childXMLObjects) {
      if (childXMLObject == null) {
        continue;
      }
      if (!(childXMLObject instanceof XSString)) {
        throw new MarshallingException("Unexpected type of child element - " + childXMLObject.getClass().getName());
      }
      XSString childString = (XSString) childXMLObject;
      if (childString.getValue() == null) {
        continue;
      }
      String localPart = childString.getElementQName().getLocalPart();
      sb.append(String.format("<%s:%s>%s</%s:%s>", prefix, localPart, childString.getValue(), prefix, localPart));
    }
  }
  if (sb.length() > 0) {
    byte[] bytes;
    try {
      bytes = sb.toString().getBytes("UTF-8");
    }
    catch (UnsupportedEncodingException e) {
      throw new MarshallingException(e);
    }
    String base64String = Base64Support.encode(bytes, true);
    ElementSupport.appendTextContent(domElement, base64String);
  }
}
 
开发者ID:litsec,项目名称:eidas-opensaml,代码行数:50,代码来源:CurrentAddressTypeMarshaller.java

示例10: createUnlinkedUser

import org.opensaml.core.xml.schema.XSString; //导入依赖的package包/类
private void createUnlinkedUser(HttpSession session, AuthChainType act,
		String ldapAttrib, String dnLabel, String defaultOC,
		Assertion assertion) {
	
	
	StringBuffer b = new StringBuffer();
	b.append(ldapAttrib).append("=").append(assertion.getSubject().getNameID().getValue()).append(",ou=").append(dnLabel).append(",ou=SAML2,").append(GlobalEntries.getGlobalEntries().getConfigManager().getCfg().getLdapRoot());
	String dn = b.toString();
	
	AuthInfo authInfo = new AuthInfo(dn,
			(String) session.getAttribute(ProxyConstants.AUTH_MECH_NAME),
			act.getName(), act.getLevel());
	((AuthController) session.getAttribute(ProxyConstants.AUTH_CTL)).setAuthInfo(authInfo);

	com.tremolosecurity.saml.Attribute attrib = new com.tremolosecurity.saml.Attribute(
			"objectClass", defaultOC);
	authInfo.getAttribs().put(attrib.getName(), attrib);

	attrib = new com.tremolosecurity.saml.Attribute(ldapAttrib, assertion
			.getSubject().getNameID().getValue());
	authInfo.getAttribs().put(attrib.getName(), attrib);

	if (assertion.getAttributeStatements().size() > 0) {
		Iterator<org.opensaml.saml.saml2.core.Attribute> samlAttribs = assertion
				.getAttributeStatements().get(0).getAttributes().iterator();
		while (samlAttribs.hasNext()) {
			org.opensaml.saml.saml2.core.Attribute samlAttrib = samlAttribs
					.next();
			// com.tremolosecurity.saml.Attribute attrib = new
			// com.tremolosecurity.saml.Attribute(samlAttrib.getName());

			attrib = authInfo.getAttribs().get(samlAttrib.getName());
			if (attrib == null) {
				attrib = new com.tremolosecurity.saml.Attribute(
						samlAttrib.getName());
				authInfo.getAttribs().put(attrib.getName(), attrib);
			}

			Iterator<XMLObject> vals = samlAttrib.getAttributeValues()
					.iterator();
			while (vals.hasNext()) {
				XMLObject strVal = vals.next();
				//XSString strVal = (XSString) vals.next();
				if (!attrib.getValues().contains(strVal)) {
					if (strVal instanceof XSString) {
						attrib.getValues().add(((XSString) strVal).getValue());
					} else if (strVal instanceof XSAny) {
						attrib.getValues().add(((XSAny) strVal).getTextContent());
					}
					
				}
			}

		}
	}
}
 
开发者ID:TremoloSecurity,项目名称:OpenUnison,代码行数:57,代码来源:SAML2Auth.java

示例11: newAttributeValue

import org.opensaml.core.xml.schema.XSString; //导入依赖的package包/类
private XSString newAttributeValue(final String value) {
    final XSString stringValue = this.attrValueBuilder.buildObject(
            AttributeValue.DEFAULT_ELEMENT_NAME, XSString.TYPE_NAME);
    stringValue.setValue(value);
    return stringValue;
}
 
开发者ID:serac,项目名称:shibboleth-idp-ext-cas,代码行数:7,代码来源:BuildSamlValidationSuccessMessageAction.java


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