本文整理汇总了Java中org.opensaml.xml.schema.XSAny类的典型用法代码示例。如果您正苦于以下问题:Java XSAny类的具体用法?Java XSAny怎么用?Java XSAny使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XSAny类属于org.opensaml.xml.schema包,在下文中一共展示了XSAny类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: wrongFrameworkHeaderShouldFail
import org.opensaml.xml.schema.XSAny; //导入依赖的package包/类
@Test
public void wrongFrameworkHeaderShouldFail() throws Exception {
SOAPClientStub soapClient = new SOAPClientStub();
serviceClient.setSOAPClient(soapClient);
serviceClient.sendRequest(req, getProperty("endpoint"), getProperty("action"), null, null);
Envelope env = (Envelope) SAMLUtil.unmarshallElementFromString(soapClient.xml);
XSAny framework = (XSAny) env.getHeader().getUnknownXMLObjects(new QName("urn:liberty:sb:2006-08", "Framework")).get(0);
framework.getUnknownAttributes().put(new QName("version"), "1.0");
env.getHeader().getUnknownXMLObjects().remove(SAMLUtil.getFirstElement(env.getHeader(), Security.class));
OIOSoapEnvelope e = new OIOSoapEnvelope(env, true, new SigningPolicy(true));
e.addSecurityTokenReference(token, Boolean.valueOf(getProperty("protectTokens")));
e.setTimestamp(5);
try {
new HttpSOAPClient().wsCall(getProperty("endpoint"), null, null, true, XMLHelper.nodeToString(e.sign(credential)), getProperty("action"));
} catch (SOAPException ex) {
assertEquals(new QName("urn:liberty:sb:2006-08", "FrameworkVersionMismatch"), ex.getFault().getCode().getValue());
}
}
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:22,代码来源:RequestTest.java
示例2: buildEnvelope
import org.opensaml.xml.schema.XSAny; //导入依赖的package包/类
/**
* Build a new soap envelope with standard OIO headers.
*
* Standard headers include sbf:Framework, wsa:MessageID, and an empty Security header.
*/
public static OIOSoapEnvelope buildEnvelope(String soapVersion, SigningPolicy signingPolicy, boolean includeFrameworkHeader) {
Envelope env = envelopeBuilder.buildObject(soapVersion, "Envelope", "s");
Header header = headerBuilder.buildObject(soapVersion, "Header", "s");
env.setHeader(header);
MessageID msgId = SAMLUtil.buildXMLObject(MessageID.class);
msgId.setValue("urn:uuid:" + UUID.randomUUID().toString());
header.getUnknownXMLObjects().add(msgId);
XSAny framework = null;
if (includeFrameworkHeader) {
framework = new XSAnyBuilder().buildObject("urn:liberty:sb:2006-08", "Framework", "sbf");
framework.getUnknownAttributes().put(new QName("version"), "2.0");
framework.getUnknownAttributes().put(new QName("urn:liberty:sb:profile", "profile"), "urn:liberty:sb:profile:basic");
framework.getUnknownAttributes().put(new QName(soapVersion, "mustUnderstand"), "1");
header.getUnknownXMLObjects().add(framework);
}
Security security = SAMLUtil.buildXMLObject(Security.class);
security.getUnknownAttributes().put(new QName(env.getElementQName().getNamespaceURI(), "mustUnderstand"), "1");
env.getHeader().getUnknownXMLObjects().add(security);
return new OIOSoapEnvelope(env, msgId, framework, signingPolicy);
}
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:31,代码来源:OIOSoapEnvelope.java
示例3: buildFault
import org.opensaml.xml.schema.XSAny; //导入依赖的package包/类
public Envelope buildFault(String request) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException, MarshalException, XMLSignatureException {
Envelope r = buildResponse(request, false);
r.getBody().getUnknownXMLObjects().clear();
Fault fault = SAMLUtil.buildXMLObject(Fault.class);
Detail detail = SAMLUtil.buildXMLObject(Detail.class);
FaultString msg = SAMLUtil.buildXMLObject(FaultString.class);
msg.setValue("test");
fault.setMessage(msg);
fault.setDetail(detail);
XSAny d = new XSAnyBuilder().buildObject("urn:test", "fault", "fa");
detail.getUnknownXMLObjects().add(d);
r.getBody().getUnknownXMLObjects().add(fault);
return r;
}
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:21,代码来源:TokenClientTest.java
示例4: failOnMissingPrivilege
import org.opensaml.xml.schema.XSAny; //导入依赖的package包/类
@Test
public void failOnMissingPrivilege() throws Exception {
final OIOAssertion assertion = getAssertion("assertion.xml", "1029275212");
Attribute attr = AttributeUtil.createAttribute(Constants.AUTHORISATIONS_ATTRIBUTE, "", "uri");
XSAnyBuilder builder = new XSAnyBuilder();
XSAny ep = builder.buildObject(SAMLConstants.SAML20_NS, AttributeValue.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
XSAnyUnmarshaller unmarshaller = new XSAnyUnmarshaller();
XMLObject val = unmarshaller.unmarshall(SAMLUtil.loadElementFromString(IOUtils.toString(getClass().getResourceAsStream("authorisations.xml"))));
ep.getUnknownXMLObjects().add(val);
attr.getAttributeValues().add(ep);
assertion.getAssertion().getAttributeStatements().get(0).getAttributes().add(attr);
context.checking(new Expectations() {{
one(req).getUserPrincipal(); will(returnValue(new OIOPrincipal(new UserAssertionImpl(assertion))));
one(req).getSession();
one(req).getRequestURI(); will(returnValue("/context/admin"));
one(req).getContextPath(); will(returnValue("/context"));
one(req).getMethod(); will(returnValue("post"));
one(res).sendError(with(equal(HttpServletResponse.SC_FORBIDDEN)), with(any(String.class)));
}});
filter.doFilter(req, res, chain);
}
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:26,代码来源:AuthzFilterTest.java
示例5: testGrantAccess
import org.opensaml.xml.schema.XSAny; //导入依赖的package包/类
@Test
public void testGrantAccess() throws Exception {
final OIOAssertion assertion = getAssertion("assertion.xml", "1029275212");
Attribute attr = AttributeUtil.createAttribute(Constants.AUTHORISATIONS_ATTRIBUTE, "", "uri");
XSAnyBuilder builder = new XSAnyBuilder();
XSAny ep = builder.buildObject(SAMLConstants.SAML20_NS, AttributeValue.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
XSAnyUnmarshaller unmarshaller = new XSAnyUnmarshaller();
XMLObject val = unmarshaller.unmarshall(SAMLUtil.loadElementFromString(IOUtils.toString(getClass().getResourceAsStream("authorisations.xml"))));
ep.getUnknownXMLObjects().add(val);
attr.getAttributeValues().add(ep);
assertion.getAssertion().getAttributeStatements().get(0).getAttributes().add(attr);
context.checking(new Expectations() {{
one(req).getUserPrincipal(); will(returnValue(new OIOPrincipal(new UserAssertionImpl(assertion))));
one(req).getSession();
one(req).getRequestURI(); will(returnValue("/context/test"));
one(req).getContextPath(); will(returnValue("/context"));
one(req).getMethod(); will(returnValue("post"));
one(chain).doFilter(req, res);
}});
filter.doFilter(req, res, chain);
}
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:26,代码来源:AuthzFilterTest.java
示例6: extractAttributeValueValue
import org.opensaml.xml.schema.XSAny; //导入依赖的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
示例7: createAttributeStatement
import org.opensaml.xml.schema.XSAny; //导入依赖的package包/类
private static AttributeStatement createAttributeStatement() {
AttributeStatement attributeStatement = create(AttributeStatement.DEFAULT_ELEMENT_NAME);
for (AttributeData attributeData : samlResponseData.getAttributes()) {
Attribute attribute = create(Attribute.DEFAULT_ELEMENT_NAME);
attribute.setFriendlyName(attributeData.getFriendlyName());
attribute.setName(attributeData.getName());
attribute.setNameFormat(attributeData.getNameFormat());
XMLObjectBuilder<XSAny> builder = getXMLObjectBuilder(XSAny.TYPE_NAME);
for (String values : attributeData.getValue().split(";", -1)) {
XSAny value = builder
.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME);
value.setTextContent(values);
attribute.getAttributeValues().add(value);
}
attributeStatement.getAttributes().add(attribute);
}
return attributeStatement;
}
开发者ID:vetsin,项目名称:SamlSnort,代码行数:26,代码来源:SamlTool.java
示例8: marshallAttributes
import org.opensaml.xml.schema.XSAny; //导入依赖的package包/类
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException {
XSAny xsAny = (XSAny) xmlObject;
Attr attribute;
for (Entry<QName, String> entry : xsAny.getUnknownAttributes().entrySet()) {
attribute = XMLHelper.constructAttribute(domElement.getOwnerDocument(), entry.getKey());
attribute.setValue(entry.getValue());
domElement.setAttributeNodeNS(attribute);
if (Configuration.isIDAttribute(entry.getKey())
|| xsAny.getUnknownAttributes().isIDAttribute(entry.getKey())) {
attribute.getOwnerElement().setIdAttributeNode(attribute, true);
}
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:XSAnyMarshaller.java
示例9: marshallElementContent
import org.opensaml.xml.schema.XSAny; //导入依赖的package包/类
/** {@inheritDoc} */
protected void marshallElementContent(XMLObject xmlObject, Element domElement) throws MarshallingException {
XSAny xsAny = (XSAny) xmlObject;
if (xsAny.getTextContent() != null) {
XMLHelper.appendTextContent(domElement, xsAny.getTextContent());
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:XSAnyMarshaller.java
示例10: processChildElement
import org.opensaml.xml.schema.XSAny; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentXMLObject, XMLObject childXMLObject)
throws UnmarshallingException {
XSAny xsAny = (XSAny) parentXMLObject;
xsAny.getUnknownXMLObjects().add(childXMLObject);
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:XSAnyUnmarshaller.java
示例11: processAttribute
import org.opensaml.xml.schema.XSAny; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException {
XSAny xsAny = (XSAny) xmlObject;
QName attribQName = XMLHelper.constructQName(attribute.getNamespaceURI(), attribute.getLocalName(), attribute
.getPrefix());
if (attribute.isId()) {
xsAny.getUnknownAttributes().registerID(attribQName);
}
xsAny.getUnknownAttributes().put(attribQName, attribute.getValue());
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:XSAnyUnmarshaller.java
示例12: getString
import org.opensaml.xml.schema.XSAny; //导入依赖的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: getXMLObject
import org.opensaml.xml.schema.XSAny; //导入依赖的package包/类
/**
* @see BRSSAMLExtensionObject#getXMLObject()
*/
public XMLObject getXMLObject() {
XSAnyBuilder builder = new XSAnyBuilder();
XSAny ep = builder.buildObject(OIOSAMLConstants.BRS_NS, DEFAULT_ELEMENT_LOCAL_NAME, OIOSAMLConstants.BRS_PREFIX);
ep.setTextContent(String.valueOf(value));
return ep;
}
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:10,代码来源:AssuranceLevel.java
示例14: createAttributeValue
import org.opensaml.xml.schema.XSAny; //导入依赖的package包/类
private static XSAny createAttributeValue() {
XSAnyBuilder builder = new XSAnyBuilder();
XSAny ep = builder.buildObject(SAMLConstants.SAML20_NS,
AttributeValue.DEFAULT_ELEMENT_LOCAL_NAME,
SAMLConstants.SAML20_PREFIX);
return ep;
}
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:8,代码来源:AttributeUtil.java
示例15: extractAttributeValueValues
import org.opensaml.xml.schema.XSAny; //导入依赖的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
示例16: createAttribute
import org.opensaml.xml.schema.XSAny; //导入依赖的package包/类
private Attribute createAttribute(String name, String value) {
Attribute attr = SAMLUtil.buildXMLObject(Attribute.class);
attr.setName(name);
XSAnyBuilder builder = new XSAnyBuilder();
XSAny ep = builder.buildObject(SAMLConstants.SAML20_NS,
AttributeValue.DEFAULT_ELEMENT_LOCAL_NAME,
SAMLConstants.SAML20_PREFIX);
ep.setTextContent(value);
ep.getUnknownAttributes().put(AttributeUtil.XSI_TYPE_ATTRIBUTE_NAME, AttributeUtil.XS_STRING);
ep.addNamespace(new Namespace(XMLConstants.XSI_NS, XMLConstants.XSI_PREFIX));
attr.getAttributeValues().add(ep);
return attr;
}
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:14,代码来源:UserAssertionImplTest.java
示例17: testGetFirstElement
import org.opensaml.xml.schema.XSAny; //导入依赖的package包/类
@Test
public void testGetFirstElement() {
XSAny h = new XSAnyBuilder().buildObject(Endpoint.TYPE_NAME);
h.getUnknownXMLObjects().add(SAMLUtil.buildXMLObject(Header.class));
h.getUnknownXMLObjects().add(SAMLUtil.buildXMLObject(PGPData.class));
assertNull(SAMLUtil.getFirstElement(h, Created.class));
assertNotNull(SAMLUtil.getFirstElement(h, Header.class));
assertNull(SAMLUtil.getFirstElement(null, Created.class));
}
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:13,代码来源:SAMLUtilTest.java
示例18: testExtractComplexAttributeValue
import org.opensaml.xml.schema.XSAny; //导入依赖的package包/类
@Test
public void testExtractComplexAttributeValue() throws Exception {
Attribute attr = AttributeUtil.createAttribute("test", "test", OIOSAMLConstants.URI_ATTRIBUTE_NAME_FORMAT);
XSAnyBuilder builder = new XSAnyBuilder();
XSAny ep = builder.buildObject(SAMLConstants.SAML20_NS, AttributeValue.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
String xml = "<t:test xmlns:t=\"http://test.org\"><t:more>text here</t:more></t:test>";
XMLObject val = new XSAnyUnmarshaller().unmarshall(SAMLUtil.loadElementFromString(xml));
ep.getUnknownXMLObjects().add(val);
attr.getAttributeValues().add(ep);
assertNotNull(AttributeUtil.extractAttributeValueValue(attr));
assertTrue(AttributeUtil.extractAttributeValueValue(attr).endsWith(xml));
}
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:15,代码来源:AttributeUtilTest.java
示例19: webSSOprofile
import org.opensaml.xml.schema.XSAny; //导入依赖的package包/类
@Bean
public WebSSOProfile webSSOprofile() {
return new WebSSOProfileImpl() {
@Override
protected AuthnRequest getAuthnRequest(SAMLMessageContext context, WebSSOProfileOptions options, AssertionConsumerService assertionConsumer, SingleSignOnService bindingService) throws SAMLException, MetadataProviderException {
AuthnRequest authnRequest = super.getAuthnRequest(context, options, assertionConsumer, bindingService);
authnRequest.setExtensions(buildExtensions());
return authnRequest;
}
/**
* Language extension to AuthnRequest:
*
* <samlp:Extensions>
<vetuma xmlns="urn:vetuma:SAML:2.0:extensions">
<LG>[fi|sv]</LG>
</vetuma>
</samlp:Extensions>
*/
private Extensions buildExtensions() {
Extensions extensions = new ExtensionsBuilder()
.buildObject("urn:oasis:names:tc:SAML:2.0:protocol", "Extensions", "saml2p");
XSAny vetuma = new XSAnyBuilder().buildObject(new QName("urn:vetuma:SAML:2.0:extensions", "vetuma"));
XSAny language = new XSAnyBuilder().buildObject(new QName("urn:vetuma:SAML:2.0:extensions", "LG"));
String idpLanguageFromTarget = TargetStoringFilter.getRequestParamTarget(((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest())
.map(t -> t.startsWith(Urls.FRONT_SV) ? "sv" : "fi")
.orElse("fi");
language.setTextContent(idpLanguageFromTarget);
extensions.getUnknownXMLObjects().add(vetuma);
vetuma.getUnknownXMLObjects().add(language);
return extensions;
}
};
}
开发者ID:solita,项目名称:kansalaisaloite,代码行数:38,代码来源:WebSecurityConfig.java
示例20: buildObject
import org.opensaml.xml.schema.XSAny; //导入依赖的package包/类
/** {@inheritDoc} */
public XSAny buildObject(String namespaceURI, String localName, String namespacePrefix) {
return new XSAnyImpl(namespaceURI, localName, namespacePrefix);
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:XSAnyBuilder.java
注:本文中的org.opensaml.xml.schema.XSAny类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论