public ApolloTracingDiagnosticEventListener(
     TracingPreference tracingPreference  = TracingPreference.OnDemand,
     ITimestampProvider?timestampProvider = null)
 {
     _tracingPreference = tracingPreference;
     _timestampProvider = timestampProvider ?? new DefaultTimestampProvider();
 }
        public PostgreSqlTaskQueueConsumer(TaskQueueConsumerOptions options, ITimestampProvider timestampProvider)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            if (timestampProvider == null)
            {
                throw new ArgumentNullException(nameof(timestampProvider));
            }

            mOptions           = options;
            mTimestampProvider = timestampProvider;

            mSignalingConnectionString = options.ConnectionOptions
                                         .ConnectionString
                                         .DeriveSignalingConnectionString(options);

            mNotificationListener = new PostgreSqlTaskQueueNotificationListener(mSignalingConnectionString,
                                                                                options.Mapping.NewTaskNotificationChannelName);

            mNotificationListener.ListenerConnectionRestored +=
                HandleListenerConnectionRestored;
            mNotificationListener.NewTaskPosted +=
                HandleNewTaskUpdateReceived;
            mNotificationListener.ListenerTimedOutWhileWaiting +=
                HandleListenerTimedOut;

            mTaskDequeueSql      = GetTaskDequeueSql(options.Mapping);
            mTaskAcquireSql      = GetTaskAcquireSql(options.Mapping);
            mTaskResultUpdateSql = GetTaskResultUpdateSql(options.Mapping);
        }
Example #3
0
        internal static ID2LAppContext CreateAppContextUnderTest(ITimestampProvider timestampProvider = null)
        {
            timestampProvider = timestampProvider ?? new DefaultTimestampProvider();
            var factory = new D2LAppContextFactory(timestampProvider);

            return(factory.Create(TestConstants.APP_ID, TestConstants.APP_KEY));
        }
Example #4
0
        public static DbContext Audit(this DbContext context, ITimestampProvider timestampProvider = null, IPrincipal principal = null)
        {
            Ensure.NotNull(context, nameof(context));

            context.ChangeTracker.DetectChanges();

            var entries = context.ChangeTracker.Entries <IAuditable>()
                          .Where(x => x.State == EntityState.Added || x.State == EntityState.Modified || x.State == EntityState.Deleted);

            var timestamp = timestampProvider?.GetTimestamp() ?? DateTime.Now;
            var sign      = principal?.Identity?.Name;

            if (entries != null)
            {
                foreach (var entry in entries)
                {
                    switch (entry.State)
                    {
                    case EntityState.Added:
                        OnAdded(context, entry, timestamp, sign);
                        break;

                    case EntityState.Modified:
                        OnModified(context, entry, timestamp, sign);
                        break;

                    case EntityState.Deleted:
                        OnDeleted(context, entry, timestamp, sign);
                        break;
                    }
                }
            }

            return(context);
        }
        internal DefaultHttpMessageCryptoServiceWrapper(ITimestampProvider<string> timestampProvider)
        {
            var symmetricAlgorithm = new AES("secretKeyPassword", "initialVectorPassword");
            var hashAlgorithm = new HMACSHA512("hashKeyString");

            this.inner = new DefaultHttpMessageCryptoService(symmetricAlgorithm, hashAlgorithm, timestampProvider);
        }
        public SqliteQueryExecutor(QueryConfiguration configuration, Akka.Serialization.Serialization serialization, ITimestampProvider timestampProvider) 
            : base(configuration, serialization, timestampProvider)
        {
            ByTagSql = base.ByTagSql + " LIMIT @Take";

            CreateEventsJournalSql = $@"
                CREATE TABLE IF NOT EXISTS {configuration.FullJournalTableName} (
                    {configuration.OrderingColumnName} INTEGER PRIMARY KEY NOT NULL,
                    {configuration.PersistenceIdColumnName} VARCHAR(255) NOT NULL,
                    {configuration.SequenceNrColumnName} INTEGER(8) NOT NULL,
                    {configuration.IsDeletedColumnName} INTEGER(1) NOT NULL,
                    {configuration.ManifestColumnName} VARCHAR(255) NULL,
                    {configuration.TimestampColumnName} INTEGER NOT NULL,
                    {configuration.PayloadColumnName} BLOB NOT NULL,
                    {configuration.TagsColumnName} VARCHAR(2000) NULL,
                    UNIQUE ({configuration.PersistenceIdColumnName}, {configuration.SequenceNrColumnName})
                );";

            CreateMetaTableSql = $@"
                CREATE TABLE IF NOT EXISTS {configuration.FullMetaTableName} (
                    {configuration.PersistenceIdColumnName} VARCHAR(255) NOT NULL,
                    {configuration.SequenceNrColumnName} INTEGER(8) NOT NULL,
                    PRIMARY KEY ({configuration.PersistenceIdColumnName}, {configuration.SequenceNrColumnName})
                );";
        }
Example #7
0
		public NestWebService() {
			_deserializer = ServiceContainer.GetService<INestWebServiceDeserializer>();
			_sessionProvider = ServiceContainer.GetService<ISessionProvider>();
			_analyticsService = ServiceContainer.GetService<IAnalyticsService>();
			_webRequestProvider = ServiceContainer.GetService<IWebRequestProvider>();
			_timestampProvider = ServiceContainer.GetService<ITimestampProvider>();
		}
Example #8
0
 public NestWebService()
 {
     _deserializer       = ServiceContainer.GetService <INestWebServiceDeserializer>();
     _sessionProvider    = ServiceContainer.GetService <ISessionProvider>();
     _analyticsService   = ServiceContainer.GetService <IAnalyticsService>();
     _webRequestProvider = ServiceContainer.GetService <IWebRequestProvider>();
     _timestampProvider  = ServiceContainer.GetService <ITimestampProvider>();
 }
Example #9
0
        /// <summary>
        /// Creates a completer to extend messages with validation data and time-stamp.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The resulting completer add a time-stamp via the time-stamp authority and optionally revocation information to the message.
        /// It is illegal to call this method with B-Level since this would not change the message in any way.
        /// </para>
        /// </remarks>
        /// <param name="level">The required level the completer must produce: T-Level, LT-Level or LTA-Level</param>
        /// <param name="timestampProvider">The client of the time-stamp authority</param>
        /// <returns>The completer of the required level that will used the provided time-stamp authority client</returns>
        public static IDataCompleter Create(Level level, ITimestampProvider timestampProvider)
        {
            if (level == Level.B_Level) throw new NotSupportedException("Nothing to complete for B-level");
            if (timestampProvider == null) throw new ArgumentNullException("timestampProvider", "A time-stamp provider is required with this method");
            if ((level & Level.T_Level) != Level.T_Level) throw new ArgumentException("This method should be used for a level that requires time stamping");

            return new TripleWrapper(level, null, null, timestampProvider, null);
        }
 public ValidateDocumentScope(
     ApolloTracingResultBuilder builder,
     ITimestampProvider timestampProvider)
 {
     _builder           = builder;
     _timestampProvider = timestampProvider;
     _startTimestamp    = timestampProvider.NowInNanoseconds();
 }
 /// <summary>
 /// Constructs a D2LUserContext with the parameters provided
 /// </summary>
 /// <param name="timestampProvider">The system timestamp provider</param>
 /// <param name="appId">The D2L app ID</param>
 /// <param name="appKey">The D2L app key</param>
 /// <param name="userId">The D2L user ID to be used</param>
 /// <param name="userKey">The D2L user key to be used</param>
 /// <param name="apiHost">The host information of the server to make API calls to</param>
 internal D2LUserContext( ITimestampProvider timestampProvider, string appId, string appKey, string userId, string userKey, HostSpec apiHost )
 {
     m_appId = appId;
     m_appKey = appKey;
     m_userId = userId;
     m_userKey = userKey;
     m_apiHost = apiHost;
     m_timestampProvider = timestampProvider;
 }
 /// <summary>
 /// Constructs a D2LUserContext with the parameters provided
 /// </summary>
 /// <param name="timestampProvider">The system timestamp provider</param>
 /// <param name="appId">The D2L app ID</param>
 /// <param name="appKey">The D2L app key</param>
 /// <param name="userId">The D2L user ID to be used</param>
 /// <param name="userKey">The D2L user key to be used</param>
 /// <param name="apiHost">The host information of the server to make API calls to</param>
 internal D2LUserContext(ITimestampProvider timestampProvider, string appId, string appKey, string userId, string userKey, HostSpec apiHost)
 {
     m_appId             = appId;
     m_appKey            = appKey;
     m_userId            = userId;
     m_userKey           = userKey;
     m_apiHost           = apiHost;
     m_timestampProvider = timestampProvider;
 }
Example #13
0
        public DataContext(string nameOrConnectionString, ITimestampProvider timestampProvider, IPrincipal principal)
            : base(nameOrConnectionString)
        {
            _timestampProvider = timestampProvider;
            _principal         = principal;

            Configuration.ProxyCreationEnabled = false;
            Configuration.LazyLoadingEnabled   = false;
            Database.Log = log => System.Diagnostics.Debug.WriteLine(log);
        }
        private void RegisterEncryptedRoute(HttpConfiguration configuration, ITimestampProvider<string> timestampProvider)
        {
            // arrange.
            var cryptoHandler = new ServerCryptoHandler("secretKeyPassword", "initialVectorPassword", "hashKeyString", timestampProvider);
            var injection = new DelegatingHandler[] { new ServerMessageDumper(), cryptoHandler, new ServerMessageDumper() };
            var handler = HttpClientFactory.CreatePipeline(new HttpControllerDispatcher(configuration), injection);

            // register encrypted HTTP route.
            configuration.Routes.MapHttpRoute("Encrypted API", "api2/{controller}/{action}", null, null, handler);
        }
Example #15
0
        protected JournalDbEngine(ActorSystem system)
        {
            _system = system;

            Settings = new JournalSettings(system.Settings.Config.GetConfig(JournalConfigPath));
            QueryMapper = new DefaultJournalQueryMapper(_system.Serialization);
            TimestampProvider = CreateTimestampProvider();

            _pendingRequestsCancellation = new CancellationTokenSource();
        }
Example #16
0
 public static async Task CreateAuthorSignedPackageInSourceAsync(
     string packageSource,
     string packageName,
     string packageVersion,
     X509Certificate2 testCertificate,
     ITimestampProvider timestampProvider = null)
 {
     var package = CreateAuthorSignedPackage(packageName, packageVersion, testCertificate, timestampProvider);
     await SimpleTestPackageUtility.CreatePackagesAsync(packageSource, package);
 }
Example #17
0
        protected JournalDbEngine(ActorSystem system)
        {
            _system = system;

            Settings          = new JournalSettings(system.Settings.Config.GetConfig(JournalConfigPath));
            QueryMapper       = new DefaultJournalQueryMapper(_system.Serialization);
            TimestampProvider = CreateTimestampProvider();

            _pendingRequestsCancellation = new CancellationTokenSource();
        }
        public MockTaskQueueConsumer(int numberOfTasks, ITimestampProvider timeProvider)
        {
            //TODO: also add task type
            mQueueDepletedTaskCompletionSource = new TaskCompletionSource <bool>();
            mQueueDepletedHandle = mQueueDepletedTaskCompletionSource.Task;

            mNumberOfTasks      = numberOfTasks;
            mRemainingTaskCount = numberOfTasks;
            mTimeProvider       = timeProvider;
        }
 public MonitorSettings(string index,string type,string timestampField,int pollingInterval = 2000, int maxUpdateCount = 100, bool includeSource = true,ITimestampProvider timestampProvider = null)
 {
     if(timestampProvider == null) TimestampProvider = new TimestampProvider();
     IncludeSource = includeSource;
     MaxUpdateCount = maxUpdateCount;
     PollingInverval = pollingInterval;
     Index = index;
     Type = type;
     TimstampField = timestampField;
 }
 public ResolveFieldValueScope(
     IMiddlewareContext context,
     ApolloTracingResultBuilder builder,
     ITimestampProvider timestampProvider)
 {
     _context           = context;
     _builder           = builder;
     _timestampProvider = timestampProvider;
     _startTimestamp    = timestampProvider.NowInNanoseconds();
 }
Example #21
0
        internal TripleWrapper(Level level, X509Certificate2 authentication, X509Certificate2 signature, ITimestampProvider timestampProvider, X509Certificate2Collection extraStore)
        {
            //basic checks
            if (level == Level.L_Level || level == Level.A_level) throw new ArgumentException("level", "Only levels B, T, LT and LTA are allowed");

            this.level = level;
            this.signature = signature;
            this.authentication = authentication;
            this.timestampProvider = timestampProvider;
            this.extraStore = extraStore;
        }
        /// <summary>
        /// Timestamps a signature for tests.
        /// </summary>
        /// <param name="timestampProvider">Timestamp provider.</param>
        /// <param name="signatureRequest">SignPackageRequest containing metadata for timestamp request.</param>
        /// <param name="signature">Signature that needs to be timestamped.</param>
        /// <param name="logger">ILogger.</param>
        /// <returns>Timestamped Signature.</returns>
        public static Task <Signature> TimestampSignature(ITimestampProvider timestampProvider, SignPackageRequest signatureRequest, Signature signature, ILogger logger)
        {
            var timestampRequest = new TimestampRequest
            {
                SignatureValue         = signature.GetBytes(),
                SigningSpec            = SigningSpecifications.V1,
                TimestampHashAlgorithm = signatureRequest.TimestampHashAlgorithm
            };

            return(TimestampSignature(timestampProvider, timestampRequest, signature, logger));
        }
 public RequestScope(
     IRequestContext context,
     DateTime startTime,
     ApolloTracingResultBuilder builder,
     ITimestampProvider timestampProvider)
 {
     _context           = context;
     _startTime         = startTime;
     _builder           = builder;
     _timestampProvider = timestampProvider;
 }
        private void RegisterTimestampRoute(HttpConfiguration configuration, ITimestampProvider<string> timestampProvider)
        {
            // arrange.
            var timestampHandler = new HttpTimestampHandler<string>(timestampProvider);
            //var injection = new DelegatingHandler[] { new ServerMessageDumper() };
            //var handler = HttpClientFactory.CreatePipeline(timestampHandler, injection);
            var handler = timestampHandler;

            // register timestamp route.
            configuration.Routes.MapHttpRoute("Timestamp Route", "api3/!timestamp!/get", null, null, handler);
        }
Example #25
0
        public static void InitializeClass(TestContext ctx)
        {
            //Bob as decryption
            bobEtk = new EncryptionToken(Utils.ReadFully("bob/bobs_public_key.etk"));

            //Bob (and Alice) used for decryption
            alice = new EHealthP12("alice/alices_private_key_store.p12", "test");
            bob   = new EHealthP12("bob/bobs_private_key_store.p12", "test");

            //create a tsa (fedict in this case)
            tsa = new Rfc3161TimestampProvider();
        }
        /// <summary>
        /// Generates a Signature for a package.
        /// </summary>
        /// <param name="testCert">Certificate to be used while generating the signature.</param>
        /// <param name="packageStream">Package stream for which the signature has to be generated.</param>
        /// <param name="timestampProvider">An optional timestamp provider.</param>
        /// <returns>Signature for the package.</returns>
        public static async Task <PrimarySignature> CreateAuthorSignatureForPackageAsync(
            X509Certificate2 testCert,
            Stream packageStream,
            ITimestampProvider timestampProvider = null)
        {
            var hashAlgorithm = HashAlgorithmName.SHA256;

            using (var request = new AuthorSignPackageRequest(testCert, hashAlgorithm))
                using (var package = new PackageArchiveReader(packageStream, leaveStreamOpen: true))
                {
                    return(await CreatePrimarySignatureForPackageAsync(package, request, timestampProvider));
                }
        }
Example #27
0
        /// <summary>
        /// Constructor expecting resources needed to perform transmission using AS2. All task required to be done once for
        /// all requests using this instance is done here.
        /// </summary>
        public As2MessageSender(
            X509Certificate certificate,
            SMimeMessageFactory sMimeMessageFactory,
            ITimestampProvider timestampProvider,
            Func <HyperwaySecureMimeContext> secureMimeContext)
        {
            this.sMimeMessageFactory = sMimeMessageFactory;
            this.timestampProvider   = timestampProvider;
            this.secureMimeContext   = secureMimeContext;

            // Establishes our AS2 System Identifier based upon the contents of the CN= field of the certificate
            this.fromIdentifier = CertificateUtils.ExtractCommonName(certificate);
        }
Example #28
0
        /// <summary>
        /// Timestamps a signature for tests.
        /// </summary>
        /// <param name="timestampProvider">Timestamp provider.</param>
        /// <param name="signatureRequest">SignPackageRequest containing metadata for timestamp request.</param>
        /// <param name="signature">Signature that needs to be timestamped.</param>
        /// <param name="logger">ILogger.</param>
        /// <returns>Timestamped Signature.</returns>
        public static Task <PrimarySignature> TimestampPrimarySignature(ITimestampProvider timestampProvider, SignPackageRequest signatureRequest, PrimarySignature signature, ILogger logger)
        {
            var signatureValue = signature.GetSignatureValue();
            var messageHash    = signatureRequest.TimestampHashAlgorithm.ComputeHash(signatureValue);

            var timestampRequest = new TimestampRequest(
                signingSpecifications: SigningSpecifications.V1,
                hashedMessage: messageHash,
                hashAlgorithm: signatureRequest.TimestampHashAlgorithm,
                target: SignaturePlacement.PrimarySignature
                );

            return(TimestampPrimarySignature(timestampProvider, timestampRequest, signature, logger));
        }
Example #29
0
        public static async Task Delete <T>(Table <T> table, ITimestampProvider timestampProvider, Condition[] filters)
        {
            var query   = BuildReadQuery(table, filters);
            var results = (await query.ExecuteAsync().ConfigureAwait(false)).ToArray();

            if (results.Length != 1)
            {
                throw new InvalidOperationException($"Expected results count to be 1 but was {results.Length}");
            }

            var timestamp = await timestampProvider.GetTimestamp(table.Name).ConfigureAwait(false);

            await query.Delete().SetTimestamp(timestamp).ExecuteAsync().ConfigureAwait(false);
        }
        public PostgreSqlTaskQueueInfo(TaskQueueInfoOptions options, ITimestampProvider timestampProvider)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            if (timestampProvider == null)
            {
                throw new ArgumentNullException(nameof(timestampProvider));
            }

            mOptions           = options;
            mTimestampProvider = timestampProvider;
        }
Example #31
0
        public App(DataContext dataContext, IStringWriter writer, ITimestampProvider timestampProvider)
        {
            if (dataContext == null)
            {
                throw new ArgumentNullException(nameof(dataContext));
            }
            if (writer == null)
            {
                throw new ArgumentNullException(nameof(writer));
            }

            _dataContext = dataContext;
            _writer      = writer;
        }
Example #32
0
        public static void InitializeClass(TestContext ctx)
        {
            //sign with generated key
            key = new WebKey(RSA.Create());

            //Bob as decryption
            bobEtk = new EncryptionToken(File.ReadAllBytes("bob/bobs_public_key.etk"));

            //Bob (and Alice) used for decryption
            alice = new EHealthP12("alice/alices_private_key_store.p12", "test");
            bob   = new EHealthP12("bob/bobs_private_key_store.p12", "test");

            //create a tsa (fedict in this case)
            tsa = new Rfc3161TimestampProvider();
        }
Example #33
0
        public static SimpleTestPackageContext CreateAuthorSignedPackage(
            string packageName,
            string packageVersion,
            X509Certificate2 testCertificate,
            ITimestampProvider timestampProvider = null)
        {
            var package = CreatePackage(packageName, packageVersion);

            package.IsPrimarySigned             = true;
            package.PrimarySignatureCertificate = testCertificate;

            package.TimestampProvider = timestampProvider;

            return(package);
        }
Example #34
0
        /// <summary>
        /// Adds a Repository countersignature to a given primary signature
        /// </summary>
        /// <param name="testCert">Certificate to be used while generating the countersignature.</param>
        /// <param name="primarySignature">Primary signature to add countersignature.</param>
        /// <param name="timestampProvider">An optional timestamp provider.</param>
        /// <returns></returns>
        public static async Task <PrimarySignature> RepositoryCountersignPrimarySignatureAsync(
            X509Certificate2 testCert,
            PrimarySignature primarySignature,
            ITimestampProvider timestampProvider = null)
        {
            var testLogger        = new TestLogger();
            var hashAlgorithm     = HashAlgorithmName.SHA256;
            var v3ServiceIndexUrl = new Uri("https://v3serviceIndex.test/api/index.json");

            using (var request = new RepositorySignPackageRequest(testCert, hashAlgorithm, hashAlgorithm, v3ServiceIndexUrl, null))
            {
                var testSignatureProvider = new X509SignatureProvider(timestampProvider);

                return(await testSignatureProvider.CreateRepositoryCountersignatureAsync(request, primarySignature, testLogger, CancellationToken.None));
            }
        }
Example #35
0
        public PostgreSqlTaskQueueProducer(TaskQueueOptions options, ITimestampProvider timestampProvider)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            if (timestampProvider == null)
            {
                throw new ArgumentNullException(nameof(timestampProvider));
            }

            mOptions           = options;
            mTimestampProvider = timestampProvider;

            mInsertSql            = GetInsertSql(mOptions.Mapping);
            mAddOrUpdateResultSql = GetInsertOrUpdateResultSql(mOptions.Mapping);
        }
Example #36
0
        IDataSealer Create(Level level, ITimestampProvider timestampProvider, WebKey key)
        {
            if (timestampProvider == null)
            {
                throw new ArgumentNullException("timestampProvider", "A time-stamp provider is required with this method");
            }
            if ((level & Level.T_Level) != Level.T_Level)
            {
                throw new ArgumentException("This method should for a level that requires time stamping");
            }

            return(new TripleWrapper(
#if !NETFRAMEWORK
                       _loggerFactory,
#endif
                       level, key, timestampProvider));
        }
Example #37
0
        public As2InboundHandler(
            ITimestampProvider timestampProvider,
            ICertificateValidator certificateValidator,
            IPersisterHandler persisterHandler,
            ITransmissionVerifier transmissionVerifier,
            SMimeMessageFactory sMimeMessageFactory,
            Func <HyperwaySecureMimeContext> secureContextFactory)
        {
            this.timestampProvider    = timestampProvider;
            this.certificateValidator = certificateValidator;

            this.persisterHandler     = persisterHandler;
            this.transmissionVerifier = transmissionVerifier;

            this.sMimeMessageFactory  = sMimeMessageFactory;
            this.secureContextFactory = secureContextFactory;
        }
        /// <summary>
        /// Generates a Signature for a given package for tests.
        /// </summary>
        /// <param name="package">Package to be used for the signature.</param>
        /// <param name="request">Sign package request for primary signature</param>
        /// <param name="timestampProvider">Provider to add timestamp to package. Defaults to null.</param>
        /// <returns>Signature for the package.</returns>
        public static async Task <PrimarySignature> CreatePrimarySignatureForPackageAsync(
            PackageArchiveReader package,
            SignPackageRequest request,
            ITimestampProvider timestampProvider = null)
        {
            Assert.False(await package.IsSignedAsync(CancellationToken.None));

            var testLogger        = new TestLogger();
            var signatureProvider = new X509SignatureProvider(timestampProvider);

            var zipArchiveHash = await package.GetArchiveHashAsync(request.SignatureHashAlgorithm, CancellationToken.None);

            var base64ZipArchiveHash = Convert.ToBase64String(zipArchiveHash);
            var signatureContent     = new SignatureContent(SigningSpecifications.V1, request.SignatureHashAlgorithm, base64ZipArchiveHash);

            return(await signatureProvider.CreatePrimarySignatureAsync(request, signatureContent, testLogger, CancellationToken.None));
        }
Example #39
0
        internal TripleWrapper(
#if !NETFRAMEWORK
            ILoggerFactory loggerFactory,
#endif
            Level level, WebKey ownWebKey, ITimestampProvider timestampProvider)
        {
            if (level == Level.L_Level || level == Level.A_level)
            {
                throw new ArgumentException("level", "Only levels B, T, LT and LTA are allowed");
            }

#if !NETFRAMEWORK
            logger = loggerFactory.CreateLogger("Egelke.EHealth.Etee");
#endif
            this.level             = level;
            this.ownWebKey         = ownWebKey;
            this.timestampProvider = timestampProvider;
        }
Example #40
0
        IDataSealer Create(Level level, ITimestampProvider timestampProvider, X509Certificate2 authSign, X509Certificate2 nonRepSign = null)
        {
            ValidateCertificates(authSign, nonRepSign);
            if (timestampProvider == null)
            {
                throw new ArgumentNullException("timestampProvider", "A time-stamp provider is required with this method");
            }
            if ((level & Level.T_Level) != Level.T_Level)
            {
                throw new ArgumentException("This method should for a level that requires time stamping");
            }

            return(new TripleWrapper(
#if !NETFRAMEWORK
                       _loggerFactory,
#endif
                       level, authSign, nonRepSign, timestampProvider, null));
        }
        public DefaultHttpMessageCryptoService(ISymmetricAlgorithm symmetricAlgorithm, IHashAlgorithm hashAlgorithm, ITimestampProvider<string> timestampProvider)
        {
            if (symmetricAlgorithm == null)
            {
                throw new ArgumentNullException("symmetricAlgorithm");
            }

            if (hashAlgorithm == null)
            {
                throw new ArgumentNullException("hashAlgorithm");
            }

            if (timestampProvider == null)
            {
                throw new ArgumentNullException("timestampProvider");
            }

            this.symmetricAlgorithm = symmetricAlgorithm;
            this.hashAlgorithm = hashAlgorithm;
            this.timestampProvider = timestampProvider;
        }
Example #42
0
 public MessagePusher(ITimestampProvider timestamps, IPusherProvider pusher)
 {
     _timestamps = timestamps;
     _pusher = pusher;
 }
Example #43
0
        public static void InitializeClass()
        {
            //Bob as decryption
            bobEtk = new EncryptionToken(Utils.ReadFully("../../bob/bobs_public_key.etk"));

            //Bob (and Alice) used for decryption
            alice = new EHealthP12("../../alice/alices_private_key_store.p12", "test");
            bob = new EHealthP12("../../bob/bobs_private_key_store.p12", "test");

            //create a tsa (fedict in this case)
            tsa = new Rfc3161TimestampProvider();
        }
Example #44
0
        public static IDataSealer Create(Level level, ITimestampProvider timestampProvider, EHealthP12 p12)
        {
            ValidateCertificates(p12["authentication"]);
            if (timestampProvider == null) throw new ArgumentNullException("timestampProvider", "A time-stamp provider is required with this method");
            if ((level & Level.T_Level) != Level.T_Level) throw new ArgumentException("This method should for a level that requires time stamping");

            return new TripleWrapper(level, p12["authentication"], null, timestampProvider, p12.ToCollection());
        }
Example #45
0
        protected AbstractQueryExecutor(QueryConfiguration configuration, Akka.Serialization.Serialization serialization, ITimestampProvider timestampProvider)
        {
            TimestampProvider = timestampProvider;
            Serialization = serialization;
            Configuration = configuration;

            var allEventColumnNames = $@"
                e.{Configuration.PersistenceIdColumnName} as PersistenceId, 
                e.{Configuration.SequenceNrColumnName} as SequenceNr, 
                e.{Configuration.TimestampColumnName} as Timestamp, 
                e.{Configuration.IsDeletedColumnName} as IsDeleted, 
                e.{Configuration.ManifestColumnName} as Manifest, 
                e.{Configuration.PayloadColumnName} as Payload";

            AllPersistenceIdsSql = $@"
                SELECT DISTINCT e.{Configuration.PersistenceIdColumnName} as PersistenceId 
                FROM {Configuration.FullJournalTableName} e;";

            HighestSequenceNrSql = $@"
                SELECT MAX(u.SeqNr) as SequenceNr 
                FROM (
                    SELECT e.{Configuration.SequenceNrColumnName} as SeqNr FROM {Configuration.FullJournalTableName} e WHERE e.{Configuration.PersistenceIdColumnName} = @PersistenceId
                    UNION
                    SELECT m.{Configuration.SequenceNrColumnName} as SeqNr FROM {Configuration.FullMetaTableName} m WHERE m.{Configuration.PersistenceIdColumnName} = @PersistenceId) as u";

            DeleteBatchSql = $@"
                DELETE FROM {Configuration.FullJournalTableName} 
                WHERE {Configuration.PersistenceIdColumnName} = @PersistenceId AND {Configuration.SequenceNrColumnName} <= @ToSequenceNr;";

            UpdateSequenceNrSql = $@"
                INSERT INTO {Configuration.FullMetaTableName} ({Configuration.PersistenceIdColumnName}, {Configuration.SequenceNrColumnName}) 
                VALUES (@PersistenceId, @SequenceNr);";

            ByPersistenceIdSql =
                $@"
                SELECT {allEventColumnNames}
                FROM {Configuration.FullJournalTableName} e
                WHERE e.{Configuration.PersistenceIdColumnName} = @PersistenceId
                AND e.{Configuration.SequenceNrColumnName} BETWEEN @FromSequenceNr AND @ToSequenceNr;";

            ByTagSql =
                $@"
                SELECT {allEventColumnNames}, e.{Configuration.OrderingColumnName} as Ordering
                FROM {Configuration.FullJournalTableName} e
                WHERE e.{Configuration.OrderingColumnName} > @Ordering AND e.{Configuration.TagsColumnName} LIKE @Tag
                ORDER BY {Configuration.OrderingColumnName} ASC";

            InsertEventSql = $@"
                INSERT INTO {Configuration.FullJournalTableName} (
                    {Configuration.PersistenceIdColumnName},
                    {Configuration.SequenceNrColumnName},
                    {Configuration.TimestampColumnName},
                    {Configuration.IsDeletedColumnName},
                    {Configuration.ManifestColumnName},
                    {Configuration.PayloadColumnName},
                    {Configuration.TagsColumnName}
                ) VALUES (
                    @PersistenceId, 
                    @SequenceNr,
                    @Timestamp,
                    @IsDeleted,
                    @Manifest,
                    @Payload,
                    @Tag
                )";

            QueryEventsSql = $@"
                SELECT {allEventColumnNames}
                FROM {Configuration.FullJournalTableName} e
                WHERE ";
        }
 /// <summary>
 /// Default constructor for D2LAppContextFactory
 /// </summary>
 public D2LAppContextFactory( ITimestampProvider timestampProvider = null )
 {
     m_timestampProvider = timestampProvider ?? new DefaultTimestampProvider();
 }
 internal D2LAppContext( string appId, string appKey, ITimestampProvider timestampProvider )
 {
     m_appId = appId;
     m_appKey = appKey;
     m_timestampProvider = timestampProvider;
 }
 internal static ID2LAppContext CreateAppContextUnderTest( ITimestampProvider timestampProvider = null )
 {
     timestampProvider = timestampProvider ?? new DefaultTimestampProvider();
     var factory = new D2LAppContextFactory( timestampProvider );
     return factory.Create( TestConstants.APP_ID, TestConstants.APP_KEY );
 }
Example #49
0
        /// <summary>
        /// Creates an instance of the <see cref="IDataSealer"/> interface suitable for all levels except for B-Level.
        /// </summary>
        /// <remarks>
        /// Uses a time-stamp authority to indicate the time when the message was created. See the eH-I TSA module for possible implementation of existing authorities.
        /// See the message definition for which authority must be used if any, the eH-I TSA module provides clients for both eHealth and Fedict but can be extended to any
        /// authority that returns compliant time-stamp-tokens.
        /// </remarks>
        /// <param name="level">The level of the sealing, only B-Level is allowed (parameter present for awareness)</param>
        /// <param name="timestampProvider">The client of the time-stamp authority</param>
        /// <seealso cref="Create(X509Certificate2, X509Certificate2, Level)"/>
        public static IDataSealer Create(Level level, ITimestampProvider timestampProvider, TimeSpan timeout)
        {
            X509Certificate2 authentication;
            X509Certificate2 signature;
            GetCertificates(timeout, out authentication, out signature);
            if (timestampProvider == null) throw new ArgumentNullException("timestampProvider", "A time-stamp provider is required with this method");
            if ((level & Level.T_Level) != Level.T_Level) throw new ArgumentException("This method should for a level that requires time stamping");

            return new TripleWrapper(level, authentication, signature, timestampProvider, null);
        }
Example #50
0
        /// <summary>
        /// Creates an instance of the <see cref="IDataSealer"/> interface suitable for all levels except for B-Level.
        /// </summary>
        /// <remarks>
        /// Uses a time-stamp authority to indicate the time when the message was created. See the eH-I TSA module for possible implementation of existing authorities.
        /// See the message definition for which authority must be used if any, the eH-I TSA module provides clients for both eHealth and Fedict but can be extended to any
        /// authority that returns compliant time-stamp-tokens.
        /// </remarks>
        /// <param name="authSign">The eHealth certificate to use for proving the origin of the message.  The certificate key must be <strong>exportable</strong>!</param>
        /// <param name="level">The level of the sealing, only B-Level is allowed (parameter present for awareness)</param>
        /// <param name="timestampProvider">The client of the time-stamp authority</param>
        /// <seealso cref="Create(X509Certificate2, X509Certificate2, Level)"/>
        public static IDataSealer Create(Level level, ITimestampProvider timestampProvider, X509Certificate2 authSign)
        {
            ValidateCertificates(authSign);
            ValidateAnyCertificates(authSign);
            if (timestampProvider == null) throw new ArgumentNullException("timestampProvider", "A time-stamp provider is required with this method");
            if ((level & Level.T_Level) != Level.T_Level) throw new ArgumentException("This method should for a level that requires time stamping");

            return new TripleWrapper(level, authSign, null, timestampProvider, null);
        }