public void SetAuth(string headerXml, Request request) { request.Auth = new RequestAuth { HmacData = _cryptographer.Hmac( _connectionInternal.SessionCredential.SharedSecret, Encoding.UTF8.GetBytes(headerXml)) }; }
public CASTRequestParams(AppProvisioningInfo provInfo, ICryptographer cryptographer) { provInfo.ValidateRequired("provInfo"); cryptographer.ValidateRequired("cryptographer"); // // To create a session, we prove our possesion of the app shared secret // We do this by creating an HMAC of some HmacContent // HmacContent content = new HmacContent(provInfo.AppIdInstance, cryptographer.HmacAlgorithm); string xmlContent = content.ToXml(); Hmac hmac = cryptographer.Hmac(provInfo.SharedSecret, xmlContent); this.AppIDInstance = provInfo.AppIdInstance; this.Credential = new CASTCredential(hmac, content); }
public CASTRequestParams(AppProvisioningInfo provInfo, ICryptographer cryptographer) { provInfo.ValidateRequired("provInfo"); cryptographer.ValidateRequired("cryptographer"); // // To create a session, we prove our possesion of the app shared secret // We do this by creating an HMAC of some HmacContent // HmacContent content = new HmacContent(provInfo.AppIdInstance, cryptographer.HmacAlgorithm); string xmlContent = content.ToXml(); Hmac hmac = cryptographer.Hmac(provInfo.SharedSecret, xmlContent); this.AppIDInstance = provInfo.AppIdInstance; this.Credential = new CASTCredential(hmac, content); }
public void InitializeTest() { _connection = Substitute.For <IConnectionInternal>(); _serviceLocator = Substitute.For <IServiceLocator>(); _serviceLocator.GetInstance <HealthVaultConfiguration>() .Returns(new HealthVaultConfiguration { MasterApplicationId = Guid.NewGuid(), RequestTimeToLiveDuration = new TimeSpan(hours: 0, minutes: 1, seconds: 5) }); _serviceLocator.GetInstance <SdkTelemetryInformation>() .Returns( new SdkTelemetryInformation() { Category = "test", FileVersion = "test", OsInformation = "test" }); ICryptographer mockCryptographer = Substitute.For <ICryptographer>(); CryptoData mockCryptoData = new CryptoData() { Algorithm = "some", Value = "some" }; mockCryptographer.Hmac(Arg.Any <string>(), Arg.Any <byte[]>()) .Returns(mockCryptoData); mockCryptographer.Hash(Arg.Any <byte[]>()) .Returns(mockCryptoData); _serviceLocator.GetInstance <ICryptographer>().Returns(mockCryptographer); _connection.SessionCredential.Returns( new SessionCredential() { SharedSecret = "someSharedSecret", Token = "someToken" }); }
private void PrepareAuth(Request request, SessionCredential credentials) { if (request == null) { throw new ArgumentNullException("request"); } if (request.IsAnonymous) { return; } if (credentials == null) { throw new ArgumentNullException("credentials"); } VerifyCredentials(); string headerXml = request.Header.ToXml(); Hmac hmac = m_cryptographer.Hmac(credentials.SharedSecret, headerXml); request.Auth = new RequestAuth(hmac); }