6 Replies Latest reply on Jun 22, 2011 10:25 PM by Shafqat Ali

    Generate Shared Secret ?

    Shafqat Ali Level 1

      I am creating service in C# wich creates new Distributor , i could not generate Distributor Shared Secret for distributor being created. Can anyone tell what is the formula for Generating Shared Scret ?

       

      Thanks

        • 1. Re: Generate Shared Secret ?
          Jim_Lester Level 4

          A shared secret is 20 bytes of binary data.  I would suggest using random data...  (and it is base64 encoded in the XML)

          • 2. Re: Generate Shared Secret ?
            Shafqat Ali Level 1

            Thanks Jim,

             

            Here is my c# code for creating distributor:

             

            Xml:

             

            <request action="create" auth="builtin" xmlns="http://ns.adobe.com/adept">
              <nonce>rNfAkgAAAA4=</nonce>
              <expiration>2011-06-20T12:07:58-00:00</expiration>
              <distributorData>
                <name>Shafqat</name>
                <distributorURL>http://www.shafqat.com</distributorURL>
                <notifyURL>http://www.shafqat.com/notify</notifyURL>
                <description>description shfqat</description>
                <maxLoanCount>9</maxLoanCount>
                <linkExpiration>19</linkExpiration>
                <sharedSecret>Q1nKX1RjimoVy5jzayWcYXe4xuU=</sharedSecret>
              </distributorData>
              <hmac>8SnrEtwNnDoXF4r4e0g8y27fveo=</hmac>
            </request>

             

            C#:

             

                        HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(new Uri("http://192.168.0.61:8080/admin/ManageDistributor"));
                        request.Method = "POST";
                        request.ContentType = "text/xml";

             

                        StreamWriter writer = new StreamWriter(request.GetRequestStream());
                        writer.Write(Encoding.UTF8.GetBytes(xml));
                        writer.Close();

             

                        HttpWebResponse webReaponse = (HttpWebResponse)request.GetResponse();
                        StreamReader reader = new StreamReader(webReaponse.GetResponseStream());
                        Response.Write(reader.ReadToEnd());
                        reader.Close();

             

            i could not get anything in response and niether distributor is created ? can you guess whats wrong with code?

             

            Thanks, Shafqat.

            • 3. Re: Generate Shared Secret ?
              Jim_Lester Level 4

              With no response at all I would suspect that your handling of the HTTPWebRequest class is off.  What happens when you use curl to do a post?

              • 4. Re: Generate Shared Secret ?
                Shafqat Ali Level 1

                Thanks Jim,

                 

                 

                I am not using CURL. This is simple asp.net/C# (.net framwork 4.0) code. When i execute that i gives error about content type. Invalid content type.

                • 5. Re: Generate Shared Secret ?
                  Jim_Lester Level 4

                  Oh so you are getting a response.  I had noticed that you are setting the Content-Type to 'text/xml' instead of the correct value "application/vnd.adobe.adept+xml" - you will want to fix that.

                  • 6. Re: Generate Shared Secret ?
                    Shafqat Ali Level 1

                    Jim i am very thankful to you for your quick response to my questions. My problem have been soleve .  it was a problem with generating hmac. i have got the solution. If anybody interested in C# version of UploadTool i will send the source code to him........

                     

                    Thanks.