Example #1
0
        /// <summary>
        /// Validate the tag
        /// </summary>
        protected override void Validate(TagCounter tagCounter)
        {
            base.Validate(tagCounter);

            if (_headerIndex != 0)
            {
                throw new PublicationsFileException("Publications file header should be the first element in publications file.");
            }

            if (_firstPublicationRecordIndex < _lastCertRecordIndex)
            {
                throw new PublicationsFileException("Certificate records should be before publication records.");
            }

            if (_cmsSignatureIndex != Count - 1)
            {
                throw new PublicationsFileException("Cms signature should be last element in publications file.");
            }

            if (tagCounter[Constants.PublicationsFileHeader.TagType] != 1)
            {
                throw new PublicationsFileException("Exactly one publications file header must exist in publications file.");
            }

            if (tagCounter[Constants.PublicationsFile.CmsSignatureTagType] != 1)
            {
                throw new PublicationsFileException("Exactly one signature must exist in publications file.");
            }
        }
Example #2
0
        }                                           // graph

        internal void RebuildIndex()
        {
            CachedIndex.Clear();
            foreach (var item in items)
            {
                CachedIndex.Add(item.XPath, item);
            }
            ;

            ContentGraph = NodeGraph.Build(items); // BuildGraph();
            if (ContentGraph != null)
            {
                var allChildren = ContentGraph.getAllChildren();

                foreach (graphWrapNode <LeafNodeDictionaryEntry> child in allChildren)
                {
                    if (!child.name.isNullOrEmpty())
                    {
                        String tag = child.name.Trim(ContentGraph.pathSeparator.ToCharArray());
                        var    m   = TagSelectorRegex.Match(tag);
                        if (m.Success)
                        {
                            tag = m.Groups[m.Groups.Count - 1].Value;
                        }
                        NodeTagCounter.Count(tag);
                    }
                }
            }

            foreach (var item in items)
            {
                TagCounter.Count(item.node.Name);
            }
        }
    public override bool Check()
    {
        tagCounter = GetComponent <TagCounter>();

        tagCounter.Tags += 1;
        throw new System.NotImplementedException();
    }
Example #4
0
        /// <summary>
        /// Validate the tag
        /// </summary>
        protected override void Validate(TagCounter tagCounter)
        {
            base.Validate(tagCounter);

            if (ErrorPayload == null)
            {
                if (Payloads.Count == 0)
                {
                    throw new TlvException("Payloads are missing in PDU.");
                }

                if (tagCounter[Constants.PduHeader.TagType] != 1)
                {
                    throw new TlvException("Exactly one header must exist in PDU.");
                }

                if (_headerIndex != 0)
                {
                    throw new TlvException("Header must be the first element in PDU.");
                }

                if (tagCounter[Constants.Pdu.MacTagType] != 1)
                {
                    throw new TlvException("Exactly one MAC must exist in PDU");
                }

                if (_macIndex != Count - 1)
                {
                    throw new TlvException("MAC must be the last element in PDU");
                }
            }
        }
Example #5
0
        public async Task <ActionResult> PutTagCounter(int id, TagCounter tagCounter)
        {
            try
            {
                if (id != tagCounter.Id)
                {
                    return(BadRequest());
                }

                var tagCounterFromDb = _context.TagCounters.FirstOrDefault(x => x.Id == id);
                if (tagCounterFromDb != null)
                {
                    tagCounterFromDb.Picture   = tagCounter.Picture;
                    tagCounterFromDb.PictureId = tagCounter.PictureId;
                    tagCounterFromDb.Tag       = tagCounter.Tag;
                    tagCounterFromDb.TagId     = tagCounter.TagId;
                    tagCounterFromDb.User      = tagCounter.User;
                    tagCounterFromDb.UserId    = tagCounter.UserId;
                    await _context.SaveChangesAsync();

                    return(Ok());
                }
                else
                {
                    return(NotFound());
                }
            }
            catch (Exception e)
            {
                return(BadRequest());
            }
        }
Example #6
0
        /// <summary>
        /// Validate the tag
        /// </summary>
        protected override void Validate(TagCounter tagCounter)
        {
            base.Validate(tagCounter);

            if (_aggregationHashChains.Count == 0)
            {
                throw new TlvException("Aggregation hash chains must exist in KSI signature.");
            }

            if (tagCounter[Constants.CalendarHashChain.TagType] > 1)
            {
                throw new TlvException("Only one calendar hash chain is allowed in KSI signature.");
            }

            if (tagCounter[Constants.CalendarHashChain.TagType] == 0 &&
                (tagCounter[Constants.PublicationRecord.TagTypeInSignature] != 0 || tagCounter[Constants.CalendarAuthenticationRecord.TagType] != 0))
            {
                throw new TlvException("No publication record or calendar authentication record is allowed in KSI signature if there is no calendar hash chain.");
            }

            if ((tagCounter[Constants.PublicationRecord.TagTypeInSignature] == 1 && tagCounter[Constants.CalendarAuthenticationRecord.TagType] == 1) ||
                tagCounter[Constants.PublicationRecord.TagTypeInSignature] > 1 ||
                tagCounter[Constants.CalendarAuthenticationRecord.TagType] > 1)
            {
                throw new TlvException("Only one from publication record or calendar authentication record is allowed in KSI signature.");
            }

            if (tagCounter[Constants.Rfc3161Record.TagType] > 1)
            {
                throw new TlvException("Only one RFC 3161 record is allowed in KSI signature.");
            }
        }
        /// <summary>
        /// Validate the tag
        /// </summary>
        protected override void Validate(TagCounter tagCounter)
        {
            base.Validate(tagCounter);

            if (tagCounter[Constants.AggregationHashChain.AggregationTimeTagType] != 1)
            {
                throw new TlvException("Exactly one aggregation time must exist in aggregation hash chain.");
            }

            if (_chainIndex.Count == 0)
            {
                throw new TlvException("Chain index is missing in aggregation hash chain.");
            }

            if (tagCounter[Constants.AggregationHashChain.InputDataTagType] > 1)
            {
                throw new TlvException("Only one input data value is allowed in aggregation hash chain.");
            }

            if (tagCounter[Constants.AggregationHashChain.InputHashTagType] != 1)
            {
                throw new TlvException("Exactly one input hash must exist in aggregation hash chain.");
            }

            if (tagCounter[Constants.AggregationHashChain.AggregationAlgorithmIdTagType] != 1)
            {
                throw new TlvException("Exactly one algorithm must exist in aggregation hash chain.");
            }

            if (_links.Count == 0)
            {
                throw new TlvException("Links are missing in aggregation hash chain.");
            }
        }
        /// <summary>
        /// Validate the tag
        /// </summary>
        protected override void Validate(TagCounter tagCounter)
        {
            base.Validate(tagCounter);

            if (tagCounter[Constants.Rfc3161Record.AggregationTimeTagType] != 1)
            {
                throw new TlvException("Exactly one aggregation time must exist in RFC#3161 record.");
            }

            if (_chainIndex.Count == 0)
            {
                throw new TlvException("Chain indexes must exist in RFC#3161 record.");
            }

            if (tagCounter[Constants.Rfc3161Record.InputHashTagType] != 1)
            {
                throw new TlvException("Exactly one input hash must exist in RFC#3161 record.");
            }

            if (tagCounter[Constants.Rfc3161Record.TstInfoPrefixTagType] != 1)
            {
                throw new TlvException("Exactly one tstInfo prefix must exist in RFC#3161 record.");
            }

            if (tagCounter[Constants.Rfc3161Record.TstInfoSuffixTagType] != 1)
            {
                throw new TlvException("Exactly one tstInfo suffix must exist in RFC#3161 record.");
            }

            if (tagCounter[Constants.Rfc3161Record.TstInfoAlgorithmTagType] != 1)
            {
                throw new TlvException("Exactly one tstInfo algorithm must exist in RFC#3161 record.");
            }

            if (_tstInfoAlgorithm == null)
            {
                throw new TlvException("Invalid tstInfo algorithm value in RFC#3161 record.");
            }

            if (tagCounter[Constants.Rfc3161Record.SignedAttributesPrefixTagType] != 1)
            {
                throw new TlvException("Exactly one signed attributes prefix must exist in RFC#3161 record.");
            }

            if (tagCounter[Constants.Rfc3161Record.SignedAttributesSuffixTagType] != 1)
            {
                throw new TlvException("Exactly one signed attributes suffix must exist in RFC#3161 record.");
            }

            if (tagCounter[Constants.Rfc3161Record.SignedAttributesAlgorithmTagType] != 1)
            {
                throw new TlvException("Exactly one signed attributes algorithm must exist in RFC#3161 record.");
            }

            if (_signedAttributesAlgorithm == null)
            {
                throw new TlvException("Invalid signed attributes algorithm value in RFC#3161 record.");
            }
        }
        /// <summary>
        /// Validate the tag
        /// </summary>
        protected override void Validate(TagCounter tagCounter)
        {
            base.Validate(tagCounter);

            if (tagCounter[Constants.PublicationData.TagType] != 1)
            {
                throw new TlvException("Exactly one publication data must exist in publication record.");
            }
        }
        /// <summary>
        /// Validate the tag
        /// </summary>
        protected override void Validate(TagCounter tagCounter)
        {
            base.Validate(tagCounter);

            if (tagCounter[Constants.PduPayload.RequestIdTagType] != 1)
            {
                throw new TlvException("Exactly one request id must exist in response payload.");
            }
        }
        /// <summary>
        /// Validate the tag
        /// </summary>
        protected override void Validate(TagCounter tagCounter)
        {
            base.Validate(tagCounter);

            if (tagCounter[Constants.ExtendResponsePayload.LastTimeTagType] > 1)
            {
                throw new TlvException("Only one calendar last time is allowed in extend response payload.");
            }

            if (Status == 0 && tagCounter[Constants.CalendarHashChain.TagType] != 1)
            {
                throw new TlvException("Exactly one calendar hash chain must exist in extend response payload.");
            }
        }
Example #12
0
        /// <summary>
        /// Validate the tag
        /// </summary>
        protected override void Validate(TagCounter tagCounter)
        {
            base.Validate(tagCounter);

            if (tagCounter[Constants.PduPayload.StatusTagType] != 1)
            {
                throw new TlvException("Exactly one status code must exist in response payload.");
            }

            if (tagCounter[Constants.PduPayload.ErrorMessageTagType] > 1)
            {
                throw new TlvException("Only one error message is allowed in response payload.");
            }
        }
Example #13
0
        /// <summary>
        /// Validate the tag
        /// </summary>
        protected override void Validate(TagCounter tagCounter)
        {
            base.Validate(tagCounter);

            if (tagCounter[Constants.CertificateRecord.CertificateIdTagType] != 1)
            {
                throw new TlvException("Exactly one certificate id must exist in certificate record.");
            }

            if (tagCounter[Constants.CertificateRecord.X509CertificateTagType] != 1)
            {
                throw new TlvException("Exactly one certificate must exist in certificate record.");
            }
        }
Example #14
0
        public async Task <ActionResult <TagCounter> > PostTagCounter(TagCounter tagCounter)
        {
            try
            {
                _context.TagCounters.Add(tagCounter);
                await _context.SaveChangesAsync();

                return(CreatedAtAction("GetTagCounters", new { id = tagCounter.Id }, tagCounter));
            }
            catch (Exception e)
            {
                return(BadRequest());
            }
        }
Example #15
0
        /// <summary>
        /// Validate the tag
        /// </summary>
        protected override void Validate(TagCounter tagCounter)
        {
            base.Validate(tagCounter);

            if (tagCounter[Constants.PublicationData.PublicationTimeTagType] != 1)
            {
                throw new TlvException("Exactly one publication time must exist in publication data.");
            }

            if (tagCounter[Constants.PublicationData.PublicationHashTagType] != 1)
            {
                throw new TlvException("Exactly one publication hash must exist in publication data.");
            }
        }
        /// <summary>
        /// Validate the tag
        /// </summary>
        protected override void Validate(TagCounter tagCounter)
        {
            base.Validate(tagCounter);

            if (tagCounter[Constants.AggregationResponsePayload.ConfigTagType] > 1)
            {
                throw new TlvException("Only one config is allowed in aggregation response payload.");
            }

            if (tagCounter[Constants.AggregationResponsePayload.RequestAcknowledgmentTagType] > 1)
            {
                throw new TlvException("Only one request acknowledgment is allowed in aggregation response payload.");
            }
        }
            /// <summary>
            /// Validate the tag
            /// </summary>
            protected override void Validate(TagCounter tagCounter)
            {
                base.Validate(tagCounter);

                if (tagCounter[Constants.AggregationHashChain.Link.LevelCorrectionTagType] > 1)
                {
                    throw new TlvException("Only one levelcorrection value is allowed in aggregation hash chain link.");
                }

                if (!Util.IsOneValueEqualTo(1, tagCounter[Constants.AggregationHashChain.Link.SiblingHashTagType], tagCounter[Constants.AggregationHashChain.Link.LegacyId],
                                            tagCounter[Constants.AggregationHashChain.Metadata.TagType]))
                {
                    throw new TlvException("Exactly one of three from sibling hash, legacy id or metadata must exist in aggregation hash chain link.");
                }
            }
Example #18
0
        /// <summary>
        /// Validate the tag
        /// </summary>
        protected override void Validate(TagCounter tagCounter)
        {
            base.Validate(tagCounter);

            if (tagCounter[Constants.ExtenderConfigResponsePayload.MaxRequestsTagType] > 1)
            {
                throw new TlvException("Only one max requests tag is allowed in extender config response payload.");
            }

            if (tagCounter[Constants.ExtenderConfigResponsePayload.CalendarFirstTimeTagType] > 1)
            {
                throw new TlvException("Only one calendar first time tag is allowed in extender config response payload.");
            }

            if (tagCounter[Constants.ExtenderConfigResponsePayload.CalendarLastTimeTagType] > 1)
            {
                throw new TlvException("Only one calendar last time tag is allowed in extender config response payload.");
            }
        }
Example #19
0
        /// <summary>
        /// Validate the tag
        /// </summary>
        protected override void Validate(TagCounter tagCounter)
        {
            base.Validate(tagCounter);

            if (tagCounter[Constants.PduHeader.LoginIdTagType] != 1)
            {
                throw new TlvException("Exactly one login id must exist in PDU header.");
            }

            if (tagCounter[Constants.PduHeader.InstanceIdTagType] > 1)
            {
                throw new TlvException("Only one instance id is allowed in PDU header.");
            }

            if (tagCounter[Constants.PduHeader.MessageIdTagType] > 1)
            {
                throw new TlvException("Only one message id is allowed in PDU header.");
            }
        }
        /// <summary>
        /// Validate the tag
        /// </summary>
        protected override void Validate(TagCounter tagCounter)
        {
            base.Validate(tagCounter);

            if (tagCounter[Constants.PduPayload.RequestIdTagType] != 1)
            {
                throw new TlvException("Exactly one request id must exist in aggregation request payload.");
            }

            if (tagCounter[Constants.AggregationRequestPayload.RequestHashTagType] != 1)
            {
                throw new TlvException("Exactly one request hash must exist in aggregation request payload.");
            }

            if (tagCounter[Constants.AggregationRequestPayload.RequestLevelTagType] > 1)
            {
                throw new TlvException("Only one request level is allowed in aggregation request payload.");
            }
        }
Example #21
0
        /// <summary>
        /// Validate the tag
        /// </summary>
        protected override void Validate(TagCounter tagCounter)
        {
            base.Validate(tagCounter);

            if (tagCounter[Constants.PublicationsFileHeader.VersionTagType] != 1)
            {
                throw new TlvException("Exactly one version must exist in publications file header.");
            }

            if (tagCounter[Constants.PublicationsFileHeader.CreationTimeTagType] != 1)
            {
                throw new TlvException("Exactly one creation time must exist in publications file header.");
            }

            if (tagCounter[Constants.PublicationsFileHeader.RepositoryUriTagType] > 1)
            {
                throw new TlvException("Only one repository uri is allowed in publications file header.");
            }
        }
Example #22
0
        /// <summary>
        /// Validate the tag
        /// </summary>
        protected override void Validate(TagCounter tagCounter)
        {
            base.Validate(tagCounter);

            if (tagCounter[Constants.PduPayload.RequestIdTagType] != 1)
            {
                throw new TlvException("Exactly one request id must exist in extend request payload.");
            }

            if (tagCounter[Constants.ExtendRequestPayload.AggregationTimeTagType] != 1)
            {
                throw new TlvException("Exactly one aggregation time must exist in extend request payload.");
            }

            if (tagCounter[Constants.ExtendRequestPayload.PublicationTimeTagType] > 1)
            {
                throw new TlvException("Only one publication time is allowed in extend request payload.");
            }
        }
Example #23
0
        /// <summary>
        /// Validate the tag
        /// </summary>
        protected override void Validate(TagCounter tagCounter)
        {
            base.Validate(tagCounter);

            if (_payloadCount != 1)
            {
                throw new TlvException("Exactly one payload must exist in PDU.");
            }

            if (ErrorPayload == null)
            {
                if (tagCounter[Constants.PduHeader.TagType] != 1)

                {
                    throw new TlvException("Exactly one header must exist in PDU.");
                }

                if (tagCounter[Constants.Pdu.MacTagType] != 1)
                {
                    throw new TlvException("Exactly one mac must exist in PDU");
                }
            }
        }
            /// <summary>
            /// Validate the tag
            /// </summary>
            protected override void Validate(TagCounter tagCounter)
            {
                base.Validate(tagCounter);

                if (tagCounter[Constants.AggregationHashChain.Metadata.ClientIdTagType] != 1)
                {
                    throw new TlvException("Exactly one client id must exist in aggregation hash chain link metadata.");
                }

                if (tagCounter[Constants.AggregationHashChain.Metadata.MachineIdTagType] > 1)
                {
                    throw new TlvException("Only one machine id is allowed in aggregation hash chain link metadata.");
                }

                if (tagCounter[Constants.AggregationHashChain.Metadata.SequenceNumberTagType] > 1)
                {
                    throw new TlvException("Only one sequence number is allowed in aggregation hash chain link metadata.");
                }

                if (tagCounter[Constants.AggregationHashChain.Metadata.RequestTimeTagType] > 1)
                {
                    throw new TlvException("Only one request time is allowed in aggregation hash chain link metadata.");
                }
            }
Example #25
0
        /// <summary>
        /// Validate the tag
        /// </summary>
        protected override void Validate(TagCounter tagCounter)
        {
            base.Validate(tagCounter);

            if (tagCounter[Constants.CalendarHashChain.PublicationTimeTagType] != 1)
            {
                throw new TlvException("Exactly one publication time must exist in calendar hash chain.");
            }

            if (tagCounter[Constants.CalendarHashChain.AggregationTimeTagType] > 1)
            {
                throw new TlvException("Only one aggregation time is allowed in calendar hash chain.");
            }

            if (tagCounter[Constants.CalendarHashChain.InputHashTagType] != 1)
            {
                throw new TlvException("Exactly one input hash must exist in calendar hash chain.");
            }

            if (_chain.Count == 0)
            {
                throw new TlvException("Links are missing in calendar hash chain.");
            }
        }
        /// <summary>
        /// Validate the tag
        /// </summary>
        protected override void Validate(TagCounter tagCounter)
        {
            base.Validate(tagCounter);

            if (tagCounter[Constants.SignatureData.SignatureTypeTagType] != 1)
            {
                throw new TlvException("Exactly one signature type must exist in signature data.");
            }

            if (tagCounter[Constants.SignatureData.SignatureValueTagType] != 1)
            {
                throw new TlvException("Exactly one signature value must exist in signature data.");
            }

            if (tagCounter[Constants.SignatureData.CertificateIdTagType] != 1)
            {
                throw new TlvException("Exactly one certificate id must exist in signature data.");
            }

            if (tagCounter[Constants.SignatureData.CertificateRepositoryUriTagType] > 1)
            {
                throw new TlvException("Only one certificate repository uri is allowed in signature data.");
            }
        }
Example #27
0
        /// <summary>
        /// Validate the tag
        /// </summary>
        protected override void Validate(TagCounter tagCounter)
        {
            base.Validate(tagCounter);

            if (tagCounter[Constants.AggregatorConfigResponsePayload.MaxLevelTagType] > 1)
            {
                throw new TlvException("Only one max level tag is allowed in aggregator config response payload.");
            }

            if (tagCounter[Constants.AggregatorConfigResponsePayload.AggregationAlgorithmTagType] > 1)
            {
                throw new TlvException("Only one aggregation algorithm tag is allowed in aggregator config response payload.");
            }

            if (tagCounter[Constants.AggregatorConfigResponsePayload.AggregationPeriodTagType] > 1)
            {
                throw new TlvException("Only one aggregation period tag is allowed in aggregator config response payload.");
            }

            if (tagCounter[Constants.AggregatorConfigResponsePayload.MaxRequestsTagType] > 1)
            {
                throw new TlvException("Only one max requests tag is allowed in aggregator config response payload.");
            }
        }