Beispiel #1
0
        public String ONVIF_GetSystemLog()
        {
            setNonce();
            /* get synced-time using base time */
            baseDateTime = DigestPassword.getCurrentTime(startDate, baseDateTime);
            /* make createTime string */
            _wsdUsernameToken.Create = DigestPassword.getCreatedTimeString(baseDateTime);
            /* make digest password */
            //_wsdUsernameToken.Password = DigestPassword.getPasswordDigest("LKqI6G/AikKCQrN0zqZFlg==", "2010-09-16T07:50:45Z", "userpassword");
            _wsdUsernameToken.Password = DigestPassword.getPasswordDigest(_wsdUsernameToken.Nonce,
                                                                          _wsdUsernameToken.Create,
                                                                          _wsdUsernameToken.plainPassword);
            /* set packet */
            StringBuilder reqMessage = new StringBuilder();

            reqMessage.Append("<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\">");
            reqMessage.Append("<s:Header>");
            reqMessage.Append("<Security ");
            reqMessage.Append("s:mustUnderstand=\"1\" ");
            reqMessage.Append("xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\">");
            reqMessage.Append("<UsernameToken><Username>" + _wsdUsernameToken.Username + "</Username>");
            reqMessage.Append("<Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest\">" + _wsdUsernameToken.Password + "</Password>");
            reqMessage.Append("<Nonce EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">" + _wsdUsernameToken.Nonce + "</Nonce>");
            reqMessage.Append("<Created xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">" + _wsdUsernameToken.Create + "</Created>");
            reqMessage.Append("</UsernameToken></Security></s:Header>");
            reqMessage.Append("<s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">");
            reqMessage.Append("<GetSystemLog xmlns=\"http://www.onvif.org/ver10/device/wsdl\"><LogType>System</LogType></GetSystemLog></s:Body></s:Envelope>");

            /* encoding */
            byte[] reqMessageBinary = EncodingHelper.String2Byte(reqMessage.ToString());

            /* Get Url */
            String Url = onvifdev.devicexaddr;

            try
            {
                _http.Connect(Url);
                _http.setONVIFHeader("\"http://www.onvif.org/ver10/device/wsdl/GetSystemLog\"");
                _http.Write(reqMessageBinary);

                String paramStr = _http.Read();
                parentForm.settbLogBox("\r\nFunction OK : " + System.Reflection.MethodBase.GetCurrentMethod().Name + "\n");

                /* parser soap response */
                XmlDocument xdoc = new XmlDocument();
                xdoc.LoadXml(paramStr.ToString());

                XmlNamespaceManager xnamespace = XMLControl.getAllNamespaces(xdoc);
                onvifdev.schemaPrefix = xnamespace.LookupPrefix(ONVIFNamespace.schema);
                onvifdev.devicePrefix = xnamespace.LookupPrefix(ONVIFNamespace.device);
                /* get function xaddr in document */

                /*
                 *   <SOAP-ENV:Header></SOAP-ENV:Header>
                 *    <SOAP-ENV:Body>
                 *      <tds:GetSystemLogResponse>
                 *        <tds:SystemLog>
                 *          <tds2:String>Mar 13 08:08:27 VB-
                 */
                String logStr = XMLControl.getLogStr(xdoc, onvifdev);
                return(logStr);
            }
            catch (XmlException xe)
            {
                parentForm.settbLogBox("\r\nXml Exception : " + xe.Message + System.Reflection.MethodBase.GetCurrentMethod().Name);
            }
            catch (WebException we)
            {
                parentForm.settbLogBox("\r\nWeb Exception : " + we.Message + System.Reflection.MethodBase.GetCurrentMethod().Name);
            }
            return("test");
        }
Beispiel #2
0
 public void setNonce()
 {
     _wsdUsernameToken.Nonce = EncodingHelper.Base64Encode(DigestPassword.getNonce(32));
 }