Beispiel #1
0
        private Identifier getSenderID(OiosiMessage message, DocumentTypeConfig docTypeConfig)
        {
            string senderID = DocumentXPathResolver.GetElementValueByXPathNavigator(
                message.MessageXml,
                docTypeConfig.EndpointType.SenderKey.XPath,
                docTypeConfig.Namespaces);
            var        senderKeyType = Utilities.GetSenderKeyTypeCode(message.MessageXml, docTypeConfig);
            Identifier id            = IdentifierUtility.GetIdentifierFromKeyType(senderID, senderKeyType);

            if (!id.IsAllowedInPublic)
            {
                string cvrNumberString;
                string endpointType;
                if (Credentials.ClientCertificate.TryGetCvrNumberString(out endpointType, out cvrNumberString))
                {
                    id = new Identifier(endpointType, cvrNumberString);
                }
                else
                {
                    throw new Exception("Sender ID is not allowed to be added to header. It was not possible to retrieve ID from certificate");
                }
            }

            return(id);
        }