internal static IPrivateKeyProvider Create(
				IPublicKeyDataProvider publicKeyDataProvider,
				TimeSpan keyLifetime,
				TimeSpan keyRotationPeriod,
				IDateTimeProvider dateTimeProvider = null
			) {
				if( keyLifetime < keyRotationPeriod ) {
					throw new ArgumentException( "Private key lifetime must exceed the rotation period", "keyLifetime" );
				}

				dateTimeProvider = dateTimeProvider ?? new DateTimeProvider();

				ID2LSecurityTokenFactory d2lSecurityTokenFactory = new D2LSecurityTokenFactory(
					dateTimeProvider,
					keyLifetime
				);

				IPrivateKeyProvider privateKeyProvider = new RsaPrivateKeyProvider(
					d2lSecurityTokenFactory
				);

				privateKeyProvider = new SavingPrivateKeyProvider(
					privateKeyProvider,
					PublicKeyDataProviderFactory.CreateInternal( publicKeyDataProvider )
				);

				privateKeyProvider = new RotatingPrivateKeyProvider(
					privateKeyProvider,
					dateTimeProvider,
					keyRotationPeriod
				);

				return privateKeyProvider;
			}
Beispiel #2
0
            internal static IPrivateKeyProvider Create(
                IPublicKeyDataProvider publicKeyDataProvider,
                TimeSpan keyLifetime,
                TimeSpan keyRotationPeriod,
                CngAlgorithm algorithm,
                IDateTimeProvider dateTimeProvider = null
                )
            {
                if (keyLifetime < keyRotationPeriod)
                {
                    throw new ArgumentException("Private key lifetime must exceed the rotation period", "keyLifetime");
                }

                dateTimeProvider = dateTimeProvider ?? DateTimeProvider.Instance;

                ID2LSecurityTokenFactory d2lSecurityTokenFactory = new D2LSecurityTokenFactory(
                    dateTimeProvider,
                    keyLifetime
                    );

                IPrivateKeyProvider privateKeyProvider = new EcDsaPrivateKeyProvider(
                    d2lSecurityTokenFactory,
                    algorithm
                    );

                privateKeyProvider = new SavingPrivateKeyProvider(
                    privateKeyProvider,
                    PublicKeyDataProviderFactory.CreateInternal(publicKeyDataProvider)
                    );

                privateKeyProvider = new RotatingPrivateKeyProvider(
                    privateKeyProvider,
                    dateTimeProvider,
                    keyRotationPeriod
                    );

                return(privateKeyProvider);
            }