This is an old revision of the document!
See all Java Examples
Get sources and binaries on GitHub
In the following chapter, typical examples of using the ADUCID® Client API are provided, particularly user authentication.
A typical example of using ADUCID® Client API includes the following steps:
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:
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); }
If calling of the startAuthenticationSession is successful, no exception is thrown.
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.
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; }
If calling of the getResult is successful, no exception is thrown.