public override AuthenticationToken CreateAuthenticationToken(IAuthenticateRequest authRequest, AuthSettings authSettings, string userId, Dictionary <string, object> authCookie) { var authResult = (ApplicationAccount)authSettings; var token = this.CreateAuthenticationToken(authResult, authRequest, userId, authCookie); token.MaxCcu = authResult.MaxCcu; token.IsCcuBurstAllowed = authResult.IsCcuBurstAllowed; token.PrivateCloud = authResult.PrivateCloud; var authOnceRequest = authRequest as IAuthOnceRequest; if (authOnceRequest != null) { token.EncryptionData = EncryptionDataGenerator.Generate(authOnceRequest.EncryptionMode); } return(token); }
public virtual AuthenticationToken CreateAuthenticationToken(IAuthenticateRequest authRequest, AuthSettings authSettings, string userId, Dictionary <string, object> authCookie) { var token = new AuthenticationToken { ApplicationId = authRequest.ApplicationId, ApplicationVersion = authRequest.ApplicationVersion, UserId = userId, AuthCookie = authCookie, Flags = authRequest.Flags, CustomAuthProvider = authRequest.ClientAuthenticationType, }; var authOnceRequest = authRequest as IAuthOnceRequest; if (authOnceRequest != null) { token.EncryptionData = EncryptionDataGenerator.Generate(authOnceRequest.EncryptionMode); } this.SetupToken(token); return(token); }
public void EncryptinDataGeneationTest([Values] EncryptionModes encryptionMode) { var d = EncryptionDataGenerator.Generate((byte)encryptionMode); var ed = new EncryptionData(Protocol.GpBinaryV162, d); Assert.That(ed.IsValid); Assert.That((EncryptionModes)ed.EncryptionMode, Is.EqualTo(encryptionMode)); switch (encryptionMode) { case EncryptionModes.PayloadEncryption: Assert.That(ed.EncryptionSecret, Is.Not.Null); Assert.That(ed.EncryptionSecret.Length, Is.EqualTo(32)); Assert.That(ed.AuthSecret, Is.Null); break; case EncryptionModes.PayloadEncryptionWithIV: Assert.That(ed.EncryptionSecret, Is.Not.Null); Assert.That(ed.EncryptionSecret.Length, Is.EqualTo(32)); Assert.That(ed.AuthSecret, Is.Null); break; case EncryptionModes.PayloadEncryptionWithIVHMAC: Assert.That(ed.EncryptionSecret, Is.Not.Null); Assert.That(ed.EncryptionSecret.Length, Is.EqualTo(32)); Assert.That(ed.AuthSecret, Is.Not.Null); Assert.That(ed.AuthSecret.Length, Is.EqualTo(32)); break; case EncryptionModes.DatagramEncyption: Assert.That(ed.EncryptionSecret, Is.Not.Null); Assert.That(ed.EncryptionSecret.Length, Is.EqualTo(32)); Assert.That(ed.AuthSecret, Is.Not.Null); Assert.That(ed.AuthSecret.Length, Is.EqualTo(32)); break; case EncryptionModes.DatagramEncyptionWithRandomInitialNumbers: Assert.That(ed.EncryptionSecret, Is.Not.Null); Assert.That(ed.EncryptionSecret.Length, Is.EqualTo(32)); Assert.That(ed.AuthSecret, Is.Not.Null); Assert.That(ed.AuthSecret.Length, Is.EqualTo(32)); break; case EncryptionModes.DatagramEncyptionGCMWithRandomInitialNumbers: Assert.That(ed.EncryptionSecret, Is.Not.Null); Assert.That(ed.EncryptionSecret.Length, Is.EqualTo(32)); Assert.That(ed.AuthSecret, Is.Null); break; default: throw new ArgumentOutOfRangeException(nameof(encryptionMode), encryptionMode, null); } }