Exemple #1
0
    private static bool reset_voiceprint_internal(
    ResetVoiceprintParams resetVoiceprintParams,
    out int result,
    out int error_id)
    {
        if (resetVoiceprintParams.Hostname.Length == 0) resetVoiceprintParams.Hostname = "pfsdk-hostname";
        if (resetVoiceprintParams.IpAddress.Length == 0) resetVoiceprintParams.IpAddress = "255.255.255.255";
        result = 0;
        error_id = 0;

        string voiceprint_reset_message = create_voiceprint_reset_message(resetVoiceprintParams);

        int tries = 1;
        if (mMutex.WaitOne())
        {
          try { tries = mTargets.Count + 1; }
          finally { mMutex.ReleaseMutex(); }
        }
        for (int i = 0; i < tries; i++)
        {
          string response;
          if (send_message(mCurrentTarget, voiceprint_reset_message, resetVoiceprintParams.CertFilePath, out response))
          {
        bool success = get_voiceprint_reset_response_status(response, out result, out error_id);
        return success;
          }
          else
          {
        if (mMutex.WaitOne())
        {
          try
          {
            mTargets.Enqueue(mCurrentTarget);
            mCurrentTarget = mTargets.Dequeue().ToString();
          }
          finally { mMutex.ReleaseMutex(); }
        }
          }
        }
        return false;
    }
Exemple #2
0
 public static bool reset_voiceprint(
 ResetVoiceprintParams resetVoiceprintParams,
 out int result,
 out int error_id)
 {
     return reset_voiceprint_internal(
       resetVoiceprintParams,
       out result,
       out error_id);
 }
Exemple #3
0
    //
    // create_voiceprint_reset_message: generates a voiceprint reset message to be sent
    // 	to the PhoneFactor backend.
    //
    // Return value:
    //     a complete voiceprint reset xml message ready to be sent to the PhoneFactor backend
    //
    private static string create_voiceprint_reset_message(
    ResetVoiceprintParams resetVoiceprintParams)
    {
        XmlDocument doc = new XmlDocument();

        // start message
        // <pfpMessage></pfpMessage>
        XmlElement root = doc.CreateElement("pfpMessage");
        root.SetAttribute("version", "1.5");
        doc.AppendChild(root);

        // message header
        // <header></header>
        XmlElement header = doc.CreateElement("header");
        root.AppendChild(header);
        XmlElement element = doc.CreateElement("source");
        header.AppendChild(element);
        element = doc.CreateElement("component");
        element.SetAttribute("type", "pfsdk");
        header.AppendChild(element);
        element = doc.CreateElement("host");
        element.SetAttribute("ip", resetVoiceprintParams.IpAddress);
        element.SetAttribute("hostname", resetVoiceprintParams.Hostname);
        header.AppendChild(element);

        // request
        // <request></request>
        XmlElement request = doc.CreateElement("request");
        Random random = new Random();
        string request_id = random.Next(10000).ToString();
        request.SetAttribute("request-id", request_id);
        request.SetAttribute("async", "0");
        request.SetAttribute("response-url", "");
        root.AppendChild(request);
        XmlElement pin_reset_request = doc.CreateElement("setPinResetRequest");
        request.AppendChild(pin_reset_request);
        XmlElement customer = doc.CreateElement("customer");
        pin_reset_request.AppendChild(customer);
        element = doc.CreateElement("licenseKey");
        element.InnerText = LICENSE_KEY;
        customer.AppendChild(element);
        element = doc.CreateElement("groupKey");
        element.InnerText = GROUP_KEY;
        customer.AppendChild(element);
        element = doc.CreateElement("username");
        element.InnerText = resetVoiceprintParams.Username;
        pin_reset_request.AppendChild(element);

        return doc.InnerXml;
    }