2014-11-10 2 views
6

wso2 보안 토큰 서비스 용 .NET 클라이언트를 만들어야합니다.wso2 보안 토큰 서비스 용 .NET 클라이언트를 만드는 방법

일반적으로 간단한 콘솔 또는 WinForm 프로젝트에 서비스 참조를 추가하여 만듭니다. 노출 된 WSDL은 서비스를 쿼리하고 응답을 적절하게 관리하는 데 사용할 수있는 클래스 집합으로 바뀝니다.

생성 된 요청 및 응답 클래스는 비어 있습니다. 속성이나 메서드가없는 클래스 선언 만 비어 있습니다. 이것은 다른 (답이없는) 스택 오버플로 질문에 설명 된 동작과 비슷합니다. http://cxf.547215.n5.nabble.com/Sample-STS-Client-tp4643980p4664175.html 및 SOAP UI에서 작동하도록 만들었습니다.이 포럼 게시물의 서비스 샘플 요청을 발견했습니다.

보안 토큰 서비스를 쿼리하는 데 필요한 복잡한 데이터 구조를 다시 만들 수있는 자동화 된 방법이 있습니까?

편집 나는 여전히 STS 서비스에서 RequestSecurityTokenResponse를 얻기 위해 필요한 최소한의 구조 위의 포럼 게시물에서 SOAP 요청을 감소 많은 시도 후

OK.

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"> 
    <soap:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"> 
    <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> 
     <wsse:UsernameToken wsu:Id="UsernameToken-6D35592DCDDA26FFF3141578725699577"> 
     <wsse:Username>USERNAME HERE</wsse:Username> 
     <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">PASSWORD HERE</wsse:Password> 
     </wsse:UsernameToken> 
     <wsu:Timestamp wsu:Id="TS-6D35592DCDDA26FFF3141578725699576"> 
     <wsu:Created>2014-11-12T10:14:16.995Z</wsu:Created> 
     <wsu:Expires>2014-11-12T10:16:16.995Z</wsu:Expires> 
     </wsu:Timestamp> 
    </wsse:Security> 
    <wsa:Action soap:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/02/trust/RST/SCT</wsa:Action> 
    <wsa:MessageID soap:mustUnderstand="1">uuid:6d4eab69-77f9-42b7-8d6b-1f710020fb0b</wsa:MessageID> 
    <wsa:To soap:mustUnderstand="1">STS ENDPOINT ADDRESS HERE</wsa:To> 
    </soap:Header> 
    <soap:Body> 
    <wst:RequestSecurityToken xmlns:wst="http://schemas.xmlsoap.org/ws/2005/02/trust"> 
     <wst:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</wst:RequestType> 
     <wst:TokenType>http://schemas.xmlsoap.org/ws/2005/02/sc/sct</wst:TokenType> 
     <wst:Claims> 
     <wsid:ClaimType Uri="http://wso2.org/claims/userid" xmlns:wsid="http://schemas.xmlsoap.org/ws/2005/05/identity"/> 
     </wst:Claims> 
    </wst:RequestSecurityToken> 
    </soap:Body> 
</soap:Envelope> 

나는 내 프로젝트의 app.config에서 정의하는 부분적인 성공을 얻은 다음과 같은 단일있는 wsHttpBinding 중 하나

: 또는 다음과 같은 CustomBinding을 추가하지 않고

<wsHttpBinding> 
    <binding name="SendUsername" messageEncoding="Text"> 
     <security mode ="TransportWithMessageCredential"> 
     <message clientCredentialType ="UserName"/> 
     <transport clientCredentialType ="Basic" /> 
     </security> 
    </binding> 
    </wsHttpBinding> 

<customBinding> 
    <binding name="wso2carbon-stsSoap12Binding"> 
     <security defaultAlgorithmSuite="Default" authenticationMode="IssuedToken" 
     requireDerivedKeys="true" securityHeaderLayout="Lax" includeTimestamp="true"> 
     <localClientSettings detectReplays="false" /> 
     <localServiceSettings detectReplays="false" /> 
     <issuedTokenParameters keyType ="SymmetricKey" tokenType ="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0"> 
      <issuer address =STS ENDPOINT ADDRESS HERE binding ="wsHttpBinding" bindingConfiguration ="SendUsername"/> 
      <claimTypeRequirements> 
      <add claimType ="http://wso2.org/claims/userid"/> 
      </claimTypeRequirements> 
     </issuedTokenParameters> 
     </security> 
     <textMessageEncoding messageVersion="Soap12" /> 
     <httpsTransport /> 
    </binding> 
    </customBinding> 

그러나 두 경우 모두 요청이 시간 초과 예외를 throw하고 WCF가 요청 된 요청을 추적하여 Claims 요소가 누락되었음을 확인할 수 있습니다. 어떤 힌트?

답변

2

WCF 구성 옵션으로 고생하고 며칠 째로 나는 부분적인 성공을 얻었습니다.

보안 토큰 서비스에서 응답을받을 수있는 열쇠는 장기적으로 연합 보안 시나리오에서 작동해야한다는 것을 깨달았 기 때문입니다. 나는 그 자체로 토큰을 필요로하지 않지만, 나는 다른 서비스에 대한 인증을 얻기 위해 그것을 필요로한다.마음에이 옵션을

나는 WCF는 이런 종류의 시나리오를 위해 제공하는 것을 탐구하기 시작하고 난 다음 구성 옵션을 내장 :

<wsFederationHttpBinding> 
    <binding name="fs"> 
     <security mode="TransportWithMessageCredential"> 
     <message issuedKeyType="SymmetricKey" issuedTokenType ="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0"> 
      <issuer address = <!-- STS address here --> binding ="customBinding" bindingConfiguration ="StsBinding"/> 
      <claimTypeRequirements> 
      <add claimType="http://wso2.org/claims/userid" /> 
      </claimTypeRequirements> 
     </message> 
     </security> 
    </binding> 
    </wsFederationHttpBinding> 

바인딩은 토큰이 필요로하는 서비스에 문의하는 데 사용됩니다 위 다음 동안 인증은 보안 토큰 발행 회사에 연락하는 방법에 대한 자세한 지침 추가 :이 구성

<customBinding> 
    <binding name="StsBinding"> 
     <textMessageEncoding messageVersion="Soap12WSAddressingAugust2004"/> 
     <useManagedPresentation/> 
     <security authenticationMode="UserNameOverTransport" includeTimestamp ="true" keyEntropyMode ="ServerEntropy" securityHeaderLayout ="Lax" 
       messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10" > 
     </security> 
     <httpsTransport authenticationScheme ="Basic"/> 
    </binding> 
    </customBinding> 

, 그리고 피들러 및 WCF 추적의 도움으로 나는 내가 STS 문 제에서 보안 토큰 응답을 얻을 볼 수 있습니다 어.

처음에 말했듯이 WCF 인프라가 토큰을 처리 할 때 잘못된 동작이 있다고 말하기 때문에 부분적으로 성공했습니다 ... 그러나 이것은 다른 질문의 하위 제재 일 수 있습니다 ;-)

나는 토큰 인증을위한 나의 탐구가 아직 링크에 대한

4
+0

감사를 체결되지 않더라도이 유효한 답으로 간주 될 수 있기를 바랍니다,하지만 그들은이 이유가 나를 도울 수 없습니다. 첫 번째는 서비스 구성에 액세스 할 수 없다는 것이고 두 번째는 샘플이 Java에 있고 .NET 클라이언트가 필요하다는 것입니다. – sblandin

관련 문제