User Tools

Site Tools


developers:integration:wsa

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
developers:integration:wsa [2018/06/27 14:03]
tjotov
developers:integration:wsa [2019/08/01 10:07]
tjotov removed
Line 4: Line 4:
   * [[developers:basic-overview|Server side integration basics]]   * [[developers:basic-overview|Server side integration basics]]
   * [[integration-api:start|ADUCID Integration API]]   * [[integration-api:start|ADUCID Integration API]]
-  * +
 For detailed methods / classes / types description see [[http://wiki.aducid.com/client-api|Javadoc SDK Client API]] For detailed methods / classes / types description see [[http://wiki.aducid.com/client-api|Javadoc SDK Client API]]
  
Line 12: Line 12:
  
 <code> <code>
-https://hostname/wsa+https://hostname/wsa-json
 </code> </code>
  
Line 18: Line 18:
  
 <code> <code>
-https://hostname/wsa?wsdl+https://hostname/wsa-json?wsdl
 </code> </code>
  
Line 26: Line 26:
 === Import WSDL into your project in Visual Studio. === === Import WSDL into your project in Visual Studio. ===
  
-Create an instance of **AducidApiServiceClient **and make calls to ADUCID and get authentication result with a few rows of code:+Create an instance of **AducidApiJsonServiceClient**.
  
 === Create a start operation Url === === Create a start operation Url ===
-This page starts authentication request. As a parameter of verifyLF method we provide URL with final page where authentication is evaluated:+This page starts authentication request.
  
-<code csharp> +<sxh csharp> 
-protected void Page_Load(object sender, EventArgs e) { +var aducid = new AducidApiJsonServiceClient(); 
-            var aducid = new AducidApiServiceClient(); +string host = "http://" + HttpContext.Current.Request.Url.Host + ":" + HttpContext.Current.Request.Url.Port; 
-            string host = "http://" + HttpContext.Current.Request.Url.Host + ":" + HttpContext.Current.Request.Url.Port; +string query = context.Request.QueryString.ToString(); 
-            var redirect aducid.startAuthenticationSession(host + "/result")+var queryParsed HttpUtility.ParseQueryString(query); 
-            Response.Redirect(redirect)+var generateQr = queryParsed["generateQrCodePicture"]; 
-} +var arg = new OperationArgument(); 
-</code>+//return URL for iOS 
 +arg.peigReturnName = host + "/result"; 
 +//QR code picture size 
 +arg.qrCodePictureHeight = 300
 +arg.qrCodePictureWidth = 300; 
 +//tab helper If - if more authentication are in web browser in more tabs this help ti identify them - has to be unique 
 +arg.id = "123"; 
 +arg.generateQrCodePicture = generateQr == "true";
  
-=== Create check result Url ===+//JSON response from WSA 
 +var response aducid.startAuthenticationSession(JsonConvert.SerializeObject(arg)); 
 +//parse and store authId 
 +dynamic responseObj JsonConvert.DeserializeObject(response); 
 +//store authId in your session 
 +context.Session["123"(string) responseObj.data.authId; 
 +context.Response.ContentType "text/plain"; 
 +//send response 
 +context.Response.Write(response); 
 +</sxh>
  
-On the result page we evaluate the authentication request using aducid.getResult+OperationArgument is a simple object 
 +<sxh csharp> 
 +public class OperationArgument 
 +    { 
 +        public String peigReturnName { get; set; } 
 +        public int qrCodePictureHeight { get; set; } 
 +        public int qrCodePictureWidth { get; set; } 
 +        public String id { get; set; } 
 +        public Boolean generateQrCodePicture { get; set; } 
 +    } 
 +</sxh> 
 +=== Create WSA proxy === 
 +Just simple "Rewrite" from WSA to C# with authId check 
 +<sxh csharp> 
 +var aducid = new AducidApiJsonServiceClient(); 
 +string host = "http://" + HttpContext.Current.Request.Url.Host + ":" + HttpContext.Current.Request.Url.Port; 
 +var response = aducid.getStatus((string)context.Session["123"]); 
 +context.Response.ContentType = "text/plain"; 
 +context.Response.Write(response); 
 +</sxh>
  
 +=== Create check Url ===
 +On the result page we evaluate the authentication
 There are two basic results – authentication is OK or an error is thrown: There are two basic results – authentication is OK or an error is thrown:
  
-<code csharp> +<sxh csharp> 
-protected void Page_Load(object senderEventArgs e+var aducid = new AducidApiJsonServiceClient(); 
-        { +//read authId from you session 
-            var queryString HttpContext.Current.Request.Url.Query+string authId = (string)context.Session["123"]; 
-            var query HttpUtility.ParseQueryString(queryString);+var aducidResult = aducid.getResult(authIdnull); 
 +//parse json 
 +dynamic aducidResultObj = JsonConvert.DeserializeObject(aducidResult); 
 +//User primary key i.e. UDI 
 +var udi aducidResultObj.data.userDatabaseIndex; 
 +//key to further ADUCID operetions on user object (with authId) 
 +string authKey2 = aducidResultObj.data.authKey2
 +//prepare response 
 +var response aducid.endAuthenticationSession(authId, authKey2); 
 +context.Response.ContentType = "text/plain"; 
 +//OK do something with your session 
 +//... 
 +//send response 
 +context.Response.Write(response); 
 +</sxh>
  
-            var sb = new StringBuilder(); 
-            var aducid = new AducidApiServiceClient(); 
-            try 
-            { 
-                var result = aducid.getResult(query.Get("authId"), query.Get("authkey")); 
-                sb.Append("<table class=\"table table-bordered\">"); 
-                sb.Append("<tr><td>authId:</td><td>" + result.authId + "</td></tr>"); 
-                sb.Append("<tr><td>authKey:</td><td>" + result.authKey + "</td></tr>"); 
-                sb.Append("<tr><td>operationName:</td><td>" + result.operationName + "</td></tr>"); 
-                sb.Append("<tr><td>UDI:</td><td>" + result.userDatabaseIndex + "</td></tr>"); 
-                sb.Append("<tr><td>Status AIM:</td><td>" + result.statusAIM + "</td></tr>"); 
-                sb.Append("<tr><td>Status auth:</td><td>" + result.statusAuth + "</td></tr>"); 
- 
-                sb.Append("</table>"); 
  
 +=== Prepare a web page ===
 +This page should contain [[integration-api:start|ADUCID Integration API]]\\
 +Provide start, check and proxy Url.
 +<sxh> 
 +   aducid.setStartOperationUrl("open");
 +   aducid.setResultOperationUrl("openCheck");
 +   aducid.setProxyUrl("proxy");
 +</sxh>
 +Override what should be done after authentication / operation:
 +<sxh> 
 +   aducid.processResult = function (result) {
 +                if (result.status == "OK") {
 +                    alert("atuhenticated");
 +                    //location.reload();
 +                }
 +                else {
 +                    alert("atuhentication failure");
 +                }
             }             }
-            catch (Exception ee) +</sxh
-            { +
-                sb.Append("Error:" + ee.Message); +
-            } +
-            lResponse.Text = sb.ToString(); +
-        } +
-</code>+
  
 +And create some HTML elements:
  
-=== Prepare a web page === +<sxh html> 
-This page should contain [[integration-api:start|ADUCID Integration API]]\\ +<h1>ADUCID Hello World example</h1> 
-Provide start, check and proxy Url.  +        <div class="row"> 
- aducid.setStartOperationUrl("myOpen"); +            <div class="col-xs-8 col-xs-offset-2"> 
- aducid.setResultOperationUrl("myPpenCheck"); + 
- aducid.setProxyUrl("myProxy");+                <div class="row"> 
 +                    <div class="col-xs-8 col-xs-offset-2"> 
 +                        <div id="main-button" class="btn btn-primary btn-lg center-block">Authenticate</div> 
 +                    </div> 
 +                </div> 
 +                <div class="row"> 
 +                    <img id="qr-code" alt="" class="img-responsive center-block" /> 
 +                </div> 
 + 
 +                <div class="row text-center"> 
 +                    <div id="qr-code-timer" class="qr-code-timer img-responsive center-block"></div> 
 +                    <div id="qr-code-hintclass="qr-code-hint"></div> 
 +                </div>
  
 +                <div id="peig-error" style="display: none;">
 +                    <h2>PEIG Error</h2>
 +                    <a class='btn  btn-lg' href='http://www.aducid.com/support/' data-lang="aducid_common_installPeig">Install PEIG</a>
 +                    <br />
 +                    <div class='btn btn-lg' onclick="location.reload()" data-lang="aducid_common_tryAgain">Try again</div>
 +                </div>
 +            </div>
 +        </div>
 +</sxh>