Ejemplo n.º 1
0
        public void TestVerifyWithSignersValidDocument()
        {
            DigitalSignatureServiceClient client = new DigitalSignatureServiceClientImpl(DSS_LOCATION);

            List<SignatureInfo> signers = client.VerifyWithSigners(validSignedDocument, "text/xml");
            Assert.NotNull(signers);

            foreach (SignatureInfo signer in signers)
            {
                Console.WriteLine("------------------------------------------");
                Console.WriteLine("Signer: " + signer.Signer.Subject);
                Console.WriteLine("Signing Time: " + signer.SigningTime);
                Console.WriteLine("Role: " + signer.Role);
                Console.WriteLine("------------------------------------------");
            }
        }
Ejemplo n.º 2
0
        public void TestVerifyValidDocumentSslNoTlsAuthn()
        {
            DigitalSignatureServiceClient client = new DigitalSignatureServiceClientImpl(DSS_LOCATION_SSL);
            client.ConfigureSsl(null);

            bool result = client.Verify(validSignedDocument, "text/xml");
            Assert.True(result);
        }
Ejemplo n.º 3
0
        public void TestVerifyValidDocumentValidTlsAuthn()
        {
            X509Certificate2 sslCertificate = new X509Certificate2(SSL_CERT_PATH);

            DigitalSignatureServiceClient client = new DigitalSignatureServiceClientImpl(DSS_LOCATION_SSL);
            client.ConfigureSsl(sslCertificate);

            bool result = client.Verify(validSignedDocument, "text/xml");
            Assert.True(result);
        }
Ejemplo n.º 4
0
 public void TestVerifyValidDocumentInvalidTlsAuthn()
 {
     X509Certificate2 invalidSslCertificate = new X509Certificate2(INVALID_SSL_CERT_PATH);
     DigitalSignatureServiceClient client = new DigitalSignatureServiceClientImpl(DSS_LOCATION_SSL);
     client.ConfigureSsl(invalidSslCertificate);
     try
     {
         client.Verify(validSignedDocument, "text/xml");
         Assert.Fail();
     }
     catch (SecurityNegotiationException e)
     {
         // expected
         Console.WriteLine("SystemException: " + e.Message);
     }
 }
Ejemplo n.º 5
0
        public void TestVerifyValidDocument()
        {
            DigitalSignatureServiceClient client = new DigitalSignatureServiceClientImpl(DSS_LOCATION);

            bool result = client.Verify(validSignedDocument, "text/xml");
            Assert.True(result);
        }
Ejemplo n.º 6
0
        public void TestVerifyInvalidSignatureDocument()
        {
            DigitalSignatureServiceClient client = new DigitalSignatureServiceClientImpl(DSS_LOCATION);

            try
            {
                client.Verify(invalidSignedDocument, "text/xml");
                Assert.Fail();
            }
            catch (SystemException e)
            {
                // expected
                Console.WriteLine("SystemException: " + e.Message);
            }
        }
Ejemplo n.º 7
0
        public void TestStoreAndRetrieve()
        {
            DigitalSignatureServiceClient client = new DigitalSignatureServiceClientImpl(DSS_LOCATION);

            // store
            StorageInfoDO storageInfo = client.Store(unsignedDocument, "text/xml");
            Assert.NotNull(storageInfo);
            Assert.NotNull(storageInfo.Artifact);
            Assert.NotNull(storageInfo.NotBefore);
            Assert.NotNull(storageInfo.NotAfter);

            // verify store
            Console.WriteLine("Artifact: " + storageInfo.Artifact);
            Console.WriteLine("NotBefore: " + storageInfo.NotBefore);
            Console.WriteLine("NotAfter: " + storageInfo.NotAfter);

            // retrieve
            byte[] resultDocument = client.Retrieve(storageInfo.Artifact);

            // verify retrieve
            Assert.NotNull(resultDocument);
            Assert.True(Arrays.AreEqual(unsignedDocument, resultDocument));
        }
Ejemplo n.º 8
0
 private DigitalSignatureServiceClient getClient()
 {
     DigitalSignatureServiceClient client = new DigitalSignatureServiceClientImpl(dssWSLocation);
     client.SetMaxReceivedMessageSize(maxReceivedMessageSize);
     client.SetLogging(true);
     return client;
 }