Esempio n. 1
0
        public static LinkIDAuthnResponse parse(ResponseType response)
        {
            String userId = null;
            Dictionary <String, List <LinkIDAttribute> > attributes = new Dictionary <string, List <LinkIDAttribute> >();

            foreach (object item in response.Items)
            {
                AssertionType assertion = (AssertionType)item;
                SubjectType   subject   = assertion.Subject;
                NameIDType    nameId    = (NameIDType)subject.Items[0];
                userId = nameId.Value;

                foreach (StatementAbstractType statement in assertion.Items)
                {
                    if (statement is AttributeStatementType)
                    {
                        AttributeStatementType attributeStatement = (AttributeStatementType)statement;
                        attributes = getAttributes(attributeStatement);
                    }
                }
            }

            LinkIDPaymentResponse      paymentResponse      = findPaymentResponse(response);
            LinkIDExternalCodeResponse externalCodeResponse = findExternalCodeResponse(response);

            return(new LinkIDAuthnResponse(userId, attributes, paymentResponse, externalCodeResponse));
        }
 public LinkIDAuthnResponse(String userId, Dictionary <String, List <LinkIDAttribute> > attributes,
                            LinkIDPaymentResponse paymentResponse, LinkIDExternalCodeResponse externalCodeResponse)
 {
     this.userId               = userId;
     this.attributes           = attributes;
     this.paymentResponse      = paymentResponse;
     this.externalCodeResponse = externalCodeResponse;
 }
Esempio n. 3
0
        private static LinkIDPaymentResponse findPaymentResponse(ResponseType response)
        {
            if (null == response.Extensions || null == response.Extensions.Any)
            {
                return(null);
            }
            if (0 == response.Extensions.Any.Length)
            {
                return(null);
            }

            XmlElement xmlElement = response.Extensions.Any[0];

            if (xmlElement.LocalName.Equals(LinkIDPaymentResponse.LOCAL_NAME))
            {
                PaymentResponseType paymentResponseType = deserializePaymentResponse(xmlElement);
                return(LinkIDPaymentResponse.fromSaml(paymentResponseType));
            }

            return(null);
        }
        public static LinkIDPaymentResponse fromSaml(PaymentResponseType paymentResponseType)
        {
            String orderReference     = null;
            String paymentStateString = null;
            String mandateReference   = null;
            String docdataReference   = null;
            String paymentMenuURL     = null;

            foreach (object item in paymentResponseType.Items)
            {
                AttributeType attributeType = (AttributeType)item;
                if (attributeType.Name.Equals(ORDER_REF_KEY) && null != attributeType.AttributeValue)
                {
                    orderReference = (String)attributeType.AttributeValue[0];
                }
                if (attributeType.Name.Equals(STATE_KEY) && null != attributeType.AttributeValue)
                {
                    paymentStateString = (String)attributeType.AttributeValue[0];
                }
                if (attributeType.Name.Equals(MANDATE_REF_KEY) && null != attributeType.AttributeValue)
                {
                    mandateReference = (String)attributeType.AttributeValue[0];
                }
                if (attributeType.Name.Equals(DOCDATA_REF_KEY) && null != attributeType.AttributeValue)
                {
                    docdataReference = (String)attributeType.AttributeValue[0];
                }
                if (attributeType.Name.Equals(MENU_URL_KEY) && null != attributeType.AttributeValue)
                {
                    paymentMenuURL = (String)attributeType.AttributeValue[0];
                }
            }

            return(new LinkIDPaymentResponse(orderReference, LinkIDPaymentResponse.parse(paymentStateString),
                                             mandateReference, docdataReference, paymentMenuURL));
        }