Пример #1
0
        public void VerificationRequestHandshakeTest()
        {
            string encodedSyn = _requester.CreateEncodedSyn();

            //Wait handle will wait the test until the handshake is complete
            ManualResetEvent waitHandle = new ManualResetEvent(false);

            //Setup callback for when the handshake is complete
            _receiver.IdentityProfileReceived += (sender, e) =>
            {
                _synAck = e.SynAck;
                waitHandle.Set();
            };

            _receiver.ProcessSyn(encodedSyn).Wait();

            if (waitHandle.WaitOne(100000))
            {
                //Check that all accessible attributes are present in the SynAck
                foreach (string attrKey in _allAttributes)
                {
                    Assert.IsNotNull(_synAck.Id.GetAttribute(attrKey));
                }
            }
            else
            {
                Assert.Fail();
            }
        }
Пример #2
0
        private async Task ProcessSynAck(string encryptedSynAck)
        {
            SynAck unverifiedSynAck = await base.DecryptAndInstantiateHandshakeToken <SynAck>(encryptedSynAck, _syn.Id);

            if (unverifiedSynAck.PublicKey != _syn.PublicKey)
            {
                throw new TokenPublicKeyMismatch();
            }

            if (!_tokenCryptoService.VerifySignature(unverifiedSynAck))
            {
                throw new SignatureDoesntMatchException("The signature was not " +
                                                        "generated by the given " +
                                                        "public Key");
            }

            _synAck = unverifiedSynAck;

            IdentityProfileReceivedEvent e = new IdentityProfileReceivedEvent()
            {
                SynAck = _synAck
            };

            IdentityProfileReceived.Invoke(this, e);
        }