//*************************************************************************************** #region Access Point internal StepType GetAccessPointInfoListTest(out AccessPointInfo[] target, out SoapException ex, out int Timeout, string[] TokenList) { StepType res = StepType.None; Timeout = 0; ex = null; target = null; bool passed = true; string logMessage = ""; string tmpCommandName = "GetAccessPointInfoList"; int tmpCommandNumber = GetAccessPointInfoList; //Get step list for command XmlNodeList m_testList = m_TestCommon.GetStepsForCommand(ServiceName + "." + tmpCommandName); if (m_testList.Count != 0) { //Get current step XmlNode test = m_testList[m_commandCount[tmpCommandNumber]]; #region Serialization Temp //AccessPointInfo[] dsr = new AccessPointInfo[1]; //dsr[0] = new AccessPointInfo(); //dsr[0].token = "test"; //dsr[0].Name = "name"; //dsr[0].Entity = "Device"; //dsr[0].Enabled = true; //dsr[0].Type = "not:Device"; //XmlSerializer serializer = new XmlSerializer(typeof(AccessPointInfo[])); //XmlReader sr = XmlReader.Create(new StringReader(test.SelectNodes("ResponseParameters")[0].InnerXml)); //TextWriter textWriter = new StreamWriter("d:\\2.txt"); //serializer.Serialize(textWriter, dsr); #endregion //Serialization Temp #region Analyze request //TokenList CommonCompare.StringArrayCompare("RequestParameters/Token", "Token", TokenList, ref logMessage, ref passed, test); #endregion //Analyze request //Generate response object targetObj; res = m_TestCommon.GenerateResponseStepTypeNotVoid(test, out targetObj, out ex, out Timeout, typeof(AccessPointInfo[])); target = (AccessPointInfo[])targetObj; //Log message m_TestCommon.writeToLog(test, logMessage, passed); Increment(m_testList.Count, tmpCommandNumber); } else { throw new SoapException("NO " + ServiceName + "." + tmpCommandName + " COMMAND IN SCRIPT", SoapException.ServerFaultCode); } return(res); }
internal StepType GetDoorInfoListTest(out DoorInfo[] target, out SoapException ex, out int Timeout, string[] TokenList, int Limit, bool LimitSpecified, int Offset, bool OffsetSpecified) { StepType res = StepType.None; Timeout = 0; ex = null; target = null; bool passed = true; string logMessage = ""; string tmpCommandName = "GetDoorInfoList"; int tmpCommandNumber = GetDoorInfoList; //Get step list for command XmlNodeList m_testList = m_TestCommon.GetStepsForCommand(ServiceName + "." + tmpCommandName); if (m_testList.Count != 0) { //Get current step XmlNode test = m_testList[m_commandCount[tmpCommandNumber]]; #region Analyze request //TokenList CommonCompare.StringArrayCompare("RequestParameters/Token", "Token", TokenList, ref logMessage, ref passed, test); //Limit if (CommonCompare.Exist2("RequestParameters/Limit", "Limit", LimitSpecified, ref logMessage, ref passed, test)) { CommonCompare.IntCompare("RequestParameters/Limit", "Limit", Limit, ref logMessage, ref passed, test); } //Offset if (CommonCompare.Exist2("RequestParameters/Offset", "Offset", OffsetSpecified, ref logMessage, ref passed, test)) { CommonCompare.IntCompare("RequestParameters/Offset", "Offset", Offset, ref logMessage, ref passed, test); } #endregion //Analyze request //Generate response object targetObj; res = m_TestCommon.GenerateResponseStepTypeNotVoid(test, out targetObj, out ex, out Timeout, typeof(DoorInfo[])); target = (DoorInfo[])targetObj; //Log message m_TestCommon.writeToLog(test, logMessage, passed); Increment(m_testList.Count, tmpCommandNumber); } else { throw new SoapException("NO " + ServiceName + "." + tmpCommandName + " COMMAND IN SCRIPT", SoapException.ServerFaultCode); } return(res); }
void ValidateParameters(Common.ParametersValidation validationRequest, ref string logMessage, ref bool passed, XmlNode test) { foreach (Common.ValidationRule rule in validationRequest.ValidationRules) { string parameterPath = string.Format("RequestParameters/{0}", rule.ParameterPath); switch (rule.Type) { case ParameterType.String: CommonCompare.StringCompare(parameterPath, rule.ParameterName, (string)rule.Value, ref logMessage, ref passed, test); break; case ParameterType.Int: CommonCompare.IntCompare(parameterPath, rule.ParameterName, (int)rule.Value, ref logMessage, ref passed, test); break; case ParameterType.OptionalInt: int?value = (int?)rule.Value; if (CommonCompare.Exist2(parameterPath, rule.ParameterName, value.HasValue, ref logMessage, ref passed, test)) { CommonCompare.IntCompare(parameterPath, rule.ParameterName, value.Value, ref logMessage, ref passed, test); } break; case ParameterType.OptionalBool: if (rule.ValueSpecified) { CommonCompare.StringCompare(parameterPath, rule.ParameterName, ((bool)rule.Value).ToString(), ref logMessage, ref passed, test); } else { CommonCompare.Exist2(parameterPath, rule.ParameterName, rule.ValueSpecified, ref logMessage, ref passed, test); } break; case ParameterType.OptionalString: { string stringValue = (string)rule.Value; if (CommonCompare.Exist2(parameterPath, rule.ParameterName, stringValue != null, ref logMessage, ref passed, test)) { CommonCompare.StringCompare(parameterPath, rule.ParameterName, (string)rule.Value, ref logMessage, ref passed, test); } } break; case ParameterType.OptionalElement: { CommonCompare.Exist2(parameterPath, rule.ParameterName, rule.Value != null, ref logMessage, ref passed, test); } break; case ParameterType.OptionalElementBoolFlag: { CommonCompare.Exist2(parameterPath, rule.ParameterName, (bool)rule.Value, ref logMessage, ref passed, test); } break; case ParameterType.StringArray: { CommonCompare.StringArrayCompare(parameterPath, rule.ParameterName, (string[])rule.Value, ref logMessage, ref passed, test); } break; case ParameterType.Log: { if (rule.Value.GetType().ToString() == "System.Byte[]") { logMessage = logMessage + rule.ParameterName + " = [Check it manually!]"; } else { logMessage = logMessage + rule.ParameterName + " = " + rule.Value.ToString(); } } break; case ParameterType.OptionalQName: { XmlQualifiedName QNameValue = (XmlQualifiedName)rule.Value; if (CommonCompare.Exist2(parameterPath, rule.ParameterName, QNameValue != null, ref logMessage, ref passed, test)) { CommonCompare.StringCompare(parameterPath + "/Namespace", rule.ParameterName + "/Namespace", QNameValue.Namespace, ref logMessage, ref passed, test); CommonCompare.StringCompare(parameterPath + "/Name", rule.ParameterName + "/Name", QNameValue.Name, ref logMessage, ref passed, test); } } break; case ParameterType.X509Cert: { Org.BouncyCastle.X509.X509Certificate cert = (new Org.BouncyCastle.X509.X509CertificateParser()).ReadCertificate((byte[])rule.Value); logMessage = logMessage + "\r\n"; logMessage = logMessage + rule.ParameterName + ": " + "\r\n" + cert.ToString(); logMessage = logMessage + "\r\n"; //TextWriter textWriter = new StringWriter(); //Org.BouncyCastle.Utilities.IO.Pem.PemWriter pemWriter = new Org.BouncyCastle.Utilities.IO.Pem.PemWriter(textWriter); //pemWriter.WriteObject(cert.CertificateStructure.SubjectPublicKeyInfo.PublicKeyData); //pemWriter.Writer.Flush(); //string privateKey = textWriter.ToString(); logMessage = logMessage + rule.ParameterName + "(PubK): " + "\r\n" + cert.CertificateStructure.SubjectPublicKeyInfo.PublicKeyData.ToString(); logMessage = logMessage + "\r\n"; logMessage = logMessage + rule.ParameterName + "(SignatureAlgorithm): " + "\r\n" + cert.CertificateStructure.SignatureAlgorithm.ObjectID.ToString(); logMessage = logMessage + "\r\n"; } break; case ParameterType.PKCS10: { Org.BouncyCastle.Pkcs.Pkcs10CertificationRequest pkcs10 = new Org.BouncyCastle.Pkcs.Pkcs10CertificationRequest((byte[])rule.Value); logMessage = logMessage + "\r\n"; logMessage = logMessage + rule.ParameterName + ": " + "\r\n" + pkcs10.ToString(); logMessage = logMessage + "\r\n"; } break; case ParameterType.PKCS12WithoutPassphrase: { Org.BouncyCastle.Pkcs.Pkcs12Store pkcs12Store = new Org.BouncyCastle.Pkcs.Pkcs12Store(); pkcs12Store.Load(new MemoryStream((byte[])rule.Value), ("").ToArray()); logMessage = logMessage + rule.ParameterName + ": " + "\r\n"; foreach (string alias in pkcs12Store.Aliases) { logMessage = logMessage + "\r\n"; logMessage = logMessage + "Alias = " + alias + "\r\n"; logMessage = logMessage + "Certificate = " + pkcs12Store.GetCertificate(alias).Certificate.ToString(); } logMessage = logMessage + "\r\n"; } break; case ParameterType.CRL: { Org.BouncyCastle.X509.X509Crl crl = (new Org.BouncyCastle.X509.X509CrlParser()).ReadCrl((byte[])rule.Value); logMessage = logMessage + "\r\n"; logMessage = logMessage + rule.ParameterName + ": " + "\r\n" + crl.ToString(); logMessage = logMessage + "\r\n"; } break; case ParameterType.Float: { CommonCompare.FloatCompare(parameterPath, rule.ParameterName, (float)rule.Value, ref logMessage, ref passed, test); } break; case ParameterType.OptionalFloat: float?fvalue = (float?)rule.Value; if (CommonCompare.Exist2(parameterPath, rule.ParameterName, fvalue.HasValue, ref logMessage, ref passed, test)) { CommonCompare.FloatCompare(parameterPath, rule.ParameterName, (float)rule.Value, ref logMessage, ref passed, test); } break; } } }