> Note that base64 encoded stuff is not url/html safe and has to be encoded also
> before sending it over the http-wire.

Hmm, interesting. This is going as the headers in a POST. It did seem
to work the last time I ran it, just now, a few minutes ago.

I am using the clj-http library and my actual POST function is:

(defn omniture-call-api [url-with-queue-method api-payload headers]
  (timbre/spy :debug " return value of omniture-call-api "
              (try+
                (http-client/post url-with-queue-method
                                  {:body api-payload
                                   :debug true
                                   :debug-body true
                                   :insecure true
                                   :headers {"X-Api-Version" "2"
                                             "X-WSSE" headers}
                                   :content-type :json
                                   :socket-timeout 4000
                                   :conn-timeout 4000
                                   :accept :json
                                   :client-params
{"http.protocol.allow-circular-redirects" true
                                                   "http.useragent"
"clj-http"}})
                (catch Object o (println (pp/pprint o))))))


The 3rd argument, headers, is what you helped me figure out earlier.



On Mar 4, 4:17 pm, Frank Siebenlist <frank.siebenl...@gmail.com>
wrote:
> .digest returns a byte array - so your PasswordDigest value is unprintable 
> and is not fit for any header/URL.
>
> Not sure what this base64-encode function does exactly, but normally base64 
> encoding takes a bunch of bytes already, so the (commented-out) 
> "digest-base64 (base64-encode (.getBytes digest))" does not need the 
> (.getBytes …) transformation as your digest consists already of bytes.
>
> Note that base64 encoded stuff is not url/html safe and has to be encoded 
> also before sending it over the http-wire.
>
> -FS.
>
> On Mar 4, 2013, at 1:00 PM, larry google groups <lawrencecloj...@gmail.com> 
> wrote:
>
>
>
>
>
>
>
> > Thank you for the suggestions. If I do this:
>
> >  (let [username (get-in @um/interactions [:omniture-api-
> > credentials :username])
> >                    secret (get-in @um/interactions [:omniture-api-
> > credentials :shared-secret])
> >                    random-number (math/round (* (rand 1 ) 1000000))
> >                    nonce (DigestUtils/md5Hex (str random-number))
> >                    nonce-encoded-base64 (base64-encode (.getBytes
> > nonce))
> >                    date-formatter (new SimpleDateFormat "yyyy-MM-
> > dd'T'HH:mm:ss")
> >                    created (.format date-formatter (new Date))
> >                    nonce-as-bytes (.getBytes nonce)
> >                    created-as-bytes (.getBytes created)
> >                    secret-as-bytes (.getBytes secret)
> >                    digest (.digest
> >                            (doto (java.security.MessageDigest/
> > getInstance "sha1")
> >                              .reset
> >                              (.update nonce-as-bytes)
> >                              (.update created-as-bytes)
> >                              (.update secret-as-
> > bytes)))
> >  ;;                  ;;digest-base64 (base64-encode (.getBytes
> > digest))
> >                    header (apply str " UsernameToken Username=\""
> > username  "\" PasswordDigest=\"" digest "\" Nonce=\"" nonce-encoded-
> > base64 "\" Created=\"" created "\"")]
> >                header)
>
> > I end up with, in part:
>
> > PasswordDigest="[B@26f7b2f4"
> > Nonce="Y2MwN2JiYzA5MDlmZjE2ZjExMGYzMjRhODA2Yjc5ODc="
> > Created="2013-03-04T15:57:52"
>
> > Which I think is still incorrect.
>
> > I also tried this with the PasswordDigest base64 encoded, and that did
> > not work either.
>
> > On Mar 4, 2:43 pm, Frank Siebenlist <frank.siebenl...@gmail.com>
> > wrote:
> >> That should work.
>
> >> No need for .reset though as the initially constructed MessageDigest is 
> >> already in its initial state.
>
> >> Be careful with .digest as it implicitly resets the MessageDigest, and 
> >> calling it a second time gives you the digest of the initial state which 
> >> is not what you want.
>
> >> (all that "incidental complexity" is why I started to write that 
> >> functional interface ;-) )
>
> >> -FS.
>
> >> On Mar 4, 2013, at 11:32 AM, Aaron Cohen <aa...@assonance.org> wrote:
>
> >>> Ah darn, thanks for the catch. The following is uglier but should work I 
> >>> guess. :\
>
> >>> digest (.digest
> >>>                (doto (java.security.MessageDigest/getInstance "sha1")
> >>>                      .reset
> >>>                      (.update nonce-bytes)
> >>>                      (.update created-bytes)
> >>>                      (.update secret-bytes)))
>
> >>> On Mon, Mar 4, 2013 at 2:25 PM, Frank Siebenlist 
> >>> <frank.siebenl...@gmail.com> wrote:
> >>>> digest (-> (java.security.MessageDigest/getInstance "sha1")
> >>>>                     .reset
> >>>>                     (.update nonce-bytes)
> >>>>                     (.update create-bytes)
> >>>>                     (.update secret-bytes)
> >>>>                     .digest)
>
> >>> There may be an issue with this snippet of code as ".update" does not 
> >>> return anything… i.e. nil.
>
> >>> -FS.
>
> >>> On Mar 4, 2013, at 11:06 AM, larry google groups 
> >>> <lawrencecloj...@gmail.com> wrote:
>
> >>>>> ;; Should "UsernameToken Username" really be unquoted in the following 
> >>>>> line?
> >>>>> ;; All the other variable names are quoted
>
> >>>> Apparently, yes. The developer at Omniture reviewed it and said my
> >>>> only problem was the way the passwordDigest was created.
>
> >>>> On Mar 4, 2:02 pm, Aaron Cohen <aa...@assonance.org> wrote:
> >>>>> I think you should try to avoid the string concatenation games. I'm not
> >>>>> sure what your current code is, but I suspect you're still ending up 
> >>>>> with
> >>>>> array toString's slipping in.
>
> >>>>> How about the following?
>
> >>>>> On Mon, Mar 4, 2013 at 1:31 PM, larry google groups <
>
> >>>>> lawrencecloj...@gmail.com> wrote:
> >>>>>> So, right now I am using this code:
>
> >>>>>>  (let [username (get-in @um/interactions [:omniture-api-
> >>>>>> credentials :username])
> >>>>>>   secret (get-in @um/interactions [:omniture-api-credentials :shared-
> >>>>>> secret])
> >>>>>>   nonce (DigestUtils/md5Hex (str (math/round (* (rand 1 ) 1000000))))
> >>>>>>   nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))
> >>>>>>   date-formatter (new SimpleDateFormat "yyyy-MM-dd'T'HH:mm:ss")
> >>>>>>   formatter gmt-timezone)
> >>>>>>   created (.format date-formatter (new Date))
>
> >>>>>    nonce-bytes (.getBytes nonce)
> >>>>>    created-bytes (.getBytes created)
> >>>>>    secret-bytes (.getBytes secret)
> >>>>>    digest (-> (java.security.MessageDigest/getInstance "sha1")
> >>>>>                     .reset
> >>>>>                     (.update nonce-bytes)
> >>>>>                     (.update create-bytes)
> >>>>>                     (.update secret-bytes)
> >>>>>                     .digest)
> >>>>>     digest-base64 (Base64/encodeBase64 digest)
>
> >>>>> ;; Should "UsernameToken Username" really be unquoted in the following 
> >>>>> line?
> >>>>> ;; All the other variable names are quoted
> >>>>>     header (apply str " UsernameToken Username=\""  username
>
> >>>>> ;; You may want digest-base64 here?
> >>>>>                               "\"PasswordDigest=\"" digest
>
> >>>>>                               "\" Nonce=\"" nonce-encoded-base64
> >>>>>                               "\"Created=\"" created "\"")]
> >>>>>              header)
>
> >>>> --
> >>>> --
> >>>> You received this message because you are subscribed to the Google
> >>>> Groups "Clojure" group.
> >>>> To post to this group, send email to clojure@googlegroups.com
> >>>> Note that posts from new members are moderated - please be patient with 
> >>>> your first post.
> >>>> To unsubscribe from this group, send email to
> >>>> clojure+unsubscr...@googlegroups.com
> >>>> For more options, visit this group at
> >>>>http://groups.google.com/group/clojure?hl=en
> >>>> ---
> >>>> You received this message because you are subscribed to the Google 
> >>>> Groups "Clojure" group.
> >>>> To unsubscribe from this group and stop receiving emails from it, send 
> >>>> an email to clojure+unsubscr...@googlegroups.com.
> >>>> For more options, visithttps://groups.google.com/groups/opt_out.
>
> >>> --
> >>> --
> >>> You received this message because you are subscribed to the Google
> >>> Groups "Clojure" group.
> >>> To post to this group, send email to clojure@googlegroups.com
> >>> Note that posts from new members are moderated - please be patient with 
> >>> your first post.
> >>> To unsubscribe from this group, send email to
> >>> clojure+unsubscr...@googlegroups.com
> >>> For more options, visit this group at
> >>>http://groups.google.com/group/clojure?hl=en
> >>> ---
> >>> You received this message because you are subscribed to the Google Groups 
> >>> "Clojure" group.
> >>> To unsubscribe from this group and stop receiving emails from it, send an 
> >>> email to clojure+unsubscr...@googlegroups.com.
> >>> For more options, visithttps://groups.google.com/groups/opt_out.
>
> > --
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Clojure" group.
> > To post to this group, send email to clojure@googlegroups.com
> > Note that posts from new members are moderated - please be patient with 
> > your first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/clojure?hl=en
> > ---
> > You received this message because you are subscribed to the Google Groups 
> > "Clojure" group.
> > To unsubscribe from this group and stop receiving emails from it, send an 
> > email to clojure+unsubscr...@googlegroups.com.
> > For more options, visithttps://groups.google.com/groups/opt_out.

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to