Example #1
0
        /// <summary>
        /// Validates the enhanced security keys
        /// </summary>
        //  Revision History
        //  MM/DD/YY Who Version ID Number Description
        //  -------- --- ------- -- ------ -------------------------------------------
        //  09/17/09 RCG 2.30.00           Created
        //  09/19/14 jrf 4.00.63 WR 534158 Modified way test details are set.
        private void ValidateEnhancedSecurityKeys()
        {
            CXMLOpenWaySystemSettings SystemSettings = new CXMLOpenWaySystemSettings("");
            bool   Skipped = File.Exists(SystemSettings.EnhancedSecurityFilePath) == false;
            string Details = "";
            string Reason  = "";
            ProcedureResultCodes ValidationResult = ProcedureResultCodes.COMPLETED;

            if (IsAborted == false)
            {
                foreach (CENTRON_AMI.EnhancedKeys KeyType in Enum.GetValues(typeof(CENTRON_AMI.EnhancedKeys)))
                {
                    if (Skipped == false)
                    {
                        ValidationResult = m_AmiDevice.ValidateEnhancedSecurityKey(SystemSettings.EnhancedSecurityFilePath, KeyType);
                        Details          = GetSecurityValidationDetails(ValidationResult);

                        if (ProcedureResultCodes.INVALID_PARAM == ValidationResult)
                        {
                            Details += ", " + TestResources.KeyNotConsistentWithSecurityFile;
                        }
                    }
                    else
                    {
                        Reason  = TestResources.ReasonProgramFileNeededToValidate;
                        Details = TestResources.NoProgram;
                    }

                    AddTestDetail(KeyType.ToDescription(), GetResultString(Skipped, ProcedureResultCodes.COMPLETED == ValidationResult),
                                  Details, Reason);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Updates the signed authorization key stored in user settings.
        /// </summary>
        //  Revision History
        //  MM/DD/YY Who Version Issue# Description
        //  -------- --- ------- ------ ---------------------------------------------
        //  10/19/09 RCG 2.30.11	    Created

        internal static void UpdateSignedAuthorizationKey()
        {
            CXMLOpenWaySystemSettings SystemSettings = new CXMLOpenWaySystemSettings("");
            bool bCanceled = false;

            // Set up the Signed Authorization endpoint
            ExternalLib.Endpoint.SecurityEndpointName = SystemSettings.AuthorizationSecurityMethod;

            // If we are not using Windows Login we need to prompt the user for a User Name and Password
            if (SystemSettings.AuthorizationSecurityMethod == AUTH_SEC_APPLICATION)
            {
                LoginDialog Login = new LoginDialog();
                Login.HelpID = "Signed Authorization Login";
                Login.Title  = "Log in to the Signed Authorization Server";

                if (Login.ShowDialog() == DialogResult.OK)
                {
                    ExternalLib.Endpoint.ExternalUserName     = Login.UserName;
                    ExternalLib.Endpoint.ExternalUserPassword = Login.Password;
                }
                else
                {
                    // The user hit cancel
                    bCanceled = true;
                }
            }

            // Set the location of the Authorization server using the url entered in Shop Manager
            if (bCanceled == false && true == ExternalLib.Endpoint.SetClientEndpointAddress(SystemSettings.AuthorizationSecurityMethod,
                                                                                            SystemSettings.AuthorizationServer + "/ami/V2009/12/security/opticalSignedAuthorization"))
            {
                // Make the request for an Authorization key. Specifying Unknown permission level and Zero duration
                // will give us the highest level for the current user and the longest duration allowed.
                SignatureAuthorization signedAuth = ExternalLib.Request.SignatureAuthorization("", PermissionLevel.Unknown, TimeSpan.Zero);
                signedAuth.Execute();

                if (signedAuth != null)
                {
                    // Create the Authorization key object and save it to the user settings.
                    Settings.Default.AuthenticationKey = new SignedAuthorizationKey(signedAuth.Result.SignedAuthorization);
                    Settings.Default.Save();
                }
            }
        }
Example #3
0
        /// <summary>
        /// Gets the list of available passwords
        /// </summary>
        /// <returns>The list of passwords.</returns>
        //  Revision History
        //  MM/DD/YY Who Version Issue# Description
        //  -------- --- ------- ------ -------------------------------------------
        //  09/17/09 RCG 2.30.00        Created

        protected List <string> GetPasswords()
        {
            List <string>             Passwords      = new List <string>();
            CXMLOpenWaySystemSettings SystemSettings = new CXMLOpenWaySystemSettings("");

            Passwords.Add(SystemSettings.CurrentPWD);

            if (Passwords.Contains(SystemSettings.PreviousPWD) == false)
            {
                Passwords.Add(SystemSettings.PreviousPWD);
            }

            if (Passwords.Contains("") == false)
            {
                Passwords.Add("");
            }

            return(Passwords);
        }
Example #4
0
        /// <summary>
        /// Gets the list of selected tests
        /// </summary>
        /// <returns>The list of selected tests</returns>
        //  Revision History
        //  MM/DD/YY Who Version ID Number Description
        //  -------- --- ------- -- ------ -------------------------------------------
        //  08/28/09 RCG 2.30.00           Created
        //  09/19/14 jrf 4.00.63 WR 534158 removed unnecessary device class paramater.
        private List <ValidationTest> GetSelectedTests()
        {
            CXMLOpenWaySystemSettings SystemSettings   = new CXMLOpenWaySystemSettings("");
            ValidationTestRun         TestRun          = new ValidationTestRun(m_strValidationTestsFile);
            List <ValidationTest>     SelectedTests    = new List <ValidationTest>();
            SignedAuthorizationKey    AuthorizationKey = null;

            if (SystemSettings.UseSignedAuthorization)
            {
                AuthorizationKey = Settings.Default.AuthenticationKey;
            }

            foreach (ValidationTestID CurrentID in TestRun.SelectedTestIDs)
            {
                switch (CurrentID)
                {
                case ValidationTestID.ClearActivityStatus:
                {
                    SelectedTests.Add(new ClearActivityStatusTest(m_Comm, m_uiBaudRate, m_strProgramFile, AuthorizationKey));
                    break;
                }

                case ValidationTestID.ClearBilling:
                {
                    SelectedTests.Add(new ClearBillingTest(m_Comm, m_uiBaudRate, m_strProgramFile, AuthorizationKey));
                    break;
                }

                case ValidationTestID.ConnectDisconnect:
                {
                    SelectedTests.Add(new ConnectDisconnectTest(m_Comm, m_uiBaudRate, m_strProgramFile, AuthorizationKey));
                    break;
                }

                case ValidationTestID.DeviceStatus:
                {
                    SelectedTests.Add(new DeviceStatusTest(m_Comm, m_uiBaudRate, m_strProgramFile, AuthorizationKey));
                    break;
                }

                case ValidationTestID.ZigBeeRadioTest:
                {
                    SelectedTests.Add(new ZigBeeRadioTest(m_Comm, m_uiBaudRate, m_strProgramFile, AuthorizationKey));
                    break;
                }

                case ValidationTestID.ShowNormalDisplay:
                {
                    SelectedTests.Add(new NormalDisplayTest(m_Comm, m_uiBaudRate, m_strProgramFile, AuthorizationKey));
                    break;
                }

                case ValidationTestID.ValidateProgram:
                {
                    SelectedTests.Add(new ValidateProgramTest(m_Comm, m_uiBaudRate, m_strProgramFile, AuthorizationKey));
                    break;
                }

                case ValidationTestID.ValidateSecurityKeys:
                {
                    SelectedTests.Add(new ValidateSecurityKeysTest(m_Comm, m_uiBaudRate, m_strProgramFile, AuthorizationKey));
                    break;
                }
                }
            }

            return(SelectedTests);
        }
Example #5
0
        /// <summary>
        /// Gets the device information from the meter.
        /// </summary>
        //  Revision History
        //  MM/DD/YY Who Version ID Number Description
        //  -------- --- ------- -- ------ -------------------------------------------
        //  08/28/09 RCG 2.30.00           Created
        //  09/19/14 jrf 4.00.63 WR 534158 Modified to use the CANSIDevice.CreateDevice()
        //                                 method to instantiate the correct device and switched
        //                                 to store the name of the meter instead of device class.
        //  10/31/14 jrf 4.00.82  WR 542694 Added support for identifying Bridge meter with signed authorizaion.
        private TestRun GetDeviceInfo()
        {
            CXMLOpenWaySystemSettings SystemSettings = new CXMLOpenWaySystemSettings("");
            CPSEM        PSEM       = new CPSEM(m_Comm);
            PSEMResponse Response   = PSEMResponse.Ok;
            string       strModel   = null;
            TestRun      NewTestRun = new TestRun();
            string       MeterType  = "";

            Response = PSEM.Identify();

            if (Response == PSEMResponse.Ok)
            {
                Response = PSEM.Negotiate(CPSEM.DEFAULT_MAX_PACKET_LEGNTH,
                                          CPSEM.DEFAULT_MAX_NUMBER_OF_PACKETS, m_uiBaudRate);
            }

            if (Response == PSEMResponse.Ok)
            {
                Response = PSEM.Logon("", CPSEM.DEFAULT_HH_PRO_USER_ID);
            }

            if (Response == PSEMResponse.Ok)
            {
                CTable00 Table0 = new CTable00(PSEM);
                CTable01 Table1 = new CTable01(PSEM, Table0.StdVersion);
                strModel = Table1.Model;

                if (strModel == AMI_CENT)
                {
                    CANSIDevice ANSIDevice = CANSIDevice.CreateDevice(m_Comm, PSEM, Settings.Default.AuthenticationKey);
                    CENTRON_AMI AMIDevice  = ANSIDevice as CENTRON_AMI;

                    if (null != AMIDevice)
                    {
                        if (SystemSettings.UseSignedAuthorization && AMIDevice.SignedAuthorizationState != null &&
                            AMIDevice.SignedAuthorizationState.Value != FeatureState.Disabled &&
                            Settings.Default.AuthenticationKey != null)
                        {
                            // Use Signed Authenticaiton
                            AMIDevice.Authenticate(Settings.Default.AuthenticationKey);
                        }
                        else
                        {
                            // Use standard security
                            AMIDevice.Security(GetPasswords());
                        }

                        MeterType = AMIDevice.MeterName;

                        if (AMIDevice.CommModule != null)
                        {
                            m_strMeterID = AMIDevice.CommModule.ElectronicSerialNumber;
                        }
                    }
                }
            }

            try
            {
                PSEM.Logoff();
                PSEM.Terminate();
            }
            catch (Exception)
            {
                // Make sure we log off.
            }

            // Handle any errors that may have occurred
            if (Response != PSEMResponse.Ok)
            {
                throw new PSEMException(PSEMException.PSEMCommands.PSEM_READ, Response, Resources.ErrorRetrievingDeviceIdentification);
            }
            else if (strModel != AMI_CENT)
            {
                throw new InvalidOperationException(Resources.MeterTypeNotSupported);
            }

            // Set up the TestRun results
            NewTestRun.MeterType   = MeterType;
            NewTestRun.MeterID     = m_strMeterID;
            NewTestRun.TestDate    = DateTime.Now;
            NewTestRun.ProgramName = m_strProgramFile;
            NewTestRun.SWVersion   = Application.ProductVersion;

            return(NewTestRun);
        }