Example #1
0
        public void GetExamCopy()
        {
            //  try
            {
                HighSecurity = highSecChkBox.Checked;
                //Create a client to connecto to phone book service on local server and
                //10048 TCP port.
                client = ScsServiceClientBuilder.CreateClient <INetworkExamService>(
                    new ScsTcpEndPoint(ipTxtBox.Text, int.Parse(portTxtBox.Text)));

                // client.Timeout = 3;
                aLogger.LogMessage($"Trying to connect to the server (timeout {client.Timeout} Seconds)", LogMsgType.Verbose);
                //Connect to the server
                client.Connect();

                aLogger.LogMessage("Connected to server", LogMsgType.Verbose);


                RequiredDetails requiredDetails = new RequiredDetails(studentNameTxtBox.Text, studentIDTxtBox.Text, examKeyTxtBox.Text, (HighSecurity? sharedKeyISTxtBox.Text:"Low Security Settings Selected"));
                //Add some persons
                var copy = client.ServiceProxy.GetExamCopyEncryptedZipped(requiredDetails);
                requiredDetails.DecryptDetails(examKeyTxtBox.Text);
                if (!ExamHelper.ValidateExamCopy(copy, examKeyTxtBox.Text, aLogger, sharedKeyISTxtBox.Text,
                                                 (highSecChkBox.Checked ? Security.FilterationSecurityLevel.High : Security.FilterationSecurityLevel.Moderate), requiredDetails.SequenceNumber))
                {
                    return;
                }

                aLogger.LogMessage("Received Exam Copy", LogMsgType.Verbose);

                aLogger.LogMessage("Checking Exam Copy...", LogMsgType.Verbose);

                var exam = Quizez.ExamHelper.GetExamFromByteArray(copy, examKeyTxtBox.Text, sharedKeyISTxtBox.Text,
                                                                  (highSecChkBox.Checked?Security.FilterationSecurityLevel.High:Security.FilterationSecurityLevel.Moderate));

                aLogger.LogMessage("Exam Checked Correcly ...", LogMsgType.Verbose);

                //Disconnect from server
                //   client.Disconnect();

                //  aLogger.LogMessage("Disconnected from server", LogMsgType.Verbose);

                anExam = exam;
            }
            // catch (Exception ex)
            {
                //  aLogger.LogMessage(ex.Message, LogMsgType.Error);
            }
        }
Example #2
0
        public FilterationResult IsValidSubmission(RequiredDetails details, string srcIP)
        {
            details.DecryptDetails(ExamKey);


            if (SecurityLevel == FilterationSecurityLevel.Moderate)
            {
                return(ModerateFilterationProcessSubmit(details));
            }
            else if (SecurityLevel == FilterationSecurityLevel.High)
            {
                return(HighFilterationProcessRequestSubmit(details, srcIP));
            }


            return(FilterationResult.DroppedUnknown); //Fail Safe
        }
Example #3
0
        public FilterationRequestResult GenerateExamCopyForSendingToStudent(Exam orgExamCopyEmpty, RequiredDetails details, string srcIP)
        {
            details.DecryptDetails(ExamKey);



            var filterResult = IsValidRequest(details, srcIP);

            if (filterResult != FilterationResult.Accepted)
            {
                throwFirewallException(filterResult, $"IP:{srcIP}");
                return(new FilterationRequestResult(filterResult, null));
            }
            var v = GetIV(details);

            details.SequenceNumber   = (long.Parse(details.SequenceNumber) + 1).ToString();
            details.VEncryptedWithKI = ExamHelper.GetVAsByteArray(v, InstructorPassword);

            var examInstance = orgExamCopyEmpty;

            examInstance.RequiredStudentDetails = details; //we received this from the student


            // examInstance.RequiredStudentDetails.SetV_CompressedEncryptedWithKI(v, InstructorPassword);

            //if(examInstance.RequiredStudentDetails.VEncryptedWithKI== null)
            //{
            //    MessageBox.Show("Set To Null");
            //}
            //else
            //{
            //    MessageBox.Show("examInstance.RequiredStudentDetails.VEncryptedWithKI");
            //}

            return(new FilterationRequestResult(filterResult, ExamHelper.GetExamFileWithoutSave(examInstance, ExamKey, details.SharedKeyIS, SecurityLevel)));
        }