User Tools

Site Tools


developers:examples:java:client-api-basic

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
developers:examples:java:client-api-basic [2019/08/01 10:13]
tjotov removed
— (current)
Line 1: Line 1:
-====== Basic authentication example using Java SDK Client API ====== 
- 
-See all [[developers:examples:java:start|Java Examples]] 
- 
-[[https://cloud-alpha.aducid.com/aducid-api-webapp|Try it out]] 
- 
-[[https://github.com/aducid-dev/client-api|Get sources and binaries on GitHub]] 
- 
-[[developers:examples:java:client-api-basic:install|How to install this example]] 
- 
-In the following chapter, typical examples of using the ADUCID<sup>®</sup>  Client API are provided, particularly user authentication. 
- 
-A typical example of using ADUCID<sup>®</sup>  Client API includes the following steps: 
- 
-   - Creating an authentication session in AIM for the requested operation. The redirect URL with identifier **authId,**  and optionally **bindingId**  and/or **bindingKey**  identifiers**,**  is returned. Then sending redirect to provided redirect URL, by which the PEIG authentication handshake is initiated (the AIM-Proxy component can be used for this action). 
-  - <font 11.0pt/11;;inherit;;inherit>Returning credentials (**authId**, **authKey**) back to the application and verifying credentials supplied from PEIG.</font> 
- 
-===   === 
- 
-==== Example of Starting Authentication Session (step 1) ==== 
- 
-When authenticating a user, an authentication session must first be created on the AIM server. This is done by the **startAuthenticationSession** operation of the **AducidAdvancedClient** object. It is necessary to provide a return URL as an operation input parameter. The **startAuthenticationSession** operation returns URL, where to redirect to start PEIG authentication handshake. 
- 
-This page starts authentication request. As a parameter of **startAuthenticationSession** method we provide URL with final page where authentication is evaluated: 
-<code java> 
-public void authenticate(HttpServletResponse response) throws AducidClientException { 
-  AducidAdvancedClient client = new AducidAdvancedClient("http://localhost:8080/AIM/services/R4"); 
-  String redirectUrl = client.startAuthenticationSession("http://returnToMyApplicationURL"); 
-  response.sendRedirect(redirectUrl); 
-} 
-</code> 
- 
-If calling of the **startAuthenticationSession** is successful, no exception is thrown. 
- 
- 
-==== Example of Verifying Authentication Session (step 2) ==== 
- 
-If authentication has been finished (for example, when the AIM proxy redirects control back to the application, by using the endpoint defined in the returnUrl value that was set in step 1), credentials can be verified by calling the **getResult**  method of the **AducidAdvancedClient**  object. Remember, **authKey**  value doesn't need to be defined, so make it optional as **getResult**  operation input. The **getResult**  operation returns **GetPSLAttributesResponse**  as an object representing authentication data. The most important values are **UDI**  as a unique user identifier (**GetPSLAttributesResponse.getUserDatabaseIndex()**) and **authKey**  as a new authentication key (**GetPSLAttributesResponse.getAuthKey()**). If you want to call Client API methods requiring **authId**  and **authKey**  pair on input, you must use that new authentication key instead of the original one. 
- 
-<code java> 
-protected GetPSLAttributesResponse authenticateCheck(String authId, String authKey) throws AducidClientException { 
-  AducidAdvancedClient client = new AducidAdvancedClient("http://localhost:8080/AIM/services/R4"); 
-  GetPSLAttributesResponse authData = client.getResult(authId, authKey); 
-  // example of method call with verified authentication key 
-  List<PersonalObjectAttribute> personalObjectAttributeList = client.read(authData.getAuthId(), authData.getAuthKey(), "ADUCID_USER"); 
-  return authData; 
-} 
-</code> 
- 
-If calling of the **getResult**  is successful, no exception is thrown. 
- 
  
developers/examples/java/client-api-basic.1564654431.txt.gz · Last modified: 2019/08/01 10:13 by tjotov