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

时间:2016-11-12 02:30:35

标签: java saml saml-2.0 opensaml

是否有使用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);

  }

我的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>

问题在于我null获得了unmarshaller。我已验证samlResponse有效

1 个答案:

答案 0 :(得分:4)

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

if (isset($_POST['submit'])){
    require_once 'includes/practice.php';
//practice.php is using library tcfpdf

$pdf->SetFont('times', '', 15);

$tb1 = '</br></br>  

                            <b>2-  Printer:</b><br /><br />
                            <table cellspacing="0" cellpadding="0" border="1"> 

                                <tr style="background-color:#f7f7f7;color:#333; ">


                                    <td width="300">SN</td>
                                    <td width="300">TYPE</td>

                                </tr>

                            </table>';

$result= mysql_query("SELECT * FROM accessories where emp_number='".$emp_number."' && is_accessory='Printer'");

 while($row = mysql_fetch_assoc($result)){
$tb2 = '<table cellspacing="0" cellpadding="2" border="1"> 
                <tr> 

                                <td width="300">'.$row['serial'].'</td>
                                <td width="300">'.$row['model'].'</td>        
                </tr>
            </table>';

            $tb1 = $tb1.$tb2;
        }


 $pdf->writeHTML($tb1, true, false, false, false, '');

      ob_end_clean();
      $pdf->Output('Report.pdf', 'D');
}

在版本3中完成的一件事是将库拆分为许多不同的模块。

是的,文档是个问题。但据我了解,开发团队已经意识到这一点。与此同时,我写了一本关于这个主题的书,A Guide to OpenSAML V3。它介绍了OpenSAML的使用和V3的变化。