我一直在使用Apache和WSS4J来实现一个SecurityTokenService。
使用实现“CustomClaimsHandler”的"org.apache.cxf.sts.claims.ClaimsHandler“,我可以创建一个包含此类属性的SAML令牌:
<saml2:Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/role" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified">
<saml2:AttributeValue xsi:type="xs:string">admin</saml2:AttributeValue>
</saml2:Attribute>
问题是,我现在正在尝试创建一个包含一些XML内容的属性。例如:
<saml2:Attribute Name="http://my/xml/content">
<saml2:AttributeValue xsi:type="???">
<somthing>
<somthingElse>text</somthingElse>
</somthing>
</saml2:AttributeValue>
</saml2:Attribute>
我已经研究过如何为“ClaimsAttributeStatementProvider”(org.apache.cxf.sts.claims)定制一个实现,但我似乎不得不使用WSS4J的“AttributeBean”类。但这门课似乎不让我改变类型。
现在有人如何处理这个问题?
======================================================================
编辑以下Colm的答案:
我在我的CXF项目中向opensaml v3.0.0添加了一个依赖项,以获得“org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport”类,如您指向我的示例所示。在调用XMLObjectProviderRegistrySupport.getBuilderFactory()之前,我似乎必须初始化opensaml的配置。我没有使用我认为CXF中的WSS4J正在使用的嵌入式配置。我管理初始化调用“org.opensaml.core.config.InitializationService.initialize();”
对于创建带有AttributeBean类型的XSAny来说,这一切似乎都很好。
问题是当WSS4J试图处理SAMLCallback时:
Caused by: java.lang.ClassCastException: org.opensaml.core.xml.schema.impl.XSAnyBuilder cannot be cast to org.opensaml.xml.XMLObjectBuilder at org.opensaml.xml.XMLConfigurator.initializeObjectProviders(XMLConfigurator.java:236) at org.opensaml.xml.XMLConfigurator.load(XMLConfigurator.java:182) at org.opensaml.xml.XMLConfigurator.load(XMLConfigurator.java:166) at org.opensaml.xml.XMLConfigurator.load(XMLConfigurator.java:143) at org.apache.wss4j.common.saml.OpenSAMLBootstrap.initializeXMLTooling(OpenSAMLBootstrap.java:105) at org.apache.wss4j.common.saml.OpenSAMLBootstrap.bootstrap(OpenSAMLBootstrap.java:86) at org.apache.wss4j.common.saml.OpenSAMLUtil.initSamlEngine(OpenSAMLUtil.java:61) at org.apache.wss4j.common.saml.SamlAssertionWrapper.(SamlAssertionWrapper.java:204) at org.apache.cxf.sts.token.provider.SAMLTokenProvider.createSamlToken(SAMLTokenProvider.java:303) at org.apache.cxf.sts.token.provider.SAMLTokenProvider.createToken(SAMLTokenProvider.java:122) ... 45 more
我想我有一个版本问题:
要么我必须让我的STS的opensaml配置了解我的opensaml v3.0.0类,要么我必须使用不同版本的CXF来获得更新版本的WSS4J。
我的CXF版本为3.0.1,并且依赖于WSS4J-ws-安全性-在2.0.1版本中常见,它依赖于opensaml版本2.6.1。
你知道如何解决这个问题吗?
问候
=========================
编辑Colm在post中解决了问题:SAML2 assertion with home defined AttributeBean in CXF
发布于 2015-02-26 12:46:35
setAttributeValues类的AttributeBean类的WSS4J方法允许您通过OpenSAML XMLObject对象。因此,您可以使用OpenSAML创建自定义属性类型,然后传递它们。下面是WSS4J中的一个测试用例,它添加了"Integer“类型(参见"testSAML2AttrAssertionIntegerAttribute"):
科姆。
https://stackoverflow.com/questions/28724098
复制相似问题