Exemple #1
0
        private static KsiService GetKsiService()
        {
            TestKsiServiceProtocol protocol = new TestKsiServiceProtocol();

            return(new KsiService(protocol, new ServiceCredentials("test", "test", HashAlgorithm.Sha2256), protocol, new ServiceCredentials("test", "test", HashAlgorithm.Sha2256),
                                  protocol,
                                  new PublicationsFileFactory(
                                      new PkiTrustStoreProvider(new X509Store(StoreName.Root),
                                                                CryptoTestFactory.CreateCertificateSubjectRdnSelector("[email protected]")))));
        }
Exemple #2
0
        public void BeginGetExtenderConfigWithoutExtendingServiceCredentials()
        {
            TestKsiServiceProtocol protocol = new TestKsiServiceProtocol();
            KsiService             service  = new KsiService(null, null, protocol, null, null, null);

            KsiServiceException ex = Assert.Throws <KsiServiceException>(delegate
            {
                service.BeginGetExtenderConfig(null, null);
            });

            Assert.That(ex.Message.StartsWith("Extending service credentials are missing."), "Unexpected exception message: " + ex.Message);
        }
Exemple #3
0
        public void BeginSignWithHashNullTest()
        {
            TestKsiServiceProtocol protocol = new TestKsiServiceProtocol();
            KsiService             service  = new KsiService(protocol, new ServiceCredentials(TestConstants.ServiceUser, TestConstants.ServicePass), null, null, null, null);

            ArgumentNullException ex = Assert.Throws <ArgumentNullException>(delegate
            {
                service.BeginSign(null, null, null);
            });

            Assert.AreEqual("hash", ex.ParamName);
        }
Exemple #4
0
        public void BeginSignWithoutSigningServiceCredentials()
        {
            TestKsiServiceProtocol protocol = new TestKsiServiceProtocol();
            KsiService             service  = new KsiService(protocol, null, null, null, null, null);

            KsiServiceException ex = Assert.Throws <KsiServiceException>(delegate
            {
                service.BeginSign(new DataHash(Base16.Decode("0111A700B0C8066C47ECBA05ED37BC14DCADB238552D86C659342D1D7E87B8772D")), null, null);
            });

            Assert.That(ex.Message.StartsWith("Signing service credentials are missing."), "Unexpected exception message: " + ex.Message);
        }
Exemple #5
0
 protected static IKsiService GetStaticKsiService(TestKsiServiceProtocol protocol, ulong requestId = 0,
                                                  PduVersion pduVersion             = PduVersion.v2,
                                                  HashAlgorithm signingMacAlgorithm = null, HashAlgorithm extendingMacAlgorithm = null)
 {
     return
         (new TestKsiService(
              protocol,
              new ServiceCredentials(TestConstants.ServiceUser, TestConstants.ServicePass, signingMacAlgorithm),
              protocol,
              new ServiceCredentials(TestConstants.ServiceUser, TestConstants.ServicePass, extendingMacAlgorithm),
              protocol,
              new PublicationsFileFactory(
                  new PkiTrustStoreProvider(new X509Store(StoreName.Root),
                                            CryptoTestFactory.CreateCertificateSubjectRdnSelector("[email protected]"))), requestId, pduVersion));
 }
Exemple #6
0
 public TestKsiService(TestKsiServiceProtocol signingServiceProtocol,
                       IServiceCredentials signingServiceCredentials,
                       TestKsiServiceProtocol extendingServiceProtocol,
                       IServiceCredentials extendingServiceCredentials,
                       TestKsiServiceProtocol publicationsFileServiceProtocol,
                       IPublicationsFileFactory publicationsFileFactory,
                       ulong requestId,
                       PduVersion pduVersion)
     :
     base(signingServiceProtocol,
          signingServiceCredentials,
          extendingServiceProtocol,
          extendingServiceCredentials,
          publicationsFileServiceProtocol,
          publicationsFileFactory,
          pduVersion)
 {
     SigningServiceProtocol   = signingServiceProtocol;
     ExtendingServiceProtocol = extendingServiceProtocol;
     RequestId = requestId;
 }