Example #1
0
        /**
           * Finishes a previously started registration.
           *
           * @param startedAuthentication
           * @param tokenResponse the response from the token/client.
           * @return a DeviceRegistration object, holding information about the registered device. Servers should
           * persist this.
           */
        public static DeviceRegistration FinishRegistration(StartedRegistration startedRegistration,
                                                            RegisterResponse tokenResponse, HashSet<String> facets = null)
        {
            ClientData clientData = tokenResponse.GetClientData();
            clientData.CheckContent(RegisterType, startedRegistration.Challenge, facets);

            RawRegisterResponse rawRegisterResponse = RawRegisterResponse.FromBase64(tokenResponse.RegistrationData);
            rawRegisterResponse.CheckSignature(startedRegistration.AppId, clientData.AsJson());

            return rawRegisterResponse.CreateDevice();
        }
        public void RegisterResponse_ConstructsProperly()
        {
            RegisterResponse registerResponse = new RegisterResponse(TestConts.REGISTRATION_RESPONSE_DATA_BASE64, TestConts.CLIENT_DATA_REGISTER_BASE64);

            Assert.IsNotNull(registerResponse);
            Assert.IsNotNull(registerResponse.GetClientData());
            Assert.IsNotNull(registerResponse.ToJson());
            Assert.IsTrue(registerResponse.GetHashCode() != 0);
            Assert.AreEqual(JsonData, registerResponse.ToJson());
            Assert.AreEqual(TestConts.REGISTRATION_RESPONSE_DATA_BASE64, registerResponse.RegistrationData);
            Assert.AreEqual(TestConts.CLIENT_DATA_REGISTER_BASE64, registerResponse.ClientData);
        }