2012-05-29 42 views
5

私たちは、ONVIFプロトコルをサポートするネットワークIPカメラを持っています。 PTZ設定を取得しようとすると、Authエラーが発生します。私はCでこれを実装しています。要求と応答は以下のとおりです。ONVIFでユーザーを認証する方法は?

要求:

"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" 
    "<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\"" 
    "xmlns:tds=\"http://www.onvif.org/ver20/ptz/wsdl\">" 
    "<soap:Body>" 
    "<tds:GetNodes/>" 
    "</soap:Body>" 
    "</soap:Envelope>" 

は応答:

<?xml version="1.0" encoding="UTF-8"?> 
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" 
       xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" 
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
       xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
       xmlns:wsa5="http://www.w3.org/2005/08/addressing" 
       xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#" 
       xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" 
       xmlns:ds="http://www.w3.org/2000/09/xmldsig#" 
       xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" 
       xmlns:ptzimg2="http://www.onvif.org/ver10/schema" 
       xmlns:ptzimg3="http://www.w3.org/2005/05/xmlmime" 
       xmlns:ptzimg4="http://docs.oasis-open.org/wsn/b-2" 
       xmlns:ptzimg5="http://docs.oasis-open.org/wsrf/bf-2" 
       xmlns:ptzimg6="http://docs.oasis-open.org/wsn/t-1" 
       xmlns:ptzimg1="http://www.onvif.org/ver20/ptz/wsdl" 
       xmlns:ptzimg7="http://www.onvif.org/ver20/imaging/wsdl" 
       xmlns:ter="http://www.onvif.org/ver10/error"> 

<SOAP-ENV:Body> 
    <SOAP-ENV:Fault> 
     <SOAP-ENV:Code> 
      <SOAP-ENV:Value> 
       SOAP-ENV:Sender 
      </SOAP-ENV:Value> 
      <SOAP-ENV:Subcode> 
       <SOAP-ENV:Value> 
        ter:NotAuthorized 
       </SOAP-ENV:Value> 
      </SOAP-ENV:Subcode> 
     </SOAP-ENV:Code> 
     <SOAP-ENV:Reason> 
      <SOAP-ENV:Text xml:lang="en"> 
       Sender Not Authorized 
      </SOAP-ENV:Text> 
     </SOAP-ENV:Reason> 
     <SOAP-ENV:Node> 
      http://www.w3.org/2003/05/soap-envelope/node/ultimateReceiver 
     </SOAP-ENV:Node> 
     <SOAP-ENV:Role> 
      http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver 
     </SOAP-ENV:Role> 
     <SOAP-ENV:Detail> 
      The action requested requires authorization and the sender is not authorized 
     </SOAP-ENV:Detail> 
    </SOAP-ENV:Fault> 
</SOAP-ENV:Body> 

どのように私は、ユーザーを認証することができますか?このリンクは役立つかもしれないおかげ

+0

Q:SOAPを手作業でコーディングしていますか? Q:カメラのモデルとメーカーは何ですか?彼らはインターフェイスライブラリをサポートしていますか?またはWSDL以外の仕様?あなたに連絡してみましたか(少なくともサンプルコードのために)? – paulsm4

+0

そのCanonカメラ、VB-M40。この認証方法は、「ONVIFプログラマーガイド」に記載されています。 "http://www.onvif.org/Portals/0/documents/WhitePapers/ONVIF_WG-APG-Application_Programmer%27s_Guide.pdf" –

答えて

2

認証が必要なコマンド。そのような認証ヘッダーを追加することができます。

snprintf(postData, sizeof(postData), 
      "<?xml version=\"1.0\" encoding=\"utf-8\"?>" 
      "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://www.w3.org/2003/05/soap-envelope\"" 
      "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\"" 
      "xmlns:tds=\"http://www.onvif.org/ver20/ptz/wsdl\">" 
      "<SOAP-ENV:Header><wsse:Security><wsse:UsernameToken>" 
      "<wsse:Username>%s</wsse:Username>" 
      "<wsse:Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-" 
      "200401-wss-username-token-profile-1.0#PasswordDigest\">" 
       "%s</wsse:Password><wsse:Nonce>%s</wsse:Nonce>" 
      "<wsu:Created>%s</wsu:Created></wsse:UsernameToken>" 
      "</wsse:Security></SOAP-ENV:Header><SOAP-ENV:Body>" 
      "<tds:GetNodes>" 
      "</SOAP-ENV:Body></SOAP-ENV:Envelope>", 
      username, base64EncDigest, nonce_char, time_char); 
+0

どのようにしてパスワードダイジェストを生成しますか?私はONVIFプログラマーAPIを見ていて、パスワードダイジェストは 'Digest = B64ENCODE(SHA1(B64DECODE(Nonce)+ Date + Password))'を実行することによって生成されるようですが、日付とパスワードの両方が変換された文字列ですバイナリ。文字列をバイナリに変換するのはどういう意味ですか?どのようにダイジェストを生成しましたか? – CadentOrange

+0

nonce_charはbase64でエンコードする必要がありますか? time_charとは何ですか?それは2014-01-02T12:47:08Zのようなタイムスタンプまたは現在の時刻ですか? – kashifmehmood

0

ONVIF Authentication in .NET 4.0 with Visual Studios 2010

Q:あなたは(ずっと SOAPフレンドリーな開発環境、私見です).NETでアプリケーションをコーディング考えるだろうか?

+0

これをチェックしました。しかし、私たちはC言語でそれを実装する必要があります。 –

1

あなたが必要とONVIFのWDSLからC++クライアントプロキシを生成するために、WSSEプラグインでのgSOAPを使用することができます。

私の仕事は大幅に簡素化されましたか? GetVideoEncoderConfigurationを呼び出して応答を読み取る例を次に示します。

_media__GetVideoEncoderConfigurations query; 
_media__GetVideoEncoderConfigurationsResponse response; 

soap_wsse_add_Security(&mediaProxy); 
soap_wsse_add_UsernameTokenDigest(&mediaProxy, NULL, m_username.c_str(), m_password.c_str()); 

if(mediaProxy.GetVideoEncoderConfigurations(&query, &response) == SOAP_OK) 
{ 
    LogSuccess("GetVideoEncoderConfigurations"); 
    for(auto it = response.Configurations.begin(); it != response.Configurations.end(); ++it) 
    { 
     onvif__VideoEncoderConfiguration* videoConf = *it; 
     log(I3) << "Name= " << videoConf->Name << ", Encoding=" << videoConf->Encoding << ", Resolution=" << videoConf->Resolution->Width << "x" << videoConf->Resolution->Height; 
    } 
} 
else 
    LogError("GetVideoEncoderConfigurations", soap_faultdetail(&mediaProxy)); 

soapメッセージを手動で作成する必要はありません。 gSOAPで生成されたコードは、下位層でそれを処理します。もちろん、wsseサポートで作業コードを生成するには2日かかりますが、手作業で10倍も高速です。詳しい情報に興味がある場合は、私に連絡することができます。

関連する問題