public void TestSaml2AuthUtil() { RSACryptoServiceProvider key = new RSACryptoServiceProvider(); Saml2AuthUtil testedInstance = new Saml2AuthUtil(); string spUrl = "http://service.provider.com"; string idpUrl = "http://identity.provider.com"; string applicationId = "urn:application:id"; string[] devices = new string[] { "test-device-1", "test-device-2" }; LinkIDAuthenticationContext linkIDContext = new LinkIDAuthenticationContext(); linkIDContext.authenticationMessage = "Test authn message"; linkIDContext.finishedMessage = "Test finished message"; // attribute suggestions Dictionary <string, List <Object> > attributeSuggestions = new Dictionary <string, List <object> >(); attributeSuggestions.Add("test.attribute.string", new List <Object> { "test" }); attributeSuggestions.Add("test.attribute.date", new List <Object> { new DateTime() }); attributeSuggestions.Add("test.attribute.boolean", new List <Object> { true }); attributeSuggestions.Add("test.attribute.integer", new List <Object> { 69 }); attributeSuggestions.Add("test.attribute.double", new List <Object> { 3.14159 }); linkIDContext.attributeSuggestions = attributeSuggestions; // payment context LinkIDPaymentContext paymentContext = new LinkIDPaymentContext(new LinkIDPaymentAmount(1, LinkIDCurrency.EUR, null)); linkIDContext.paymentContext = paymentContext; // callback LinkIDCallback callback = new LinkIDCallback("http://www.google.be", "1234", true); linkIDContext.callback = callback; AttributeWSNamespace.AuthnRequestType authnRequest = Saml2AuthUtil.generateAuthnRequest(linkIDContext); Assert.NotNull(authnRequest); }
private static PollResult doLinkIDPoll() { // Allow any SSL certficate ( ONLY FOR DEVELOPMENT!! ) ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(WCFUtil.AnyCertificateValidationCallback); LinkIDAuthSession linkIDSession = (LinkIDAuthSession)HttpContext.Current.Session[LINKID_SESSION]; PollResult result; if (null == linkIDSession) { // configure linkID authentication context LinkIDAuthenticationContext linkIDContext = new LinkIDAuthenticationContext(); linkIDContext.authenticationMessage = "WS Authn Message"; linkIDContext.finishedMessage = "WS Finished Message"; linkIDContext.applicationName = TestUtil.APP_NAME; linkIDContext.language = TestUtil.language; linkIDContext.identityProfile = "linkid_basic"; // attribute suggestions Dictionary <string, List <Object> > attributeSuggestions = new Dictionary <string, List <object> >(); attributeSuggestions.Add("test.attribute.string", new List <Object> { "test" }); attributeSuggestions.Add("test.attribute.multi.date", new List <Object> { DateTime.Now }); attributeSuggestions.Add("test.attribute.boolean", new List <Object> { true }); attributeSuggestions.Add("test.attribute.integer", new List <Object> { 69 }); attributeSuggestions.Add("test.attribute.double", new List <Object> { 3.14159 }); linkIDContext.attributeSuggestions = attributeSuggestions; // linkIDContext.paymentContext = new LinkIDPaymentContext(new LinkIDPaymentAmount(199, LinkIDCurrency.EUR, null)); // linkIDContext.callback = new LinkIDCallback("https://www.google.be", null, true); // start the linkID authentication linkIDSession = TestUtil.getClient().authStart(linkIDContext, HttpContext.Current.Request.UserAgent); //qr.Src = "data:image/png;base64," + linkIDSession.qrCodeInfo.qrEncoded; HttpContext.Current.Session[LINKID_SESSION] = linkIDSession; result = new PollResult(false, linkIDSession.qrCodeInfo.qrEncoded, false, null); } else { // poll linkID authentication LinkIDAuthPollResponse pollResponse = TestUtil.getClient().authPoll(linkIDSession.sessionId, TestUtil.language); String info = ""; info = "<h2>Poll response</h2>"; info += "AuthenticationState: " + pollResponse.linkIDAuthenticationState + "<br/>"; info += "PaymentState: " + pollResponse.paymentState + "<br/>"; if (null != pollResponse.linkIDAuthnResponse) { // logged in, dump user data info += pollResponse.linkIDAuthnResponse.ToString(); } result = new PollResult(true, null, null != pollResponse.linkIDAuthnResponse, info); } return(result); }