[RPG]fingerprint

Please do not use to report errors- use your regional help desk.
Please mark posts as being for RPG or RDMLX (LANSA) developer.
To subscribe by email, display this forum, scroll to the end and select ‘Subscribe Forum’.
Post Reply
MegumiSawada
Posts: 268
Joined: Tue Feb 19, 2013 5:18 pm

[RPG]fingerprint

Post by MegumiSawada »

Hi,

Is there any demo program & documents for fingerprint reading on LongRange?
Could I have it please?

Best Regards,
Megumi Sawada
jasonzhou
Posts: 130
Joined: Wed Jan 11, 2017 3:26 pm

Re: [RPG]fingerprint

Post by jasonzhou »

Please try this:

Code: Select all

Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #LRNG_FORM)

Mthroutine Name(HandleRequest) Options(*REDEFINE)
Define_Com Class(#PRIM_ALPH) Name(#UserName)
Define_Com Class(#PRIM_ALPH) Name(#Password)

#Com_Owner.Using Element('/Form.Fields')

Case Of_Field(#COM_OWNER.RequestACTION)

When (= LOGIN)
* Normal Login (using Username & Password)
#COM_OWNER.Get_TextBox Name(UserNameInput) Value(#UserName)
#COM_OWNER.Get_TextBox Name(PasswordInput) Value(#Password)

* Check if we should save user/password for fingerprint login
If (#COM_OWNER.Get( UseTouchIDCheckBox.Value ) <> '')
#COM_OWNER.Set Property('/Runoperation.Type') To(RegisterTouchID)
#COM_OWNER.Set Property('/Runoperation.UserName') To(#UserName)
#COM_OWNER.Set Property('/Runoperation.Password') To(#Password)
Endif

* Switch away from login page
#COM_OWNER.SwitchRequestPROGRAM := 'LREX0000'

When (= TOUCHID)
#COM_OWNER.Get Property('/Form.TouchID.UserName') InTo(#UserName)
#COM_OWNER.Get Property('/Form.TouchID.Password') InTo(#Password)

* Switch away from login page
#COM_OWNER.SwitchRequestPROGRAM := 'LREX0000'

Otherwise

#COM_OWNER.Set Property('/Form.TouchID.Enabled') To(true)
#COM_OWNER.Set Property('/Form.TouchID.OnAuthenticated') To(TOUCHID)

#COM_OWNER.Set_TextBox Placeholder('Enter username') Layout_Row(1) Name(UserNameInput)
#COM_OWNER.Set_TextBox Placeholder('Enter password') Layout_Row(2) Name(PasswordInput)
#COM_OWNER.Set_Checkbox Layout_Row(3) Name(UseTouchIDCheckBox) Text('Allow login using fingerprint')
#COM_OWNER.Set_Button Layout_Col(1) Layout_Row(4) Text('Login') OnClick(LOGIN)

Endcase
*
#Com_Owner.EndUsing

Endroutine

End_Com
jasonzhou
Posts: 130
Joined: Wed Jan 11, 2017 3:26 pm

Re: [RPG]fingerprint

Post by jasonzhou »

Hi Megumi,

Here is RPG demo code for your reference:

Code: Select all

/free

        DoW (RequestPROGRAM = ProgramINFO.Name);
        //
          Select;
            When (RequestACTION = 'ON_LOGIN');
              Exsr Login;
              IsNewForm = False;

            When (RequestACTION = 'ON_TOUCHID_AUTHED');
              Exsr TouchIDAuthenticated;
              IsNewForm = False;

            When (RequestACTION = 'ON_TOUCHID_CANCELLED');
              Exsr TouchIDCancelled;
              IsNewForm = False;

            When (RequestACTION = 'ON_TOUCHID_ERROR');
              Exsr TouchIDError;
              IsNewForm = False;

            Other;
              IsNewForm = true;
              Exsr EnableTouchID;
          endsl;

          Exsr DisplayFormView;

        Enddo;
        *InLR = True;
        Return;


        /// ----------------------------------------------------------------------
        Begsr Login;
          USERNAME = LRNG_GetPropAsStr('/Form.Fields.UserName.Value');
          PASSWORD = LRNG_GetPropAsStr('/Form.Fields.Password.Value');

	  // get checkbox value to know if allow fingerprint logging next time
	  // if true, connect username and password with touch id
          If LRNG_GetBoolProperty('/Form.Fields.UseTouchIDCheckbox.Value');
            LRNG_Using('/RunOperation');
              LRNG_SetProperty('Type' : 'RegisterTouchID');
              LRNG_SetProperty('Username' : USERNAME);
              LRNG_SetProperty('Password' : PASSWORD);
            LRNG_EndUsing();
          Endif;

          //
          MESSAGE = 'Login is successful. ' + 'Username: ' + USERNAME;

          LRNG_SetProperty('/Form.Fields.Info.Text' : MESSAGE);

        Endsr;

        Begsr EnableTouchID;
          If LRNG_GetSystemValue('HAS-TOUCHID-HARDWARE') = 'Y';
            LRNG_SetProperty('/Form.TouchID.Enabled' : 'True');
            LRNG_SetProperty('/Form.TouchID.OnAuthenticated' :
                             'ON_TOUCHID_AUTHED');
            LRNG_SetProperty('/Form.TouchID.OnCancelled' :
                             'ON_TOUCHID_CANCELLED');
            LRNG_SetProperty('/Form.TouchID.OnError' :
                             'ON_TOUCHID_ERROR');
          Endif;
        Endsr;

        Begsr TouchIDAuthenticated;
          LRNG_SetProperty('/Form.Fields.UserName.Value' :
                           LRNG_GetPropAsStr('Form.TouchID.Username'));
          LRNG_SetProperty('/Form.Fields.Password.Value' :
                           LRNG_GetPropAsStr('Form.TouchID.Password'));
          Exsr Login;
        Endsr;

        Begsr TouchIDCancelled;
          LRNG_Using('/RunOperation');
            LRNG_SetProperty('Type' : 'ShowMessage');
            LRNG_SetProperty('Title' : 'Cancelled');
            LRNG_SetProperty('Message' : 'Touch ID login is cancelled');
          LRNG_EndUsing();
        Endsr;

        Begsr TouchIDError;
          MESSAGE = LRNG_GetPropAsStr('Form.TouchID.ErrorDescription');
          LRNG_Using('/RunOperation');
            LRNG_SetProperty('Type' : 'ShowMessage');
            LRNG_SetProperty('Title' :
                             'Error when authenticate Touch ID');
            LRNG_SetProperty('Message' :  MESSAGE);
          LRNG_EndUsing();
        Endsr;

        /// ----------------------------------------------------------------------
        Begsr DisplayFormView;
          If (NOT IsNewForm);
            LRNG_SetSendChangesOnly();
          Endif;
          LRNG_Send();
          EXFMT FormView;
          LRNG_Receive();
          LRNG_GetRequestedAction(RequestPROGRAM:RequestACTION);
        Endsr;
      /end-free
 

Code: Select all

     A                                       DSPSIZ(27 132)
     A          R FORMVIEW
     A                                  8 20HTML('<<USERNAME>>
     A                                      Type : TEXTBOX
     A                                      Placeholder: "User Name"
     A                                      ')
     A
     A                                 10 20HTML('<<PASSWORD>>
     A                                      Type : TEXTBOX
     A                                      Placeholder: "Password"
     A                                      ')
     A
     A
     A                                 12 20HTML('<<USETOUCHIDCHECKBOX>>
     A                                      Type : CHECKBOX
     A                                      Text: "Allow login
     A                                             using fingerprint"
     A                                      ')
     A
     A                                 14 20HTML('<<INFO>>
     A                                      Type : LABEL
     A                                      Color: RED
     A                                      ')
     A
     A
     A                                 18 20HTML('<<BUTTON>>
     A                                      Type : BUTTON
     A                                      Text: "Login"
     A                                      ONCLICK: ON_LOGIN
     A                                      ')
     A
MegumiSawada
Posts: 268
Joined: Tue Feb 19, 2013 5:18 pm

Re: [RPG]fingerprint

Post by MegumiSawada »

Thank you!
MegumiSawada
Posts: 268
Joined: Tue Feb 19, 2013 5:18 pm

Re: [RPG]fingerprint

Post by MegumiSawada »

Hi Jason,

Thank you for your code. I've checked the behavior and now understand it.

Two more questions:
1) If the device is used by multiple users(and all of them has already registered their fingerprint to the device),can we still use this Touch ID functionality ?

2) I believe LongRange does not support Biometric authentication other than finger print authentication.
Is it technically possible if the device support the Biometric authentication?

Thank you in advance!

Best Regards,
Megumi Sawada
jasonzhou
Posts: 130
Joined: Wed Jan 11, 2017 3:26 pm

Re: [RPG]fingerprint

Post by jasonzhou »

1) If the device is used by multiple users(and all of them has already registered their fingerprint to the device),can we still use this Touch ID functionality ?

The Touch ID device can only tell if the fingerprint matches one of the enrolled fingerprints, in other words, it’s unable to tell if the fingerprints are from a single individual using multiple fingers or from various individuals using a single fingerprint. This means the mechanism will only work if the device is used by a single user. User should make sure only saving his or her own fingerprints on the device.

2) I believe LongRange does not support Biometric authentication other than finger print authentication.
Is it technically possible if the device support the Biometric authentication?

We'll do further investigation on it and will put reply in this topic https://longrange.lansa.com.au/viewtopic.php?f=11&t=603
Post Reply