我一直在使用Apache CXF和WSS4J来实现SecurityTokenService。
使用实现“org.apache.cxf.sts.claims.ClaimsHandler”的“CustomClaimsHandler”我可以创建一个包含这种属性的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>
在收到回复后,我加入了这个链接:SAML2 xml structured attribute values
我在我的CXF STS项目中添加了对opensaml-core v3.0.0的依赖,以获取“org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport”类,如响应中的示例所示。 在调用XMLObjectProviderRegistrySupport.getBuilderFactory()之前,我似乎必须初始化opensaml的配置。
我管理了初始化调用“org.opensaml.core.config.InitializationService.initialize();”
对于使用XSAny类型创建AttributeBean,所有似乎都很好。
问题是当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-core v3.0.0类吗? 或者我必须使用不同版本的CXF才能获得更新版本的WSS4J?
我的CXF版本是3.0.1并且依赖于版本2.0.1中的WSS4J-ws-security-common,它依赖于opensaml版本2.6.1
有人有线索吗? 此致
答案 0 :(得分:2)
您不能将OpenSAML 3与CXF 3.0.x或WSS4J 2.0.x一起使用。如果您确实需要使用OpenSAML 3,那么您将需要使用当前使用OpenSAML 3的CXF主SNAPSHOT代码(3.1.0-SNAPSHOT)。
科尔姆。