public TestHelper Request_new_redirect_url(PersonalIdentificationNumber signer)
        {
            var signerResponse      = _jobResponse.Signers.First(s => s.Identifier.IsSameAs(signer));
            var redirectUrlResponse = _directClient.RequestNewRedirectUrl(signerResponse).Result;

            return(this);
        }
        public void Can_create_job_with_multiple_signers()
        {
            var signer1 = new PersonalIdentificationNumber("12345678910");
            var signer2 = new PersonalIdentificationNumber("10987654321");

            _fixture.TestHelper
            .Create_direct_job(signer1, signer2);
            _fixture.TestHelper
            .Sign_job(signer1)
            .Get_status()
            .Expect_job_to_have_status(
                JobStatus.InProgress,
                ExpectedSignerStatus(signer1, SignatureStatus.Signed),
                ExpectedSignerStatus(signer2, SignatureStatus.Waiting)
                )
            .Get_XAdES(signer1)
            .Sign_job(signer2)
            .Get_status()
            .Expect_job_to_have_status(
                JobStatus.CompletedSuccessfully,
                ExpectedSignerStatus(signer1, SignatureStatus.Signed),
                ExpectedSignerStatus(signer2, SignatureStatus.Signed)
                )
            .Get_XAdES(signer2)
            .Confirm_status();
        }
        public async Task SpecifyingQueues()
        {
            ClientConfiguration clientConfiguration = null; // As initialized earlier
            var directClient = new DirectClient(clientConfiguration);

            var organizationNumber = "123456789";
            var sender             = new Sender(organizationNumber, new PollingQueue("CustomPollingQueue"));

            Document documentToSign = null; // As initialized earlier
            ExitUrls exitUrls       = null; // As initialized earlier

            var signer = new PersonalIdentificationNumber("00000000000");

            var job = new Job(
                documentToSign,
                new List <Signer> {
                new Signer(signer)
            },
                "SendersReferenceToSignatureJob",
                exitUrls,
                sender,
                StatusRetrievalMethod.Polling
                );

            await directClient.Create(job);

            var changedJob = await directClient.GetStatusChange(sender);
        }
        public void Can_request_new_redirect_url()
        {
            var signer = new PersonalIdentificationNumber("01048200229");

            _fixture.TestHelper
            .Create_direct_job(signer)
            .Request_new_redirect_url(signer)
            .Sign_job(signer);
        }
예제 #5
0
            public void Initializes_with_properties()
            {
                //Arrange
                var personalIdentificationNumber = new PersonalIdentificationNumber("01013300001");

                //Act
                var signer = new SignerStub(personalIdentificationNumber);

                //Assert
                Assert.True(personalIdentificationNumber.IsSameAs(signer.Identifier), $"Actual {nameof(PersonalIdentificationNumber)}  was not same as initialized value.");
            }
            public void Simple_constructor()
            {
                //Arrange
                var url    = new Uri("http://redirect.no");
                var signer = new PersonalIdentificationNumber("12345678910");

                //Act
                var reference = new RedirectReference(url, signer);

                //Assert
                Assert.Equal(url, reference.Url);
                Assert.Equal(signer, reference.Signer);
            }
        public void create_job_with_queue()
        {
            var signer          = new PersonalIdentificationNumber("12345678910");
            var senderWithQueue = new Sender(BringPublicOrganizationNumber, new PollingQueue("CustomDirectPollingQueue"));

            _fixture.TestHelper
            .Create_pollable_direct_job(senderWithQueue, signer)
            .Sign_job(signer)
            .Get_status_by_polling(senderWithQueue)
            .Expect_job_to_have_status(JobStatus.CompletedSuccessfully)
            .Get_status_by_polling(senderWithQueue)
            .Expect_job_to_have_status(JobStatus.NoChanges);
        }
            public void Returns_masked_personal_identification_number()
            {
                //Arrange
                var pin = "01013300001";
                var personalIdentificationNumber       = new PersonalIdentificationNumber(pin);
                var maskedPersonalIdentificationNumber = "010133*****";

                //Act
                var toString = personalIdentificationNumber.ToString();

                //Assert
                Assert.Contains(maskedPersonalIdentificationNumber, toString);
                Assert.DoesNotContain(pin, toString);
            }
        internal Signature(signature signature)
        {
            SignatureStatus   = new SignatureStatus(signature.status.Value);
            XadesReference    = signature.xadesurl == null ? null : new XadesReference(new Uri(signature.xadesurl));
            DateTimeForStatus = signature.status.since;

            if (signature.Item is notifications)
            {
                Identifier = new ContactInformation((notifications)signature.Item);
            }
            else if (signature.Item is string)
            {
                Identifier = new PersonalIdentificationNumber((string)signature.Item);
            }
        }
        public void Can_retrieve_status_by_polling()
        {
            var signer = new PersonalIdentificationNumber("12345678910");

            _fixture.TestHelper
            .Create_pollable_direct_job(_fixture.Sender, signer)
            .Sign_job(signer)
            .Get_status_by_polling(_fixture.Sender)
            .Expect_job_to_have_status(
                JobStatus.CompletedSuccessfully,
                ExpectedSignerStatus(signer, SignatureStatus.Signed)
                )
            .Get_XAdES(signer)
            .Get_PAdES()
            .Confirm_status();
        }
        public void Can_create_job_with_one_signer()
        {
            var signer = new PersonalIdentificationNumber("01048200229");

            _fixture.TestHelper
            .Create_direct_job(signer)
            .Sign_job(signer)
            .Get_status()
            .Expect_job_to_have_status(
                JobStatus.CompletedSuccessfully,
                ExpectedSignerStatus(signer, SignatureStatus.Signed)
                )
            .Get_XAdES(signer)
            .Get_PAdES()
            .Confirm_status();
        }
        public async Task PollForStatus()
        {
            ClientConfiguration clientConfiguration = null; // As initialized earlier
            var directClient = new DirectClient(clientConfiguration);

            Document documentToSign = null; // As initialized earlier
            ExitUrls exitUrls = null; // As initialized earlier

            var signer = new PersonalIdentificationNumber("12345678910");

            var job = new Job(
                documentToSign,
                new List<Signer> {new Signer(signer)},
                "SendersReferenceToSignatureJob",
                exitUrls,
                statusRetrievalMethod: StatusRetrievalMethod.Polling
                );

            await directClient.Create(job);

            var changedJob = await directClient.GetStatusChange();

            if (changedJob.Status == JobStatus.NoChanges)
            {
                // Queue is empty. Additional polling will result in blocking for a defined period.
            }

            // Repeat the above until signer signs the document

            changedJob = await directClient.GetStatusChange();

            if (changedJob.Status == JobStatus.CompletedSuccessfully)
            {
                // Get PAdES
            }

            if (changedJob.GetSignatureFrom(signer).SignatureStatus.Equals(SignatureStatus.Signed))
            {
                // Get XAdES
            }

            // Confirm status change to avoid receiving it again
            await directClient.Confirm(changedJob.References.Confirmation);
        }
        internal SignerResponse(directsignerresponse signerResponse)
        {
            switch (signerResponse.ItemElementName)
            {
            case ItemChoiceType1.personalidentificationnumber:
                Identifier = new PersonalIdentificationNumber(signerResponse.Item);
                break;

            case ItemChoiceType1.signeridentifier:
                Identifier = new CustomIdentifier(signerResponse.Item);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            RedirectUrl = new Uri(signerResponse.redirecturl);
            SignerUrl   = new Uri(signerResponse.href);
        }
 public RedirectReference(Uri url, PersonalIdentificationNumber signer)
 {
     Url    = url;
     Signer = signer;
 }
 public SignerStub(PersonalIdentificationNumber personalIdentificationNumber)
     : base(personalIdentificationNumber)
 {
 }
예제 #16
0
 public Signer(PersonalIdentificationNumber personalIdentificationNumber, Notifications notifications)
     : base(personalIdentificationNumber)
 {
     Notifications = notifications;
 }
예제 #17
0
 public Signer(PersonalIdentificationNumber personalIdentificationNumber, NotificationsUsingLookup notificationsUsingLookup)
     : base(personalIdentificationNumber)
 {
     NotificationsUsingLookup = notificationsUsingLookup;
 }