internal static XmlElement CreateAuthnRequestContainer( string merchantReference, string merchantId, string returnUrl, ServiceIds serviceIds) { var authnRequest = new AuthnRequest { Id = merchantReference, IssueInstant = DateTimeOffset.Now.ToString( IdinConstants.IdinDateTimeFormat, CultureInfo.InvariantCulture), Issuer = merchantId, AssertionConsumerServiceUrl = returnUrl, AttributeConsumingServiceIndex = (uint)serviceIds, RequestedAuthnContext = new RequestedAuthnContext(), }; var namespaces = new XmlSerializerNamespaces(); namespaces.Add("samlp", SamlNamespaces.Protocol); namespaces.Add(SamlConstants.Prefix, SamlNamespaces.Assertion); var doc = new XmlDocument(); var nav = doc.CreateNavigator(); using (var writer = nav.AppendChild()) { var serializer = new XmlSerializer(typeof(AuthnRequest)); serializer.Serialize(writer, authnRequest, namespaces); } return(doc.DocumentElement); }
private List <string> GetSelectedAttributeNames(ServiceIds serviceIds) { var attributeNames = new List <string>(); foreach (ServiceIds value in Enum.GetValues(serviceIds.GetType())) { if (serviceIds.HasFlag(value)) { switch (value) { case ServiceIds.Name: attributeNames.Add($"{AttributePrefix}legallastname"); attributeNames.Add($"{AttributePrefix}preferredlastname"); attributeNames.Add($"{AttributePrefix}partnerlastname"); attributeNames.Add($"{AttributePrefix}legallastnameprefix"); attributeNames.Add($"{AttributePrefix}preferredlastnameprefix"); attributeNames.Add($"{AttributePrefix}partnerlastnameprefix"); attributeNames.Add($"{AttributePrefix}initials"); break; case ServiceIds.Address: attributeNames.Add($"{AttributePrefix}street"); attributeNames.Add($"{AttributePrefix}houseno"); attributeNames.Add($"{AttributePrefix}postalcode"); attributeNames.Add($"{AttributePrefix}city"); attributeNames.Add($"{AttributePrefix}country"); break; case ServiceIds.DateOfBirth: attributeNames.Add($"{AttributePrefix}dateofbirth"); break; case ServiceIds.EighteenOrOlder: if (!serviceIds.HasFlag(ServiceIds.DateOfBirth)) { attributeNames.Add($"{AttributePrefix}18orolder"); } break; case ServiceIds.Gender: attributeNames.Add($"{AttributePrefix}gender"); break; case ServiceIds.Phone: attributeNames.Add($"{AttributePrefix}telephone"); break; case ServiceIds.Email: attributeNames.Add($"{AttributePrefix}email"); break; } } } attributeNames.Add($"{AttributePrefix}NameID"); return(attributeNames); }
public static int EncodeHeader(System.IO.Stream buffer, ServiceIds ServiceID, UInt32 Xid, UInt16 ResponseDelayFactor, UInt16 DCPDataLength, out long DCPDataLength_pos) { EncodeU16(buffer, (ushort)ServiceID); //big endian uint32 EncodeU32(buffer, Xid); //ResponseDelayFactor, 1 = Allowed value without spread, 2 – 0x1900 = Allowed value with spread EncodeU16(buffer, ResponseDelayFactor); DCPDataLength_pos = buffer.Position; EncodeU16(buffer, DCPDataLength); return(10); }
public static int DecodeHeader(System.IO.Stream buffer, out ServiceIds ServiceID, out UInt32 Xid, out UInt16 ResponseDelayFactor, out UInt16 DCPDataLength) { ushort val; DecodeU16(buffer, out val); ServiceID = (ServiceIds)val; //big endian uint32 DecodeU32(buffer, out Xid); //ResponseDelayFactor, 1 = Allowed value without spread, 2 – 0x1900 = Allowed value with spread DecodeU16(buffer, out ResponseDelayFactor); DecodeU16(buffer, out DCPDataLength); return(10); }
private async Task <StatusResult> SendTransactionWithoutErrorRequestAsync( string entranceCode, ServiceIds serviceIds) { var client = CreateIdinClient(); var trxRes = await SendTransactionRequestAsync( client, entranceCode, serviceIds); return(await client.RequestStatusAsync( new RequestStatusSettings { TransactionId = trxRes.Transaction.TransactionId, SubId = 0, })); }
/// <summary> /// Constructor that highlights all required fields for this object; use this one to specify your own messageId /// </summary> public AuthenticationRequest(string entranceCode, ServiceIds requestedServiceId, string issuerId, string merchantReference = null, AssuranceLevel assuranceLevel = AssuranceLevel.Loa3, TimeSpan?expirationPeriod = null, string language = "nl", string merchantDocumentId = null) { if (expirationPeriod > MaxExpirationPeriod) { throw new ArgumentOutOfRangeException(nameof(expirationPeriod), "The expiration period cannot be greater than five minutes."); } if (merchantReference != null && !MerchantReferenceFormat.IsMatch(merchantReference)) { throw new ArgumentException("MerchantReference does not follow expected format - " + MerchantReferenceFormat, nameof(merchantReference)); } if (!String.IsNullOrEmpty(merchantDocumentId)) { if ((requestedServiceId & ServiceIds.Sign) != 0) { if ((requestedServiceId & ServiceIds.ConsumerBin) == 0) { throw new ArgumentException("ConsumerID BIN attribute should be present."); } } else if (requestedServiceId != ServiceIds.Sign) { throw new ArgumentException("DocumentID should not be filled if the Sign service is not requested."); } } else { if (requestedServiceId == ServiceIds.Sign || (requestedServiceId & ServiceIds.Sign) != 0) { throw new ArgumentException("DocumentID should be present."); } } EntranceCode = entranceCode; MerchantReference = merchantReference ?? GenerateMerchantReference(); Language = language; RequestedServiceId = requestedServiceId; IssuerId = issuerId; AssuranceLevel = assuranceLevel; ExpirationPeriod = expirationPeriod; DocumentId = merchantDocumentId; }
private static async Task <TransactionResult> SendTransactionRequestAsync( IdinClient client, string entranceCode, ServiceIds serviceIds) { var merchantReference = MerchantReference; var dirRes = await client.GetIssuersAsync( new GetIssuersSettings { SubId = 0 }); var issuerId = dirRes.Issuers[0].IssuerId; var returnUrl = new Uri("http://localhost/"); return(await client.InitiateTransactionAsync( new InitiateTransactionSettings { IssuerId = issuerId, ReturnUrl = returnUrl, MerchantReference = merchantReference, EntranceCode = entranceCode, ServiceIds = serviceIds, Language = "nl", SubId = 0, })); }
public static int EncodeHeader(System.IO.Stream buffer, ServiceIds ServiceID, UInt32 Xid, UInt16 ResponseDelayFactor, UInt16 DCPDataLength) { long dummy; return(EncodeHeader(buffer, ServiceID, Xid, ResponseDelayFactor, DCPDataLength, out dummy)); }
public async Task When_service_ids_are_requested_then_the_corresponding_attributes_should_be_returned(ServiceIds serviceIds) { var statusResult = await SendTransactionWithoutErrorRequestAsync(TestEntranceCodes.Success, serviceIds); var consumer = statusResult.Consumer; consumer.Attributes.Should().NotBeEmpty(); var attributeNames = GetSelectedAttributeNames(serviceIds); if (attributeNames.Count > 0) { consumer.Attributes.Keys.Should().Contain(attributeNames); } }
public ClusterService(ServiceIds serviceId) { m_ServiceId = serviceId; m_CommandHandlers = RegisterHandlers(this); }