예제 #1
0
        public void RegisterResponse_FromJson()
        {
            RegisterResponse registerResponse = RegisterResponse.FromJson <RegisterResponse>(JsonData);

            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);
        }
예제 #2
0
파일: U2F.cs 프로젝트: polymorp/U2F_Core
        /// <summary>
        /// Finishes a previously started registration.
        /// </summary>
        /// <param name="startedRegistration">started registration response.</param>
        /// <param name="tokenResponse">tokenResponse the response from the token/client.</param>
        /// <param name="facets">A list of valid facets to verify against. (note: optional)</param>
        /// <returns>a DeviceRegistration object, holding information about the registered device. Servers should persist this.</returns>
        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());
        }