2016-12-12 7 views
1

안녕 난이 ErrorMessage가 가지고 : 푸른 광고에서 SAML 응답의 유효성을 검사에opensaml 3 서명이 null 인

net.shibboleth.utilities.java.support.logic.ConstraintViolationException: Signature was null 

합니다. 테스트 목적으로

내가 XML로 응답 파일을 저장하는 태그 발견

Signature signature = response.getAssertions().get(0).getSignature() // returns null 

SAMLSignatureProfileValidator profValidator = new SAMLSignatureProfileValidator(); 
profValidator.validate(signature); 
:에서 삭제

InitializationService.initialize(); 
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); 
documentBuilderFactory.setNamespaceAware(true); 
DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder(); 
String content = new String(Files.readAllBytes(Paths.get("saml_response_azure.xml"))); 
Document document = docBuilder.parse(new ByteArrayInputStream(content.trim().getBytes())); 

Element element = document.getDocumentElement(); 
Unmarshaller unmarshaller = XMLObjectProviderRegistrySupport.getUnmarshallerFactory().getUnmarshaller(element); 
Response response = (Response) unmarshaller.unmarshall(element); 

그리고 오류 : 내가 XML 응답을 언 마샬링

<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> 
     <ds:SignedInfo> 
      <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" /> 
      <ds:SignatureMethod 
       Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" /> 
      <ds:Reference URI="#_97031c65-0139-4047-a416-9495df5d6ed7"> 
       <ds:Transforms> 
        <ds:Transform 
         Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" /> 
        <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" /> 
       </ds:Transforms> 
       <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" /> 
       <ds:DigestValue> 
        KMaFHRt8inqVYsMGKnAryKUTQUbYGPUDPxdvj6T08OQ= 
       </ds:DigestValue> 
      </ds:Reference> 
     </ds:SignedInfo> 
     <ds:SignatureValue> 
      ..... 
     </ds:SignatureValue> 
     <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#"> 
      <X509Data> 
       <X509Certificate> 
        .... 
       </X509Certificate> 
      </X509Data> 
     </KeyInfo> 
    </ds:Signature> 

+0

어딘가에 전체 응답을 제공 할 수 있습니까? 예를 들어 –

+0

https://gist.github.com/Gobliins/26d8f760f120430eaeb29c223f2e436f 자격 증명을 임의의 정보로 바 꾸었습니다 – Gobliins

+0

Btw. opensaml 2.6.x에서이 문제가 없었습니다 – Gobliins

답변

2

좋아, 내가 찾은 것 같아, 당신이 어떤 구현 의존성을 POM에 추가하지 않은 것 같습니다. POM을 사용하고이 종속성을 포함 시키면 서명 객체가 생성됩니다.

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

종속성의 모듈 구조는 OpenSAML 버전 2와 큰 차이가 있습니다.

+0

Worked. 이것에 대해서도 살펴보실 수 있습니까? https://stackoverflow.com/questions/41116985/opensaml-xmlns-is-not-generated-on-nameidpolicy-and-authncontext – Gobliins