Lines Matching defs:this

16   *       notice, this list of conditions and the following disclaimer.
18 * notice, this list of conditions and the following disclaimer in the
22 * derived from this software without specific prior written permission.
87 */ this._secrets={};
88 this._parameters={};
92 this._secrets['consumer_key'] = consumer_key;
95 this._secrets['shared_secret'] = shared_secret;
97 this._default_signature_method= "HMAC-SHA1";
98 this._action = "GET";
99 this._nonce_chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
102 this.reset = function() {
103 this._parameters={};
104 this._path=undefined;
105 return this;
110 * @param {string,object} List of parameters for the call, this can either be a URI string (e.g. "foo=bar&gorp=banana" or an object/hash)
112 this.setParameters = function (parameters) {
117 parameters=this._parseParameterString(parameters);
119 this._parameters = parameters;
120 if (this._parameters['oauth_nonce'] === undefined) {
121 this._getNonce();
123 if (this._parameters['oauth_timestamp'] === undefined) {
124 this._getTimestamp();
126 if (this._parameters['oauth_method'] === undefined) {
127 this.setSignatureMethod();
129 if (this._parameters['oauth_consumer_key'] === undefined) {
130 this._getApiKey();
132 if(this._parameters['oauth_token'] === undefined) {
133 this._getAccessToken();
136 return this;
143 this.setQueryString = function (parameters) {
144 return this.setParameters(parameters);
151 this.setURL = function (path) {
155 this._path = path;
156 return this;
163 this.setPath = function(path){
164 return this.setURL(path);
171 this.setAction = function(action) {
179 this._action = action;
180 return this;
187 this.setTokensAndSecrets = function(signatures) {
191 this._secrets[i] = signatures[i];
195 if (this._secrets['api_key']) {
196 this._secrets.consumer_key = this._secrets.api_key;
198 if (this._secrets['access_token']) {
199 this._secrets.oauth_token = this._secrets.access_token;
201 if (this._secrets['access_secret']) {
202 this._secrets.oauth_secret = this._secrets.access_secret;
205 if (this._secrets.consumer_key === undefined) {
208 if (this._secrets.shared_secret === undefined) {
211 if ((this._secrets.oauth_token !== undefined) && (this._secrets.oauth_secret === undefined)) {
214 return this;
221 this.setSignatureMethod = function(method) {
223 method = this._default_signature_method;
229 this._parameters['oauth_signature_method']= method.toUpperCase();
230 return this;
242 this.sign = function (args) {
248 this.setAction(args['action']);
251 this.setPath(args['path']);
254 this.setSignatureMethod(args['method']);
256 this.setTokensAndSecrets(args['signatures']);
258 this.setParameters(args['parameters']);
261 var normParams = this._normalizedParameters();
262 this._parameters['oauth_signature']=this._generateSignature(normParams);
264 parameters: this._parameters,
265 signature: this._oauthEscape(this._parameters['oauth_signature']),
266 signed_url: this._path + '?' + this._normalizedParameters(),
267 header: this.getHeaderString()
279 this.getHeaderString = function(args) {
280 if (this._parameters['oauth_signature'] === undefined) {
281 this.sign(args);
285 for (var pName in this._parameters)
290 if ((this._parameters[pName]) instanceof Array)
292 var pLength = this._parameters[pName].length;
295 result += pName +'="'+this._oauthEscape(this._parameters[pName][j])+'" ';
300 result += pName + '="'+this._oauthEscape(this._parameters[pName])+'" ';
311 this._parseParameterString = function(paramString){
339 this._oauthEscape = function(string) {
354 this._getNonce = function (length) {
359 var cLength = this._nonce_chars.length;
362 result += this._nonce_chars.substring(rnum,rnum+1);
364 this._parameters['oauth_nonce']=result;
368 this._getApiKey = function() {
369 if (this._secrets.consumer_key === undefined) {
372 this._parameters['oauth_consumer_key']=this._secrets.consumer_key;
373 return this._parameters.oauth_consumer_key;
376 this._getAccessToken = function() {
377 if (this._secrets['oauth_secret'] === undefined) {
380 if (this._secrets['oauth_token'] === undefined) {
383 this._parameters['oauth_token'] = this._secrets.oauth_token;
384 return this._parameters.oauth_token;
387 this._getTimestamp = function() {
390 this._parameters['oauth_timestamp'] = ts;
394 this.b64_hmac_sha1 = function(k,d,_p,_z){
401 this._normalizedParameters = function() {
405 for (var paramName in this._parameters)
421 if (this._parameters[paramName] instanceof Array)
423 var sorted = this._parameters[paramName].sort();
429 elements.push(this._oauthEscape(paramName) + '=' +
430 this._oauthEscape(sorted[j]));
434 elements.push(this._oauthEscape(paramName) + '=' +
435 this._oauthEscape(this._parameters[paramName]));
440 this._generateSignature = function() {
442 var secretKey = this._oauthEscape(this._secrets.shared_secret)+'&'+
443 this._oauthEscape(this._secrets.oauth_secret);
444 if (this._parameters['oauth_signature_method'] == 'PLAINTEXT')
448 if (this._parameters['oauth_signature_method'] == 'HMAC-SHA1')
450 var sigString = this._oauthEscape(this._action)+'&'+this._oauthEscape(this._path)+'&'+this._oauthEscape(this._normalizedParameters());
451 return this.b64_hmac_sha1(secretKey,sigString);
456 return this;