Function

checkPINValue

Module

XuDsigS

Last Modified

7/15/2014 3:26:44 PM

Scope

Interfaced

Declaration

function checkPINValue(InputForm: TComponent): TPINResult;

Calls Hierarchy


checkPINValue
 ├sCardReady
 │ ├SCardEstablishContext
 │ ├SCardListReadersA
 │ └SCardConnectA
 ├CryptAcquireContext
 ├setPINValue
 │ ├CryptAcquireContext
 │ ├CryptSetProvParam
 │ └CryptReleaseContext
 └CryptReleaseContext

Called-By Hierarchy


                                                       checkPINValue
                                                    getSANFromCard┤ 
                                                          SetSAN┘ │ 
                           TfrmFrame.DigitalSigningSetup1Click┤   │ 
                                             ExecuteSignOrders┤   │ 
                                  TfrmOrders.mnuActSignClick┘ │   │ 
                                         TfrmReview.cmdOKClick┘   │ 
                                               ReviewChanges┘     │ 
                           TfrmFrame.AllowContextChangeAll┤       │ 
                                TfrmFrame.FormCloseQuery┤ │       │ 
                              TfrmFrame.mnuFileNextClick┤ │       │ 
                            TfrmFrame.mnuFileOpenClick┤ │ │       │ 
                                TfrmFrame.UMInitiate┤ │ │ │       │ 
                       TfrmFrame.mnuFileNextClick...┤ │ │ │       │ 
                       TfrmFrame.mnuFileRefreshClick┤ │ │ │       │ 
                       TfrmOrders.CheckOrderStatus┤ │ │ │ │       │ 
                   TfrmOrders.mnuActChgEvntClick┤ │ │ │ │ │       │ 
                      TfrmOrders.mnuActHoldClick┤ │ │ │ │ │       │ 
                    TfrmOrders.mnuActUnholdClick┤ │ │ │ │ │       │ 
                     TfrmOrders.mnuActRenewClick┤ │ │ │ │ │       │ 
                    TfrmOrders.mnuActChangeClick┤ │ │ │ │ │       │ 
                      TfrmOrders.mnuActCopyClick┘ │ │ │ │ │       │ 
                            TfrmMeds.mnuActDCClick┤ │ │ │ │       │ 
                           TfrmMeds.CheckMedStatus┘ │ │ │ │       │ 
                        TfrmMeds.mnuActHoldClick┤   │ │ │ │       │ 
                       TfrmMeds.mnuActRenewClick┤   │ │ │ │       │ 
                      TfrmMeds.mnuActUnholdClick┤   │ │ │ │       │ 
                      TfrmMeds.mnuActChangeClick┤   │ │ │ │       │ 
                        TfrmMeds.mnuActCopyClick┤   │ │ │ │       │ 
                      TfrmMeds.mnuActRefillClick┘   │ │ │ │       │ 
                                  TfrmFrame.ViewInfo┘ │ │ │       │ 
                               TfrmDCSumm.ViewInfo┤   │ │ │       │ 
                             TfrmConsults.ViewInfo┤   │ │ │       │ 
                     TfrmFrame.pnlRemindersMouseUp┤   │ │ │       │ 
                      TfrmFrame.RemindersChanged┘ │   │ │ │       │ 
                          TfrmFrame.FormCreate┘   │   │ │ │       │ 
                            TfrmFrame.pnlCIRNClick┤   │ │ │       │ 
                      TfrmFrame.pnlVistaWebClick┤ │   │ │ │       │ 
                           TfrmFrame.FormKeyDown┘ │   │ │ │       │ 
                         TfrmFrame.pnlPatientClick┤   │ │ │       │ 
                           TfrmFrame.pnlVisitClick┤   │ │ │       │ 
                     TfrmFrame.pnlPrimaryCareClick┤   │ │ │       │ 
                       TfrmFrame.pnlRemindersClick┤   │ │ │       │ 
                        TfrmFrame.pnlPostingsClick┤   │ │ │       │ 
                            TfrmFrame.pnlFlagClick┤   │ │ │       │ 
                              TfrmFrame.laMHVClick┤   │ │ │       │ 
                             TfrmFrame.laVAA2Click┤   │ │ │       │ 
                               TfrmOrders.ViewInfo┤   │ │ │       │ 
                                 TfrmMeds.ViewInfo┤   │ │ │       │ 
                              TfrmSurgery.ViewInfo┤   │ │ │       │ 
                                TfrmNotes.ViewInfo┤   │ │ │       │ 
                             TfrmProblems.ViewInfo┘   │ │ │       │ 
                     TfrmFrame.mnuFileNotifRemoveClick┤ │ │       │ 
                             TfrmFrame.NextButtonClick┘ │ │       │ 
                           TfrmFrame.SetUpNextButton┘   │ │       │ 
                     TfrmFrame.mnuFileOpenClick...┤     │ │       │ 
                              TfrmFrame.FormResize┘     │ │       │ 
                            TfrmFrame.ChangeFont┘       │ │       │ 
                    TfrmFrame.LoadSizesForUser┤         │ │       │ 
               TfrmFrame.LoadUserPreferences┘ │         │ │       │ 
                      TfrmFrame.UMInitiate┘   │         │ │       │ 
                    TfrmFrame.mnuFontSizeClick┘         │ │       │ 
                           TfrmFrame.mnuFileOpenClick...┤ │       │ 
                           TfrmFrame.ctxContextorPending┤ │       │ 
                          TfrmFrame.StartCCOWContextor┘ │ │       │ 
                                TfrmFrame.FormCreate┘   │ │       │ 
                         TfrmFrame.ctxContextorCommitted┤ │       │ 
                       TfrmFrame.StartCCOWContextor...┘ │ │       │ 
                  TfrmFrame.mnuFileResumeContextGetClick┤ │       │ 
                  TfrmFrame.mnuFileResumeContextSetClick┘ │       │ 
                                  TfrmFrame.FormCloseQuery┤       │ 
                              TfrmFrame.mnuFileReviewClick┤       │ 
                                           UpdateEncounter┘       │ 
                         TfrmFrame.mnuFileEncounterClick┤         │ 
                                 TfrmFrame.ViewInfo...┤ │         │ 
                    TfrmODMedIV.SetValuesFromResponses┤ │         │ 
                             TfrmODMedIV.SetupDialog┤ │ │         │ 
                   TfrmODMedIV.cboSolutionMouseClick┘ │ │         │ 
                       TfrmODMedIV.cboSolutionExit┘   │ │         │ 
                  TfrmODMedIV.cboSolutionMouseClick...┤ │         │ 
                     TfrmODMedIV.cboAdditiveMouseClick┤ │         │ 
                         TfrmODMedIV.cboAdditiveExit┘ │ │         │ 
                                TfrmODAuto.SetupDialog┤ │         │ 
                                   ActivateOrderDialog┤ │         │ 
                           TfrmRemDlg.btnFinishClick┤ │ │         │ 
           TfrmConsults.mnuActNewConsultRequestClick┤ │ │         │ 
                   TfrmConsults.cmdNewConsultClick┘ │ │ │         │ 
                TfrmConsults.mnuActNewProcedureClick┤ │ │         │ 
                      TfrmConsults.cmdNewProcClick┘ │ │ │         │ 
                                        ChangeOrders┤ │ │         │ 
                      TfrmOrders.mnuActChangeClick┤ │ │ │         │ 
                        TfrmMeds.mnuActChangeClick┘ │ │ │         │ 
                                     ChangeOrdersEvt┤ │ │         │ 
                                          CopyOrders┤ │ │         │ 
                        TfrmOrders.mnuActCopyClick┤ │ │ │         │ 
                          TfrmMeds.mnuActCopyClick┤ │ │ │         │ 
                           TfrmODActive.btnOKClick┘ │ │ │         │ 
                                      TransferOrders┤ │ │         │ 
                        TfrmOrders.mnuActCopyClick┤ │ │ │         │ 
                          TfrmMeds.mnuActCopyClick┤ │ │ │         │ 
                           TfrmODActive.btnOKClick┘ │ │ │         │ 
                            TfrmOrders.lstWriteClick┤ │ │         │ 
               TfrmOrders.PlaceOrderForDefaultDialog┤ │ │         │ 
                  TfrmOrders.DisplayDefaultDlgList┤ │ │ │         │ 
                       TfrmOrders.ResetOrderPage┘ │ │ │ │         │ 
               TfrmOrders.btnDelayedOrderClick┘   │ │ │ │         │ 
                                 DisplayEvntDialog┤ │ │ │         │ 
                             SetDelayEventForMed┘ │ │ │ │         │ 
                      TfrmMeds.mnuActCopyClick┘   │ │ │ │         │ 
                                 DisplayEvntDialog┤ │ │ │         │ 
                                  SetViewForCopy┘ │ │ │ │         │ 
                    TfrmOrders.mnuActCopyClick┘   │ │ │ │         │ 
                                 DisplayEvntDialog┘ │ │ │         │ 
                                ExecuteChangeEvt┘   │ │ │         │ 
                 TfrmOrders.mnuActChgEvntClick┘     │ │ │         │ 
                             TfrmMeds.mnuActNewClick┤ │ │         │ 
                           TfrmOMNavA.ActivateDialog┤ │ │         │ 
                         TfrmOMNavA.grdMenuKeyDown┤ │ │ │         │ 
                         TfrmOMNavA.grdMenuMouseUp┘ │ │ │         │ 
                                TfrmOMSet.DoNextItem┘ │ │         │ 
                              TfrmOMSet.InsertList┤   │ │         │ 
                               ActivateOrderList┘ │   │ │         │ 
                     TfrmRemDlg.btnFinishClick┤   │   │ │         │ 
                             ActivateOrderHTML┤   │   │ │         │ 
                    TfrmOrders.lstWriteClick┤ │   │   │ │         │ 
    TfrmOrders.PlaceOrderForDefaultDialog...┘ │   │   │ │         │ 
                              ActivateOrderSet┤   │   │ │         │ 
                   TfrmRemDlg.btnFinishClick┤ │   │   │ │         │ 
TfrmConsults.mnuActNewConsultRequestClick...┤ │   │   │ │         │ 
     TfrmConsults.mnuActNewProcedureClick...┤ │   │   │ │         │ 
                    TfrmOrders.lstWriteClick┤ │   │   │ │         │ 
    TfrmOrders.PlaceOrderForDefaultDialog...┤ │   │   │ │         │ 
                     TfrmMeds.mnuActNewClick┤ │   │   │ │         │ 
                TfrmOMNavA.ActivateDialog...┤ │   │   │ │         │ 
                     TfrmOMSet.DoNextItem...┘ │   │   │ │         │ 
                       TfrmOMNavA.DoSelectList┘   │   │ │         │ 
                     TfrmOMNavA.grdMenuKeyUp┤     │   │ │         │ 
                   TfrmOMNavA.grdMenuMouseUp┘     │   │ │         │ 
                                        SkipToNext┤   │ │         │ 
                         TfrmOMSet.DoNextItem...┘ │   │ │         │ 
                            TfrmOMSet.UMDelayEvent┘   │ │         │ 
                               TfrmOMSet.InsertList...┤ │         │ 
                                TfrmODMeds.SetupDialog┤ │         │ 
                             TfrmODMeds.btnSelectClick┤ │         │ 
                             TfrmODMeds.UMDelayClick┘ │ │         │ 
                                    ExecuteRenewOrders┘ │         │ 
                         TfrmOrders.mnuActRenewClick┤   │         │ 
                           TfrmMeds.mnuActRenewClick┘   │         │ 
                                        EncounterPresent┤         │ 
                                      ReadyForNewOrder┤ │         │ 
                           TfrmRemDlg.btnFinishClick┤ │ │         │ 
        TfrmConsults.mnuActNewConsultRequestClick...┤ │ │         │ 
             TfrmConsults.mnuActNewProcedureClick...┤ │ │         │ 
                                     ChangeOrders...┤ │ │         │ 
                                     ChangeOrdersEvt┤ │ │         │ 
                                       CopyOrders...┤ │ │         │ 
                                   TransferOrders...┤ │ │         │ 
                            TfrmOrders.lstWriteClick┤ │ │         │ 
                             TfrmMeds.mnuActNewClick┘ │ │         │ 
                                     ReadyForNewOrder1┤ │         │ 
            TfrmOrders.PlaceOrderForDefaultDialog...┘ │ │         │ 
                              TfrmOrders.mnuActDCClick┤ │         │ 
                             TfrmOrders.mnuActRelClick┤ │         │ 
                            TfrmOrders.mnuActHoldClick┤ │         │ 
                          TfrmOrders.mnuActUnholdClick┤ │         │ 
                           TfrmOrders.mnuActRenewClick┤ │         │ 
                         TfrmOrders.mnuActReleaseClick┤ │         │ 
                         TfrmOrders.mnuActOnChartClick┤ │         │ 
                            TfrmOrders.mnuActSignClick┤ │         │ 
                                TfrmMeds.mnuActDCClick┤ │         │ 
                              TfrmMeds.mnuActHoldClick┤ │         │ 
                             TfrmMeds.mnuActRenewClick┤ │         │ 
                            TfrmMeds.mnuActUnholdClick┤ │         │ 
                              TfrmMeds.mnuActCopyClick┤ │         │ 
                            TfrmMeds.mnuActRefillClick┘ │         │ 
                                     EncounterPresentEDO┤         │ 
                                   ReadyForNewOrder...┤ │         │ 
                         TfrmOrders.mnuActChgEvntClick┤ │         │ 
                          TfrmOrders.mnuActChangeClick┤ │         │ 
                            TfrmOrders.mnuActCopyClick┤ │         │ 
                       TfrmOrders.btnDelayedOrderClick┤ │         │ 
                            TfrmMeds.mnuActChangeClick┤ │         │ 
                              TfrmMeds.mnuActCopyClick┘ │         │ 
                                             UpdateVisit┤         │ 
                                           EditPCEData┤ │         │ 
                             TfrmSurgery.cmdPCEClick┤ │ │         │ 
                                 UpdateEncounterInfo┘ │ │         │ 
                             TfrmNotes.cmdPCEClick┘   │ │         │ 
                        TfrmVitals.btnEnterVitalsClick┘ │         │ 
                                             UpdateVisit┤         │ 
                                        EncounterPresent┘         │ 
                         TfrmProblems.lstProbActsClick┘           │ 
                     TfrmProblems.wgProbDataDblClick┤             │ 
                           TfrmProblems.lstViewClick┘             │ 
                   TfrmProblems.HighlightDuplicate┘               │ 
                         TfrmProblems.AddProblem┤                 │ 
              TfrmProblems.lstProbActsClick...┤ │                 │ 
                 TfrmProblems.lstProbPickClick┤ │                 │ 
              TfrmProblems.lstProbPickDblClick┤ │                 │ 
              TfrmProblems.edProbEntKeyPress┘ │ │                 │ 
                      TfrmProblems.UMPLLexicon┘ │                 │ 
                   TfrmdlgProb.bbChangeProbClick┘                 │ 
                                              ExecuteSignOrders...┤ 
                                          TfrmReview.cmdOKClick...┘ 

Calls

Name Declaration Comments
CryptAcquireContext function CryptAcquireContext(phProv :PHCRYPTPROV; pszContainer :LPAWSTR; pszProvider :LPAWSTR; dwProvType :DWORD; dwFlags :DWORD) :BOOL;stdcall; -
CryptReleaseContext function CryptReleaseContext(hProv :HCRYPTPROV; dwFlags :DWORD) :BOOL;stdcall; -
sCardReady function sCardReady: boolean; -
setPINValue function setPINValue(PinValue: String; handle: Dword): Boolean; -

Called-By

Name Declaration Comments
TfrmReview.cmdOKClick procedure cmdOKClick(Sender: TObject); -
ExecuteSignOrders {Forward} function ExecuteSignOrders(SelectedList: TList): Boolean; -
getSANFromCard function getSANFromCard(InputForm: TComponent; crypto: tCryptography): String; -


Source

1477  function checkPINValue(InputForm: TComponent): TPINResult;
1478  var
1479    ready: Boolean;
1480    handle2: DWORD;
1481    Container: String;
1482    ErrVal: Integer;
1483    Done: Boolean;
1484    fPinEntry: TfrmPINPrompt;
1485    LoopCount: Integer;
1486  begin
1487    if not sCardReady then
1488    begin
1489      ShowMessage('Put a smart card in the Reader, then Press OK');
1490      sleep(5000);
1491      if not sCardReady then
1492      begin
1493        Result := prError;
1494        exit;
1495      end;
1496    end;
1497    handle2 := 0;
1498    Container := '';
1499    ready := CryptAcquireContext(@handle2,PChar(Container),pchar('ActivClient Cryptographic Service Provider'),1,0);
1500    if ready = false then
1501    begin
1502     // Unable to aquire context, check if failure was due to
1503     // absence of key container.
1504  
1505     CryptAcquireContext(@handle2,
1506                  pchar(Container),
1507                  pchar('ActivClient Cryptographic Service Provider'),
1508                  1,
1509                  CRYPT_NEWKEYSET);
1510    end;
1511    if handle2 = 0 then
1512    begin
1513      ErrVal := GetLastError;
1514      ShowMessage('Could not aquire context Last Error val was '+IntToStr(ErrVal)+'  '+SysErrorMessage(ErrVal));
1515      Result := prError;
1516      exit;
1517    end;
1518    try
1519      Result := prOK;
1520      Done := false;
1521      LoopCount := 1;
1522      fPinEntry := TfrmPINPrompt.Create(InputForm);
1523      try
1524        while not Done do
1525        begin
1526          fPinEntry.edtPINValue.Text := '';
1527          if fPinEntry.ShowModal() = mrOK then
1528          begin
1529            PinValue := fPinEntry.edtPinValue.Text;
1530            if PinValue = '' then
1531            begin
1532              ShowMessage('Enter a valid PIN value or Press Cancel');
1533              Dec(LoopCount);
1534            end
1535            else
1536            begin
1537              ready := setPINValue(PinValue,handle2);
1538              if ready then
1539              begin
1540                LastPINValue := PinValue;
1541                Result := prOK;
1542                Done := true;
1543              end
1544              else
1545              begin
1546                if LoopCount < 3 then
1547                begin
1548                  ShowMessage('Invalid PIN entry - You only have '+IntToStr(3-LoopCount)+' attempts left before it is locked.');
1549                end
1550                else
1551                begin
1552                  ShowMessage('That was three (3) unsuccessful tries, the Card Reader is Locked');
1553                  Result := prLocked;
1554                  Done := true;
1555                end;
1556              end;
1557            end;
1558            Inc(LoopCount);
1559          end
1560          else
1561          begin
1562            ShowMessage('Pin Entry was cancelled');
1563            Result := prCancel;
1564            Done := true;
1565          end;
1566        end;
1567      finally
1568        fPinEntry.Free;
1569      end;
1570    finally
1571      if not (handle2 = 0) then
1572      begin
1573        CryptReleaseContext(handle2, 0);
1574      end;
1575    end;
1576  end;