1 2 bbq.ajax.SoapUsernameDigestToken = Class.create(/** @lends bbq.ajax.SoapUsernameDigestToken.prototype */ { 3 _options: null, 4 5 /** 6 * <p>Allows for sending a UsernameDigest authentication token with a SOAP request.</p> 7 * 8 * <p>Instances of this class are intended to be passed as the "authentcation" property 9 * of the options object for instances of bbq.ajax.SoapRequest.</p> 10 * 11 * @example 12 * <pre><code class="language-javascript"> 13 * var token = new bbq.ajax.SoapUsernameDigestToken({ 14 * username: "foo", 15 * password: "bar" 16 * }); 17 * </code></pre> 18 * @constructs 19 * @param {Object} options 20 * @see bbq.ajax.SoapRequest 21 */ 22 initialize: function(options) { 23 this._options = options; 24 }, 25 26 getSecurityHeader: function() { 27 var created = new Date(); 28 var nonce = String(created.getTime()).replace(/\D/gi,''); 29 var digest = nonce + created + this._options.password; 30 digest = Crypto.SHA1.b64_sha1(digest); 31 nonce = Crypto.rstr2b64(nonce); 32 33 return "<wsse:UsernameToken>" + 34 "<wsse:Username>" + this._options.username + "</wsse:Username>" + 35 "<wsse:Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest\">" + digest + "</wsse:Password>" + 36 "<wsse:Nonce>" + nonce + "</wsse:Nonce>" + 37 "<wsu:Created>" + created + "</wsu:Created>" + 38 "</wsse:UsernameToken>"; 39 } 40 }); 41