public AuthorizationHeader(ClientCredentials credentials, Nonce nonce, TimeStamp timestamp, Signature signature) { this.credentials = credentials; this.timestamp = timestamp; this.nonce = nonce; this.signature = signature; }
protected override Signature GenerateSignature(WebRequest request, Nonce nonce, TimeStamp timestamp) { BaseString baseString = new BaseString(request.RequestUri, request.Method, nonce, timestamp, credentials, HmacSha1Signature.MethodName); baseString.Token = token; return new HmacSha1Signature(baseString.ToString(), credentials, token); }
public BaseString(Uri uri, string httpMethod, Nonce nonce, TimeStamp timestamp, ClientCredentials credentials, string type) { this.uri = uri; this.httpMethod = httpMethod; this.nonce = nonce; this.timestamp = timestamp; this.credentials = credentials; this.signatureType = type; }
public void WithoutToken() { Nonce nonce = new Nonce(4543704); TimeStamp timestamp = new TimeStamp("1327332614"); ClientCredentials credentials = new ClientCredentials(CLIENT_IDENTIFIER, CLIENT_SHARED_SECRET); PlainTextSignature signature = new PlainTextSignature(credentials); Assert.AreEqual("PLAINTEXT", signature.Method); Assert.AreEqual("3nis2ci4qp4zksz&", signature.Value); }
public void WithToken() { Nonce nonce = new Nonce(4543704); TimeStamp timestamp = new TimeStamp("1327332614"); ClientCredentials credentials = new ClientCredentials(CLIENT_IDENTIFIER, CLIENT_SHARED_SECRET); AccessToken token = new AccessToken(ACCESS_TOKEN, ACCESS_TOKEN_SECRET); ; PlainTextSignature signature = new PlainTextSignature(credentials, token); Assert.AreEqual("PLAINTEXT", signature.Method); Assert.AreEqual("3nis2ci4qp4zksz&4i5cdsnulour8f5", signature.Value); }
public void WithToken() { Nonce nonce = new Nonce(4543704); TimeStamp timestamp = new TimeStamp("1327332614"); ClientCredentials credentials = new ClientCredentials(CLIENT_IDENTIFIER, CLIENT_SHARED_SECRET); AccessToken token = new AccessToken(ACCESS_TOKEN, ACCESS_TOKEN_SECRET);; PlainTextSignature signature = new PlainTextSignature(credentials, token); Assert.AreEqual("PLAINTEXT", signature.Method); Assert.AreEqual("3nis2ci4qp4zksz&4i5cdsnulour8f5", signature.Value); }
public void RequestOnNonStandardPort() { Nonce nonce = new Nonce("1234"); TimeStamp timestamp = new TimeStamp("1327772674"); Uri requestUri = new Uri("http://api.netflix.com:5050/catalog/titles"); ClientCredentials credentials = new ClientCredentials("key", "secret"); BaseString baseString = new BaseString(requestUri, "PUT", nonce, timestamp, credentials, HmacSha1Signature.MethodName); string expectedBaseString = "PUT&http%3A%2F%2Fapi.netflix.com%3A5050%2Fcatalog%2Ftitles&oauth_consumer_key%3Dkey%26oauth_nonce%3D1234%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1327772674%26oauth_version%3D1.0"; Assert.AreEqual(expectedBaseString, baseString.ToString()); }
public void RequestWithQueryParameters() { Nonce nonce = new Nonce("1234"); TimeStamp timestamp = new TimeStamp("1327772674"); Uri requestUri = new Uri("http://api.netflix.com/catalog/titles?arg1=value1&arg2=&arg3"); ClientCredentials credentials = new ClientCredentials("key", "secret"); BaseString baseString = new BaseString(requestUri, "GET", nonce, timestamp, credentials, HmacSha1Signature.MethodName); string expectedBaseString = "GET&http%3A%2F%2Fapi.netflix.com%2Fcatalog%2Ftitles&arg1%3Dvalue1%26arg2%3D%26arg3%3D%26oauth_consumer_key%3Dkey%26oauth_nonce%3D1234%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1327772674%26oauth_version%3D1.0"; Assert.AreEqual(expectedBaseString, baseString.ToString()); }
public void NonceMustBeUniqueAccrossAllRequest() { Nonce nonce1 = Nonce.Generate(); Nonce nonce2 = Nonce.Generate(); Nonce nonce3 = Nonce.Generate(); Assert.AreNotEqual(nonce1, nonce2); Assert.AreNotEqual(nonce1, nonce3); Assert.AreNotEqual(nonce2, nonce1); Assert.AreNotEqual(nonce2, nonce3); Assert.AreNotEqual(nonce3, nonce1); Assert.AreNotEqual(nonce3, nonce2); }
private AuthorizationHeader GenerateAuthorizationHeader(Nonce nonce, TimeStamp timestamp, Signature signature) { AuthorizationHeader header = new AuthorizationHeader(credentials, nonce, timestamp, signature); header.Token = token; return header; }
protected abstract Signature GenerateSignature(WebRequest request, Nonce nonce, TimeStamp timestamp);
public void Init() { nonce = new Nonce(int.Parse(NONCE_VALUE)); timestamp = new TimeStamp(TIMESTAMP_VALUE); token = new AccessToken(ACCESS_TOKEN, ACCESS_TOKEN_SECRET); credentials = new ClientCredentials(CLIENT_IDENTIFIER, CLIENT_SHARED_SECRET); signature = new PlainTextSignature(credentials, token); }
public override bool Equals(Object obj) { Nonce other = obj as Nonce; return(other != null && value == other.value); }
protected override Signature GenerateSignature(WebRequest request, Nonce nonce, TimeStamp timestamp) { return new PlainTextSignature(credentials, token); }