Video Screencast Help

VIP API Using Java - AuthenticateUser - How To Handle OTP

Created: 21 Sep 2012


I am trying to write java code for authenticateUser(), and I cannot find a way to get the OTP ( security code ) into the request.

I have successfully written code to call getServerTime, createUser, addCredential and getUserInfo.  The documentation for authenticateUser shows the required fields as requestId and userid.  It then shows the PIN as being optional.  It then shows a sub-element of optAuthData, but does not have anything in the required or type columns.  Obviously, the OTP is required to authenticate.

The XML in the documentation:

Sample authenticateUser Request

<?xml version='1.0' encoding='UTF-8'?>

<S:Envelope xmlns:S="">


<AuthenticateUserRequest xmlns="



<userId>John Walker</userId>








I cannot determine howto add the otpAutData to the request.  The general way that the API works is that you have a "type" that you use to set the data, then you "set" that structure into the request.   For example, to set the userid in the request, this is the code:

           userId.setUserIdType( "37701" ) ;

           authenticateUserRequestType.setUserId( userId ) ;

Along that line of thinking, I used this code to set the OTP:

          otpType.setOtpType( "123456" ) ;

          otpAuthDataType.setOtp( otpType ) ;

BUT, I get an error when I try to set it into the request with: 

          authenticateUserRequestType.setOtpAuthDataType( otpAuthDataType ) ;

I have tried everything I can possibly imagine, but I get errors on everything I have tried. 

Is there anyone out there who has called authenticateUser() using Java and can let me know how to handle the OTP???

I have included the entire source code set below, in case that is helpful.


Mark Turner

import java.rmi.RemoteException;










public class VipUserServicesAuthenticateUser {

 public static void main(String[] args) throws RemoteException {

String pathToP12File = "C:\\SymantecVIP\\VIPWebTestDrive\\SampleCode\\testdrive.p12";

String password = "password";

 System.setProperty("", "pkcs12");

System.setProperty("", pathToP12File);

System.setProperty("", password);

 AuthenticationServiceStub authenticationServiceStub =

new AuthenticationServiceStub("");

 AuthenticateUserRequest authenticateUserRequestBean = new AuthenticateUserRequest();

AuthenticateUserRequestType authenticateUserRequestType = new AuthenticateUserRequestType();

UserIdType userId = new UserIdType() ;

OtpAuthDataType otpAuthDataType = new OtpAuthDataType() ;

OtpType otpType = new OtpType() ;

authenticateUserRequestBean.setAuthenticateUserRequest( authenticateUserRequestType ) ;

RequestIdType requestIdType = new RequestIdType();

requestIdType.setRequestIdType( "rqstId" + System.currentTimeMillis() );

authenticateUserRequestType.setRequestId( requestIdType );

userId.setUserIdType( "37701" ) ;

authenticateUserRequestType.setUserId( userId ) ;

otpType.setOtpType( "123456" ) ;

otpAuthDataType.setOtp( otpType ) ;

authenticateUserRequestType.setOtpAuthDataType( otpAuthDataType ) ;

AuthenticateUserResponse authenticateUserResponseBean =

authenticationServiceStub.authenticateUser( authenticateUserRequestBean, otpAuthDataType ) ;

AuthenticateUserResponseType authenticateUserResponse =

authenticateUserResponseBean.getAuthenticateUserResponse() ;

 System.out.println("Get User Info Status : " + authenticateUserResponse.getStatus());

System.out.println("Get User Info Status message : " + authenticateUserResponse.getStatusMessage());

System.out.println("Get User Info USERID : " + authenticateUserResponse.getDetailMessage()) ;



Discussion Filed Under: