Symantec Developer Group

 View Only

VIP API Using Java - AuthenticateUser - How To Handle OTP

  • 1.  VIP API Using Java - AuthenticateUser - How To Handle OTP

    Posted Sep 21, 2012 04:57 PM

    Hi,

    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="http://schemas.xmlsoap.org/soap/envelope/">

    <S:Body>

    <AuthenticateUserRequest xmlns="http://schemas.verisign.com/vip/2011/

    04/vipuserservices">

    <requestId>abcd1234</requestId>

    <userId>John Walker</userId>

    <pin>1abcef</pin>

    <otpAuthData>

    <otp>123456</otp>

    </otpAuthData>

    </AuthenticateUserRequest>

    </S:Body>

    </S:Envelope>

     

    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.

    Thanks.

    Mark Turner

     

    import java.rmi.RemoteException;

     import com.verisign.vipuserservices.wsclient.AuthenticationServiceStub;

    import com.verisign.vipuserservices.wsclient.AuthenticationServiceStub.AuthenticateUserRequest;

    import com.verisign.vipuserservices.wsclient.AuthenticationServiceStub.AuthenticateUserRequestType;

    import com.verisign.vipuserservices.wsclient.AuthenticationServiceStub.AuthenticateUserResponse;

    import com.verisign.vipuserservices.wsclient.AuthenticationServiceStub.AuthenticateUserResponseType;

    import com.verisign.vipuserservices.wsclient.AuthenticationServiceStub.OtpAuthDataType;

    import com.verisign.vipuserservices.wsclient.AuthenticationServiceStub.OtpType;

    import com.verisign.vipuserservices.wsclient.AuthenticationServiceStub.RequestIdType;

    import com.verisign.vipuserservices.wsclient.AuthenticationServiceStub.UserIdType;

      

    public class VipUserServicesAuthenticateUser {

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

     

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

    String password = "password";

     System.setProperty("javax.net.ssl.keyStoreType", "pkcs12");

    System.setProperty("javax.net.ssl.keyStore", pathToP12File);

    System.setProperty("javax.net.ssl.keyStorePassword", password);

     AuthenticationServiceStub authenticationServiceStub =

    new AuthenticationServiceStub("https://pilot-vipuserservices-auth.verisign.com/vipuserservices/AuthenticationService_1_1");

     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()) ;

     }

    }