如何使用opensaml v3?几乎没有文档,v2是EOL

gau*_*nix 8 java saml opensaml saml-2.0

是否有使用Open SAML库v3的端到端示例?我找不到任何文档,根据https://wiki.shibboleth.net/confluence/display/OpenSAML/Home,v2是EOL.

我正在使用以下代码来获取SAML断言 -

  private UnmarshallerFactory unmarshallerFactory;
  private DocumentBuilder docBuilder;

  @PostConstruct
  public void init() {

    try {
      InitializationService.initialize();
      DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
      documentBuilderFactory.setNamespaceAware(true);
      docBuilder = documentBuilderFactory.newDocumentBuilder();
      unmarshallerFactory = XMLObjectProviderRegistrySupport.getUnmarshallerFactory();
    } catch (Exception e){
      logger.error("Error: ",e);
    }
  }

  public Assertion getSamlAssertion(String samlResponse)
      throws IOException, XMLParserException, UnmarshallingException, SAXException {

    Document document = docBuilder.parse(new StringInputStream(samlResponse));

    Element element = document.getDocumentElement();
    Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(element);
    XMLObject responseXmlObj = unmarshaller.unmarshall(element);
    Response response = (Response) responseXmlObj;
    return response.getAssertions().get(0);

  }
Run Code Online (Sandbox Code Playgroud)

我的POM-

         <dependency>
            <groupId>org.opensaml</groupId>
            <artifactId>opensaml-core</artifactId>
            <version>3.2.0</version>
        </dependency>


        <dependency>
            <groupId>org.opensaml</groupId>
            <artifactId>opensaml-saml-api</artifactId>
            <version>3.2.0</version>
        </dependency>
Run Code Online (Sandbox Code Playgroud)

问题是,我收到nullunmarshaller.我已经证实这samlResponse是有效的

Ste*_*son 4

您必须将实现包含在 POM 中。

<dependency>
    <groupId>org.opensaml</groupId>
    <artifactId>opensaml-saml-impl</artifactId>
    <version>3.2.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

版本 3 中所做的事情之一是将库拆分为许多不同的模块。

是的,文档有问题。但据我了解,开发团队已经意识到了这一点。与此同时,我写了一本关于该主题的书,《OpenSAML V3 指南》。它逐步介绍了 OpenSAML 的使用以及 V3 中的更改。