Sample code for using IDA APIs in relying party application in Java
MOSIP has built an application for demonstrations that uses MOSIP’s ID authentication APIs. Any relying party who wants to use MOSIP’s authentication APIs in their application can follow the steps used in the authentication-demo-ui application.
Code Base
Go to the IdaController.java > onSendAuthRequest () method in the authentication-demo-UI code.
Steps
Create the AuthRequestDTO.
AuthTypeDTO authTypeDTO = new AuthTypeDTO();
Set the authentication types in the DTO.
authTypeDTO.setBio(isBioAuthType()); authTypeDTO.setOtp(isOtpAuthType()); authTypeDTO.setDemo(isDemoAuthType()); authRequestDTO.setRequestedAuth(authTypeDTO);
Set the individual ID, ID type, environment, and domain URI.
authRequestDTO.setIndividualId(idValue.getText()); authRequestDTO.setIndividualIdType(idTypebox.getValue()); authRequestDTO.setEnv(env.getProperty("ida.request.captureFinger.env")); authRequestDTO.setDomainUri(env.getProperty("ida.request.captureFinger.domainUri"));
Create a request DTO and set the encrypted request section.
Add other request body parameters, such as unique transaction ID per transaction, current time in request time, consent, auth request ID (
mosip.identity.kyc
for KYC authentication andmosip.identity.auth
for authentication), version (as1.0
), and thumbprint of the request.Create an authentication request map and add the request block, requestSessionKey, requestHMAC, and other parameters to the authentication request.
Set the HTTP headers with the signature and content type.
For the signature of the authentication request, follow the getSignature() and sign() methods in IdaContoller.java. These methods call the sign() method in SignatureUtil.java.