├── .gitignore ├── CommandLine ├── BaseAttribute.cs ├── CommandLine.csproj ├── CommandLine.csproj.DotSettings ├── CommandLine.sln ├── Core │ ├── ArgumentsExtensions.cs │ ├── InstanceBuilder.cs │ ├── InstanceChooser.cs │ ├── KeyValuePairHelper.cs │ ├── NameExtensions.cs │ ├── NameLookup.cs │ ├── OptionMapper.cs │ ├── OptionSpecification.cs │ ├── PreprocessorGuards.cs │ ├── ReflectionExtensions.cs │ ├── Scalar.cs │ ├── Sequence.cs │ ├── Specification.cs │ ├── SpecificationExtensions.cs │ ├── SpecificationGuards.cs │ ├── SpecificationProperty.cs │ ├── SpecificationPropertyExtensions.cs │ ├── SpecificationPropertyRules.cs │ ├── Switch.cs │ ├── Token.cs │ ├── TokenPartitioner.cs │ ├── Tokenizer.cs │ ├── TypeConverter.cs │ ├── TypeDescriptor.cs │ ├── TypeLookup.cs │ ├── ValueMapper.cs │ ├── ValueSpecification.cs │ └── Verb.cs ├── Error.cs ├── ErrorExtensions.cs ├── Infrastructure │ ├── EnumerableExtensions`1.cs │ ├── EnumerableExtentions.cs │ ├── ErrorHandling.cs │ ├── ExceptionExtensions.cs │ ├── FSharpOptionHelper.cs │ ├── Maybe.cs │ ├── PopsicleSetter.cs │ ├── ReflectionHelper.cs │ ├── ResultExtensions.cs │ ├── StringBuilderExtensions.cs │ └── StringExtensions.cs ├── NameInfo.cs ├── NullInstance.cs ├── OptionAttribute.cs ├── Parser.cs ├── ParserExtensions.cs ├── ParserResult.cs ├── ParserResultExtensions.cs ├── ParserSettings.cs ├── Properties │ └── AssemblyInfo.cs ├── Text │ ├── AssemblyLicenseAttribute.cs │ ├── AssemblyUsageAttribute.cs │ ├── CopyrightInfo.cs │ ├── Example.cs │ ├── HeadingInfo.cs │ ├── HelpText.cs │ ├── MultiLineTextAttribute.cs │ ├── SentenceBuilder.cs │ └── UsageAttribute.cs ├── UnParserExtensions.cs ├── ValueAttribute.cs ├── VerbAttribute.cs └── paket.references ├── Readme.docx ├── Xades-master ├── .gitignore ├── Documents │ ├── Guide du Kit de démarrage Signature avancée XAdES.docx │ ├── Installation du Kit de démarrage Signature avancée XAdES.docx │ └── Microsoft.Xades.chm ├── LISEZMOI.txt ├── Source │ ├── Library │ │ ├── AllDataObjectsTimeStampCollection.cs │ │ ├── AssemblyInfo.cs │ │ ├── CRLIdentifier.cs │ │ ├── CRLRef.cs │ │ ├── CRLRefCollection.cs │ │ ├── CRLRefs.cs │ │ ├── CRLValue.cs │ │ ├── CRLValueCollection.cs │ │ ├── CRLValues.cs │ │ ├── Cert.cs │ │ ├── CertCollection.cs │ │ ├── CertRefs.cs │ │ ├── CertificateValues.cs │ │ ├── CertifiedRole.cs │ │ ├── CertifiedRoleCollection.cs │ │ ├── CertifiedRoles.cs │ │ ├── ClaimedRole.cs │ │ ├── ClaimedRoleCollection.cs │ │ ├── ClaimedRoles.cs │ │ ├── CommitmentTypeIndication.cs │ │ ├── CommitmentTypeIndicationCollection.cs │ │ ├── CommitmentTypeQualifier.cs │ │ ├── CommitmentTypeQualifierCollection.cs │ │ ├── CommitmentTypeQualifiers.cs │ │ ├── CompleteCertificateRefs.cs │ │ ├── CompleteRevocationRefs.cs │ │ ├── CounterSignatureCollection.cs │ │ ├── DataObjectFormat.cs │ │ ├── DataObjectFormatCollection.cs │ │ ├── DigestAlgAndValueType.cs │ │ ├── DigestMethod.cs │ │ ├── DocumentationReference.cs │ │ ├── DocumentationReferenceCollection.cs │ │ ├── DocumentationReferences.cs │ │ ├── EncapsulatedPKIData.cs │ │ ├── EncapsulatedX509Certificate.cs │ │ ├── EncapsulatedX509CertificateCollection.cs │ │ ├── HashDataInfo.cs │ │ ├── HashDataInfoCollection.cs │ │ ├── Identifier.cs │ │ ├── IndividualDataObjectsTimeStampCollection.cs │ │ ├── IssuerSerial.cs │ │ ├── Library.csproj │ │ ├── Microsoft.Xades.snk │ │ ├── NoticeNumberCollection.cs │ │ ├── NoticeNumbers.cs │ │ ├── NoticeRef.cs │ │ ├── OCSPIdentifier.cs │ │ ├── OCSPRef.cs │ │ ├── OCSPRefCollection.cs │ │ ├── OCSPRefs.cs │ │ ├── OCSPValue.cs │ │ ├── OCSPValueCollection.cs │ │ ├── OCSPValues.cs │ │ ├── ObjectIdentifier.cs │ │ ├── ObjectReference.cs │ │ ├── ObjectReferenceCollection.cs │ │ ├── OtherCertificate.cs │ │ ├── OtherCertificateCollection.cs │ │ ├── OtherRef.cs │ │ ├── OtherRefCollection.cs │ │ ├── OtherRefs.cs │ │ ├── OtherValue.cs │ │ ├── OtherValueCollection.cs │ │ ├── OtherValues.cs │ │ ├── QualifyingProperties.cs │ │ ├── RevocationValues.cs │ │ ├── SPUri.cs │ │ ├── SPUserNotice.cs │ │ ├── SigPolicyQualifier.cs │ │ ├── SigPolicyQualifierCollection.cs │ │ ├── SigPolicyQualifiers.cs │ │ ├── SignaturePolicyId.cs │ │ ├── SignaturePolicyIdentifier.cs │ │ ├── SignatureProductionPlace.cs │ │ ├── SignatureTimeStampCollection.cs │ │ ├── SignedDataObjectProperties.cs │ │ ├── SignedProperties.cs │ │ ├── SignedSignatureProperties.cs │ │ ├── SignerRole.cs │ │ ├── SigningCertificate.cs │ │ ├── TimeStamp.cs │ │ ├── Transform.cs │ │ ├── TransformCollection.cs │ │ ├── Transforms.cs │ │ ├── UnsignedDataObjectProperties.cs │ │ ├── UnsignedDataObjectProperty.cs │ │ ├── UnsignedDataObjectPropertyCollection.cs │ │ ├── UnsignedProperties.cs │ │ ├── UnsignedSignatureProperties.cs │ │ ├── XAdES.xsd │ │ ├── XMLTimeStamp.cs │ │ ├── XadesObject.cs │ │ ├── XadesSignedXml.cs │ │ ├── doc │ │ │ └── XAdES.xml │ │ └── xmldsig-core-schema.xsd │ ├── Microsoft.Xades.shfbproj │ ├── Microsoft.Xades.sln │ ├── Microsoft.Xades.snk │ └── TestClient │ │ ├── App.ico │ │ ├── Asn1Parser.cs │ │ ├── AssemblyInfo.cs │ │ ├── HttpTsaClient.cs │ │ ├── MainForm.cs │ │ ├── MainForm.resx │ │ ├── TestClient.csproj │ │ ├── ViewSignatureForm.cs │ │ ├── ViewSignatureForm.resx │ │ ├── XmlRenderTree.cs │ │ ├── XmlRenderTree.resx │ │ └── app.config └── licence.txt ├── Xades.IntegrationTests ├── IntegrationTest.cs ├── NUnitTestHelper.cs ├── Properties │ └── AssemblyInfo.cs ├── TestData │ ├── certificate.pfx │ └── root-certificate.cer ├── TestXml │ ├── Integration │ │ ├── exportNsiListResponse-expired.xml │ │ ├── exportNsiListResponse.xml │ │ └── getstate.xml │ ├── Invalid │ │ ├── certificate-not-match-by-digest-value.xml │ │ ├── certificate-not-match-by-issuer-name.xml │ │ ├── certificate-not-match-by-serial-number.xml │ │ ├── commitment.xml │ │ ├── data-object-format.xml │ │ ├── hash-algorithm-not-supported.xml │ │ ├── invalid-reference-to-signature.xml │ │ ├── invalid-reference-to-signed-element.xml │ │ ├── invalid-signature.xml │ │ ├── not-signed.xml │ │ ├── signature-not-found.xml │ │ ├── signed-insde.xml │ │ ├── signed-more-than-once.xml │ │ ├── signing-role.xml │ │ └── xmldsig.xml │ ├── NotSigned │ │ ├── not-signed-child.xml │ │ └── not-signed-root.xml │ └── Valid │ │ ├── sign.xml │ │ └── sing-certificate-is-not-installed.xml ├── Xades.IntegrationTests.csproj └── packages.config ├── Xades.UnitTests ├── IssuerComparerTests.cs ├── Properties │ └── AssemblyInfo.cs ├── Xades.UnitTests.csproj └── packages.config ├── Xades.sln ├── Xades ├── Abstractions │ ├── ICertificateMatcher.cs │ ├── ICryptoProvider.cs │ ├── IIssuerComparer.cs │ └── IXadesService.cs ├── Exceptions │ └── XadesBesValidationException.cs ├── Helpers │ ├── ArrayHelper.cs │ ├── CertificateHelper.cs │ ├── CollectionHelper.cs │ ├── ConvertHelper.cs │ ├── DateTimeHelper.cs │ ├── EnumerableHelper.cs │ ├── KeyInfoHelper.cs │ ├── X509NameHelper.cs │ ├── XadesSignedXmlHelper.cs │ └── XmlDocumentHelper.cs ├── Implementations │ ├── AdditionalXmlDsigC14NTransform.cs │ ├── CertificateMatcher.cs │ ├── GostCryptoProvider.cs │ ├── GostXadesBesService.cs │ └── IssuerComparer.cs ├── Models │ └── XadesInfo.cs ├── Properties │ └── AssemblyInfo.cs ├── Xades.csproj ├── XadesBesSignedXml.cs └── packages.config ├── XadesDemo ├── App.config ├── Commands │ ├── CertificateCommand.cs │ ├── CommandBase.cs │ ├── GetStateCommand.cs │ ├── GisCommandBase.cs │ ├── ICommand.cs │ ├── SendCommand.cs │ ├── SignCommand.cs │ ├── VerifyCommand.cs │ └── XadesCommandBase.cs ├── Configurations │ ├── Options │ │ ├── CertificateOptions.cs │ │ ├── GetStateOptions.cs │ │ ├── OptionBase.cs │ │ ├── SendOptions.cs │ │ ├── SignOptions.cs │ │ ├── VerifyOptions.cs │ │ └── XadesOptionBase.cs │ └── Sections │ │ ├── GisServiceConfiguration.cs │ │ ├── MethodCollection.cs │ │ ├── MethodElement.cs │ │ ├── ServiceCollection.cs │ │ ├── ServiceElement.cs │ │ ├── SigningConfiguration.cs │ │ └── SoapConfiguration.cs ├── Helpers │ ├── CsvHelper.cs │ └── PathHelper.cs ├── Infrastructure │ ├── Constants.cs │ ├── GisSoapFormatter.cs │ └── RussianSentenceBuilder.cs ├── Program.cs ├── Properties │ └── AssemblyInfo.cs ├── Templates │ ├── Inspection │ │ ├── get-state-template.xml │ │ └── import-inspection-plan-template.xml │ ├── NsiAsync │ │ ├── get-state-template.xml │ │ └── import-municipal-services-template.xml │ ├── NsiCommonAsync │ │ ├── export-nsi-item-template.xml │ │ ├── export-nsi-list-template.xml │ │ └── get-state-template.xml │ ├── is-request-header-template.xml │ ├── request-header-template.xml │ └── soap-template.xml ├── XadesDemo.csproj └── packages.config └── examples ├── exportNsiItem error request.csv ├── exportNsiItem error response.csv ├── exportNsiItem get-state error response.csv ├── exportNsiItem get-state response.csv ├── exportNsiItem request.csv ├── exportNsiItem response.csv ├── exportNsiList get-state response.csv ├── exportNsiList response.csv ├── importInspectionPlan get-state response error.csv ├── importInspectionPlan get-state response.csv ├── importInspectionPlan request error.csv ├── importInspectionPlan request.csv ├── importInspectionPlan response error.csv ├── importInspectionPlan response.csv ├── importMunicipalServices get-state response error.csv ├── importMunicipalServices request error.csv ├── importMunicipalServices response error.csv ├── importMunicipalServices response error1.csv └── команды.txt /.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | obj 3 | *.suo 4 | *.user 5 | packages -------------------------------------------------------------------------------- /CommandLine/CommandLine.csproj.DotSettings: -------------------------------------------------------------------------------- 1 |  2 | True 3 | True -------------------------------------------------------------------------------- /CommandLine/CommandLine.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommandLine", "CommandLine.csproj", "{E1BD3C65-49C3-49E7-BABA-C60980CB3F20}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {E1BD3C65-49C3-49E7-BABA-C60980CB3F20}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {E1BD3C65-49C3-49E7-BABA-C60980CB3F20}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {E1BD3C65-49C3-49E7-BABA-C60980CB3F20}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {E1BD3C65-49C3-49E7-BABA-C60980CB3F20}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /CommandLine/Core/ArgumentsExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information. 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using CSharpx; 7 | 8 | namespace CommandLine.Core 9 | { 10 | static class ArgumentsExtensions 11 | { 12 | public static IEnumerable Preprocess( 13 | this IEnumerable arguments, 14 | IEnumerable< 15 | Func, IEnumerable> 16 | > preprocessorLookup) 17 | { 18 | return preprocessorLookup.TryHead().MapValueOrDefault( 19 | func => 20 | { 21 | var errors = func(arguments); 22 | return errors.Any() 23 | ? errors 24 | : arguments.Preprocess(preprocessorLookup.TailNoFail()); 25 | }, 26 | Enumerable.Empty()); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /CommandLine/Core/KeyValuePairHelper.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information. 2 | 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using CSharpx; 6 | 7 | namespace CommandLine.Core 8 | { 9 | static class KeyValuePairHelper 10 | { 11 | public static IEnumerable>> ForSwitch( 12 | IEnumerable tokens) 13 | { 14 | return tokens.Select(t => t.Text.ToKeyValuePair("true")); 15 | } 16 | 17 | public static IEnumerable>> ForScalar( 18 | IEnumerable tokens) 19 | { 20 | return tokens.Pairwise((f, s) => f.Text.ToKeyValuePair(s.Text)); 21 | } 22 | 23 | public static IEnumerable>> ForSequence( 24 | IEnumerable tokens) 25 | { 26 | return from t in tokens.Pairwise( 27 | (f, s) => 28 | f.IsName() 29 | ? f.Text.ToKeyValuePair(tokens.SkipWhile(t => !t.Equals(f)).SkipWhile(t => t.Equals(f)).TakeWhile(v => v.IsValue()).Select(x => x.Text).ToArray()) 30 | : string.Empty.ToKeyValuePair()) 31 | where t.Key.Length > 0 && t.Value.Any() 32 | select t; 33 | } 34 | 35 | private static KeyValuePair> ToKeyValuePair(this string value, params string[] values) 36 | { 37 | return new KeyValuePair>(value, values); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /CommandLine/Core/NameExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information. 2 | 3 | using System; 4 | 5 | namespace CommandLine.Core 6 | { 7 | static class NameExtensions 8 | { 9 | public static bool MatchName(this string value, string shortName, string longName, StringComparer comparer) 10 | { 11 | return value.Length == 1 12 | ? comparer.Equals(value, shortName) 13 | : comparer.Equals(value, longName); 14 | } 15 | 16 | public static NameInfo FromOptionSpecification(this OptionSpecification specification) 17 | { 18 | return new NameInfo( 19 | specification.ShortName, 20 | specification.LongName); 21 | } 22 | 23 | public static NameInfo FromSpecification(this Specification specification) 24 | { 25 | switch (specification.Tag) 26 | { 27 | case SpecificationType.Option: 28 | return FromOptionSpecification((OptionSpecification)specification); 29 | default: 30 | return NameInfo.EmptyName; 31 | } 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /CommandLine/Core/NameLookup.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information. 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using CSharpx; 7 | 8 | namespace CommandLine.Core 9 | { 10 | enum NameLookupResult 11 | { 12 | NoOptionFound, 13 | BooleanOptionFound, 14 | OtherOptionFound 15 | } 16 | 17 | static class NameLookup 18 | { 19 | public static NameLookupResult Contains(string name, IEnumerable specifications, StringComparer comparer) 20 | { 21 | var option = specifications.FirstOrDefault(a => name.MatchName(a.ShortName, a.LongName, comparer)); 22 | if (option == null) return NameLookupResult.NoOptionFound; 23 | return option.ConversionType == typeof(bool) 24 | ? NameLookupResult.BooleanOptionFound 25 | : NameLookupResult.OtherOptionFound; 26 | } 27 | 28 | public static Maybe HavingSeparator(string name, IEnumerable specifications, 29 | StringComparer comparer) 30 | { 31 | return specifications.SingleOrDefault( 32 | a => name.MatchName(a.ShortName, a.LongName, comparer) && a.Separator != '\0') 33 | .ToMaybe() 34 | .MapValueOrDefault(spec => Maybe.Just(spec.Separator), Maybe.Nothing()); 35 | } 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /CommandLine/Core/OptionMapper.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information. 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using CSharpx; 7 | using RailwaySharp.ErrorHandling; 8 | 9 | namespace CommandLine.Core 10 | { 11 | static class OptionMapper 12 | { 13 | public static Result< 14 | IEnumerable, Error> 15 | MapValues( 16 | IEnumerable propertyTuples, 17 | IEnumerable>> options, 18 | Func, Type, bool, Maybe> converter, 19 | StringComparer comparer) 20 | { 21 | var sequencesAndErrors = propertyTuples 22 | .Select( 23 | pt => 24 | { 25 | var matched = options.FirstOrDefault(s => 26 | s.Key.MatchName(((OptionSpecification)pt.Specification).ShortName, ((OptionSpecification)pt.Specification).LongName, comparer)).ToMaybe(); 27 | return matched.IsJust() 28 | ? ( 29 | from sequence in matched 30 | from converted in 31 | converter( 32 | sequence.Value, 33 | pt.Property.PropertyType, 34 | pt.Specification.TargetType != TargetType.Sequence) 35 | select Tuple.Create( 36 | pt.WithValue(Maybe.Just(converted)), Maybe.Nothing()) 37 | ) 38 | .GetValueOrDefault( 39 | Tuple.Create>( 40 | pt, 41 | Maybe.Just( 42 | new BadFormatConversionError( 43 | ((OptionSpecification)pt.Specification).FromOptionSpecification())))) 44 | : Tuple.Create(pt, Maybe.Nothing()); 45 | } 46 | ); 47 | return Result.Succeed( 48 | sequencesAndErrors.Select(se => se.Item1), 49 | sequencesAndErrors.Select(se => se.Item2).OfType>().Select(se => se.Value)); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /CommandLine/Core/OptionSpecification.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information. 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using CSharpx; 7 | 8 | namespace CommandLine.Core 9 | { 10 | sealed class OptionSpecification : Specification 11 | { 12 | private readonly string shortName; 13 | private readonly string longName; 14 | private readonly char separator; 15 | private readonly string setName; 16 | 17 | public OptionSpecification(string shortName, string longName, bool required, string setName, Maybe min, Maybe max, 18 | char separator, Maybe defaultValue, string helpText, string metaValue, IEnumerable enumValues, 19 | Type conversionType, TargetType targetType) 20 | : base(SpecificationType.Option, required, min, max, defaultValue, helpText, metaValue, enumValues, conversionType, targetType) 21 | { 22 | this.shortName = shortName; 23 | this.longName = longName; 24 | this.separator = separator; 25 | this.setName = setName; 26 | } 27 | 28 | public static OptionSpecification FromAttribute(OptionAttribute attribute, Type conversionType, IEnumerable enumValues) 29 | { 30 | return new OptionSpecification( 31 | attribute.ShortName, 32 | attribute.LongName, 33 | attribute.Required, 34 | attribute.SetName, 35 | attribute.Min == -1 ? Maybe.Nothing() : Maybe.Just(attribute.Min), 36 | attribute.Max == -1 ? Maybe.Nothing() : Maybe.Just(attribute.Max), 37 | attribute.Separator, 38 | attribute.Default.ToMaybe(), 39 | attribute.HelpText, 40 | attribute.MetaValue, 41 | enumValues, 42 | conversionType, 43 | conversionType.ToTargetType()); 44 | } 45 | 46 | public static OptionSpecification NewSwitch(string shortName, string longName, bool required, string helpText, string metaValue) 47 | { 48 | return new OptionSpecification(shortName, longName, required, string.Empty, Maybe.Nothing(), Maybe.Nothing(), 49 | '\0', Maybe.Nothing(), helpText, metaValue, Enumerable.Empty(), typeof(bool), TargetType.Switch); 50 | } 51 | 52 | public string ShortName 53 | { 54 | get { return shortName; } 55 | } 56 | 57 | public string LongName 58 | { 59 | get { return longName; } 60 | } 61 | 62 | public char Separator 63 | { 64 | get { return separator; } 65 | } 66 | 67 | public string SetName 68 | { 69 | get { return setName; } 70 | } 71 | } 72 | } -------------------------------------------------------------------------------- /CommandLine/Core/PreprocessorGuards.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information. 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | 7 | namespace CommandLine.Core 8 | { 9 | static class PreprocessorGuards 10 | { 11 | public static IEnumerable, IEnumerable>> 12 | Lookup(StringComparer nameComparer) 13 | { 14 | return new List, IEnumerable>> 15 | { 16 | HelpCommand(nameComparer), 17 | VersionCommand(nameComparer) 18 | }; 19 | } 20 | 21 | public static Func, IEnumerable> HelpCommand(StringComparer nameComparer) 22 | { 23 | return 24 | arguments => 25 | nameComparer.Equals("--help", arguments.First()) 26 | ? new Error[] { new HelpRequestedError() } 27 | : Enumerable.Empty(); 28 | } 29 | 30 | public static Func, IEnumerable> VersionCommand(StringComparer nameComparer) 31 | { 32 | return 33 | arguments => 34 | nameComparer.Equals("--version", arguments.First()) 35 | ? new Error[] { new VersionRequestedError() } 36 | : Enumerable.Empty(); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /CommandLine/Core/Scalar.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information. 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using CommandLine.Infrastructure; 7 | using CSharpx; 8 | 9 | namespace CommandLine.Core 10 | { 11 | static class Scalar 12 | { 13 | public static IEnumerable Partition( 14 | IEnumerable tokens, 15 | Func> typeLookup) 16 | { 17 | return from tseq in tokens.Pairwise( 18 | (f, s) => 19 | f.IsName() && s.IsValue() 20 | ? typeLookup(f.Text).MapValueOrDefault(info => 21 | info.TargetType == TargetType.Scalar ? new[] { f, s } : new Token[] { }, new Token[] { }) 22 | : new Token[] { }) 23 | from t in tseq 24 | select t; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /CommandLine/Core/Sequence.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information. 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using CommandLine.Infrastructure; 7 | using CSharpx; 8 | 9 | namespace CommandLine.Core 10 | { 11 | static class Sequence 12 | { 13 | public static IEnumerable Partition( 14 | IEnumerable tokens, 15 | Func> typeLookup) 16 | { 17 | return from tseq in tokens.Pairwise( 18 | (f, s) => 19 | f.IsName() && s.IsValue() 20 | ? typeLookup(f.Text).MapValueOrDefault(info => 21 | info.TargetType == TargetType.Sequence 22 | ? new[] { f }.Concat(tokens.OfSequence(f, info)) 23 | : new Token[] { }, new Token[] { }) 24 | : new Token[] { }) 25 | from t in tseq 26 | select t; 27 | } 28 | 29 | private static IEnumerable OfSequence(this IEnumerable tokens, Token nameToken, TypeDescriptor info) 30 | { 31 | var nameIndex = tokens.IndexOf(t => t.Equals(nameToken)); 32 | if (nameIndex >= 0) 33 | { 34 | return info.NextValue.MapValueOrDefault( 35 | _ => info.MaxItems.MapValueOrDefault( 36 | n => tokens.Skip(nameIndex + 1).Take(n), 37 | tokens.Skip(nameIndex + 1).TakeWhile(v => v.IsValue())), 38 | tokens.Skip(nameIndex + 1).TakeWhile(v => v.IsValue())); 39 | } 40 | return new Token[] { }; 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /CommandLine/Core/SpecificationGuards.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information. 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using CSharpx; 6 | 7 | namespace CommandLine.Core 8 | { 9 | static class SpecificationGuards 10 | { 11 | public static readonly IEnumerable, string>> Lookup = new List, string>> 12 | { 13 | Tuple.Create(GuardAgainstScalarWithRange(), "Scalar option specifications do not support range specification."), 14 | Tuple.Create(GuardAgainstSequenceWithWrongRange(), "Bad range in sequence option specifications."), 15 | Tuple.Create(GuardAgainstSequenceWithZeroRange(), "Zero is not allowed in range of sequence option specifications."), 16 | Tuple.Create(GuardAgainstOneCharLongName(), "Long name should be longest than one character.") 17 | }; 18 | 19 | private static Func GuardAgainstScalarWithRange() 20 | { 21 | return spec => spec.TargetType == TargetType.Scalar 22 | && (spec.Min.IsJust() || spec.Max.IsJust()); 23 | } 24 | 25 | private static Func GuardAgainstSequenceWithWrongRange() 26 | { 27 | return spec => spec.TargetType == TargetType.Sequence 28 | && spec.HavingRange((min, max) => min > max); 29 | } 30 | 31 | private static Func GuardAgainstOneCharLongName() 32 | { 33 | return spec => spec.IsOption() && ((OptionSpecification)spec).LongName.Length == 1; 34 | } 35 | 36 | private static Func GuardAgainstSequenceWithZeroRange() 37 | { 38 | return spec => spec.TargetType == TargetType.Sequence 39 | && (spec.HavingMin(min => min == 0) 40 | || spec.HavingMax(max => max == 0)); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /CommandLine/Core/SpecificationProperty.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information. 2 | 3 | using System; 4 | using System.Reflection; 5 | using CSharpx; 6 | 7 | namespace CommandLine.Core 8 | { 9 | class SpecificationProperty 10 | { 11 | private readonly Specification specification; 12 | private readonly PropertyInfo property; 13 | private readonly Maybe value; 14 | 15 | private SpecificationProperty(Specification specification, PropertyInfo property, Maybe value) 16 | { 17 | this.property = property; 18 | this.specification = specification; 19 | this.value = value; 20 | } 21 | 22 | public static SpecificationProperty Create(Specification specification, PropertyInfo property, Maybe value) 23 | { 24 | if (value == null) throw new ArgumentNullException("value"); 25 | 26 | return new SpecificationProperty(specification, property, value); 27 | } 28 | 29 | public Specification Specification 30 | { 31 | get { return specification; } 32 | } 33 | 34 | public PropertyInfo Property 35 | { 36 | get { return property; } 37 | } 38 | 39 | public Maybe Value 40 | { 41 | get { return value; } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /CommandLine/Core/SpecificationPropertyExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information. 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using CSharpx; 7 | 8 | namespace CommandLine.Core 9 | { 10 | static class SpecificationPropertyExtensions 11 | { 12 | public static SpecificationProperty WithSpecification(this SpecificationProperty specProp, Specification newSpecification) 13 | { 14 | if (newSpecification == null) throw new ArgumentNullException("newSpecification"); 15 | 16 | return SpecificationProperty.Create(newSpecification, specProp.Property, specProp.Value); 17 | } 18 | 19 | public static SpecificationProperty WithValue(this SpecificationProperty specProp, Maybe newValue) 20 | { 21 | if (newValue == null) throw new ArgumentNullException("newValue"); 22 | 23 | return SpecificationProperty.Create(specProp.Specification, specProp.Property, newValue); 24 | } 25 | 26 | public static Type GetConversionType(this SpecificationProperty specProp) 27 | { 28 | switch (specProp.Specification.TargetType) 29 | { 30 | case TargetType.Sequence: 31 | return specProp.Property.PropertyType.GetGenericArguments() 32 | .SingleOrDefault() 33 | .ToMaybe() 34 | .FromJustOrFail( 35 | new InvalidOperationException("Sequence properties should be of type IEnumerable.")); 36 | default: 37 | return specProp.Property.PropertyType; 38 | } 39 | } 40 | 41 | public static IEnumerable Validate( 42 | this IEnumerable specProps, 43 | IEnumerable, 44 | IEnumerable>> rules) 45 | { 46 | return rules.SelectMany(rule => rule(specProps)); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /CommandLine/Core/Switch.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information. 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using CSharpx; 7 | 8 | namespace CommandLine.Core 9 | { 10 | static class Switch 11 | { 12 | public static IEnumerable Partition( 13 | IEnumerable tokens, 14 | Func> typeLookup) 15 | { 16 | return from t in tokens 17 | where typeLookup(t.Text).MapValueOrDefault(info => t.IsName() && info.TargetType == TargetType.Switch, false) 18 | select t; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /CommandLine/Core/TokenPartitioner.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information. 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using CSharpx; 7 | 8 | namespace CommandLine.Core 9 | { 10 | static class TokenPartitioner 11 | { 12 | public static 13 | Tuple< 14 | IEnumerable>>, // options 15 | IEnumerable, // values 16 | IEnumerable // errors 17 | > Partition( 18 | IEnumerable tokens, 19 | Func> typeLookup) 20 | { 21 | var tokenList = tokens.Memorize(); 22 | var switches = Switch.Partition(tokenList, typeLookup).Memorize(); 23 | var scalars = Scalar.Partition(tokenList, typeLookup).Memorize(); 24 | var sequences = Sequence.Partition(tokenList, typeLookup).Memorize(); 25 | var nonOptions = tokenList 26 | .Where(t => !switches.Contains(t)) 27 | .Where(t => !scalars.Contains(t)) 28 | .Where(t => !sequences.Contains(t)).Memorize(); 29 | var values = nonOptions.Where(v => v.IsValue()).Memorize(); 30 | var errors = nonOptions.Except(values).Memorize(); 31 | 32 | return Tuple.Create( 33 | KeyValuePairHelper.ForSwitch(switches) 34 | .Concat(KeyValuePairHelper.ForScalar(scalars)) 35 | .Concat(KeyValuePairHelper.ForSequence(sequences)), 36 | values.Select(t => t.Text), 37 | errors); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /CommandLine/Core/TypeDescriptor.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information. 2 | 3 | using System; 4 | using CSharpx; 5 | 6 | namespace CommandLine.Core 7 | { 8 | struct TypeDescriptor 9 | { 10 | private readonly TargetType targetType; 11 | private readonly Maybe maxItems; 12 | private readonly Maybe nextValue; 13 | 14 | private TypeDescriptor(TargetType targetType, Maybe maxItems, Maybe nextValue = null) 15 | { 16 | this.targetType = targetType; 17 | this.maxItems = maxItems; 18 | this.nextValue = nextValue; 19 | } 20 | 21 | public TargetType TargetType 22 | { 23 | get { return targetType; } 24 | } 25 | 26 | public Maybe MaxItems 27 | { 28 | get { return maxItems; } 29 | } 30 | 31 | public Maybe NextValue 32 | { 33 | get { return this.nextValue; } 34 | } 35 | 36 | public static TypeDescriptor Create(TargetType tag, Maybe maximumItems, TypeDescriptor next = default(TypeDescriptor)) 37 | { 38 | if (maximumItems == null) throw new ArgumentNullException("maximumItems"); 39 | 40 | return new TypeDescriptor(tag, maximumItems, next.ToMaybe()); 41 | } 42 | } 43 | 44 | static class TypeDescriptorExtensions 45 | { 46 | public static TypeDescriptor WithNextValue(this TypeDescriptor descriptor, Maybe nextValue) 47 | { 48 | return TypeDescriptor.Create(descriptor.TargetType, descriptor.MaxItems, nextValue.GetValueOrDefault(default(TypeDescriptor))); 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /CommandLine/Core/TypeLookup.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information. 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using CSharpx; 7 | 8 | namespace CommandLine.Core 9 | { 10 | static class TypeLookup 11 | { 12 | public static Maybe FindTypeDescriptorAndSibling( 13 | string name, 14 | IEnumerable specifications, 15 | StringComparer comparer) 16 | { 17 | var info = 18 | specifications.SingleOrDefault(a => name.MatchName(a.ShortName, a.LongName, comparer)) 19 | .ToMaybe() 20 | .Map( 21 | first => 22 | { 23 | var descr = TypeDescriptor.Create(first.TargetType, first.Max); 24 | var next = specifications 25 | .SkipWhile(s => s.Equals(first)).Take(1) 26 | .SingleOrDefault(x => x.IsValue()).ToMaybe() 27 | .Map(second => TypeDescriptor.Create(second.TargetType, second.Max)); 28 | return descr.WithNextValue(next); 29 | }); 30 | return info; 31 | 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /CommandLine/Core/ValueSpecification.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information. 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using CSharpx; 6 | 7 | namespace CommandLine.Core 8 | { 9 | sealed class ValueSpecification : Specification 10 | { 11 | private readonly int index; 12 | private readonly string metaName; 13 | 14 | public ValueSpecification(int index, string metaName, bool required, Maybe min, Maybe max, Maybe defaultValue, 15 | string helpText, string metaValue, IEnumerable enumValues, 16 | Type conversionType, TargetType targetType) 17 | : base(SpecificationType.Value, required, min, max, defaultValue, helpText, metaValue, enumValues, conversionType, targetType) 18 | { 19 | this.index = index; 20 | this.metaName = metaName; 21 | } 22 | 23 | public static ValueSpecification FromAttribute(ValueAttribute attribute, Type conversionType, IEnumerable enumValues) 24 | { 25 | return new ValueSpecification( 26 | attribute.Index, 27 | attribute.MetaName, 28 | attribute.Required, 29 | attribute.Min == -1 ? Maybe.Nothing() : Maybe.Just(attribute.Min), 30 | attribute.Max == -1 ? Maybe.Nothing() : Maybe.Just(attribute.Max), 31 | attribute.Default.ToMaybe(), 32 | attribute.HelpText, 33 | attribute.MetaValue, 34 | enumValues, 35 | conversionType, 36 | conversionType.ToTargetType()); 37 | } 38 | 39 | public int Index 40 | { 41 | get { return index; } 42 | } 43 | 44 | public string MetaName 45 | { 46 | get { return metaName;} 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /CommandLine/Core/Verb.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information. 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | 7 | namespace CommandLine.Core 8 | { 9 | sealed class Verb 10 | { 11 | private readonly string name; 12 | private readonly string helpText; 13 | 14 | public Verb(string name, string helpText) 15 | { 16 | if (name == null) throw new ArgumentNullException("name"); 17 | if (helpText == null) throw new ArgumentNullException("helpText"); 18 | 19 | this.name = name; 20 | this.helpText = helpText; 21 | } 22 | 23 | public string Name 24 | { 25 | get { return name; } 26 | } 27 | 28 | public string HelpText 29 | { 30 | get { return helpText; } 31 | } 32 | 33 | public static Verb FromAttribute(VerbAttribute attribute) 34 | { 35 | return new Verb( 36 | attribute.Name, 37 | attribute.HelpText 38 | ); 39 | } 40 | 41 | public static IEnumerable> SelectFromTypes(IEnumerable types) 42 | { 43 | return from type in types 44 | let attrs = type.GetCustomAttributes(typeof(VerbAttribute), true) 45 | where attrs.Length == 1 46 | select Tuple.Create( 47 | FromAttribute((VerbAttribute)attrs.Single()), 48 | type); 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /CommandLine/ErrorExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information. 2 | 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using CommandLine.Core; 6 | using CommandLine.Infrastructure; 7 | 8 | namespace CommandLine 9 | { 10 | static class ErrorExtensions 11 | { 12 | public static ParserResult ToParserResult(this IEnumerable errors, T instance) 13 | { 14 | return errors.Any() 15 | ? (ParserResult)new NotParsed(instance.GetType().ToTypeInfo(), errors) 16 | : (ParserResult)new Parsed(instance); 17 | } 18 | 19 | public static IEnumerable OnlyMeaningfulOnes(this IEnumerable errors) 20 | { 21 | return errors 22 | .Where(e => !e.StopsProcessing) 23 | .Where(e => !(e.Tag == ErrorType.UnknownOptionError 24 | && ((UnknownOptionError)e).Token.EqualsOrdinalIgnoreCase("help"))); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /CommandLine/Infrastructure/EnumerableExtensions`1.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information. 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | 7 | namespace CommandLine.Infrastructure 8 | { 9 | static class EnumerableExtensions 10 | { 11 | public static int IndexOf(this IEnumerable source, Func predicate) 12 | { 13 | var index = -1; 14 | foreach (var item in source) 15 | { 16 | index++; 17 | if (predicate(item)) 18 | { 19 | break; 20 | } 21 | } 22 | return index; 23 | } 24 | 25 | public static object ToUntypedArray(this IEnumerable value, Type type) 26 | { 27 | var array = Array.CreateInstance(type, value.Count()); 28 | value.ToArray().CopyTo(array, 0); 29 | return array; 30 | } 31 | 32 | public static bool Empty(this IEnumerable source) 33 | { 34 | return !source.Any(); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /CommandLine/Infrastructure/ExceptionExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information. 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | 8 | namespace CommandLine.Infrastructure 9 | { 10 | static class ExceptionExtensions 11 | { 12 | public static void RethrowWhenAbsentIn(this Exception exception, IEnumerable validExceptions) 13 | { 14 | if (!validExceptions.Contains(exception.GetType())) 15 | { 16 | throw exception; 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /CommandLine/Infrastructure/FSharpOptionHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using CommandLine.Core; 3 | //using Microsoft.FSharp.Core; 4 | 5 | //namespace CommandLine.Infrastructure 6 | //{ 7 | // static class FSharpOptionHelper 8 | // { 9 | // public static Type GetUnderlyingType(Type type) 10 | // { 11 | // return type 12 | // .GetGenericArguments()[0]; 13 | // } 14 | 15 | // public static object Some(Type type, object value) 16 | // { 17 | // return typeof(FSharpOption<>) 18 | // .MakeGenericType(type) 19 | // .StaticMethod( 20 | // "Some", value); 21 | // } 22 | 23 | // public static object None(Type type) 24 | // { 25 | // return typeof(FSharpOption<>) 26 | // .MakeGenericType(type) 27 | // .StaticProperty( 28 | // "None"); 29 | // } 30 | 31 | // public static object ValueOf(object value) 32 | // { 33 | // return typeof(FSharpOption<>) 34 | // .MakeGenericType(GetUnderlyingType(value.GetType())) 35 | // .InstanceProperty( 36 | // "Value", value); 37 | // } 38 | 39 | // public static bool IsSome(object value) 40 | // { 41 | // return (bool)typeof(FSharpOption<>) 42 | // .MakeGenericType(GetUnderlyingType(value.GetType())) 43 | // .StaticMethod( 44 | // "get_IsSome", value); 45 | // } 46 | // } 47 | //} 48 | -------------------------------------------------------------------------------- /CommandLine/Infrastructure/PopsicleSetter.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information. 2 | 3 | using System; 4 | 5 | namespace CommandLine.Infrastructure 6 | { 7 | static class PopsicleSetter 8 | { 9 | public static void Set(bool consumed, ref T field, T value) 10 | { 11 | if (consumed) 12 | { 13 | throw new InvalidOperationException(); 14 | } 15 | 16 | field = value; 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /CommandLine/Infrastructure/ReflectionHelper.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information. 2 | 3 | using System; 4 | using System.Linq; 5 | using System.Reflection; 6 | using CommandLine.Core; 7 | using CSharpx; 8 | 9 | namespace CommandLine.Infrastructure 10 | { 11 | static class ReflectionHelper 12 | { 13 | public static Maybe GetAttribute() 14 | where TAttribute : Attribute 15 | { 16 | var assembly = Assembly.GetEntryAssembly() ?? Assembly.GetExecutingAssembly(); 17 | var attributes = assembly.GetCustomAttributes(typeof(TAttribute), false); 18 | 19 | return attributes.Length > 0 20 | ? Maybe.Just((TAttribute)attributes[0]) 21 | : Maybe.Nothing(); 22 | } 23 | 24 | public static string GetAssemblyName() 25 | { 26 | var assembly = Assembly.GetEntryAssembly() ?? Assembly.GetExecutingAssembly(); 27 | return assembly.GetName().Name; 28 | } 29 | 30 | public static string GetAssemblyVersion() 31 | { 32 | var assembly = Assembly.GetEntryAssembly() ?? Assembly.GetExecutingAssembly(); 33 | return assembly.GetName().Version.ToStringInvariant(); 34 | } 35 | 36 | public static bool IsFSharpOptionType(Type type) 37 | { 38 | return type.FullName.StartsWith( 39 | "Microsoft.FSharp.Core.FSharpOption`1", StringComparison.Ordinal); 40 | } 41 | 42 | public static T CreateDefaultImmutableInstance(Type[] constructorTypes) 43 | { 44 | var t = typeof(T); 45 | var ctor = t.GetConstructor(constructorTypes); 46 | var values = (from prms in ctor.GetParameters() 47 | select prms.ParameterType.CreateDefaultForImmutable()).ToArray(); 48 | return (T)ctor.Invoke(values); 49 | } 50 | 51 | public static object CreateDefaultImmutableInstance(Type type, Type[] constructorTypes) 52 | { 53 | var ctor = type.GetConstructor(constructorTypes); 54 | var values = (from prms in ctor.GetParameters() 55 | select prms.ParameterType.CreateDefaultForImmutable()).ToArray(); 56 | return ctor.Invoke(values); 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /CommandLine/Infrastructure/ResultExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information. 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | 8 | using CSharpx; 9 | 10 | using RailwaySharp.ErrorHandling; 11 | 12 | namespace CommandLine.Infrastructure 13 | { 14 | static class ResultExtensions 15 | { 16 | public static IEnumerable SuccessfulMessages(this Result result) 17 | { 18 | if (result.Tag == ResultType.Ok) 19 | { 20 | var ok = (Ok)result; 21 | return ok.Messages; 22 | } 23 | return Enumerable.Empty(); 24 | } 25 | 26 | public static Maybe ToMaybe(this Result result) 27 | { 28 | if (result.Tag == ResultType.Ok) 29 | { 30 | var ok = (Ok)result; 31 | return Maybe.Just(ok.Success); 32 | } 33 | return Maybe.Nothing(); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /CommandLine/Infrastructure/StringExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information. 2 | 3 | using System; 4 | using System.Globalization; 5 | using System.Text; 6 | 7 | namespace CommandLine.Infrastructure 8 | { 9 | static class StringExtensions 10 | { 11 | public static string ToOneCharString(this char c) 12 | { 13 | return new string(c, 1); 14 | } 15 | 16 | public static string ToStringInvariant(this T value) 17 | { 18 | return Convert.ToString(value, CultureInfo.InvariantCulture); 19 | } 20 | 21 | public static string ToStringLocal(this T value) 22 | { 23 | return Convert.ToString(value, CultureInfo.CurrentCulture); 24 | } 25 | 26 | public static string FormatInvariant(this string value, params object[] arguments) 27 | { 28 | return string.Format(CultureInfo.InvariantCulture, value, arguments); 29 | } 30 | 31 | public static string FormatLocal(this string value, params object[] arguments) 32 | { 33 | return string.Format(CultureInfo.CurrentCulture, value, arguments); 34 | } 35 | 36 | public static string Spaces(this int value) 37 | { 38 | return new string(' ', value); 39 | } 40 | 41 | public static bool EqualsOrdinal(this string strA, string strB) 42 | { 43 | return string.CompareOrdinal(strA, strB) == 0; 44 | } 45 | 46 | public static bool EqualsOrdinalIgnoreCase(this string strA, string strB) 47 | { 48 | return string.Compare(strA, strB, StringComparison.OrdinalIgnoreCase) == 0; 49 | } 50 | 51 | public static int SafeLength(this string value) 52 | { 53 | return value == null ? 0 : value.Length; 54 | } 55 | 56 | public static string JoinTo(this string value, params string[] others) 57 | { 58 | var builder = new StringBuilder(value); 59 | foreach (var v in others) 60 | { 61 | builder.Append(v); 62 | } 63 | return builder.ToString(); 64 | } 65 | 66 | public static bool IsBooleanString(this string value) 67 | { 68 | return value.Equals("true", StringComparison.OrdinalIgnoreCase) 69 | || value.Equals("false", StringComparison.OrdinalIgnoreCase); 70 | } 71 | 72 | public static bool ToBoolean(this string value) 73 | { 74 | return value.Equals("true", StringComparison.OrdinalIgnoreCase); 75 | } 76 | } 77 | } -------------------------------------------------------------------------------- /CommandLine/NullInstance.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information. 2 | 3 | namespace CommandLine 4 | { 5 | /// 6 | /// Models a null result when constructing a in a faling verbs scenario. 7 | /// 8 | public sealed class NullInstance 9 | { 10 | internal NullInstance() { } 11 | } 12 | } -------------------------------------------------------------------------------- /CommandLine/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information. 2 | 3 | using System; 4 | using System.Reflection; 5 | using System.Runtime.CompilerServices; 6 | using System.Runtime.InteropServices; 7 | 8 | [assembly: AssemblyTitle("CommandLine.dll")] 9 | [assembly: AssemblyDescription("Command Line Parser Library allows CLR applications to define a syntax for parsing command line arguments.")] 10 | [assembly: AssemblyCulture("")] 11 | [assembly: InternalsVisibleTo("CommandLine.Tests, PublicKey=" + 12 | "002400000480000094000000060200000024000052534131000400000100010015eb7571d696c0" + 13 | "75627830f9468969103bc35764467bdbccfc0850f2fbe6913ee233d5d7cf3bbcb870fd42e6a8cc" + 14 | "846d706b5cef35389e5b90051991ee8b6ed73ee1e19f108e409be69af6219b2e31862405f4b8ba" + 15 | "101662fbbb54ba92a35d97664fe65c90c2bebd07aef530b01b709be5ed01b7e4d67a6b01c8643e" + 16 | "42a20fb4")] 17 | [assembly: InternalsVisibleTo("CommandLine.FSharp, PublicKey=" + 18 | "002400000480000094000000060200000024000052534131000400000100010015eb7571d696c0" + 19 | "75627830f9468969103bc35764467bdbccfc0850f2fbe6913ee233d5d7cf3bbcb870fd42e6a8cc" + 20 | "846d706b5cef35389e5b90051991ee8b6ed73ee1e19f108e409be69af6219b2e31862405f4b8ba" + 21 | "101662fbbb54ba92a35d97664fe65c90c2bebd07aef530b01b709be5ed01b7e4d67a6b01c8643e" + 22 | "42a20fb4")] 23 | #if DEBUG 24 | [assembly: AssemblyConfiguration("Debug")] 25 | #else 26 | [assembly: AssemblyConfiguration("Release")] 27 | #endif 28 | [assembly: ComVisible(false)] 29 | [assembly: CLSCompliant(true)] -------------------------------------------------------------------------------- /CommandLine/Text/UsageAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information. 2 | 3 | using System; 4 | 5 | namespace CommandLine.Text 6 | { 7 | /// 8 | /// Applied to a static property that yields a sequence of , 9 | /// provides data to render usage section of help screen. 10 | /// 11 | [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)] 12 | public sealed class UsageAttribute : Attribute 13 | { 14 | /// 15 | /// Application name, script or any means that starts current program. 16 | /// 17 | public string ApplicationAlias { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /CommandLine/ValueAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information. 2 | 3 | using System; 4 | 5 | namespace CommandLine 6 | { 7 | /// 8 | /// Models an value specification, or better how to handle values not bound to options. 9 | /// 10 | [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)] 11 | public sealed class ValueAttribute : BaseAttribute 12 | { 13 | private readonly int index; 14 | private string metaName; 15 | 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | public ValueAttribute(int index) : base() 20 | { 21 | this.index = index; 22 | this.metaName = string.Empty; 23 | } 24 | 25 | /// 26 | /// Gets the position this option has on the command line. 27 | /// 28 | public int Index 29 | { 30 | get { return index; } 31 | } 32 | 33 | /// 34 | /// Gets or sets name of this positional value specification. 35 | /// 36 | public string MetaName 37 | { 38 | get { return metaName; } 39 | set 40 | { 41 | if (value == null) throw new ArgumentNullException("value"); 42 | 43 | metaName = value; 44 | } 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /CommandLine/VerbAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information. 2 | 3 | using System; 4 | 5 | namespace CommandLine 6 | { 7 | /// 8 | /// Models a verb command specification. 9 | /// 10 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = true)] 11 | public sealed class VerbAttribute : Attribute 12 | { 13 | private readonly string name; 14 | private string helpText; 15 | 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The long name of the verb command. 20 | /// Thrown if is null, empty or whitespace. 21 | public VerbAttribute(string name) 22 | { 23 | if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("name"); 24 | 25 | this.name = name; 26 | this.helpText = string.Empty; 27 | } 28 | 29 | /// 30 | /// Gets the verb name. 31 | /// 32 | public string Name 33 | { 34 | get { return name; } 35 | } 36 | 37 | /// 38 | /// Gets or sets a short description of this command line option. Usually a sentence summary. 39 | /// 40 | public string HelpText 41 | { 42 | get { return helpText; } 43 | set 44 | { 45 | if (value == null) 46 | { 47 | throw new ArgumentNullException("value"); 48 | } 49 | 50 | helpText = value; 51 | } 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /CommandLine/paket.references: -------------------------------------------------------------------------------- 1 | FSharp.Core 2 | File:Maybe.cs Infrastructure 3 | File:EnumerableExtensions.cs Infrastructure 4 | File:ErrorHandling.cs Infrastructure 5 | -------------------------------------------------------------------------------- /Readme.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Good-Samaritan/signature-demo-net/81ec74c924c6a61254f04835db4ccb804fa77f0c/Readme.docx -------------------------------------------------------------------------------- /Xades-master/.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | obj 3 | -------------------------------------------------------------------------------- /Xades-master/Documents/Guide du Kit de démarrage Signature avancée XAdES.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Good-Samaritan/signature-demo-net/81ec74c924c6a61254f04835db4ccb804fa77f0c/Xades-master/Documents/Guide du Kit de démarrage Signature avancée XAdES.docx -------------------------------------------------------------------------------- /Xades-master/Documents/Installation du Kit de démarrage Signature avancée XAdES.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Good-Samaritan/signature-demo-net/81ec74c924c6a61254f04835db4ccb804fa77f0c/Xades-master/Documents/Installation du Kit de démarrage Signature avancée XAdES.docx -------------------------------------------------------------------------------- /Xades-master/Documents/Microsoft.Xades.chm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Good-Samaritan/signature-demo-net/81ec74c924c6a61254f04835db4ccb804fa77f0c/Xades-master/Documents/Microsoft.Xades.chm -------------------------------------------------------------------------------- /Xades-master/LISEZMOI.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Good-Samaritan/signature-demo-net/81ec74c924c6a61254f04835db4ccb804fa77f0c/Xades-master/LISEZMOI.txt -------------------------------------------------------------------------------- /Xades-master/Source/Library/AllDataObjectsTimeStampCollection.cs: -------------------------------------------------------------------------------- 1 | // AllDataObjectsTimeStampCollection.cs 2 | // 3 | // XAdES Starter Kit for Microsoft .NET 3.5 (and above) 4 | // 2010 Microsoft France 5 | // Published under the CECILL-B Free Software license agreement. 6 | // (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt) 7 | // 8 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 9 | // WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 10 | // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 11 | // THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE 12 | // AND INFORMATION REMAINS WITH THE USER. 13 | // 14 | 15 | using System; 16 | using System.Collections; 17 | 18 | namespace Microsoft.Xades 19 | { 20 | /// 21 | /// Collection class that derives from ArrayList. It provides the minimally 22 | /// required functionality to add instances of typed classes and obtain typed 23 | /// elements through a custom indexer. 24 | /// 25 | public class AllDataObjectsTimeStampCollection : ArrayList 26 | { 27 | /// 28 | /// New typed indexer for the collection 29 | /// 30 | /// Index of the object to retrieve from collection 31 | public new TimeStamp this[int index] 32 | { 33 | get 34 | { 35 | return (TimeStamp)base[index]; 36 | } 37 | set 38 | { 39 | base[index] = value; 40 | } 41 | } 42 | 43 | /// 44 | /// Add typed object to the collection 45 | /// 46 | /// Typed object to be added to collection 47 | /// The object that has been added to collection 48 | public TimeStamp Add(TimeStamp objectToAdd) 49 | { 50 | base.Add(objectToAdd); 51 | 52 | return objectToAdd; 53 | } 54 | 55 | /// 56 | /// Add new typed object to the collection 57 | /// 58 | /// The newly created object that has been added to collection 59 | public TimeStamp Add() 60 | { 61 | return this.Add(new TimeStamp("AllDataObjectsTimeStamp")); 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /Xades-master/Source/Library/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // AssemblyInfo.cs 2 | // 3 | // XAdES Starter Kit for Microsoft .NET 3.5 (and above) 4 | // 2010 Microsoft France 5 | // Published under the CECILL-B Free Software license agreement. 6 | // (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt) 7 | // 8 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 9 | // WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 10 | // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 11 | // THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE 12 | // AND INFORMATION REMAINS WITH THE USER. 13 | // 14 | 15 | using System.Reflection; 16 | using System.Runtime.CompilerServices; 17 | 18 | // General Information about an assembly is controlled through the following 19 | // set of attributes. Change these attribute values to modify the information 20 | // associated with an assembly. 21 | [assembly: AssemblyTitle("XAdES Library")] 22 | [assembly: AssemblyDescription("XAdES Library")] 23 | [assembly: AssemblyConfiguration("")] 24 | [assembly: AssemblyCompany("Microsoft France")] 25 | [assembly: AssemblyProduct("XAdES Starter Kit")] 26 | [assembly: AssemblyCopyright("2010")] 27 | [assembly: AssemblyTrademark("")] 28 | [assembly: AssemblyCulture("")] 29 | 30 | // Version information for an assembly consists of the following four values: 31 | // Major Version 32 | // Minor Version 33 | // Build Number 34 | // Revision 35 | // You can specify all the values or you can default the Revision and Build Numbers 36 | // by using the '*' as shown below: 37 | 38 | [assembly: AssemblyVersion("1.0.0.0")] 39 | 40 | // In order to sign your assembly you must specify a key to use. Refer to the 41 | // Microsoft .NET Framework documentation for more information on assembly signing. 42 | 43 | [assembly: AssemblyDelaySign(false)] 44 | [assembly: AssemblyKeyName("")] 45 | -------------------------------------------------------------------------------- /Xades-master/Source/Library/CRLRefCollection.cs: -------------------------------------------------------------------------------- 1 | // CRLRefCollection.cs 2 | // 3 | // XAdES Starter Kit for Microsoft .NET 3.5 (and above) 4 | // 2010 Microsoft France 5 | // Published under the CECILL-B Free Software license agreement. 6 | // (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt) 7 | // 8 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 9 | // WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 10 | // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 11 | // THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE 12 | // AND INFORMATION REMAINS WITH THE USER. 13 | // 14 | 15 | using System; 16 | using System.Collections; 17 | 18 | namespace Microsoft.Xades 19 | { 20 | /// 21 | /// Collection class that derives from ArrayList. It provides the minimally 22 | /// required functionality to add instances of typed classes and obtain typed 23 | /// elements through a custom indexer. 24 | /// 25 | public class CRLRefCollection : ArrayList 26 | { 27 | /// 28 | /// New typed indexer for the collection 29 | /// 30 | /// Index of the object to retrieve from collection 31 | public new CRLRef this[int index] 32 | { 33 | get 34 | { 35 | return (CRLRef)base[index]; 36 | } 37 | set 38 | { 39 | base[index] = value; 40 | } 41 | } 42 | 43 | /// 44 | /// Add typed object to the collection 45 | /// 46 | /// Typed object to be added to collection 47 | /// The object that has been added to collection 48 | public CRLRef Add(CRLRef objectToAdd) 49 | { 50 | base.Add(objectToAdd); 51 | 52 | return objectToAdd; 53 | } 54 | 55 | /// 56 | /// Add new typed object to the collection 57 | /// 58 | /// The newly created object that has been added to collection 59 | public CRLRef Add() 60 | { 61 | return this.Add(new CRLRef()); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Xades-master/Source/Library/CRLValue.cs: -------------------------------------------------------------------------------- 1 | // CRLValue.cs 2 | // 3 | // XAdES Starter Kit for Microsoft .NET 3.5 (and above) 4 | // 2010 Microsoft France 5 | // Published under the CECILL-B Free Software license agreement. 6 | // (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt) 7 | // 8 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 9 | // WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 10 | // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 11 | // THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE 12 | // AND INFORMATION REMAINS WITH THE USER. 13 | // 14 | 15 | using System; 16 | using System.Xml; 17 | 18 | namespace Microsoft.Xades 19 | { 20 | /// 21 | /// This class consist of a sequence of at least one Certificate Revocation 22 | /// List. Each EncapsulatedCRLValue will contain the base64 encoding of a 23 | /// DER-encoded X509 CRL. 24 | /// 25 | public class CRLValue : EncapsulatedPKIData 26 | { 27 | #region Constructors 28 | /// 29 | /// Default constructor 30 | /// 31 | public CRLValue() 32 | { 33 | this.TagName = "EncapsulatedCRLValue"; 34 | } 35 | #endregion 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Xades-master/Source/Library/CRLValueCollection.cs: -------------------------------------------------------------------------------- 1 | // CRLValueCollection.cs 2 | // 3 | // XAdES Starter Kit for Microsoft .NET 3.5 (and above) 4 | // 2010 Microsoft France 5 | // Published under the CECILL-B Free Software license agreement. 6 | // (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt) 7 | // 8 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 9 | // WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 10 | // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 11 | // THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE 12 | // AND INFORMATION REMAINS WITH THE USER. 13 | // 14 | 15 | using System; 16 | using System.Collections; 17 | 18 | namespace Microsoft.Xades 19 | { 20 | /// 21 | /// Collection class that derives from ArrayList. It provides the minimally 22 | /// required functionality to add instances of typed classes and obtain typed 23 | /// elements through a custom indexer. 24 | /// 25 | public class CRLValueCollection : ArrayList 26 | { 27 | /// 28 | /// New typed indexer for the collection 29 | /// 30 | /// Index of the object to retrieve from collection 31 | public new CRLValue this[int index] 32 | { 33 | get 34 | { 35 | return (CRLValue)base[index]; 36 | } 37 | set 38 | { 39 | base[index] = value; 40 | } 41 | } 42 | 43 | /// 44 | /// Add typed object to the collection 45 | /// 46 | /// Typed object to be added to collection 47 | /// The object that has been added to collection 48 | public CRLValue Add(CRLValue objectToAdd) 49 | { 50 | base.Add(objectToAdd); 51 | 52 | return objectToAdd; 53 | } 54 | 55 | /// 56 | /// Add new typed object to the collection 57 | /// 58 | /// The newly created object that has been added to collection 59 | public CRLValue Add() 60 | { 61 | return this.Add(new CRLValue()); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Xades-master/Source/Library/CertCollection.cs: -------------------------------------------------------------------------------- 1 | // CertCollection.cs 2 | // 3 | // XAdES Starter Kit for Microsoft .NET 3.5 (and above) 4 | // 2010 Microsoft France 5 | // Published under the CECILL-B Free Software license agreement. 6 | // (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt) 7 | // 8 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 9 | // WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 10 | // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 11 | // THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE 12 | // AND INFORMATION REMAINS WITH THE USER. 13 | // 14 | 15 | using System; 16 | using System.Collections; 17 | 18 | namespace Microsoft.Xades 19 | { 20 | /// 21 | /// Collection class that derives from ArrayList. It provides the minimally 22 | /// required functionality to add instances of typed classes and obtain typed 23 | /// elements through a custom indexer. 24 | /// 25 | public class CertCollection : ArrayList 26 | { 27 | /// 28 | /// New typed indexer for the collection 29 | /// 30 | /// Index of the object to retrieve from collection 31 | public new Cert this[int index] 32 | { 33 | get 34 | { 35 | return (Cert)base[index]; 36 | } 37 | set 38 | { 39 | base[index] = value; 40 | } 41 | } 42 | 43 | /// 44 | /// Add typed object to the collection 45 | /// 46 | /// Typed object to be added to collection 47 | /// The object that has been added to collection 48 | public Cert Add(Cert objectToAdd) 49 | { 50 | base.Add(objectToAdd); 51 | 52 | return objectToAdd; 53 | } 54 | 55 | /// 56 | /// Add new typed object to the collection 57 | /// 58 | /// The newly created object that has been added to collection 59 | public Cert Add() 60 | { 61 | return this.Add(new Cert()); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Xades-master/Source/Library/CertifiedRole.cs: -------------------------------------------------------------------------------- 1 | // CertifiedRole.cs 2 | // 3 | // XAdES Starter Kit for Microsoft .NET 3.5 (and above) 4 | // 2010 Microsoft France 5 | // Published under the CECILL-B Free Software license agreement. 6 | // (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt) 7 | // 8 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 9 | // WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 10 | // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 11 | // THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE 12 | // AND INFORMATION REMAINS WITH THE USER. 13 | // 14 | 15 | using System; 16 | using System.Xml; 17 | 18 | namespace Microsoft.Xades 19 | { 20 | /// 21 | /// The CertifiedRoles element contains one or more wrapped attribute 22 | /// certificates for the signer 23 | /// 24 | public class CertifiedRole : EncapsulatedPKIData 25 | { 26 | #region Constructors 27 | /// 28 | /// Default constructor 29 | /// 30 | public CertifiedRole() 31 | { 32 | this.TagName = "CertifiedRole"; 33 | } 34 | #endregion 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Xades-master/Source/Library/CertifiedRoleCollection.cs: -------------------------------------------------------------------------------- 1 | // CertifiedRoleCollection.cs 2 | // 3 | // XAdES Starter Kit for Microsoft .NET 3.5 (and above) 4 | // 2010 Microsoft France 5 | // Published under the CECILL-B Free Software license agreement. 6 | // (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt) 7 | // 8 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 9 | // WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 10 | // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 11 | // THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE 12 | // AND INFORMATION REMAINS WITH THE USER. 13 | // 14 | 15 | using System; 16 | using System.Collections; 17 | 18 | namespace Microsoft.Xades 19 | { 20 | /// 21 | /// Collection class that derives from ArrayList. It provides the minimally 22 | /// required functionality to add instances of typed classes and obtain typed 23 | /// elements through a custom indexer. 24 | /// 25 | public class CertifiedRoleCollection : ArrayList 26 | { 27 | /// 28 | /// New typed indexer for the collection 29 | /// 30 | /// Index of the object to retrieve from collection 31 | public new CertifiedRole this[int index] 32 | { 33 | get 34 | { 35 | return (CertifiedRole)base[index]; 36 | } 37 | set 38 | { 39 | base[index] = value; 40 | } 41 | } 42 | 43 | /// 44 | /// Add typed object to the collection 45 | /// 46 | /// Typed object to be added to collection 47 | /// The object that has been added to collection 48 | public CertifiedRole Add(CertifiedRole objectToAdd) 49 | { 50 | base.Add(objectToAdd); 51 | 52 | return objectToAdd; 53 | } 54 | 55 | /// 56 | /// Add new typed object to the collection 57 | /// 58 | /// The newly created object that has been added to collection 59 | public CertifiedRole Add() 60 | { 61 | return this.Add(new CertifiedRole()); 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /Xades-master/Source/Library/ClaimedRoleCollection.cs: -------------------------------------------------------------------------------- 1 | // ClaimedRoleCollection.cs 2 | // 3 | // XAdES Starter Kit for Microsoft .NET 3.5 (and above) 4 | // 2010 Microsoft France 5 | // Published under the CECILL-B Free Software license agreement. 6 | // (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt) 7 | // 8 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 9 | // WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 10 | // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 11 | // THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE 12 | // AND INFORMATION REMAINS WITH THE USER. 13 | // 14 | 15 | using System; 16 | using System.Collections; 17 | 18 | namespace Microsoft.Xades 19 | { 20 | /// 21 | /// Collection class that derives from ArrayList. It provides the minimally 22 | /// required functionality to add instances of typed classes and obtain typed 23 | /// elements through a custom indexer. 24 | /// 25 | public class ClaimedRoleCollection : ArrayList 26 | { 27 | /// 28 | /// New typed indexer for the collection 29 | /// 30 | /// Index of the object to retrieve from collection 31 | public new ClaimedRole this[int index] 32 | { 33 | get 34 | { 35 | return (ClaimedRole)base[index]; 36 | } 37 | set 38 | { 39 | base[index] = value; 40 | } 41 | } 42 | 43 | /// 44 | /// Add typed object to the collection 45 | /// 46 | /// Typed object to be added to collection 47 | /// The object that has been added to collection 48 | public ClaimedRole Add(ClaimedRole objectToAdd) 49 | { 50 | base.Add(objectToAdd); 51 | 52 | return objectToAdd; 53 | } 54 | 55 | /// 56 | /// Add new typed object to the collection 57 | /// 58 | /// The newly created object that has been added to collection 59 | public ClaimedRole Add() 60 | { 61 | return this.Add(new ClaimedRole()); 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /Xades-master/Source/Library/CommitmentTypeIndicationCollection.cs: -------------------------------------------------------------------------------- 1 | // ACommitmentTypeIndicationCollection.cs 2 | // 3 | // XAdES Starter Kit for Microsoft .NET 3.5 (and above) 4 | // 2010 Microsoft France 5 | // Published under the CECILL-B Free Software license agreement. 6 | // (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt) 7 | // 8 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 9 | // WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 10 | // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 11 | // THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE 12 | // AND INFORMATION REMAINS WITH THE USER. 13 | // 14 | 15 | using System; 16 | using System.Collections; 17 | 18 | namespace Microsoft.Xades 19 | { 20 | /// 21 | /// Collection class that derives from ArrayList. It provides the minimally 22 | /// required functionality to add instances of typed classes and obtain typed 23 | /// elements through a custom indexer. 24 | /// 25 | public class CommitmentTypeIndicationCollection : ArrayList 26 | { 27 | /// 28 | /// New typed indexer for the collection 29 | /// 30 | /// Index of the object to retrieve from collection 31 | public new CommitmentTypeIndication this[int index] 32 | { 33 | get 34 | { 35 | return (CommitmentTypeIndication)base[index]; 36 | } 37 | set 38 | { 39 | base[index] = value; 40 | } 41 | } 42 | 43 | /// 44 | /// Add typed object to the collection 45 | /// 46 | /// Typed object to be added to collection 47 | /// The object that has been added to collection 48 | public CommitmentTypeIndication Add(CommitmentTypeIndication objectToAdd) 49 | { 50 | base.Add(objectToAdd); 51 | 52 | return objectToAdd; 53 | } 54 | 55 | /// 56 | /// Add new typed object to the collection 57 | /// 58 | /// The newly created object that has been added to collection 59 | public CommitmentTypeIndication Add() 60 | { 61 | return this.Add(new CommitmentTypeIndication()); 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /Xades-master/Source/Library/CommitmentTypeQualifierCollection.cs: -------------------------------------------------------------------------------- 1 | // CommitmentTypeQualifierCollection.cs 2 | // 3 | // XAdES Starter Kit for Microsoft .NET 3.5 (and above) 4 | // 2010 Microsoft France 5 | // Published under the CECILL-B Free Software license agreement. 6 | // (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt) 7 | // 8 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 9 | // WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 10 | // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 11 | // THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE 12 | // AND INFORMATION REMAINS WITH THE USER. 13 | // 14 | 15 | using System; 16 | using System.Collections; 17 | 18 | namespace Microsoft.Xades 19 | { 20 | /// 21 | /// Collection class that derives from ArrayList. It provides the minimally 22 | /// required functionality to add instances of typed classes and obtain typed 23 | /// elements through a custom indexer. 24 | /// 25 | public class CommitmentTypeQualifierCollection : ArrayList 26 | { 27 | /// 28 | /// New typed indexer for the collection 29 | /// 30 | /// Index of the object to retrieve from collection 31 | public new CommitmentTypeQualifier this[int index] 32 | { 33 | get 34 | { 35 | return (CommitmentTypeQualifier)base[index]; 36 | } 37 | set 38 | { 39 | base[index] = value; 40 | } 41 | } 42 | 43 | /// 44 | /// Add typed object to the collection 45 | /// 46 | /// Typed object to be added to collection 47 | /// The object that has been added to collection 48 | public CommitmentTypeQualifier Add(CommitmentTypeQualifier objectToAdd) 49 | { 50 | base.Add(objectToAdd); 51 | 52 | return objectToAdd; 53 | } 54 | 55 | /// 56 | /// Add new typed object to the collection 57 | /// 58 | /// The newly created object that has been added to collection 59 | public CommitmentTypeQualifier Add() 60 | { 61 | return this.Add(new CommitmentTypeQualifier()); 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /Xades-master/Source/Library/CounterSignatureCollection.cs: -------------------------------------------------------------------------------- 1 | // CounterSignatureCollection.cs 2 | // 3 | // XAdES Starter Kit for Microsoft .NET 3.5 (and above) 4 | // 2010 Microsoft France 5 | // Published under the CECILL-B Free Software license agreement. 6 | // (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt) 7 | // 8 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 9 | // WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 10 | // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 11 | // THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE 12 | // AND INFORMATION REMAINS WITH THE USER. 13 | // 14 | 15 | using System; 16 | using System.Collections; 17 | using System.Security.Cryptography.Xml; 18 | 19 | namespace Microsoft.Xades 20 | { 21 | /// 22 | /// Collection class that derives from ArrayList. It provides the minimally 23 | /// required functionality to add instances of typed classes and obtain typed 24 | /// elements through a custom indexer. 25 | /// 26 | public class CounterSignatureCollection : ArrayList 27 | { 28 | /// 29 | /// New typed indexer for the collection 30 | /// 31 | /// Index of the object to retrieve from collection 32 | public new XadesSignedXml this[int index] 33 | { 34 | get 35 | { 36 | return (XadesSignedXml)base[index]; 37 | } 38 | set 39 | { 40 | base[index] = value; 41 | } 42 | } 43 | 44 | /// 45 | /// Add typed object to the collection 46 | /// 47 | /// Typed object to be added to collection 48 | /// The object that has been added to collection 49 | public XadesSignedXml Add(XadesSignedXml objectToAdd) 50 | { 51 | base.Add(objectToAdd); 52 | 53 | return objectToAdd; 54 | } 55 | 56 | /// 57 | /// Add new typed object to the collection 58 | /// 59 | /// The newly created object that has been added to collection 60 | public XadesSignedXml Add() 61 | { 62 | return this.Add(new XadesSignedXml()); 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /Xades-master/Source/Library/DataObjectFormatCollection.cs: -------------------------------------------------------------------------------- 1 | // DataObjectFormatCollection.cs 2 | // 3 | // XAdES Starter Kit for Microsoft .NET 3.5 (and above) 4 | // 2010 Microsoft France 5 | // Published under the CECILL-B Free Software license agreement. 6 | // (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt) 7 | // 8 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 9 | // WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 10 | // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 11 | // THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE 12 | // AND INFORMATION REMAINS WITH THE USER. 13 | // 14 | 15 | using System; 16 | using System.Collections; 17 | 18 | namespace Microsoft.Xades 19 | { 20 | /// 21 | /// Collection class that derives from ArrayList. It provides the minimally 22 | /// required functionality to add instances of typed classes and obtain typed 23 | /// elements through a custom indexer. 24 | /// 25 | public class DataObjectFormatCollection : ArrayList 26 | { 27 | /// 28 | /// New typed indexer for the collection 29 | /// 30 | /// Index of the object to retrieve from collection 31 | public new DataObjectFormat this[int index] 32 | { 33 | get 34 | { 35 | return (DataObjectFormat)base[index]; 36 | } 37 | set 38 | { 39 | base[index] = value; 40 | } 41 | } 42 | 43 | /// 44 | /// Add typed object to the collection 45 | /// 46 | /// Typed object to be added to collection 47 | /// The object that has been added to collection 48 | public DataObjectFormat Add(DataObjectFormat objectToAdd) 49 | { 50 | base.Add(objectToAdd); 51 | 52 | return objectToAdd; 53 | } 54 | 55 | /// 56 | /// Add new typed object to the collection 57 | /// 58 | /// The newly created object that has been added to collection 59 | public DataObjectFormat Add() 60 | { 61 | return this.Add(new DataObjectFormat()); 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /Xades-master/Source/Library/DocumentationReferenceCollection.cs: -------------------------------------------------------------------------------- 1 | // DocumentationReferenceCollection.cs 2 | // 3 | // XAdES Starter Kit for Microsoft .NET 3.5 (and above) 4 | // 2010 Microsoft France 5 | // Published under the CECILL-B Free Software license agreement. 6 | // (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt) 7 | // 8 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 9 | // WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 10 | // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 11 | // THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE 12 | // AND INFORMATION REMAINS WITH THE USER. 13 | // 14 | 15 | using System; 16 | using System.Collections; 17 | 18 | namespace Microsoft.Xades 19 | { 20 | /// 21 | /// Collection class that derives from ArrayList. It provides the minimally 22 | /// required functionality to add instances of typed classes and obtain typed 23 | /// elements through a custom indexer. 24 | /// 25 | public class DocumentationReferenceCollection : ArrayList 26 | { 27 | /// 28 | /// New typed indexer for the collection 29 | /// 30 | /// Index of the object to retrieve from collection 31 | public new DocumentationReference this[int index] 32 | { 33 | get 34 | { 35 | return (DocumentationReference)base[index]; 36 | } 37 | set 38 | { 39 | base[index] = value; 40 | } 41 | } 42 | 43 | /// 44 | /// Add typed object to the collection 45 | /// 46 | /// Typed object to be added to collection 47 | /// The object that has been added to collection 48 | public DocumentationReference Add(DocumentationReference objectToAdd) 49 | { 50 | base.Add(objectToAdd); 51 | 52 | return objectToAdd; 53 | } 54 | 55 | /// 56 | /// Add new typed object to the collection 57 | /// 58 | /// The newly created object that has been added to collection 59 | public DocumentationReference Add() 60 | { 61 | return this.Add(new DocumentationReference()); 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /Xades-master/Source/Library/EncapsulatedX509Certificate.cs: -------------------------------------------------------------------------------- 1 | // EncapsulatedX509Certificate.cs 2 | // 3 | // XAdES Starter Kit for Microsoft .NET 3.5 (and above) 4 | // 2010 Microsoft France 5 | // Published under the CECILL-B Free Software license agreement. 6 | // (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt) 7 | // 8 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 9 | // WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 10 | // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 11 | // THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE 12 | // AND INFORMATION REMAINS WITH THE USER. 13 | // 14 | 15 | using System; 16 | using System.Xml; 17 | 18 | namespace Microsoft.Xades 19 | { 20 | /// 21 | /// The EncapsulatedX509Certificate element is able to contain the 22 | /// base64 encoding of a DER-encoded X.509 certificate 23 | /// 24 | public class EncapsulatedX509Certificate : EncapsulatedPKIData 25 | { 26 | #region Constructors 27 | /// 28 | /// Default constructor 29 | /// 30 | public EncapsulatedX509Certificate() 31 | { 32 | this.TagName = "EncapsulatedX509Certificate"; 33 | } 34 | #endregion 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Xades-master/Source/Library/EncapsulatedX509CertificateCollection.cs: -------------------------------------------------------------------------------- 1 | // EncapsulatedX509CertificateCollection.cs 2 | // 3 | // XAdES Starter Kit for Microsoft .NET 3.5 (and above) 4 | // 2010 Microsoft France 5 | // Published under the CECILL-B Free Software license agreement. 6 | // (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt) 7 | // 8 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 9 | // WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 10 | // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 11 | // THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE 12 | // AND INFORMATION REMAINS WITH THE USER. 13 | // 14 | 15 | using System; 16 | using System.Collections; 17 | 18 | namespace Microsoft.Xades 19 | { 20 | /// 21 | /// Collection class that derives from ArrayList. It provides the minimally 22 | /// required functionality to add instances of typed classes and obtain typed 23 | /// elements through a custom indexer. 24 | /// 25 | public class EncapsulatedX509CertificateCollection : ArrayList 26 | { 27 | /// 28 | /// New typed indexer for the collection 29 | /// 30 | /// Index of the object to retrieve from collection 31 | public new EncapsulatedX509Certificate this[int index] 32 | { 33 | get 34 | { 35 | return (EncapsulatedX509Certificate)base[index]; 36 | } 37 | set 38 | { 39 | base[index] = value; 40 | } 41 | } 42 | 43 | /// 44 | /// Add typed object to the collection 45 | /// 46 | /// Typed object to be added to collection 47 | /// The object that has been added to collection 48 | public EncapsulatedX509Certificate Add(EncapsulatedX509Certificate objectToAdd) 49 | { 50 | base.Add(objectToAdd); 51 | 52 | return objectToAdd; 53 | } 54 | 55 | /// 56 | /// Add new typed object to the collection 57 | /// 58 | /// The newly created object that has been added to collection 59 | public EncapsulatedX509Certificate Add() 60 | { 61 | return this.Add(new EncapsulatedX509Certificate()); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Xades-master/Source/Library/HashDataInfoCollection.cs: -------------------------------------------------------------------------------- 1 | // HashDataInfoCollection.cs 2 | // 3 | // XAdES Starter Kit for Microsoft .NET 3.5 (and above) 4 | // 2010 Microsoft France 5 | // Published under the CECILL-B Free Software license agreement. 6 | // (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt) 7 | // 8 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 9 | // WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 10 | // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 11 | // THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE 12 | // AND INFORMATION REMAINS WITH THE USER. 13 | // 14 | 15 | using System; 16 | using System.Collections; 17 | 18 | namespace Microsoft.Xades 19 | { 20 | /// 21 | /// Collection class that derives from ArrayList. It provides the minimally 22 | /// required functionality to add instances of typed classes and obtain typed 23 | /// elements through a custom indexer. 24 | /// 25 | public class HashDataInfoCollection : ArrayList 26 | { 27 | /// 28 | /// New typed indexer for the collection 29 | /// 30 | /// Index of the object to retrieve from collection 31 | public new HashDataInfo this[int index] 32 | { 33 | get 34 | { 35 | return (HashDataInfo)base[index]; 36 | } 37 | set 38 | { 39 | base[index] = value; 40 | } 41 | } 42 | 43 | /// 44 | /// Add typed object to the collection 45 | /// 46 | /// Typed object to be added to collection 47 | /// The object that has been added to collection 48 | public HashDataInfo Add(HashDataInfo objectToAdd) 49 | { 50 | base.Add(objectToAdd); 51 | 52 | return objectToAdd; 53 | } 54 | 55 | /// 56 | /// Add new typed object to the collection 57 | /// 58 | /// The newly created object that has been added to collection 59 | public HashDataInfo Add() 60 | { 61 | return this.Add(new HashDataInfo()); 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /Xades-master/Source/Library/IndividualDataObjectsTimeStampCollection.cs: -------------------------------------------------------------------------------- 1 | // individualDataObjectsTimeStampCollection.cs 2 | // 3 | // XAdES Starter Kit for Microsoft .NET 3.5 (and above) 4 | // 2010 Microsoft France 5 | // Published under the CECILL-B Free Software license agreement. 6 | // (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt) 7 | // 8 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 9 | // WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 10 | // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 11 | // THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE 12 | // AND INFORMATION REMAINS WITH THE USER. 13 | // 14 | 15 | using System; 16 | using System.Collections; 17 | 18 | namespace Microsoft.Xades 19 | { 20 | /// 21 | /// Collection class that derives from ArrayList. It provides the minimally 22 | /// required functionality to add instances of typed classes and obtain typed 23 | /// elements through a custom indexer. 24 | /// 25 | public class IndividualDataObjectsTimeStampCollection : ArrayList 26 | { 27 | /// 28 | /// New typed indexer for the collection 29 | /// 30 | /// Index of the object to retrieve from collection 31 | public new TimeStamp this[int index] 32 | { 33 | get 34 | { 35 | return (TimeStamp)base[index]; 36 | } 37 | set 38 | { 39 | base[index] = value; 40 | } 41 | } 42 | 43 | /// 44 | /// Add typed object to the collection 45 | /// 46 | /// Typed object to be added to collection 47 | /// The object that has been added to collection 48 | public TimeStamp Add(TimeStamp objectToAdd) 49 | { 50 | base.Add(objectToAdd); 51 | 52 | return objectToAdd; 53 | } 54 | 55 | /// 56 | /// Add new typed object to the collection 57 | /// 58 | /// Name of the tag when serializing into XML using GetXml() 59 | /// The newly created object that has been added to collection 60 | public TimeStamp Add(string tagName) 61 | { 62 | return this.Add(new TimeStamp(tagName)); 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /Xades-master/Source/Library/Microsoft.Xades.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Good-Samaritan/signature-demo-net/81ec74c924c6a61254f04835db4ccb804fa77f0c/Xades-master/Source/Library/Microsoft.Xades.snk -------------------------------------------------------------------------------- /Xades-master/Source/Library/NoticeNumberCollection.cs: -------------------------------------------------------------------------------- 1 | // NoticeNumberCollection.cs 2 | // 3 | // XAdES Starter Kit for Microsoft .NET 3.5 (and above) 4 | // 2010 Microsoft France 5 | // Published under the CECILL-B Free Software license agreement. 6 | // (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt) 7 | // 8 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 9 | // WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 10 | // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 11 | // THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE 12 | // AND INFORMATION REMAINS WITH THE USER. 13 | // 14 | 15 | using System; 16 | using System.Collections; 17 | using System.Security.Cryptography.Xml; 18 | 19 | namespace Microsoft.Xades 20 | { 21 | /// 22 | /// Collection class that derives from ArrayList. It provides the minimally 23 | /// required functionality to add instances of typed classes and obtain typed 24 | /// elements through a custom indexer. 25 | /// 26 | public class NoticeNumberCollection : ArrayList 27 | { 28 | /// 29 | /// New typed indexer for the collection 30 | /// 31 | /// Index of the object to retrieve from collection 32 | public new int this[int index] 33 | { 34 | get 35 | { 36 | return (int)base[index]; 37 | } 38 | set 39 | { 40 | base[index] = value; 41 | } 42 | } 43 | 44 | /// 45 | /// Add typed object to the collection 46 | /// 47 | /// Typed object to be added to collection 48 | /// The object that has been added to collection 49 | public int Add(int objectToAdd) 50 | { 51 | base.Add(objectToAdd); 52 | 53 | return objectToAdd; 54 | } 55 | 56 | /// 57 | /// Add new typed object to the collection 58 | /// 59 | /// The newly created object that has been added to collection 60 | public int Add() 61 | { 62 | return this.Add(new int()); 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /Xades-master/Source/Library/OCSPRefCollection.cs: -------------------------------------------------------------------------------- 1 | // OCSPRefCollection.cs 2 | // 3 | // XAdES Starter Kit for Microsoft .NET 3.5 (and above) 4 | // 2010 Microsoft France 5 | // Published under the CECILL-B Free Software license agreement. 6 | // (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt) 7 | // 8 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 9 | // WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 10 | // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 11 | // THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE 12 | // AND INFORMATION REMAINS WITH THE USER. 13 | // 14 | 15 | using System; 16 | using System.Collections; 17 | 18 | namespace Microsoft.Xades 19 | { 20 | /// 21 | /// Collection class that derives from ArrayList. It provides the minimally 22 | /// required functionality to add instances of typed classes and obtain typed 23 | /// elements through a custom indexer. 24 | /// 25 | public class OCSPRefCollection : ArrayList 26 | { 27 | /// 28 | /// New typed indexer for the collection 29 | /// 30 | /// Index of the object to retrieve from collection 31 | public new OCSPRef this[int index] 32 | { 33 | get 34 | { 35 | return (OCSPRef)base[index]; 36 | } 37 | set 38 | { 39 | base[index] = value; 40 | } 41 | } 42 | 43 | /// 44 | /// Add typed object to the collection 45 | /// 46 | /// Typed object to be added to collection 47 | /// The object that has been added to collection 48 | public OCSPRef Add(OCSPRef objectToAdd) 49 | { 50 | base.Add(objectToAdd); 51 | 52 | return objectToAdd; 53 | } 54 | 55 | /// 56 | /// Add new typed object to the collection 57 | /// 58 | /// The newly created object that has been added to collection 59 | public OCSPRef Add() 60 | { 61 | return this.Add(new OCSPRef()); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Xades-master/Source/Library/OCSPValue.cs: -------------------------------------------------------------------------------- 1 | // OCSPValue.cs 2 | // 3 | // XAdES Starter Kit for Microsoft .NET 3.5 (and above) 4 | // 2010 Microsoft France 5 | // Published under the CECILL-B Free Software license agreement. 6 | // (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt) 7 | // 8 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 9 | // WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 10 | // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 11 | // THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE 12 | // AND INFORMATION REMAINS WITH THE USER. 13 | // 14 | 15 | using System; 16 | using System.Xml; 17 | 18 | namespace Microsoft.Xades 19 | { 20 | /// 21 | /// This class consist of a sequence of at least one OCSP Response. The 22 | /// EncapsulatedOCSPValue element contains the base64 encoding of a 23 | /// DER-encoded OCSP Response 24 | /// 25 | public class OCSPValue : EncapsulatedPKIData 26 | { 27 | #region Constructors 28 | /// 29 | /// Default constructor 30 | /// 31 | public OCSPValue() 32 | { 33 | this.TagName = "EncapsulatedOCSPValue"; 34 | } 35 | #endregion 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Xades-master/Source/Library/OCSPValueCollection.cs: -------------------------------------------------------------------------------- 1 | // OCSPValueCollection.cs 2 | // 3 | // XAdES Starter Kit for Microsoft .NET 3.5 (and above) 4 | // 2010 Microsoft France 5 | // Published under the CECILL-B Free Software license agreement. 6 | // (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt) 7 | // 8 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 9 | // WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 10 | // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 11 | // THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE 12 | // AND INFORMATION REMAINS WITH THE USER. 13 | // 14 | 15 | using System; 16 | using System.Collections; 17 | 18 | namespace Microsoft.Xades 19 | { 20 | /// 21 | /// Collection class that derives from ArrayList. It provides the minimally 22 | /// required functionality to add instances of typed classes and obtain typed 23 | /// elements through a custom indexer. 24 | /// 25 | public class OCSPValueCollection : ArrayList 26 | { 27 | /// 28 | /// New typed indexer for the collection 29 | /// 30 | /// Index of the object to retrieve from collection 31 | public new OCSPValue this[int index] 32 | { 33 | get 34 | { 35 | return (OCSPValue)base[index]; 36 | } 37 | set 38 | { 39 | base[index] = value; 40 | } 41 | } 42 | 43 | /// 44 | /// Add typed object to the collection 45 | /// 46 | /// Typed object to be added to collection 47 | /// The object that has been added to collection 48 | public OCSPValue Add(OCSPValue objectToAdd) 49 | { 50 | base.Add(objectToAdd); 51 | 52 | return objectToAdd; 53 | } 54 | 55 | /// 56 | /// Add new typed object to the collection 57 | /// 58 | /// The newly created object that has been added to collection 59 | public OCSPValue Add() 60 | { 61 | return this.Add(new OCSPValue()); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Xades-master/Source/Library/ObjectReferenceCollection.cs: -------------------------------------------------------------------------------- 1 | // ObjectReferenceCollection.cs 2 | // 3 | // XAdES Starter Kit for Microsoft .NET 3.5 (and above) 4 | // 2010 Microsoft France 5 | // Published under the CECILL-B Free Software license agreement. 6 | // (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt) 7 | // 8 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 9 | // WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 10 | // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 11 | // THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE 12 | // AND INFORMATION REMAINS WITH THE USER. 13 | // 14 | 15 | using System; 16 | using System.Collections; 17 | 18 | namespace Microsoft.Xades 19 | { 20 | /// 21 | /// Collection class that derives from ArrayList. It provides the minimally 22 | /// required functionality to add instances of typed classes and obtain typed 23 | /// elements through a custom indexer. 24 | /// 25 | public class ObjectReferenceCollection : ArrayList 26 | { 27 | /// 28 | /// New typed indexer for the collection 29 | /// 30 | /// Index of the object to retrieve from collection 31 | public new ObjectReference this[int index] 32 | { 33 | get 34 | { 35 | return (ObjectReference)base[index]; 36 | } 37 | set 38 | { 39 | base[index] = value; 40 | } 41 | } 42 | 43 | /// 44 | /// Add typed object to the collection 45 | /// 46 | /// Typed object to be added to collection 47 | /// The object that has been added to collection 48 | public ObjectReference Add(ObjectReference objectToAdd) 49 | { 50 | base.Add(objectToAdd); 51 | 52 | return objectToAdd; 53 | } 54 | 55 | /// 56 | /// Add new typed object to the collection 57 | /// 58 | /// The newly created object that has been added to collection 59 | public ObjectReference Add() 60 | { 61 | return this.Add(new ObjectReference()); 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /Xades-master/Source/Library/OtherCertificateCollection.cs: -------------------------------------------------------------------------------- 1 | // OtherCertificateCollection.cs 2 | // 3 | // XAdES Starter Kit for Microsoft .NET 3.5 (and above) 4 | // 2010 Microsoft France 5 | // Published under the CECILL-B Free Software license agreement. 6 | // (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt) 7 | // 8 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 9 | // WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 10 | // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 11 | // THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE 12 | // AND INFORMATION REMAINS WITH THE USER. 13 | // 14 | 15 | using System; 16 | using System.Collections; 17 | 18 | namespace Microsoft.Xades 19 | { 20 | /// 21 | /// Collection class that derives from ArrayList. It provides the minimally 22 | /// required functionality to add instances of typed classes and obtain typed 23 | /// elements through a custom indexer. 24 | /// 25 | public class OtherCertificateCollection : ArrayList 26 | { 27 | /// 28 | /// New typed indexer for the collection 29 | /// 30 | /// Index of the object to retrieve from collection 31 | public new OtherCertificate this[int index] 32 | { 33 | get 34 | { 35 | return (OtherCertificate)base[index]; 36 | } 37 | set 38 | { 39 | base[index] = value; 40 | } 41 | } 42 | 43 | /// 44 | /// Add typed object to the collection 45 | /// 46 | /// Typed object to be added to collection 47 | /// The object that has been added to collection 48 | public OtherCertificate Add(OtherCertificate objectToAdd) 49 | { 50 | base.Add(objectToAdd); 51 | 52 | return objectToAdd; 53 | } 54 | 55 | /// 56 | /// Add new typed object to the collection 57 | /// 58 | /// The newly created object that has been added to collection 59 | public OtherCertificate Add() 60 | { 61 | return this.Add(new OtherCertificate()); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Xades-master/Source/Library/OtherRef.cs: -------------------------------------------------------------------------------- 1 | // OtherRef.cs 2 | // 3 | // XAdES Starter Kit for Microsoft .NET 3.5 (and above) 4 | // 2010 Microsoft France 5 | // Published under the CECILL-B Free Software license agreement. 6 | // (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt) 7 | // 8 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 9 | // WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 10 | // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 11 | // THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE 12 | // AND INFORMATION REMAINS WITH THE USER. 13 | // 14 | 15 | using System; 16 | using System.Xml; 17 | 18 | namespace Microsoft.Xades 19 | { 20 | /// 21 | /// Alternative forms of validation data can be included in this class 22 | /// 23 | public class OtherRef 24 | { 25 | #region Private variables 26 | private XmlElement anyXmlElement; 27 | #endregion 28 | 29 | #region Public properties 30 | /// 31 | /// The generic XML element that represents any other type of ref 32 | /// 33 | public XmlElement AnyXmlElement 34 | { 35 | get 36 | { 37 | return this.anyXmlElement; 38 | } 39 | set 40 | { 41 | this.anyXmlElement = value; 42 | } 43 | } 44 | #endregion 45 | 46 | #region Constructors 47 | /// 48 | /// Default constructor 49 | /// 50 | public OtherRef() 51 | { 52 | } 53 | #endregion 54 | 55 | #region Public methods 56 | /// 57 | /// Check to see if something has changed in this instance and needs to be serialized 58 | /// 59 | /// Flag indicating if a member needs serialization 60 | public bool HasChanged() 61 | { 62 | bool retVal = false; 63 | 64 | if (this.anyXmlElement != null) 65 | { 66 | retVal = true; 67 | } 68 | 69 | return retVal; 70 | } 71 | 72 | /// 73 | /// Load state from an XML element 74 | /// 75 | /// XML element containing new state 76 | public void LoadXml(System.Xml.XmlElement xmlElement) 77 | { 78 | this.anyXmlElement = xmlElement; 79 | } 80 | 81 | /// 82 | /// Returns the XML representation of the this object 83 | /// 84 | /// XML element containing the state of this object 85 | public XmlElement GetXml() 86 | { 87 | XmlDocument creationXmlDocument; 88 | XmlElement retVal; 89 | 90 | creationXmlDocument = new XmlDocument(); 91 | retVal = creationXmlDocument.CreateElement("xades", "OtherRef", XadesSignedXml.XadesNamespaceUri); 92 | 93 | if (this.anyXmlElement != null) 94 | { 95 | retVal.AppendChild(creationXmlDocument.ImportNode(this.anyXmlElement, true)); 96 | } 97 | 98 | return retVal; 99 | } 100 | #endregion 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /Xades-master/Source/Library/OtherRefCollection.cs: -------------------------------------------------------------------------------- 1 | // OtherRefCollection.cs 2 | // 3 | // XAdES Starter Kit for Microsoft .NET 3.5 (and above) 4 | // 2010 Microsoft France 5 | // Published under the CECILL-B Free Software license agreement. 6 | // (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt) 7 | // 8 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 9 | // WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 10 | // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 11 | // THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE 12 | // AND INFORMATION REMAINS WITH THE USER. 13 | // 14 | 15 | using System; 16 | using System.Collections; 17 | 18 | namespace Microsoft.Xades 19 | { 20 | /// 21 | /// Collection class that derives from ArrayList. It provides the minimally 22 | /// required functionality to add instances of typed classes and obtain typed 23 | /// elements through a custom indexer. 24 | /// 25 | public class OtherRefCollection : ArrayList 26 | { 27 | /// 28 | /// New typed indexer for the collection 29 | /// 30 | /// Index of the object to retrieve from collection 31 | public new OtherRef this[int index] 32 | { 33 | get 34 | { 35 | return (OtherRef)base[index]; 36 | } 37 | set 38 | { 39 | base[index] = value; 40 | } 41 | } 42 | 43 | /// 44 | /// Add typed object to the collection 45 | /// 46 | /// Typed object to be added to collection 47 | /// The object that has been added to collection 48 | public OtherRef Add(OtherRef objectToAdd) 49 | { 50 | base.Add(objectToAdd); 51 | 52 | return objectToAdd; 53 | } 54 | 55 | /// 56 | /// Add new typed object to the collection 57 | /// 58 | /// The newly created object that has been added to collection 59 | public OtherRef Add() 60 | { 61 | return this.Add(new OtherRef()); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Xades-master/Source/Library/OtherValue.cs: -------------------------------------------------------------------------------- 1 | // OtherValue.cs 2 | // 3 | // XAdES Starter Kit for Microsoft .NET 3.5 (and above) 4 | // 2010 Microsoft France 5 | // Published under the CECILL-B Free Software license agreement. 6 | // (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt) 7 | // 8 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 9 | // WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 10 | // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 11 | // THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE 12 | // AND INFORMATION REMAINS WITH THE USER. 13 | // 14 | 15 | using System; 16 | using System.Xml; 17 | 18 | namespace Microsoft.Xades 19 | { 20 | /// 21 | /// This class provides a placeholder for other revocation information 22 | /// 23 | public class OtherValue 24 | { 25 | #region Private variables 26 | private XmlElement anyXmlElement; 27 | #endregion 28 | 29 | #region Public properties 30 | /// 31 | /// The generic XML element that represents any other value 32 | /// 33 | public XmlElement AnyXmlElement 34 | { 35 | get 36 | { 37 | return this.anyXmlElement; 38 | } 39 | set 40 | { 41 | this.anyXmlElement = value; 42 | } 43 | } 44 | #endregion 45 | 46 | #region Constructors 47 | /// 48 | /// Default constructor 49 | /// 50 | public OtherValue() 51 | { 52 | } 53 | #endregion 54 | 55 | #region Public methods 56 | /// 57 | /// Check to see if something has changed in this instance and needs to be serialized 58 | /// 59 | /// Flag indicating if a member needs serialization 60 | public bool HasChanged() 61 | { 62 | bool retVal = false; 63 | 64 | if (this.anyXmlElement != null) 65 | { 66 | retVal = true; 67 | } 68 | 69 | return retVal; 70 | } 71 | 72 | /// 73 | /// Load state from an XML element 74 | /// 75 | /// XML element containing new state 76 | public void LoadXml(System.Xml.XmlElement xmlElement) 77 | { 78 | this.anyXmlElement = xmlElement; 79 | } 80 | 81 | /// 82 | /// Returns the XML representation of the this object 83 | /// 84 | /// XML element containing the state of this object 85 | public XmlElement GetXml() 86 | { 87 | XmlDocument creationXmlDocument; 88 | XmlElement retVal; 89 | 90 | creationXmlDocument = new XmlDocument(); 91 | retVal = creationXmlDocument.CreateElement("xades", "OtherValue", XadesSignedXml.XadesNamespaceUri); 92 | 93 | if (this.anyXmlElement != null) 94 | { 95 | retVal.AppendChild(creationXmlDocument.ImportNode(this.anyXmlElement, true)); 96 | } 97 | 98 | return retVal; 99 | } 100 | #endregion 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /Xades-master/Source/Library/OtherValueCollection.cs: -------------------------------------------------------------------------------- 1 | // OtherValueCollection.cs 2 | // 3 | // XAdES Starter Kit for Microsoft .NET 3.5 (and above) 4 | // 2010 Microsoft France 5 | // Published under the CECILL-B Free Software license agreement. 6 | // (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt) 7 | // 8 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 9 | // WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 10 | // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 11 | // THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE 12 | // AND INFORMATION REMAINS WITH THE USER. 13 | // 14 | 15 | using System; 16 | using System.Collections; 17 | 18 | namespace Microsoft.Xades 19 | { 20 | /// 21 | /// Collection class that derives from ArrayList. It provides the minimally 22 | /// required functionality to add instances of typed classes and obtain typed 23 | /// elements through a custom indexer. 24 | /// 25 | public class OtherValueCollection : ArrayList 26 | { 27 | /// 28 | /// New typed indexer for the collection 29 | /// 30 | /// Index of the object to retrieve from collection 31 | public new OtherValue this[int index] 32 | { 33 | get 34 | { 35 | return (OtherValue)base[index]; 36 | } 37 | set 38 | { 39 | base[index] = value; 40 | } 41 | } 42 | 43 | /// 44 | /// Add typed object to the collection 45 | /// 46 | /// Typed object to be added to collection 47 | /// The object that has been added to collection 48 | public OtherValue Add(OtherValue objectToAdd) 49 | { 50 | base.Add(objectToAdd); 51 | 52 | return objectToAdd; 53 | } 54 | 55 | /// 56 | /// Add new typed object to the collection 57 | /// 58 | /// The newly created object that has been added to collection 59 | public OtherValue Add() 60 | { 61 | return this.Add(new OtherValue()); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Xades-master/Source/Library/SigPolicyQualifierCollection.cs: -------------------------------------------------------------------------------- 1 | // SigPolicyQualifierCollection.cs 2 | // 3 | // XAdES Starter Kit for Microsoft .NET 3.5 (and above) 4 | // 2010 Microsoft France 5 | // Published under the CECILL-B Free Software license agreement. 6 | // (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt) 7 | // 8 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 9 | // WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 10 | // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 11 | // THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE 12 | // AND INFORMATION REMAINS WITH THE USER. 13 | // 14 | 15 | using System; 16 | using System.Collections; 17 | 18 | namespace Microsoft.Xades 19 | { 20 | /// 21 | /// Collection class that derives from ArrayList. It provides the minimally 22 | /// required functionality to add instances of typed classes and obtain typed 23 | /// elements through a custom indexer. 24 | /// 25 | public class SigPolicyQualifierCollection : ArrayList 26 | { 27 | /// 28 | /// New typed indexer for the collection 29 | /// 30 | /// Index of the object to retrieve from collection 31 | public new SigPolicyQualifier this[int index] 32 | { 33 | get 34 | { 35 | return (SigPolicyQualifier)base[index]; 36 | } 37 | set 38 | { 39 | base[index] = value; 40 | } 41 | } 42 | 43 | /// 44 | /// Add typed object to the collection 45 | /// 46 | /// Typed object to be added to collection 47 | /// The object that has been added to collection 48 | public SigPolicyQualifier Add(SigPolicyQualifier objectToAdd) 49 | { 50 | base.Add(objectToAdd); 51 | 52 | return objectToAdd; 53 | } 54 | 55 | /// 56 | /// Add new typed object to the collection 57 | /// 58 | /// The newly created object that has been added to collection 59 | public SigPolicyQualifier Add() 60 | { 61 | return this.Add(new SigPolicyQualifier()); 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /Xades-master/Source/Library/SignatureTimeStampCollection.cs: -------------------------------------------------------------------------------- 1 | // SignatureTimeStampCollection.cs 2 | // 3 | // XAdES Starter Kit for Microsoft .NET 3.5 (and above) 4 | // 2010 Microsoft France 5 | // Published under the CECILL-B Free Software license agreement. 6 | // (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt) 7 | // 8 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 9 | // WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 10 | // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 11 | // THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE 12 | // AND INFORMATION REMAINS WITH THE USER. 13 | // 14 | 15 | using System; 16 | using System.Collections; 17 | 18 | namespace Microsoft.Xades 19 | { 20 | /// 21 | /// Collection class that derives from ArrayList. It provides the minimally 22 | /// required functionality to add instances of typed classes and obtain typed 23 | /// elements through a custom indexer. 24 | /// 25 | public class SignatureTimeStampCollection : ArrayList 26 | { 27 | /// 28 | /// New typed indexer for the collection 29 | /// 30 | /// Index of the object to retrieve from collection 31 | public new TimeStamp this[int index] 32 | { 33 | get 34 | { 35 | return (TimeStamp)base[index]; 36 | } 37 | set 38 | { 39 | base[index] = value; 40 | } 41 | } 42 | 43 | /// 44 | /// Add typed object to the collection 45 | /// 46 | /// Typed object to be added to collection 47 | /// The object that has been added to collection 48 | public TimeStamp Add(TimeStamp objectToAdd) 49 | { 50 | base.Add(objectToAdd); 51 | 52 | return objectToAdd; 53 | } 54 | 55 | /// 56 | /// Add new typed object to the collection 57 | /// 58 | /// Name of the tag when serializing into XML using GetXml() 59 | /// The newly created object that has been added to collection 60 | public TimeStamp Add(string tagName) 61 | { 62 | return this.Add(new TimeStamp(tagName)); 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /Xades-master/Source/Library/SignedSignatureProperties.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Good-Samaritan/signature-demo-net/81ec74c924c6a61254f04835db4ccb804fa77f0c/Xades-master/Source/Library/SignedSignatureProperties.cs -------------------------------------------------------------------------------- /Xades-master/Source/Library/TransformCollection.cs: -------------------------------------------------------------------------------- 1 | // TransformCollection.cs 2 | // 3 | // XAdES Starter Kit for Microsoft .NET 3.5 (and above) 4 | // 2010 Microsoft France 5 | // Published under the CECILL-B Free Software license agreement. 6 | // (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt) 7 | // 8 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 9 | // WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 10 | // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 11 | // THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE 12 | // AND INFORMATION REMAINS WITH THE USER. 13 | // 14 | 15 | using System; 16 | using System.Collections; 17 | 18 | namespace Microsoft.Xades 19 | { 20 | /// 21 | /// Collection class that derives from ArrayList. It provides the minimally 22 | /// required functionality to add instances of typed classes and obtain typed 23 | /// elements through a custom indexer. 24 | /// 25 | public class TransformCollection : ArrayList 26 | { 27 | /// 28 | /// New typed indexer for the collection 29 | /// 30 | /// Index of the object to retrieve from collection 31 | public new Transform this[int index] 32 | { 33 | get 34 | { 35 | return (Transform)base[index]; 36 | } 37 | set 38 | { 39 | base[index] = value; 40 | } 41 | } 42 | 43 | /// 44 | /// Add typed object to the collection 45 | /// 46 | /// Typed object to be added to collection 47 | /// The object that has been added to collection 48 | public Transform Add(Transform objectToAdd) 49 | { 50 | base.Add(objectToAdd); 51 | 52 | return objectToAdd; 53 | } 54 | 55 | /// 56 | /// Add new typed object to the collection 57 | /// 58 | /// The newly created object that has been added to collection 59 | public Transform Add() 60 | { 61 | return this.Add(new Transform()); 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /Xades-master/Source/Library/UnsignedDataObjectPropertyCollection.cs: -------------------------------------------------------------------------------- 1 | // UnsignedDataObjectPropertyCollection.cs 2 | // 3 | // XAdES Starter Kit for Microsoft .NET 3.5 (and above) 4 | // 2010 Microsoft France 5 | // Published under the CECILL-B Free Software license agreement. 6 | // (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt) 7 | // 8 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 9 | // WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 10 | // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 11 | // THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE 12 | // AND INFORMATION REMAINS WITH THE USER. 13 | // 14 | 15 | using System; 16 | using System.Collections; 17 | 18 | namespace Microsoft.Xades 19 | { 20 | /// 21 | /// Collection class that derives from ArrayList. It provides the minimally 22 | /// required functionality to add instances of typed classes and obtain typed 23 | /// elements through a custom indexer. 24 | /// 25 | public class UnsignedDataObjectPropertyCollection : ArrayList 26 | { 27 | /// 28 | /// New typed indexer for the collection 29 | /// 30 | /// Index of the object to retrieve from collection 31 | public new UnsignedDataObjectProperty this[int index] 32 | { 33 | get 34 | { 35 | return (UnsignedDataObjectProperty)base[index]; 36 | } 37 | set 38 | { 39 | base[index] = value; 40 | } 41 | } 42 | 43 | /// 44 | /// Add typed object to the collection 45 | /// 46 | /// Typed object to be added to collection 47 | /// The object that has been added to collection 48 | public UnsignedDataObjectProperty Add(UnsignedDataObjectProperty objectToAdd) 49 | { 50 | base.Add(objectToAdd); 51 | 52 | return objectToAdd; 53 | } 54 | 55 | /// 56 | /// Add new typed object to the collection 57 | /// 58 | /// The newly created object that has been added to collection 59 | public UnsignedDataObjectProperty Add() 60 | { 61 | return this.Add(new UnsignedDataObjectProperty()); 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /Xades-master/Source/Library/XMLTimeStamp.cs: -------------------------------------------------------------------------------- 1 | // XMLTimeStamp.cs 2 | // 3 | // XAdES Starter Kit for Microsoft .NET 3.5 (and above) 4 | // 2010 Microsoft France 5 | // Published under the CECILL-B Free Software license agreement. 6 | // (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt) 7 | // 8 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 9 | // WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 10 | // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 11 | // THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE 12 | // AND INFORMATION REMAINS WITH THE USER. 13 | // 14 | 15 | using System; 16 | using System.Xml; 17 | using System.Security.Cryptography; 18 | 19 | namespace Microsoft.Xades 20 | { 21 | /// 22 | /// This class contains a timestamp encoded as XML 23 | /// 24 | public class XMLTimeStamp 25 | { 26 | #region Private variables 27 | private XmlElement anyXmlElement; 28 | #endregion 29 | 30 | #region Public properties 31 | /// 32 | /// The generic XML element that represents an XML timestamp 33 | /// 34 | public XmlElement AnyXmlElement 35 | { 36 | get 37 | { 38 | return this.anyXmlElement; 39 | } 40 | set 41 | { 42 | this.anyXmlElement = value; 43 | } 44 | } 45 | #endregion 46 | 47 | #region Constructors 48 | /// 49 | /// Default constructor 50 | /// 51 | public XMLTimeStamp() 52 | { 53 | } 54 | #endregion 55 | 56 | #region Public methods 57 | /// 58 | /// Check to see if something has changed in this instance and needs to be serialized 59 | /// 60 | /// Flag indicating if a member needs serialization 61 | public bool HasChanged() 62 | { 63 | bool retVal = false; 64 | 65 | if (this.anyXmlElement != null) 66 | { 67 | retVal = true; 68 | } 69 | 70 | return retVal; 71 | } 72 | 73 | /// 74 | /// Load state from an XML element 75 | /// 76 | /// XML element containing new state 77 | public void LoadXml(System.Xml.XmlElement xmlElement) 78 | { 79 | this.anyXmlElement = xmlElement; 80 | } 81 | 82 | /// 83 | /// Returns the XML representation of the this object 84 | /// 85 | /// XML element containing the state of this object 86 | public XmlElement GetXml() 87 | { 88 | XmlDocument creationXmlDocument; 89 | XmlElement retVal; 90 | 91 | creationXmlDocument = new XmlDocument(); 92 | retVal = creationXmlDocument.CreateElement("xades", "XMLTimeStamp", XadesSignedXml.XadesNamespaceUri); 93 | 94 | if (this.anyXmlElement != null) 95 | { 96 | retVal.AppendChild(creationXmlDocument.ImportNode(this.anyXmlElement, true)); 97 | } 98 | 99 | return retVal; 100 | } 101 | #endregion 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /Xades-master/Source/Microsoft.Xades.shfbproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 6 | Debug 7 | AnyCPU 8 | 2.0 9 | {d56ce0ab-3c97-47c7-b70a-ebf09f65f71a} 10 | 1.8.0.3 11 | 13 | Documentation 14 | Documentation 15 | Documentation 16 | 17 | .\Help\ 18 | Documentation 19 | Microsoft.Xades Library Documentation Help 20 | 21 | 22 | 23 | 24 | 25 | CSharp 26 | 27 | 28 | The MicrosoftSamples namespace contains classes that are used to implement ASP.NET AccessManager for MOSS 2007 extension in ASP.NET/Windows SharePoint Services/Microsoft Office SharePoint Server Web server applications. 29 | 30 | 31 | 32 | 33 | 34 | Microsoft.Xades is a set of .NET Framework classes that help developer on how to develop XAdES applications. It is provided &quot%3bAS IS&quot%3b. 35 | Summary, Parameter, Returns, AutoDocumentCtors, TypeParameter, AutoDocumentDispose 36 | 37 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /Xades-master/Source/Microsoft.Xades.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 11.00 2 | # Visual Studio 2010 3 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Library", "Library\Library.csproj", "{EE1DC57A-344A-4B0A-82CE-5FD328C14894}" 4 | EndProject 5 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "TestClient\TestClient.csproj", "{27438A93-E658-4F37-B485-919ED2000107}" 6 | EndProject 7 | Global 8 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 9 | Debug|Any CPU = Debug|Any CPU 10 | Release|Any CPU = Release|Any CPU 11 | EndGlobalSection 12 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 13 | {EE1DC57A-344A-4B0A-82CE-5FD328C14894}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 14 | {EE1DC57A-344A-4B0A-82CE-5FD328C14894}.Debug|Any CPU.Build.0 = Debug|Any CPU 15 | {EE1DC57A-344A-4B0A-82CE-5FD328C14894}.Release|Any CPU.ActiveCfg = Release|Any CPU 16 | {EE1DC57A-344A-4B0A-82CE-5FD328C14894}.Release|Any CPU.Build.0 = Release|Any CPU 17 | {27438A93-E658-4F37-B485-919ED2000107}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 18 | {27438A93-E658-4F37-B485-919ED2000107}.Debug|Any CPU.Build.0 = Debug|Any CPU 19 | {27438A93-E658-4F37-B485-919ED2000107}.Release|Any CPU.ActiveCfg = Release|Any CPU 20 | {27438A93-E658-4F37-B485-919ED2000107}.Release|Any CPU.Build.0 = Release|Any CPU 21 | EndGlobalSection 22 | GlobalSection(SolutionProperties) = preSolution 23 | HideSolutionNode = FALSE 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Xades-master/Source/Microsoft.Xades.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Good-Samaritan/signature-demo-net/81ec74c924c6a61254f04835db4ccb804fa77f0c/Xades-master/Source/Microsoft.Xades.snk -------------------------------------------------------------------------------- /Xades-master/Source/TestClient/App.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Good-Samaritan/signature-demo-net/81ec74c924c6a61254f04835db4ccb804fa77f0c/Xades-master/Source/TestClient/App.ico -------------------------------------------------------------------------------- /Xades-master/Source/TestClient/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // AssemblyInfo.cs 2 | // 3 | // XAdES Starter Kit for Microsoft .NET 3.5 (and above) 4 | // 2010 Microsoft France 5 | // Published under the CECILL-B Free Software license agreement. 6 | // (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt) 7 | // 8 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 9 | // WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 10 | // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 11 | // THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE 12 | // AND INFORMATION REMAINS WITH THE USER. 13 | // 14 | 15 | using System.Reflection; 16 | using System.Runtime.CompilerServices; 17 | 18 | // General Information about an assembly is controlled through the following 19 | // set of attributes. Change these attribute values to modify the information 20 | // associated with an assembly. 21 | [assembly: AssemblyTitle("XAdES Sample")] 22 | [assembly: AssemblyDescription("XAdES Sample")] 23 | [assembly: AssemblyConfiguration("")] 24 | [assembly: AssemblyCompany("Microsoft France")] 25 | [assembly: AssemblyProduct("XAdES Starter Kit")] 26 | [assembly: AssemblyCopyright("2010")] 27 | [assembly: AssemblyTrademark("")] 28 | [assembly: AssemblyCulture("")] 29 | 30 | // Version information for an assembly consists of the following four values: 31 | // Major Version 32 | // Minor Version 33 | // Build Number 34 | // Revision 35 | // You can specify all the values or you can default the Revision and Build Numbers 36 | // by using the '*' as shown below: 37 | 38 | [assembly: AssemblyVersion("1.0.0.0")] 39 | 40 | // In order to sign your assembly you must specify a key to use. Refer to the 41 | // Microsoft .NET Framework documentation for more information on assembly signing. 42 | 43 | [assembly: AssemblyDelaySign(false)] 44 | [assembly: AssemblyKeyName("")] 45 | -------------------------------------------------------------------------------- /Xades-master/Source/TestClient/MainForm.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Good-Samaritan/signature-demo-net/81ec74c924c6a61254f04835db4ccb804fa77f0c/Xades-master/Source/TestClient/MainForm.cs -------------------------------------------------------------------------------- /Xades-master/Source/TestClient/XmlRenderTree.cs: -------------------------------------------------------------------------------- 1 | // XMLRenderTree.cs 2 | // 3 | // XAdES Starter Kit for Microsoft .NET 3.5 (and above) 4 | // 2010 Microsoft France 5 | // Published under the CECILL-B Free Software license agreement. 6 | // (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt) 7 | // 8 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 9 | // WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 10 | // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 11 | // THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE 12 | // AND INFORMATION REMAINS WITH THE USER. 13 | // 14 | 15 | using System; 16 | using System.Xml; 17 | using System.Windows.Forms; 18 | 19 | namespace Microsoft.Xades.Test 20 | { 21 | /// 22 | /// Control to render XmlNodes 23 | /// 24 | public class XmlRenderTree : TreeView 25 | { 26 | /// 27 | /// Default constructor 28 | /// 29 | public XmlRenderTree() 30 | { 31 | } 32 | 33 | public void RenderXmlNode(XmlNode xmlNode) 34 | { 35 | this.SuspendLayout(); 36 | this.Visible = false; 37 | this.Nodes.Clear(); 38 | this.RenderLevel(xmlNode); 39 | this.Visible = true; 40 | this.ResumeLayout(false); 41 | } 42 | 43 | private string GetText(XmlNode xmlNode) 44 | { 45 | string retVal; 46 | 47 | retVal = "<" + xmlNode.LocalName; 48 | if (xmlNode.Attributes != null) 49 | { 50 | foreach (XmlAttribute xmlAttribute in xmlNode.Attributes) 51 | { 52 | retVal += " " + xmlAttribute.LocalName + "=\"" + xmlAttribute.Value + "\""; 53 | } 54 | } 55 | retVal += ">"; 56 | if (xmlNode is XmlText) 57 | { 58 | retVal += xmlNode.InnerText + ""; 59 | } 60 | 61 | return retVal; 62 | } 63 | 64 | private void RenderLevel(XmlNode xmlNode) 65 | { 66 | TreeNode newTreeNode; 67 | 68 | newTreeNode = new TreeNode(this.GetText(xmlNode)); 69 | if (this.SelectedNode == null) 70 | { 71 | this.Nodes.Add(newTreeNode); 72 | } 73 | else 74 | { 75 | this.SelectedNode.Nodes.Add(newTreeNode); 76 | } 77 | foreach (XmlNode childXmlNode in xmlNode) 78 | { 79 | if (!(childXmlNode is XmlWhitespace)) 80 | { 81 | this.SelectedNode = newTreeNode; 82 | this.RenderLevel(childXmlNode); 83 | if (childXmlNode is XmlText) 84 | { 85 | newTreeNode.Collapse(); 86 | } 87 | else 88 | { 89 | newTreeNode.Expand(); 90 | } 91 | } 92 | } 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /Xades-master/Source/TestClient/XmlRenderTree.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | text/microsoft-resx 32 | 33 | 34 | 1.0.0.0 35 | 36 | 37 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 38 | 39 | 40 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 41 | 42 | 43 | -------------------------------------------------------------------------------- /Xades-master/Source/TestClient/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Xades-master/licence.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Good-Samaritan/signature-demo-net/81ec74c924c6a61254f04835db4ccb804fa77f0c/Xades-master/licence.txt -------------------------------------------------------------------------------- /Xades.IntegrationTests/NUnitTestHelper.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Good-Samaritan/signature-demo-net/81ec74c924c6a61254f04835db4ccb804fa77f0c/Xades.IntegrationTests/NUnitTestHelper.cs -------------------------------------------------------------------------------- /Xades.IntegrationTests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Xades.IntegrationTests")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Xades.UnitTests")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("327a3743-dc1d-4396-8b7e-7acc4db77402")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Xades.IntegrationTests/TestData/certificate.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Good-Samaritan/signature-demo-net/81ec74c924c6a61254f04835db4ccb804fa77f0c/Xades.IntegrationTests/TestData/certificate.pfx -------------------------------------------------------------------------------- /Xades.IntegrationTests/TestData/root-certificate.cer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Good-Samaritan/signature-demo-net/81ec74c924c6a61254f04835db4ccb804fa77f0c/Xades.IntegrationTests/TestData/root-certificate.cer -------------------------------------------------------------------------------- /Xades.IntegrationTests/TestXml/Invalid/not-signed.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Xades.IntegrationTests/TestXml/Invalid/xmldsig.xml: -------------------------------------------------------------------------------- 1 | 2 | qiOVHr/L0rV1/cCse4LsR8LCNeyq3Fpx+cfetl+qK9c=jowpgbvHE8+JPZrCmLO1Rqz0tPJPqc0uiRR1rpVwPtUoxRtdzOQA1HsZCaIJimAFgkuWZ55pFk/22D5f8r0e7w==MIICXzCCAgygAwIBAgIBHTAKBgYqhQMCAgMFADB/MQswCQYDVQQGEwJSVTETMBEGA1UECAwKU29tZS1TdGF0ZTEWMBQGA1UEBwwNWWVrYXRlcmluYnVyZzEMMAoGA1UECgwDWFJNMQwwCgYDVQQLDANYUk0xDDAKBgNVBAMMA1hSTTEZMBcGCSqGSIb3DQEJARYKeHJtQHhybS5ydTAeFw0xNTA2MjIxMjI5MTZaFw0xODA2MjExMjI5MTZaMEwxSjBIBgNVBAMMQdCi0LXRgdGC0L7QstGL0Lkg0LrQu9GO0Ycg0LTQu9GPINC30LDQv9GD0YHQutCwIHVuaXQt0YLQtdGB0YLQvtCyMGMwHAYGKoUDAgITMBIGByqFAwICJAAGByqFAwICHgEDQwAEQNmYG0THIuf2BJFozoQ8+uOE8f5gCPFgbZRpU5IZxfP64JWZBRd6xvcZFeP2AK1olWqkL3c/DmQUXNIrGCyPouyjgaEwgZ4wCQYDVR0TBAIwADAsBglghkgBhvhCAQ0EHxYdT3BlblNTTCBHZW5lcmF0ZWQgQ2VydGlmaWNhdGUwHQYDVR0OBBYEFB5y2x6+GOBpbosvc86WzDeluzL7MB8GA1UdIwQYMBaAFNZV1gwgLxZ31GZEaUN8RVUHAibbMA4GA1UdDwEB/wQEAwIE8DATBgNVHSUEDDAKBggrBgEFBQcDAjAKBgYqhQMCAgMFAANBANsjDU81fFpzNFy+4G75Gj9lAF2mGb8fWPJS3QhS+hdhfhHPF+zyodFqAWsX1MNAOH8ZNnxPbMD1wSuW9T8sfVk=Проверка -------------------------------------------------------------------------------- /Xades.IntegrationTests/TestXml/NotSigned/not-signed-child.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | test data 5 | 6 | -------------------------------------------------------------------------------- /Xades.IntegrationTests/TestXml/NotSigned/not-signed-root.xml: -------------------------------------------------------------------------------- 1 |  2 | -------------------------------------------------------------------------------- /Xades.IntegrationTests/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Xades.UnitTests/IssuerComparerTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using Xades.Implementations; 3 | 4 | namespace Xades.UnitTests 5 | { 6 | [TestFixture] 7 | public class IssuerComparerTests 8 | { 9 | private const string Windows_81_V1 = "CN=\"Тестовый УЦ ООО \"\"КРИПТО-ПРО\"\"\", O=\"ООО \"\"КРИПТО-ПРО\"\"\", C=RU, E=info@cryptopro.ru, " + 10 | "L=Москва, S=77 г. Москва, STREET=\"ул.Сущёвский вал, д. 18\", ИНН=007717107991, ОГРН=1037700085444"; 11 | private const string FromSignature = "1.2.643.100.1=1037700085444,1.2.643.3.131.1.1=007717107991,STREET=ул. Сущёвский вал\\, " + 12 | "д. 18,ST=77 г. Москва,L=Москва,1.2.840.113549.1.9.1=info@cryptopro.ru,C=RU,O=ООО \\\"КРИПТО-ПРО\\\"," + 13 | "CN=Тестовый УЦ ООО \\\"КРИПТО-ПРО\\\""; 14 | private const string Windows_81_V2 = "CN=\"Тестовый УЦ ООО \"\"КРИПТО-ПРО\"\"\", O=\"ООО \"\"КРИПТО-ПРО\"\"\", C=RU, E=info@cryptopro.ru, " + 15 | "L=Москва, S=77 г. Москва, STREET=\"ул. Сущёвский вал, д. 18\", INN=007717107991, OGRN=1037700085444"; 16 | 17 | [TestCase(Windows_81_V1, FromSignature, ExpectedResult = true, TestName = "При декодировании могут быть убраны пробелы после точки")] 18 | [TestCase(Windows_81_V1, FromSignature, ExpectedResult = true, TestName = "При декодировании могут использоваться имена полей ИНН/ОГРН/ОГРНИП")] 19 | [TestCase(Windows_81_V2, FromSignature, ExpectedResult = true, TestName = "При декодировании могут использоваться имена полей INN/OGRN/OGRNIP")] 20 | public bool AreSameIssuer_Tests(string first, string second) 21 | { 22 | return new IssuerComparer().AreSameIssuer(first, second); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Xades.UnitTests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Xades.UnitTests")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Xades.UnitTests")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("8b774d0b-7372-4c1b-ba7e-07605aca034f")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Xades.UnitTests/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Xades/Abstractions/ICertificateMatcher.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Good-Samaritan/signature-demo-net/81ec74c924c6a61254f04835db4ccb804fa77f0c/Xades/Abstractions/ICertificateMatcher.cs -------------------------------------------------------------------------------- /Xades/Abstractions/ICryptoProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Security.Cryptography; 2 | using System.Security.Cryptography.X509Certificates; 3 | using System.Security.Cryptography.Xml; 4 | using Microsoft.Xades; 5 | using Xades.Models; 6 | 7 | namespace Xades.Abstractions 8 | { 9 | public interface ICryptoProvider 10 | { 11 | /// 12 | /// URI метода подписи 13 | /// 14 | string SignatureMethod { get; } 15 | 16 | /// 17 | /// URI метода хеширования 18 | /// 19 | string DigestMethod { get; } 20 | 21 | /// 22 | /// Получение реализации асимметричного алгоритма 23 | /// 24 | /// Сертификат, исользуемый для подписания 25 | /// Пароль от контейнера закрытого ключа 26 | /// 27 | AsymmetricAlgorithm GetAsymmetricAlgorithm(X509Certificate2 certificate, string privateKeyPassword); 28 | 29 | /// 30 | /// Получение Reference-элемента для XML-документа 31 | /// 32 | /// Идентификатор подписываемого узла XML-документа 33 | /// Идентификатор подписи 34 | /// 35 | Reference GetReference(string signedElementId, string signatureId); 36 | 37 | /// 38 | /// Получение форматтера, с помощью которого будет производиться подпись 39 | /// 40 | /// Сертификат, с помощью которого будет производиться подпись 41 | /// 42 | AsymmetricSignatureFormatter GetSignatureFormatter(X509Certificate2 certificate); 43 | 44 | /// 45 | /// Получение реализации алгоритма хеширования по URI 46 | /// 47 | /// URI метода хеширования 48 | /// 49 | HashAlgorithm GetHashAlgorithm(string algorithm); 50 | 51 | /// 52 | /// Получение объекта XadesObject 53 | /// 54 | /// Информация о XAdES-подписи 55 | /// Идентификатор подписи 56 | /// 57 | XadesObject GetXadesObject(XadesInfo xadesInfo, string signatureId); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Xades/Abstractions/IIssuerComparer.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Good-Samaritan/signature-demo-net/81ec74c924c6a61254f04835db4ccb804fa77f0c/Xades/Abstractions/IIssuerComparer.cs -------------------------------------------------------------------------------- /Xades/Abstractions/IXadesService.cs: -------------------------------------------------------------------------------- 1 | namespace Xades.Abstractions 2 | { 3 | public interface IXadesService 4 | { 5 | /// 6 | /// Валидация XAdES подписи 7 | /// Бросает исключение, если подпись не верна. 8 | /// 9 | /// 10 | /// 11 | void ValidateSignature(string xmlData, string elementId); 12 | 13 | /// 14 | /// Подпись XML-документа с помощью XAdES подписи 15 | /// 16 | /// XML-документ, который необходимо подписать 17 | /// Значение атрибута Id узла XML-документа, который необходимо подписать 18 | /// Отпечаток сертификата, который необходимо использовать для подписи 19 | /// Пароль от контейнера закрытого ключа используемого сертификата 20 | /// Подписанный XML-документ 21 | string Sign(string xmlData, string elementId, string certificateThumbprint, string certificatePassword); 22 | } 23 | } -------------------------------------------------------------------------------- /Xades/Exceptions/XadesBesValidationException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Xades.Exceptions 5 | { 6 | [Serializable] 7 | public class XadesBesValidationException : Exception 8 | { 9 | public XadesBesValidationException() 10 | { 11 | } 12 | 13 | public XadesBesValidationException(string message) : base(message) 14 | { 15 | } 16 | 17 | public XadesBesValidationException(string message, Exception inner) : base(message, inner) 18 | { 19 | } 20 | 21 | protected XadesBesValidationException(SerializationInfo info, StreamingContext context) : base(info, context) 22 | { 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Xades/Helpers/ArrayHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Xades.Helpers 4 | { 5 | public static class ArrayHelper 6 | { 7 | public static bool AreEquals(byte[] first, byte[] second) 8 | { 9 | return AreEquals(first, second, (x, y) => x.Equals(y)); 10 | } 11 | 12 | public static bool AreEquals(string[] first, string[] second) 13 | { 14 | return AreEquals(first, second, (x, y) => string.Equals(x, y, StringComparison.InvariantCultureIgnoreCase)); 15 | } 16 | 17 | private static bool AreEquals(T[] first, T[] second, Func comparator) 18 | { 19 | if (first == second) 20 | { 21 | return true; 22 | } 23 | if (first.Length != second.Length) 24 | { 25 | return false; 26 | } 27 | for (var i = 0; i < first.Length; i++) 28 | { 29 | var equals = comparator.Invoke(first[i], second[i]); 30 | if (!equals) 31 | { 32 | return false; 33 | } 34 | } 35 | return true; 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /Xades/Helpers/CertificateHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Security.Cryptography.X509Certificates; 5 | 6 | namespace Xades.Helpers 7 | { 8 | public static class CertificateHelper 9 | { 10 | /// 11 | /// Получение сертификата из личного локального хранилища по отпечатку 12 | /// 13 | /// Отпечаток требуемого сертификата 14 | /// Сертификат с нужным отпечатком 15 | public static X509Certificate2 GetCertificateByThumbprint(string thumbprint) 16 | { 17 | var certificateStore = new X509Store(StoreName.My, StoreLocation.CurrentUser); 18 | 19 | try 20 | { 21 | certificateStore.Open(OpenFlags.ReadOnly); 22 | var certificateCollection = certificateStore.Certificates 23 | .Cast() 24 | .Where(i => string.Equals(i.Thumbprint, thumbprint, StringComparison.InvariantCultureIgnoreCase)) 25 | .ToArray(); 26 | 27 | if (!certificateCollection.Any()) 28 | { 29 | throw new ArgumentException("Некорректный отпечаток сертификата"); 30 | } 31 | 32 | var activeCertificates = certificateCollection.Where(i => DateTime.Parse(i.GetEffectiveDateString()) <= DateTime.Now && 33 | DateTime.Now <= DateTime.Parse(i.GetExpirationDateString())) 34 | .ToArray(); 35 | if (activeCertificates.Any()) 36 | { 37 | return activeCertificates[0]; 38 | } 39 | 40 | throw new ArgumentException(string.Format("Сертификат с указанным отпечатком {0} недействителен", thumbprint)); 41 | } 42 | finally 43 | { 44 | certificateStore.Close(); 45 | } 46 | } 47 | 48 | /// 49 | /// Получение сертификатов из локального хранилища текущего пользователя 50 | /// 51 | /// Сертификаты из локального хранилища текущего пользователя 52 | public static IEnumerable GetCertificates() 53 | { 54 | var certificateStore = new X509Store(StoreName.My, StoreLocation.CurrentUser); 55 | 56 | try 57 | { 58 | certificateStore.Open(OpenFlags.ReadOnly); 59 | return certificateStore.Certificates.OfType(); 60 | } 61 | finally 62 | { 63 | certificateStore.Close(); 64 | } 65 | } 66 | } 67 | } -------------------------------------------------------------------------------- /Xades/Helpers/CollectionHelper.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Linq; 3 | 4 | namespace Xades.Helpers 5 | { 6 | public static class CollectionHelper 7 | { 8 | public static bool IsNotEmpty(this IEnumerable enumerable) 9 | { 10 | return enumerable != null && enumerable.OfType().Any(); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /Xades/Helpers/ConvertHelper.cs: -------------------------------------------------------------------------------- 1 | using System.Numerics; 2 | 3 | namespace Xades.Helpers 4 | { 5 | public static class ConvertHelper 6 | { 7 | public static string BigIntegerToHex(string str) 8 | { 9 | return BigInteger.Parse(str).ToString("X"); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /Xades/Helpers/DateTimeHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Xades.Helpers 4 | { 5 | public static class DateTimeHelper 6 | { 7 | public static DateTimeOffset ToDateTimeOffset(this DateTime dateTime, int timeZoneOffsetMinutes = 0) 8 | { 9 | var shiftedDateTime = dateTime.AddMinutes(timeZoneOffsetMinutes); 10 | var unspecifiedDateTime = DateTime.SpecifyKind(shiftedDateTime, DateTimeKind.Unspecified); 11 | return new DateTimeOffset(unspecifiedDateTime, new TimeSpan(0, timeZoneOffsetMinutes, 0)); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Xades/Helpers/EnumerableHelper.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | 4 | namespace Xades.Helpers 5 | { 6 | public static class EnumerableHelper 7 | { 8 | public static bool AreSequenceEquals(IEnumerable first, IEnumerable second) 9 | { 10 | var sortedFirst = first.OrderBy(x => x).ToArray(); 11 | var sortedSecond = second.OrderBy(x => x).ToArray(); 12 | return ArrayHelper.AreEquals(sortedFirst, sortedSecond); 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /Xades/Helpers/KeyInfoHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Security.Cryptography.X509Certificates; 3 | using System.Security.Cryptography.Xml; 4 | using System.Xml; 5 | 6 | namespace Xades.Helpers 7 | { 8 | public static class KeyInfoHelper 9 | { 10 | public static KeyInfo Create(X509Certificate2 certificate) 11 | { 12 | var xmlDocument = new XmlDocument(); 13 | 14 | var x509DataElement = xmlDocument.CreateElement("ds", "X509Data", KeyInfoNamespace); 15 | var x509CertificateElement = xmlDocument.CreateElement("ds", "X509Certificate", KeyInfoNamespace); 16 | x509CertificateElement.InnerText = Convert.ToBase64String(certificate.GetRawCertData()); 17 | 18 | x509DataElement.AppendChild(x509CertificateElement); 19 | 20 | var keyInfo = new KeyInfo(); 21 | keyInfo.AddClause(new KeyInfoNode(x509DataElement)); 22 | 23 | return keyInfo; 24 | } 25 | 26 | private const string KeyInfoNamespace = "http://www.w3.org/2000/09/xmldsig#"; 27 | } 28 | } -------------------------------------------------------------------------------- /Xades/Helpers/X509NameHelper.cs: -------------------------------------------------------------------------------- 1 | using Org.BouncyCastle.Asn1.X509; 2 | 3 | namespace Xades.Helpers 4 | { 5 | public static class X509NameHelper 6 | { 7 | public static string ToX509IssuerName(this X509Name x509Name) 8 | { 9 | return x509Name.ToString().Replace("E=", "1.2.840.113549.1.9.1="); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Xades/Helpers/XadesSignedXmlHelper.cs: -------------------------------------------------------------------------------- 1 | using System.Xml; 2 | using Microsoft.Xades; 3 | 4 | namespace Xades.Helpers 5 | { 6 | public static class XadesSignedXmlHelper 7 | { 8 | public static void InjectSignatureTo(this XadesSignedXml signedXml, XmlDocument originalDoc) 9 | { 10 | var signatureElement = signedXml.GetXml(); 11 | var importSignatureElement = originalDoc.ImportNode(signatureElement, true); 12 | var signedDataContainer = signedXml.GetIdElement(originalDoc, signedXml.SignedElementId); 13 | signedDataContainer.InsertBefore(importSignatureElement, signedDataContainer.FirstChild); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Xades/Helpers/XmlDocumentHelper.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Good-Samaritan/signature-demo-net/81ec74c924c6a61254f04835db4ccb804fa77f0c/Xades/Helpers/XmlDocumentHelper.cs -------------------------------------------------------------------------------- /Xades/Implementations/GostXadesBesService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xades.Abstractions; 3 | using Xades.Helpers; 4 | 5 | namespace Xades.Implementations 6 | { 7 | public class GostXadesBesService : IXadesService 8 | { 9 | public void ValidateSignature(string xmlData, string elementId) 10 | { 11 | if (string.IsNullOrEmpty(xmlData)) 12 | { 13 | throw new ArgumentNullException("xmlData"); 14 | } 15 | if (string.IsNullOrWhiteSpace(elementId)) 16 | { 17 | throw new ArgumentNullException("elementId"); 18 | } 19 | 20 | 21 | var document = XmlDocumentHelper.Create(xmlData); 22 | var signedXml = new XadesBesSignedXml(document, elementId) 23 | { 24 | CertificateMatcher = new CertificateMatcher(new GostCryptoProvider()) 25 | }; 26 | using (new AdditionalXmlDsigC14NTransformOperation(document)) 27 | { 28 | signedXml.Validate(); 29 | } 30 | } 31 | 32 | public string Sign(string xmlData, string elementId, string certificateThumbprint, string certificatePassword) 33 | { 34 | if (string.IsNullOrEmpty(xmlData)) 35 | { 36 | throw new ArgumentNullException("xmlData"); 37 | } 38 | if (string.IsNullOrEmpty(elementId)) 39 | { 40 | throw new ArgumentNullException("elementId"); 41 | } 42 | if (string.IsNullOrEmpty(certificateThumbprint)) 43 | { 44 | throw new ArgumentNullException("certificateThumbprint"); 45 | } 46 | 47 | var originalDoc = XmlDocumentHelper.Create(xmlData); 48 | var certificate = CertificateHelper.GetCertificateByThumbprint(certificateThumbprint); 49 | 50 | var xadesSignedXml = new XadesBesSignedXml(originalDoc) 51 | { 52 | SignedElementId = elementId, 53 | CryptoProvider = new GostCryptoProvider() 54 | }; 55 | 56 | var element = xadesSignedXml.FindElement(elementId, originalDoc); 57 | if (element == null) 58 | { 59 | throw new InvalidOperationException(string.Format("Не удалось найти узел c Id {0}", elementId)); 60 | } 61 | 62 | xadesSignedXml.ComputeSignature(certificate, certificatePassword); 63 | xadesSignedXml.InjectSignatureTo(originalDoc); 64 | 65 | return originalDoc.OuterXml; 66 | } 67 | } 68 | } -------------------------------------------------------------------------------- /Xades/Implementations/IssuerComparer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using System.Text.RegularExpressions; 4 | using Org.BouncyCastle.Asn1.X509; 5 | using Xades.Abstractions; 6 | using Xades.Helpers; 7 | 8 | namespace Xades.Implementations 9 | { 10 | public class IssuerComparer : IIssuerComparer 11 | { 12 | static IssuerComparer() 13 | { 14 | var regexps = new Dictionary 15 | { 16 | { "^(ОГРН|OGRN|OID.1.2.643.100.1)=", "1.2.643.100.1="}, 17 | { "^(ОГРНИП|OGRNIP|OID.1.2.643.100.5)=", "1.2.643.100.5="}, 18 | { "^(ИНН|INN|OID.1.2.643.3.131.1.1)=", "1.2.643.3.131.1.1="}, 19 | { "^(E|Е|OID.1.2.840.113549.1.9.1)=", "1.2.840.113549.1.9.1="}, 20 | { "^S=", "ST="}, 21 | { "\\\"", string.Empty}, 22 | { ". ", "."}, 23 | }; 24 | RegexpToReplace = regexps.ToDictionary(x => new Regex(x.Key), x => x.Value); 25 | } 26 | 27 | private static IEnumerable ParseIssuer(string issuer) 28 | { 29 | return Tokenize(issuer).Select(ReplaceOids); 30 | } 31 | 32 | private static string ReplaceOids(string oidString) 33 | { 34 | foreach (var item in RegexpToReplace) 35 | { 36 | oidString = item.Key.Replace(oidString, item.Value); 37 | } 38 | return oidString; 39 | } 40 | 41 | private static IEnumerable Tokenize(string issuer) 42 | { 43 | var tokenizer = new X509NameTokenizer(issuer); 44 | while (tokenizer.HasMoreTokens()) 45 | { 46 | yield return tokenizer.NextToken(); 47 | } 48 | } 49 | 50 | private static readonly Dictionary RegexpToReplace; 51 | 52 | public bool AreSameIssuer(string first, string second) 53 | { 54 | var firstTokens = ParseIssuer(first); 55 | var secondTokens = ParseIssuer(second); 56 | return EnumerableHelper.AreSequenceEquals(firstTokens, secondTokens); 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /Xades/Models/XadesInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Security.Cryptography.X509Certificates; 3 | 4 | namespace Xades.Models 5 | { 6 | public class XadesInfo 7 | { 8 | public byte[] RawCertData { get; private set; } 9 | public DateTime SigningDateTimeUtc { get; private set; } 10 | public int TimeZoneOffsetMinutes { get; private set; } 11 | 12 | public XadesInfo(X509Certificate certificate) 13 | { 14 | var offset = TimeZoneInfo.Local.GetUtcOffset(DateTime.Now); 15 | 16 | RawCertData = certificate.GetRawCertData(); 17 | SigningDateTimeUtc = DateTime.UtcNow; 18 | TimeZoneOffsetMinutes = Convert.ToInt32(offset.TotalMinutes); 19 | } 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /Xades/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Xades")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Xades")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("ad2ae594-3cca-489c-b2ff-fe757306ecca")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Xades/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /XadesDemo/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 |
5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /XadesDemo/Commands/CertificateCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xades.Helpers; 3 | using XadesDemo.Configurations.Options; 4 | 5 | namespace XadesDemo.Commands 6 | { 7 | public class CertificateCommand : CommandBase 8 | { 9 | public CertificateCommand(CertificateOptions option) : base(option) 10 | { 11 | } 12 | 13 | protected override void OnExecute(CertificateOptions option) 14 | { 15 | Option.Verbose = true; 16 | var certificates = CertificateHelper.GetCertificates(); 17 | Info("Информация о сертификатах"); 18 | foreach (var cert in certificates) 19 | { 20 | Info(string.Format("Субъект: {0}", cert.Subject)); 21 | Info(string.Format("Отпечаток: {0}", cert.Thumbprint)); 22 | Console.WriteLine(); 23 | } 24 | } 25 | 26 | } 27 | } -------------------------------------------------------------------------------- /XadesDemo/Commands/CommandBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using XadesDemo.Configurations.Options; 3 | 4 | namespace XadesDemo.Commands 5 | { 6 | public abstract class CommandBase : ICommand 7 | where TOption : OptionBase 8 | { 9 | protected readonly TOption Option; 10 | 11 | protected abstract void OnExecute(TOption option); 12 | 13 | protected CommandBase(TOption option) 14 | { 15 | Option = option; 16 | } 17 | 18 | public void Execute() 19 | { 20 | try 21 | { 22 | OnExecute(Option); 23 | } 24 | catch (Exception ex) 25 | { 26 | Error(string.Format("Ошибка выполнения команды: {0}", ex.Message), ex); 27 | } 28 | } 29 | 30 | protected void Error(string message, Exception ex = null) 31 | { 32 | 33 | if (ex != null && Option.Verbose) 34 | { 35 | message += string.Format("\n\rStackTrace:{0}", ex.StackTrace); 36 | } 37 | PrintMessage(message, ConsoleColor.Red); 38 | } 39 | protected void Info(string message) 40 | { 41 | PrintMessage(message, canWrite: Option.Verbose); 42 | } 43 | 44 | protected void Warning(string message) 45 | { 46 | PrintMessage(message, ConsoleColor.Yellow); 47 | } 48 | 49 | protected void Success(string message) 50 | { 51 | PrintMessage(message, ConsoleColor.Green); 52 | } 53 | 54 | private static void PrintMessage(string message, ConsoleColor color = ConsoleColor.White, bool canWrite = true) 55 | { 56 | if (canWrite) 57 | { 58 | Console.ForegroundColor = color; 59 | Console.WriteLine(message); 60 | Console.ResetColor(); 61 | } 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /XadesDemo/Commands/GetStateCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xades.Abstractions; 3 | using XadesDemo.Configurations.Options; 4 | using XadesDemo.Configurations.Sections; 5 | using XadesDemo.Infrastructure; 6 | 7 | namespace XadesDemo.Commands 8 | { 9 | public class GetStateCommand : GisCommandBase 10 | { 11 | public GetStateCommand(GetStateOptions option, IXadesService xadesService, SigningConfiguration signingConfig, GisServiceConfiguration serviceConfig) 12 | : base(option, xadesService, signingConfig, serviceConfig) 13 | { 14 | } 15 | 16 | protected override bool IsSignatureRequired { get { return false;}} 17 | 18 | protected override void OnExecute(GetStateOptions option) 19 | { 20 | var valuesDictionary = new [] { new Tuple(Constants.MessageGuidXpath, option.MessageGuid) }; 21 | SendRequest(option.ServiceName, Constants.GetStateMethodName, valuesDictionary, option.OutputFileName); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /XadesDemo/Commands/ICommand.cs: -------------------------------------------------------------------------------- 1 | namespace XadesDemo.Commands 2 | { 3 | public interface ICommand 4 | { 5 | void Execute(); 6 | } 7 | } -------------------------------------------------------------------------------- /XadesDemo/Commands/SendCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using Xades.Abstractions; 4 | using XadesDemo.Configurations.Options; 5 | using XadesDemo.Configurations.Sections; 6 | 7 | namespace XadesDemo.Commands 8 | { 9 | public class SendCommand : GisCommandBase 10 | { 11 | public SendCommand(SendOptions option, IXadesService xadesService, SigningConfiguration signingConfig, GisServiceConfiguration serviceConfig) 12 | : base(option, xadesService, signingConfig, serviceConfig) 13 | { 14 | } 15 | 16 | protected override bool IsSignatureRequired 17 | { 18 | get { return true; } 19 | } 20 | 21 | protected override void OnExecute(SendOptions option) 22 | { 23 | var valueDictionary = Enumerable.Empty>(); 24 | if (!string.IsNullOrEmpty(option.ParametersFileName)) 25 | { 26 | Info(string.Format("Чтение данных из {0}...", option.ParametersFileName)); 27 | valueDictionary = Helpers.CsvHelper.ReadCsv(option.ParametersFileName); 28 | } 29 | 30 | SendRequest(option.ServiceName, option.MethodName, valueDictionary, option.OutputFileName); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /XadesDemo/Commands/SignCommand.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using Xades.Abstractions; 3 | using Xades.Helpers; 4 | using XadesDemo.Configurations.Options; 5 | using XadesDemo.Configurations.Sections; 6 | 7 | namespace XadesDemo.Commands 8 | { 9 | public class SignCommand : XadesCommandBase 10 | { 11 | public SignCommand(SignOptions option, IXadesService xadesService, SigningConfiguration signingConfig) : base(option, xadesService, signingConfig) 12 | { 13 | } 14 | 15 | protected override void OnExecute(SignOptions option) 16 | { 17 | Info(string.Format("Выпоняется чтение файла {0}...", option.InputFileName)); 18 | var xmlDocument = XmlDocumentHelper.Load(option.InputFileName); 19 | var elementId = Option.Element; 20 | 21 | Info("Выполняется подпись файла..."); 22 | var resultXmlText = Sign(xmlDocument, elementId); 23 | File.WriteAllText(option.OutputFileName, resultXmlText); 24 | Success("Файл успешно подписан"); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /XadesDemo/Commands/VerifyCommand.cs: -------------------------------------------------------------------------------- 1 | using Xades.Abstractions; 2 | using Xades.Helpers; 3 | using XadesDemo.Configurations.Options; 4 | using XadesDemo.Configurations.Sections; 5 | 6 | namespace XadesDemo.Commands 7 | { 8 | public class VerifyCommand : XadesCommandBase 9 | { 10 | public VerifyCommand(VerifyOptions option, IXadesService xadesService, SigningConfiguration signingConfig) : base(option, xadesService, signingConfig) 11 | { 12 | } 13 | 14 | protected override void OnExecute(VerifyOptions option) 15 | { 16 | Info(string.Format("Выполняется чтение файла {0}...", option.InputFileName)); 17 | var xmlDocument = XmlDocumentHelper.Load(option.InputFileName); 18 | var elementId = option.Element; 19 | 20 | Info("Проверка подписи файла..."); 21 | Validate(xmlDocument, elementId); 22 | Success("Подпись элемента верна"); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /XadesDemo/Configurations/Options/CertificateOptions.cs: -------------------------------------------------------------------------------- 1 | using CommandLine; 2 | 3 | namespace XadesDemo.Configurations.Options 4 | { 5 | [Verb("list-certs", HelpText = "Отобразить список сертификатов, установленных в локальное хранилище пользователя")] 6 | public class CertificateOptions : OptionBase 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /XadesDemo/Configurations/Options/GetStateOptions.cs: -------------------------------------------------------------------------------- 1 | using CommandLine; 2 | 3 | namespace XadesDemo.Configurations.Options 4 | { 5 | [Verb("get-state", HelpText = "Запрос ответа на асинхронный метод ГИС ЖКХ")] 6 | public class GetStateOptions : XadesOptionBase 7 | { 8 | [Option('s', "service", HelpText = "Имя сервиса", Required = true)] 9 | public string ServiceName { get; set; } 10 | 11 | [Option('g', "guid", HelpText = "Уникальный идентификатор запроса в ГИС ЖКХ (MessageGUID)", Required = true)] 12 | public string MessageGuid { get; set; } 13 | 14 | [Option('o', "output", HelpText = "Файл для сохранения результатов выполнения запроса", Required = true)] 15 | public string OutputFileName { get; set; } 16 | 17 | [Option('a', "auth", HelpText = "Логин:пароль для basic авторизации", Required = true)] 18 | public override string BasicAuthorization { get; set; } 19 | } 20 | } -------------------------------------------------------------------------------- /XadesDemo/Configurations/Options/OptionBase.cs: -------------------------------------------------------------------------------- 1 | using CommandLine; 2 | 3 | namespace XadesDemo.Configurations.Options 4 | { 5 | public abstract class OptionBase 6 | { 7 | [Option('v', "verbose", Default = false, HelpText = "Включить отладочный вывод")] 8 | public bool Verbose { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /XadesDemo/Configurations/Options/SendOptions.cs: -------------------------------------------------------------------------------- 1 | using CommandLine; 2 | 3 | namespace XadesDemo.Configurations.Options 4 | { 5 | [Verb("send", HelpText = "Отправка запроса в ГИС ЖКХ")] 6 | public class 7 | SendOptions : XadesOptionBase 8 | { 9 | [Option('s', "service", HelpText = "Имя сервиса", Required = true)] 10 | public string ServiceName { get; set; } 11 | 12 | [Option('m', "method", HelpText = "Метод сервиса", Required = true)] 13 | public string MethodName { get; set; } 14 | 15 | [Option('o', "output", HelpText = "Файл для сохранения результатов выполнения запроса", Required = true)] 16 | public string OutputFileName { get; set; } 17 | 18 | [Option('c', "csv", HelpText = "Файл с входными параметрами для запроса")] 19 | public string ParametersFileName { get; set; } 20 | 21 | [Option('p', "password", HelpText = "Пароль от выбраного сертификата")] 22 | public override string Password { get; set; } 23 | 24 | [Option('a', "auth", HelpText = "Логин:пароль для basic авторизации", Required = true)] 25 | public override string BasicAuthorization { get; set; } 26 | } 27 | } -------------------------------------------------------------------------------- /XadesDemo/Configurations/Options/SignOptions.cs: -------------------------------------------------------------------------------- 1 | using CommandLine; 2 | 3 | namespace XadesDemo.Configurations.Options 4 | { 5 | [Verb("sign", HelpText = "Подписать XML файл")] 6 | public class SignOptions : XadesOptionBase 7 | { 8 | [Option('f', "input", HelpText = "Файл, который необходимо подписать", Required = true)] 9 | public string InputFileName { get; set; } 10 | 11 | [Option('o', "output", HelpText = "Файл для сохранения подписанного документа", Required = true)] 12 | public string OutputFileName { get; set; } 13 | 14 | [Option('e', "element", HelpText = "Id элемента, который необходимо подписать(по умолчанию подписывается корневой элемент)")] 15 | public string Element { get; set; } 16 | 17 | [Option('p', "password", HelpText = "Пароль от выбраного сертификата")] 18 | public override string Password { get; set; } 19 | } 20 | } -------------------------------------------------------------------------------- /XadesDemo/Configurations/Options/VerifyOptions.cs: -------------------------------------------------------------------------------- 1 | using CommandLine; 2 | 3 | namespace XadesDemo.Configurations.Options 4 | { 5 | [Verb("verify", HelpText = "Проверка подписи XML файла")] 6 | public class VerifyOptions : XadesOptionBase 7 | { 8 | [Option('f', "input", HelpText = "Подписанный XML файл", Required = true)] 9 | public string InputFileName { get; set; } 10 | 11 | [Option('e', "element", HelpText = "Id подписанного элемента(по умолчанию проверяется корневой элемент)")] 12 | public string Element { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /XadesDemo/Configurations/Options/XadesOptionBase.cs: -------------------------------------------------------------------------------- 1 | namespace XadesDemo.Configurations.Options 2 | { 3 | public abstract class XadesOptionBase : OptionBase 4 | { 5 | public virtual string Password { get; set; } 6 | public virtual string BasicAuthorization { get; set; } 7 | } 8 | } -------------------------------------------------------------------------------- /XadesDemo/Configurations/Sections/GisServiceConfiguration.cs: -------------------------------------------------------------------------------- 1 | using System.Configuration; 2 | 3 | namespace XadesDemo.Configurations.Sections 4 | { 5 | public class GisServiceConfiguration : ConfigurationSection 6 | { 7 | [ConfigurationProperty("Services")] 8 | public ServiceCollection Services 9 | { 10 | get { return (ServiceCollection) (base["Services"]); } 11 | } 12 | 13 | [ConfigurationProperty("OrgPpaGuid", IsRequired = true)] 14 | public string OrgPpaGuid 15 | { 16 | get { return (string)base["OrgPpaGuid"]; } 17 | set { base["OrgPpaGuid"] = value; } 18 | } 19 | 20 | [ConfigurationProperty("BaseUrl", IsRequired = true)] 21 | public string BaseUrl 22 | { 23 | get { return (string)base["BaseUrl"]; } 24 | set { base["BaseUrl"] = value; } 25 | } 26 | 27 | [ConfigurationProperty("SoapConfiguration", IsRequired = true)] 28 | public SoapConfiguration SoapConfiguration 29 | { 30 | get { return (SoapConfiguration)base["SoapConfiguration"]; } 31 | set { base["SoapConfiguration"] = value; } 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /XadesDemo/Configurations/Sections/MethodCollection.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Configuration; 3 | using System.Linq; 4 | 5 | namespace XadesDemo.Configurations.Sections 6 | { 7 | [ConfigurationCollection(typeof(MethodElement), AddItemName = "Method")] 8 | public class MethodCollection : ConfigurationElementCollection 9 | { 10 | protected override ConfigurationElement CreateNewElement() 11 | { 12 | return new MethodElement(); 13 | } 14 | 15 | protected override object GetElementKey(ConfigurationElement element) 16 | { 17 | return ((MethodElement)(element)).MethodName; 18 | } 19 | 20 | public MethodElement this[string name] 21 | { 22 | get { 23 | var key = BaseGetAllKeys().FirstOrDefault(x => string.Equals((string)x, name, StringComparison.InvariantCultureIgnoreCase)); 24 | return (MethodElement)BaseGet(key ?? name); 25 | } 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /XadesDemo/Configurations/Sections/MethodElement.cs: -------------------------------------------------------------------------------- 1 | using System.Configuration; 2 | 3 | namespace XadesDemo.Configurations.Sections 4 | { 5 | public class MethodElement : ConfigurationElement 6 | { 7 | [ConfigurationProperty("MethodName", IsKey = true, IsRequired = true)] 8 | public string MethodName 9 | { 10 | get { return ((string)(base["MethodName"]));} 11 | set { base["MethodName"] = value; } 12 | } 13 | 14 | [ConfigurationProperty("Action", IsKey = false, IsRequired = true)] 15 | public string Action 16 | { 17 | get { return ((string)(base["Action"])); } 18 | set { base["Action"] = value; } 19 | } 20 | 21 | [ConfigurationProperty("RequiredBody", DefaultValue = true)] 22 | public bool RequiredBody 23 | { 24 | get { return ((bool)(base["RequiredBody"])); } 25 | set { base["RequiredBody"] = value; } 26 | } 27 | 28 | [ConfigurationProperty("Template", IsKey = false, IsRequired = true)] 29 | public string Template 30 | { 31 | get { return ((string)(base["Template"])); } 32 | set { base["Template"] = value; } 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /XadesDemo/Configurations/Sections/ServiceCollection.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Configuration; 3 | using System.Linq; 4 | 5 | namespace XadesDemo.Configurations.Sections 6 | { 7 | [ConfigurationCollection(typeof(ServiceElement), AddItemName = "Service")] 8 | public class ServiceCollection : ConfigurationElementCollection 9 | { 10 | protected override ConfigurationElement CreateNewElement() 11 | { 12 | return new ServiceElement(); 13 | } 14 | 15 | protected override object GetElementKey(ConfigurationElement element) 16 | { 17 | return ((ServiceElement)(element)).ServiceName; 18 | } 19 | 20 | public ServiceElement this[string name] 21 | { 22 | get 23 | { 24 | var key = BaseGetAllKeys().FirstOrDefault(x => string.Equals((string)x, name, StringComparison.InvariantCultureIgnoreCase)); 25 | return (ServiceElement)BaseGet(key ?? name); 26 | } 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /XadesDemo/Configurations/Sections/ServiceElement.cs: -------------------------------------------------------------------------------- 1 | using System.Configuration; 2 | 3 | namespace XadesDemo.Configurations.Sections 4 | { 5 | public class ServiceElement : ConfigurationElement 6 | { 7 | [ConfigurationProperty("ServiceName", DefaultValue = "", IsKey = true, IsRequired = true)] 8 | public string ServiceName 9 | { 10 | get { return ((string)(base["ServiceName"])); } 11 | set { base["ServiceName"] = value; } 12 | } 13 | 14 | [ConfigurationProperty("Path", DefaultValue = "", IsKey = false, IsRequired = true)] 15 | public string Path 16 | { 17 | get { return ((string)(base["Path"])); } 18 | set { base["Path"] = value; } 19 | } 20 | 21 | [ConfigurationProperty("AddSignature", DefaultValue = true, IsKey = false)] 22 | public bool AddSignature 23 | { 24 | get { return ((bool)(base["AddSignature"])); } 25 | set { base["AddSignature"] = value; } 26 | } 27 | 28 | [ConfigurationProperty("AddOrgPpaGuid", IsRequired = true, IsKey = false)] 29 | public bool AddOrgPpaGuid 30 | { 31 | get { return ((bool)(base["AddOrgPpaGuid"])); } 32 | set { base["AddOrgPpaGuid"] = value; } 33 | } 34 | 35 | [ConfigurationProperty("Methods")] 36 | public MethodCollection Methods 37 | { 38 | get { return (MethodCollection) base["Methods"]; } 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /XadesDemo/Configurations/Sections/SigningConfiguration.cs: -------------------------------------------------------------------------------- 1 | using System.Configuration; 2 | 3 | namespace XadesDemo.Configurations.Sections 4 | { 5 | public class SigningConfiguration : ConfigurationSection 6 | { 7 | [ConfigurationProperty("CertificateThumbprint", IsRequired = true)] 8 | public string CertificateThumbprint 9 | { 10 | get { return (string)base["CertificateThumbprint"]; } 11 | set { base["CertificateThumbprint"] = value; } 12 | } 13 | 14 | [ConfigurationProperty("CertificatePassword", IsRequired = false)] 15 | public string CertificatePassword 16 | { 17 | get { return (string)base["CertificatePassword"]; } 18 | set { base["CertificatePassword"] = value; } 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /XadesDemo/Configurations/Sections/SoapConfiguration.cs: -------------------------------------------------------------------------------- 1 | using System.Configuration; 2 | 3 | namespace XadesDemo.Configurations.Sections 4 | { 5 | public class SoapConfiguration : ConfigurationElement 6 | { 7 | [ConfigurationProperty("SoapTemplate", IsRequired = true)] 8 | public string SoapTemplatePath 9 | { 10 | get { return (string)base["SoapTemplate"]; } 11 | set { base["SoapTemplate"] = value; } 12 | } 13 | 14 | [ConfigurationProperty("ISRequestHeaderTemplate", IsRequired = true)] 15 | public string ISRequestHeaderTemplatePath 16 | { 17 | get { return (string)base["ISRequestHeaderTemplate"]; } 18 | set { base["ISRequestHeaderTemplate"] = value; } 19 | } 20 | 21 | [ConfigurationProperty("RequestHeaderTemplate", IsRequired = true)] 22 | public string RequestHeaderTemplatePath 23 | { 24 | get { return (string)base["RequestHeaderTemplate"]; } 25 | set { base["RequestHeaderTemplate"] = value; } 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /XadesDemo/Helpers/CsvHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Text.RegularExpressions; 7 | using CsvHelper; 8 | 9 | namespace XadesDemo.Helpers 10 | { 11 | public static class CsvHelper 12 | { 13 | private static char[] Separators = {';'}; 14 | private const string Separator = ";"; 15 | 16 | public static void WriteCsv(string outputFile, IEnumerable> valuesDictionary) 17 | { 18 | using (var writer = new StreamWriter(outputFile, false, Encoding.UTF8)) 19 | { 20 | var serializer = new CsvSerializer(writer); 21 | serializer.Configuration.Delimiter = Separator; 22 | serializer.Configuration.Encoding = Encoding.UTF8; 23 | serializer.Configuration.IgnoreBlankLines = true; 24 | serializer.Write(valuesDictionary.Select(x => x.Item1).ToArray()); 25 | //используется замена "переводов строк" , "табуляции" и "сдвига каретки" на "пробел" для сохранения формата csv файла 26 | serializer.Write(valuesDictionary.Select(x => Regex.Replace(x.Item2, "\n|\r|\t", " ")).ToArray()); 27 | } 28 | } 29 | 30 | public static IEnumerable> ReadCsv(string inputFile) 31 | { 32 | if (!File.Exists(inputFile)) 33 | { 34 | throw new ArgumentException("Указан несуществующий файл с параметрами"); 35 | } 36 | 37 | if (string.IsNullOrEmpty(inputFile)) 38 | { 39 | return Enumerable.Empty>(); 40 | } 41 | 42 | var lines = File.ReadAllLines(inputFile); 43 | 44 | return lines[0].Split(Separators) 45 | .Zip(lines[1].Split(Separators), (xpath, value) => new { xpath, value }) 46 | .Select( item => new Tuple( item.xpath, item.value)); 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /XadesDemo/Helpers/PathHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | namespace XadesDemo.Helpers 5 | { 6 | public static class PathHelper 7 | { 8 | public static string AppPath = AppDomain.CurrentDomain.BaseDirectory; 9 | public static string ToAppAbsolutePath(string fileName) 10 | { 11 | return Path.Combine(AppPath, fileName); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /XadesDemo/Infrastructure/Constants.cs: -------------------------------------------------------------------------------- 1 | namespace XadesDemo.Infrastructure 2 | { 3 | internal static class Constants 4 | { 5 | private const string envelopNamespaceCondition = "namespace-uri()='http://schemas.xmlsoap.org/soap/envelope/'"; 6 | 7 | internal const string GisServicesConfigSectionName = "GisServicesConfig"; 8 | internal const string XadesConfigSectionName = "signingConfig"; 9 | 10 | internal const string SignElementName = "sign-element"; 11 | internal const string SoapContentXpath = "*[local-name()='Envelope' and " + envelopNamespaceCondition + "]/*[local-name()='Body' and " + envelopNamespaceCondition + "]/*"; 12 | internal const string SoapBodyXpath = "*[local-name()='Envelope' and " + envelopNamespaceCondition + "]/*[local-name()='Body' and " + envelopNamespaceCondition + "]"; 13 | internal const string SoapHeaderXpath = "*[local-name()='Envelope' and " + envelopNamespaceCondition + "]/*[local-name()='Header'and " + envelopNamespaceCondition + "]"; 14 | internal const string SignatureName = "Signature"; 15 | 16 | internal const string GetStateMethodName = "getState"; 17 | internal const string MessageGuidXpath = "./m:getStateRequest/m:MessageGUID"; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /XadesDemo/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Configuration; 3 | using CommandLine; 4 | using CommandLine.Text; 5 | using Xades.Implementations; 6 | using XadesDemo.Commands; 7 | using XadesDemo.Configurations.Options; 8 | using XadesDemo.Configurations.Sections; 9 | using XadesDemo.Infrastructure; 10 | 11 | namespace XadesDemo 12 | { 13 | class Program 14 | { 15 | static void Main(string[] args) 16 | { 17 | try 18 | { 19 | var gisConfig = (GisServiceConfiguration)ConfigurationManager.GetSection(Constants.GisServicesConfigSectionName); 20 | var xadesConfig = (SigningConfiguration)ConfigurationManager.GetSection(Constants.XadesConfigSectionName); 21 | var xadesService = new GostXadesBesService(); 22 | 23 | SentenceBuilder.UseSentenceBuilder(new RussianSentenceBuilder()); 24 | 25 | ICommand command = Parser.Default.ParseArguments(args) 26 | .MapResult( 27 | (SignOptions o) => new SignCommand(o, xadesService, xadesConfig), 28 | (VerifyOptions o) => new VerifyCommand(o, xadesService, xadesConfig), 29 | (SendOptions o) => new SendCommand(o, xadesService, xadesConfig, gisConfig), 30 | (GetStateOptions o) => new GetStateCommand(o, xadesService, xadesConfig, gisConfig), 31 | (CertificateOptions o) => new CertificateCommand(o), 32 | errors => (ICommand)null); 33 | if (command != null) 34 | { 35 | command.Execute(); 36 | } 37 | 38 | } 39 | catch(Exception ex) 40 | { 41 | Console.ForegroundColor = ConsoleColor.Red; 42 | Console.WriteLine("Произошла ошибка:"); 43 | Console.WriteLine(ex.ToString()); 44 | } 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /XadesDemo/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("Утилита для работы с ЭЦП формата XAdES-BES с использованием ГОСТ алгоритмов, версия")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("")] 12 | [assembly: AssemblyCopyright("")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("49e26f30-f505-439c-9e75-d7576a5cbbdb")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /XadesDemo/Templates/Inspection/get-state-template.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /XadesDemo/Templates/Inspection/import-inspection-plan-template.xml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /XadesDemo/Templates/NsiAsync/get-state-template.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /XadesDemo/Templates/NsiAsync/import-municipal-services-template.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /XadesDemo/Templates/NsiCommonAsync/export-nsi-item-template.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | NSI 4 | 5 | -------------------------------------------------------------------------------- /XadesDemo/Templates/NsiCommonAsync/export-nsi-list-template.xml: -------------------------------------------------------------------------------- 1 |  2 | NSI 3 | -------------------------------------------------------------------------------- /XadesDemo/Templates/NsiCommonAsync/get-state-template.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /XadesDemo/Templates/is-request-header-template.xml: -------------------------------------------------------------------------------- 1 |  2 | -------------------------------------------------------------------------------- /XadesDemo/Templates/request-header-template.xml: -------------------------------------------------------------------------------- 1 |  2 | -------------------------------------------------------------------------------- /XadesDemo/Templates/soap-template.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /XadesDemo/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /examples/exportNsiItem error request.csv: -------------------------------------------------------------------------------- 1 | q1:exportNsiItemRequest/q1:RegistryNumber;q1:exportNsiItemRequest/q1:ModifiedAfter 2 | 22215;2014-06-07T14:18:40.403+04:00 3 | -------------------------------------------------------------------------------- /examples/exportNsiItem error response.csv: -------------------------------------------------------------------------------- 1 | ns4:AckRequest/ns4:Ack/ns4:MessageGUID;ns4:AckRequest/ns4:Ack/ns4:RequesterMessageGUID 2 | 9c0ee3b4-e79a-11e6-88b0-005056b6513d;e6f58201-1cb9-4458-9b4d-cda1bd646c4d 3 | -------------------------------------------------------------------------------- /examples/exportNsiItem get-state error response.csv: -------------------------------------------------------------------------------- 1 | ns13:getStateResult/ns4:RequestState;ns13:getStateResult/ns4:MessageGUID;ns13:getStateResult/ns4:ErrorMessage/ns4:ErrorCode;ns13:getStateResult/ns4:ErrorMessage/ns4:Description;ns13:getStateResult/ns4:ErrorMessage/ns4:StackTrace 2 | 3;9c0ee3b4-e79a-11e6-88b0-005056b6513d;INT016001;Справочник с реестровым номером 22215 не найден.;ru.lanit.hcs.integration.common.exception.OperationProcessorException at ru.lanit.hcs.integration.nsicommon.spring.processor.ExportNsiItemProcessor.process(ExportNsiItemProcessor.java:86) at ru.lanit.hcs.integration.nsicommon.spring.processor.ExportNsiItemProcessor.process(ExportNsiItemProcessor.java:28) at ru.lanit.hcs.integration.common.spring.mdp.OperationProcessorInvokerMDP.process(OperationProcessorInvokerMDP.java:295) at ru.lanit.hcs.integration.common.spring.mdp.OperationProcessorInvokerMDP.internalOnMessage(OperationProcessorInvokerMDP.java:174) at ru.lanit.hcs.integration.common.spring.mdp.OperationProcessorInvokerMDP.onMessage(OperationProcessorInvokerMDP.java:86) at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:746) at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:684) at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:651) at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:317) at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:255) at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1166) at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1158) at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1055) at java.lang.Thread.run(Thread.java:745) 3 | -------------------------------------------------------------------------------- /examples/exportNsiItem request.csv: -------------------------------------------------------------------------------- 1 | q1:exportNsiItemRequest/q1:RegistryNumber;q1:exportNsiItemRequest/q1:ModifiedAfter 2 | 225;2015-07-07T14:28:40.403+03:00 3 | -------------------------------------------------------------------------------- /examples/exportNsiItem response.csv: -------------------------------------------------------------------------------- 1 | ns4:AckRequest/ns4:Ack/ns4:MessageGUID;ns4:AckRequest/ns4:Ack/ns4:RequesterMessageGUID 2 | 15730299-e799-11e6-88b0-005056b6513d;f28b1bc5-642e-4442-8009-ac1b6950a504 3 | -------------------------------------------------------------------------------- /examples/exportNsiList response.csv: -------------------------------------------------------------------------------- 1 | ns4:AckRequest/ns4:Ack/ns4:MessageGUID;ns4:AckRequest/ns4:Ack/ns4:RequesterMessageGUID 2 | 49c7885e-e797-11e6-88b0-005056b6513d;c9ec86ca-93ed-451b-a5e4-aba9b33172d7 3 | -------------------------------------------------------------------------------- /examples/importInspectionPlan get-state response error.csv: -------------------------------------------------------------------------------- 1 | ns13:getStateResult/ns4:RequestState;ns13:getStateResult/ns4:MessageGUID;ns13:getStateResult/ns4:ErrorMessage/ns4:ErrorCode;ns13:getStateResult/ns4:ErrorMessage/ns4:Description 2 | 3;3f3c0a12-e7a8-11e6-88b0-005056b6513d;INT017023;"Год плана" и год "Начала проведения проверки" должны быть идентичными. 3 | -------------------------------------------------------------------------------- /examples/importInspectionPlan get-state response.csv: -------------------------------------------------------------------------------- 1 | ns13:getStateResult/ns4:RequestState;ns13:getStateResult/ns4:MessageGUID;ns13:getStateResult/ns13:CommonResult/ns4:GUID;ns13:getStateResult/ns13:CommonResult/ns4:TransportGUID;ns13:getStateResult/ns13:CommonResult/ns4:UpdateDate;ns13:getStateResult/ns13:CommonResult/ns4:GUID;ns13:getStateResult/ns13:CommonResult/ns4:TransportGUID;ns13:getStateResult/ns13:CommonResult/ns4:UpdateDate 2 | 3;f29ababe-e7a7-11e6-88b0-005056b6513d;8d27ccfb-20c5-46cb-a6ed-fab184306871;e7d71657-845c-46de-9e72-4b85efc483c2;2017-01-31T14:25:19.985+03:00;a587bf8e-3f8f-4716-8819-66fb428433e6;26b7d41b-ed73-46ed-b33d-a739f4810dcb;2017-01-31T14:25:19.959+03:00 3 | -------------------------------------------------------------------------------- /examples/importInspectionPlan request error.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Good-Samaritan/signature-demo-net/81ec74c924c6a61254f04835db4ccb804fa77f0c/examples/importInspectionPlan request error.csv -------------------------------------------------------------------------------- /examples/importInspectionPlan request.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Good-Samaritan/signature-demo-net/81ec74c924c6a61254f04835db4ccb804fa77f0c/examples/importInspectionPlan request.csv -------------------------------------------------------------------------------- /examples/importInspectionPlan response error.csv: -------------------------------------------------------------------------------- 1 | ns4:AckRequest/ns4:Ack/ns4:MessageGUID;ns4:AckRequest/ns4:Ack/ns4:RequesterMessageGUID 2 | 3f3c0a12-e7a8-11e6-88b0-005056b6513d;9da97ebd-9aaa-4d52-9aa6-0af585eb5518 3 | -------------------------------------------------------------------------------- /examples/importInspectionPlan response.csv: -------------------------------------------------------------------------------- 1 | ns4:AckRequest/ns4:Ack/ns4:MessageGUID;ns4:AckRequest/ns4:Ack/ns4:RequesterMessageGUID 2 | f29ababe-e7a7-11e6-88b0-005056b6513d;ce8920c1-40ec-4960-b6e1-ecff32d028ef 3 | -------------------------------------------------------------------------------- /examples/importMunicipalServices get-state response error.csv: -------------------------------------------------------------------------------- 1 | ns13:getStateResult/ns4:RequestState;ns13:getStateResult/ns4:MessageGUID;ns13:getStateResult/ns13:ImportResult/ns4:GUID;ns13:getStateResult/ns13:ImportResult/ns4:TransportGUID;ns13:getStateResult/ns13:ImportResult/ns4:Error/ns4:ErrorCode;ns13:getStateResult/ns13:ImportResult/ns4:Error/ns4:Description;ns13:getStateResult/ns13:ImportResult/ns4:Error/ns4:ErrorCode;ns13:getStateResult/ns13:ImportResult/ns4:Error/ns4:Description;ns13:getStateResult/ns13:ImportResult/ns4:Error/ns4:ErrorCode;ns13:getStateResult/ns13:ImportResult/ns4:Error/ns4:Description;ns13:getStateResult/ns13:ImportResult/ns4:Error/ns4:ErrorCode;ns13:getStateResult/ns13:ImportResult/ns4:Error/ns4:Description 2 | 3;858f1b30-e7af-11e6-88b0-005056b6513d;00000000-0000-0000-0000-000000000000;314a0bce-7ebf-442d-959c-ee110dd36454;INT002000;Значение в поле ElementGuid отсутствует в реестре.;INT016014;Не найден элемент справочника с уникальным идентификатором 00000000-0000-0000-0000-000000000000 в статусе «Активный»;INT002000;Значение в поле MunicipalResourceRef отсутствует в реестре.;INT002000;Значение в поле MunicipalServiceRef отсутствует в реестре. 3 | -------------------------------------------------------------------------------- /examples/importMunicipalServices request error.csv: -------------------------------------------------------------------------------- 1 | m:importMunicipalServicesRequest/m:ImportMainMunicipalService/m1:TransportGUID;m:importMunicipalServicesRequest/m:ImportMainMunicipalService/m:ElementGuid;m:importMunicipalServicesRequest/m:ImportMainMunicipalService/m:MunicipalServiceRef/m2:Code;m:importMunicipalServicesRequest/m:ImportMainMunicipalService/m:MunicipalServiceRef/m2:GUID;m:importMunicipalServicesRequest/m:ImportMainMunicipalService/m:MunicipalServiceRef/m2:Name;m:importMunicipalServicesRequest/m:ImportMainMunicipalService/m:GeneralNeeds;m:importMunicipalServicesRequest/m:ImportMainMunicipalService/m:MainMunicipalServiceName;m:importMunicipalServicesRequest/m:ImportMainMunicipalService/m:MunicipalResourceRef/m2:Code;m:importMunicipalServicesRequest/m:ImportMainMunicipalService/m:MunicipalResourceRef/m2:GUID;m:importMunicipalServicesRequest/m:ImportMainMunicipalService/m:MunicipalResourceRef/m2:Name;m:importMunicipalServicesRequest/m:ImportMainMunicipalService/m1:OKEI;m:importMunicipalServicesRequest/m:ImportMainMunicipalService/m:SortOrder 2 | {Util:RandomGuid};00000000-0000-0000-0000-000000000000;0;00000000-0000-0000-0000-000000000000;TestName;true;SomeName;0;00000000-0000-0000-0000-000000000000;TestName;002;a 3 | -------------------------------------------------------------------------------- /examples/importMunicipalServices response error.csv: -------------------------------------------------------------------------------- 1 | ns4:AckRequest/ns4:Ack/ns4:MessageGUID;ns4:AckRequest/ns4:Ack/ns4:RequesterMessageGUID 2 | 858f1b30-e7af-11e6-88b0-005056b6513d;a89d0d00-d22a-4432-863d-12657b3785f6 3 | -------------------------------------------------------------------------------- /examples/команды.txt: -------------------------------------------------------------------------------- 1 | NsiCommonAsync 2 | 3 | xades-demo.exe send -s NsiCommonAsync -m exportNsiList -o "exportNsiList response.csv" -a "sit:rZ_GG72XS^Vf55ZW" 4 | 5 | xades-demo.exe get-state -s NsiCommonAsync -g 1377f6ce-e78e-11e6-88b0-005056b6513d -o "exportNsiList get-state response.csv" -a "sit:rZ_GG72XS^Vf55ZW" 6 | 7 | xades-demo.exe send -s NsiCommonAsync -m exportNsiItem -c "exportNsiItem request.csv" -o "exportNsiItem response.csv" -a "sit:rZ_GG72XS^Vf55ZW" 8 | 9 | xades-demo.exe get-state -s NsiCommonAsync -g 15730299-e799-11e6-88b0-005056b6513d -o "exportNsiItem get-state response.csv" -a "sit:rZ_GG72XS^Vf55ZW" 10 | 11 | NsiCommonAsync Error 12 | 13 | xades-demo.exe send -s NsiCommonAsync -m exportNsiItem -c "exportNsiItem request error.csv" -o "exportNsiItem response error.csv" -a "sit:rZ_GG72XS^Vf55ZW" 14 | 15 | xades-demo.exe get-state -s NsiCommonAsync -g 9c0ee3b4-e79a-11e6-88b0-005056b6513d -o "exportNsiItem get-state response error.csv" -a "sit:rZ_GG72XS^Vf55ZW" 16 | 17 | InspectionPlanItem 18 | 19 | xades-demo.exe send -s Inspection -m importInspectionPlan -c "importInspectionPlan request.csv" -o "importInspectionPlan response.csv" -a "sit:rZ_GG72XS^Vf55ZW" 20 | 21 | xades-demo.exe get-state -s Inspection -g f29ababe-e7a7-11e6-88b0-005056b6513d -o "importInspectionPlan get-state response.csv" -a "sit:rZ_GG72XS^Vf55ZW" 22 | 23 | InspectionPlanItem Error 24 | 25 | xades-demo.exe send -s Inspection -m importInspectionPlan -c "importInspectionPlan request error.csv" -o "importInspectionPlan response error.csv" -a "sit:rZ_GG72XS^Vf55ZW" 26 | 27 | xades-demo.exe get-state -s Inspection -g 3f3c0a12-e7a8-11e6-88b0-005056b6513d -o "importInspectionPlan get-state response error.csv" -a "sit:rZ_GG72XS^Vf55ZW" 28 | 29 | NsiAsync with error: 30 | 31 | xades-demo.exe send -s NsiAsync -m importMunicipalServices -c "importMunicipalServices request error.csv" -o "importMunicipalServices response error.csv" -a "sit:rZ_GG72XS^Vf55ZW" 32 | 33 | xades-demo.exe get-state -s NsiAsync -g 858f1b30-e7af-11e6-88b0-005056b6513d -o "importMunicipalServices get-state response error.csv" -a "sit:rZ_GG72XS^Vf55ZW" --------------------------------------------------------------------------------