Page 1 of 1

Identity Protection Act

Posted: Sat Jun 11, 2011 6:35 am
by RDalzell
Good Morning All,

A recent law has been enacted and mandatory requirements are to be implemented within the year.

Has anybody created a mask which during display would only display the last four digits of a credit card or social security number, yet if a user which has the necessary permissions, would enable the viewing of the entire field during edit?

The other aspect is the encryption/decryption of these fields.

Looking for any ideas/suggestions.

Best regards,
Rick

Re: Identity Protection Act

Posted: Sat Jun 11, 2011 10:26 am
by rdonnay
Try this:

Code: Select all

#INCLUDE "dcdialog.CH"

FUNCTION Main()

LOCAL GetList[0], cCard, bCard, lProtect := .t., oCard

cCard := '4567 8898 7345 0098'

@ 0,0 DCSAY 'Card Number' GET cCard PICTURE {||CardPicture( lProtect )} ;
      SAYSIZE 0 SAYBOTTOM GETOBJECT oCard EDITPROTECT {||lProtect}

@ 2,0 DCPUSHBUTTON CAPTION {||IIF( lProtect,'Un-Protect','Protect' )} ;
      SIZE 10 ACTION {||lProtect := !lProtect, DC_GetRefresh(GetList)}

DCREAD GUI FIT TITLE 'Credit Card Protection'

RETURN nil

* ------------

PROC appsys ; return

* ------------

FUNCTION CardPicture( lProtect )

IF lProtect
  RETURN '**** **** **** 9999'
ENDIF

RETURN '9999 9999 9999 9999'

Re: Identity Protection Act

Posted: Sun Jun 12, 2011 4:09 am
by RDalzell
Roger,

Better than Perfect...
Learned even more with that example.

Am I able to perform masking for Date fields as well?

Code: Select all

#include "DcDialog.Ch"

FUNCTION Main()

  LOCAL GetList[0], cCard1, cCard2, dDob1, dDob2, cSoc1, cSoc2, lProtect1 := .f., oCard1, oCard2, oDob1, oDob2, oSoc1, oSoc2

  PRIVATE lProtect2 := .t.

  dDob1  := CtoD('01/01/1950')
  dDob2  := CtoD('12/31/1960')
  cSoc1  := '123-45-6789'
  cSoc2  := '987-65-4321'
  cCard1 := '4567 8898 7345 0098'
  cCard2 := '4567 8898 7345 0098'


  @  0.00, 0.00 DCSAY 'Card Number 1'     SAYSIZE 0   SAYBOTTOM   GET cCard1         PICTURE {|| CardPicture( lProtect1 ) } ;
                                                                  GETOBJECT oCard1   EDITPROTECT {|| lProtect1 }

  @  0.00,40.00 DCSAY 'Birth Date  1'     SAYSIZE 0   SAYBOTTOM   GET dDob1          PICTURE {|| DobPicture( lProtect1 ) } ;
                                                                  GETOBJECT oDob1    EDITPROTECT {|| lProtect1 }

  @  0.00,70.00 DCSAY 'Social      1'     SAYSIZE 0   SAYBOTTOM   GET cSoc1          PICTURE {|| SocPicture( lProtect1 ) } ;
                                                                  GETOBJECT oSoc1    EDITPROTECT {|| lProtect1 }


  @  1.25, 0.00 DCSAY 'Card Number 2'     SAYSIZE 0   SAYBOTTOM   GET cCard2         PICTURE {|| CardPictureX( lProtect2 ) } ;
					 GETOBJECT oCard2 ;
					 GOTFOCUS{||  CardPictureX( .f. ), DC_GetRefresh(oCard2) } ;
					 LOSTFOCUS{|| CardPictureX( .t. ), DC_GetRefresh(oCard2) }

  @  1.25,40.00 DCSAY 'Birth Date  2'     SAYSIZE 0   SAYBOTTOM   GET dDob2          PICTURE {|| DobPictureX( lProtect2 ) } ;
					 GETOBJECT oDob2 ;
					 GOTFOCUS{||  DobPictureX( .f. ), DC_GetRefresh(oDob2) } ;
					 LOSTFOCUS{|| DobPictureX( .t. ), DC_GetRefresh(oDob2) }

  @  1.25,70.00 DCSAY 'Social      2'     SAYSIZE 0   SAYBOTTOM   GET cSoc2          PICTURE {|| SocPictureX( lProtect2 ) } ;
					 GETOBJECT oSoc2 ;
					 GOTFOCUS{||  SocPictureX( .f. ), DC_GetRefresh(oSoc2) } ;
					 LOSTFOCUS{|| SocPictureX( .t. ), DC_GetRefresh(oSoc2) }


  @  4.00, 0.00 DCPUSHBUTTON              CAPTION {|| IIF( lProtect1,'Un-Protect','Protect' ) } ;
                SIZE 10                   ACTION {|| lProtect1 := !lProtect1, DC_GetRefresh(GetList) }

  DCGETOPTIONS ;
		   NOCONFIRM ;
			NOMAXBUTTON ;
			HILITEGETS GRA_CLR_RED


  DCREAD GUI ;
         FIT ;
			OPTIONS GetOptions ;
			TITLE 'Credit Card Protection'

RETURN Nil

*---

STATIC FUNCTION CardPicture( lProtect )

  IF lProtect
    RETURN '**** **** **** 9999'
  ENDIF

RETURN '9999 9999 9999 9999'

*---

STATIC FUNCTION CardPictureX( lProtectX )

  lProtect2 := lProtectX

  IF lProtect2
    RETURN '**** **** **** 9999'
  ENDIF

RETURN '9999 9999 9999 9999'

*---

STATIC FUNCTION DobPicture( lProtect )

  IF lProtect
    RETURN '**/**/9999'
  ENDIF

RETURN '@D'

*---

STATIC FUNCTION DobPictureX( lProtectX )

  lProtect2 := lProtectX

  IF lProtect2
    RETURN '**/**/9999'
  ENDIF

RETURN '@D'

*---

STATIC FUNCTION SocPicture( lProtect )

  IF lProtect
    RETURN '***-**-9999'
  ENDIF

RETURN '999-99-9999'

*---

STATIC FUNCTION SocPictureX( lProtectX )

  lProtect2 := lProtectX

  IF lProtect2
    RETURN '***-**-9999'
  ENDIF

RETURN '999-99-9999'

*---

PROCEDURE AppSys
RETURN
Thank you,
Rick

Re: Identity Protection Act

Posted: Sun Jun 12, 2011 8:46 am
by rdonnay
I haven't found any way to mask date pictures.

You could try this instead:

Code: Select all

d := Date()
c := DtoC(d)

@ 10,0 DCGET d HIDE {||lProtected}
@ 10,0 DCGET c HIDE {||.NOT. Protected}  PICTURE '**\**\****'

Re: Identity Protection Act

Posted: Sun Jun 12, 2011 8:55 am
by RDalzell
Roger,

That will do it. Often times the simplest is the best.

Thanks

Re: Identity Protection Act

Posted: Mon Jun 13, 2011 12:34 pm
by Cliff Wiernik
Roger,

Just wondering on a slightly different scenario. We have staff that can see the data and other that cannot. However, since the user can print any screen, we don't want the fields to display the full data even for those with access unless the user is actually entering the data into the field at that time. We disable the print screen functionality when in the field. Thus, the data appears like.

xxxx-xxxx-xxxx-9999 when not in the field
9999-9999-9999-9999 when editing in the field

We utilize a different temp variable to actually edit the field and use the gotfocus/lostfocus clauses to move the temp variable value to/from the actual data variable being used.

Works fine, but we had to disable the screen print capability as it caused a focus change that did not trigger the gotfocus/lostfocus sequence.

I wonder if you had any thoughts on this scenario compared to our code.

Cliff.

Re: Identity Protection Act

Posted: Wed Jun 15, 2011 4:57 pm
by rdonnay
Why don't you trigger the lostfocus when you call the print routine?

Code: Select all

@ .. dcpushbutton caption 'Print' ;
action {||PostAppEvent(xbeP_KillInputFocus,,,oGet), ;
             DC_CompleteEvents(), ;
             PrintScreen()}