Common > Activate token authentication system

    1.6 Activate token authentication system

    To activate the token authentication system is necessary to activate and confirm the Otp option. By the method IWSCommon RequestTokenOtp you can request a new token .
    By the method IWSCommon SetOtpActive activate the otp authentication procedure .

    Parameter
    optValue
    Type: String
    OTP value returnde by the Aruba OTP Mobile App

    /// IWsCommon.RequestTokenOtp  and SetOtpActive Methods (c# .NET)
    public static string ActivateOTPAuthentication(WsCommonClient client, String optValue)
    {
        //specify the account login details 
        client.ClientCredentials.UserName.UserName = "ARU-0000";
        client.ClientCredentials.UserName.Password = "0123456789";
    
        StringBuilder stringBuilder = new StringBuilder();
    
        try
        {
            // STEP 1: call method RequestTokenOtp 
            // obtaining a WsResultOfRequestedTokenOtp item
            WsResultOfRequestedTokenOtp result =
                client.RequestTokenOtp();
    
            // if the call is Success print returned values
            if (result.Success)
            {
                stringBuilder.Append("Operation 'RequestTokenOtp' ends successfully\n");
    
                // get Value returned from server
                RequestedTokenOtp item = result.Value;
    
                // print result
                stringBuilder.Append("OTP detail\n");
    
                stringBuilder.Append("\n\tActivationCode: ");
                stringBuilder.Append(item.ActivationCode);
                stringBuilder.Append("\n\tUsername: ");
                stringBuilder.Append(item.Username);
                stringBuilder.Append("\n\tStatus: ");
                stringBuilder.Append(item.Status);
    
                // STEP 2: call method SetOtpActive 
                // obtaining a WsResultOfUserOtpActiveData item
                WsResultOfUserOtpActiveData result2 = client.SetOtpActive(optValue);
    
                if (result2.Success)
                {
                    UserOtpActiveData item2 = result2.Value;
    
                    stringBuilder.Append("\n\nOperation 'SetOtpActive' ends successfully\n");
                    stringBuilder.Append("\n\tToken: ");
                    stringBuilder.Append(item2.Token);
                    stringBuilder.Append("\n\tSetOtpActivOk: ");
                    stringBuilder.Append(item2.SetOtpActivOk);                            
                }
                else
                {
                    throw new ApplicationException(result.ResultMessage);
                }
            }
            else
            {
                throw new ApplicationException(result.ResultMessage);
            }
        }
        catch (Exception ex)
        {
            // re-run the error
            throw new ApplicationException(ex.Message);
        }
    
        return stringBuilder.ToString();
    }
    
    /// IWsCommon.RequestTokenOtp and setOtpActive Methods (JAVA)
    public static String ActivateOTPAuthentication(IWsCommon client, String optValue)
    {
        //specify the account login details 
        ((BindingProvider) client).getRequestContext()
            .put(BindingProvider.USERNAME_PROPERTY, "ARU-0000");
        ((BindingProvider) client).getRequestContext()
            .put(BindingProvider.PASSWORD_PROPERTY, "0123456789");
    
        StringBuilder StringBuilder = new StringBuilder();
    
        try
        {
                    
            // STEP 1: call method RequestTokenOtp 
            // obtaining a WsResultOfRequestedTokenOtp item
            WsResultOfRequestedTokenOtp result =
                client.requestTokenOtp();
    
            // if the call is Success print returned values
            if (result.isSuccess())
            {
                StringBuilder.append("Operation 'RequestTokenOtp' ends successfully\n");
    
                // get Value returned from server
                RequestedTokenOtp item = result.getValue();
    
                // print result
                StringBuilder.append("OTP detail\n");
    
                StringBuilder.append("\n\tActivationCode: ");
                StringBuilder.append(item.ActivationCode);
                StringBuilder.append("\n\tUsername: ");
                StringBuilder.append(item.Username);
                StringBuilder.append("\n\tStatus: ");
                StringBuilder.append(item.Status);
    
                // STEP 2: call method SetOtpActive 
                // obtaining a WsResultOfUserOtpActiveData item
                WsResultOfUserOtpActiveData result2 = client.setOtpActive(optValue);
    
                if (result2.isSuccess())
                {
                    UserOtpActiveData item2 = result2.getValue();
    
                    StringBuilder.append("\n\nOperation 'SetOtpActive' ends successfully\n");
                    StringBuilder.append("\n\tToken: ");
                    StringBuilder.append(item2.getToken());
                    StringBuilder.append("\n\tSetOtpActivOk: ");
                    StringBuilder.append(item2.getSetOtpActivOk());                            
                }
                else
                {
                    throw new Exception(result.getResultMessage());
                }
            }
            else
            {
                throw new Exception(result.getResultMessage());
            }
        }
        catch (Exception ex)
        {
            // re-run the error
            System.out.println(ex);
        }
    
        return StringBuilder.toString();
    }
    
    Version
    API: v2.7 URL:https://api.dc1.computing.cloud.it/WsCommon/v2.7/WsCommon.svc?wsdl