Exemple #1
0
        private static void updatePassword(GXDLMSSettings settings, GXByteBuffer buff, GXDLMSTranslatorStructure xml)
        {
            int len = buff.GetUInt8();
            // Get authentication information.
            if (buff.GetUInt8() != 0x80)
            {
                throw new Exception("Invalid tag.");
            }
            len = buff.GetUInt8();
            if (settings.Authentication == Authentication.Low)
            {
                settings.Password = new byte[len];
                buff.Get(settings.Password);
            }
            else
            {
                settings.CtoSChallenge = new byte[len];
                buff.Get(settings.CtoSChallenge);
            }

            if (xml != null)
            {
                if (xml.OutputType == TranslatorOutputType.SimpleXml)
                {
                    if (settings.Authentication == Authentication.Low)
                    {
                        xml.AppendLine(TranslatorGeneralTags.CallingAuthentication,
                                       "Value",
                                       GXCommon.ToHex(settings.Password, false));
                    }
                    else
                    {
                        xml.AppendLine(TranslatorGeneralTags.CallingAuthentication,
                                       "Value",
                                       GXCommon.ToHex(settings.CtoSChallenge, false));
                    }
                }
                else
                {
                    xml.AppendStartTag(
                        TranslatorGeneralTags.CallingAuthentication);
                    xml.AppendStartTag(TranslatorGeneralTags.CharString);
                    if (settings.Authentication == Authentication.Low)
                    {
                        xml.Append(GXCommon.ToHex(settings.Password, false));
                    }
                    else
                    {
                        xml.Append(
                            GXCommon.ToHex(settings.CtoSChallenge, false));
                    }
                    xml.AppendEndTag(TranslatorGeneralTags.CharString);
                    xml.AppendEndTag(TranslatorGeneralTags.CallingAuthentication);
                }
            }
        }
Exemple #2
0
 private static void AppendServerSystemTitleToXml(
     GXDLMSSettings settings, GXDLMSTranslatorStructure xml,
     int tag)
 {
     if (xml != null)
     {
         // RespondingAuthentication
         if (xml.OutputType == TranslatorOutputType.SimpleXml)
         {
             xml.AppendLine(tag, "Value", GXCommon.ToHex(settings.StoCChallenge, false));
         }
         else
         {
             xml.Append(tag, true);
             xml.Append((int)TranslatorGeneralTags.CharString, true);
             xml.Append(GXCommon.ToHex(settings.StoCChallenge, false));
             xml.Append((int)TranslatorGeneralTags.CharString, false);
             xml.Append(tag, false);
             xml.Append("\r\n");
         }
     }
 }