Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Security Timeout 1

Status
Not open for further replies.

finsys

Programmer
Jan 31, 2002
56
GB
I'm just starting to develop an app which requires some security features due to the nature of the data. One of the items in the spec is that after say 30 mins of inactivity, the application locks out the user and they to re-input their password to continue. I'm trying to figure out the best way to do this.

I thought of having a timer class ticking away in the background, incrementing a counter. When the counter reaches a certain value, it calls the lockout routine. I would then need to intercept keystrokes and reset the counter each time a key is pressed or mouse clicked. I'd use the keypreview property to get the keystroke before the control with focus and the keypress event of the form would do the reseting of the counter. Trouble is there's LOTS of forms in the app, so this would have to be set on every form (I suppose I can make a new form class...).

I did spot you can set the _SCREEN to have keypreview, BUT it has no keypress event for you to then process any keystrokes! That would seem the tidiest place to control the counter from, but I can't see a way of doing it.

Anyone every done this before or have any better ideas?

TIA
Ric
 
finsys,

You could use the background screen's addobject like this:

_screen.AddObject("timer1","timer")
 
Dontcha jsut love it - key in a question and then find you got something wrong. I just found there is a keypress event for _SCREEN (type _screen. in the command window and let intellisense do the rest :) ) - but how can run code on the event and anyone know if _SCREEN will always intercept the keystroke first? I was thinking that if no forms are displayed in the apps main window, then the form method of checking for activity would not work.
 
mgagnon, creating the timer is not a problem, that's the easy part. It's the keystroke detection that is buggin me.
 
How about if you were to try something like this. Create your timer that fires every 30 minutes. Then in your timer event, put in this code:

*... We'll give them another 30 seconds to type or click
KeyVal = INKEY(30, "MS") &&... Show cursor and mouse.
IF KeyVal = 0 &&... no key pressed,
This.Interval = 0
DO FORM Relogin
This.Interval = 180000 &&... reset to 30 minutes
ELSE
KEYBOARD CHR(KeyVal) &&... need to grab the key too
ENDIF

Dave S.
 
Hi FinSys

I had similar problem.

I modified my base class (form, text, label etc...) and I put in KeyPress and MouseMove events

nMyCounter=0

and then I trap it in Timer event

If you havent a base class for your object you can create it and then open your forms as a table and modify field Class and ClassLoc for your object
Andrea C.P.
Italy [atom]
 
Dave, that wouldn't give a full 30 minutes of no use, the timeout would be dependant on when during the 30 minute timer period they stopped using the system.

Andrea, I'll probably end up sticking in the forms like that. I've had to create a base form class anyhow due to other features required. Also it struck me that if no forms are active and only the main screen is open, chances are the user is not doing anything with the application anyhow!
 
Finsys,

Screen object have not MouseMove event but if you can simulate a screen object creating your ScreenForm defining it as Top Level Form (ShowWindow=2) and define his MouseMove event. Then you have only to define your existing forms as In Top Level Form (ShowWindow=1) so they are placed in active TopLevelForm (your ScreenForm) and not in Screen. Andrea C.P.
Italy [atom]
 
HI

1. Add a timer event to your form class.
The timer event shall contain code as to what to do when the count down is over.

2. In the keypress event...add code...
myTimer.Reset()
This will restart the timer every time a key is pressed.

Take care suitable for mouse movement.
Fairly, MouseMove Event of the form will do to detect mouse movement. So put the myTimer.Reset() in that event also. It is very unlikely that a user only moves the moves over an object and avoid the form canvass.
If such a huge container is placed and the mouse movent need to be tracked, you need to add the code in that containers mouseMOve event as well. Example.. GridClass ..

Once you can reset the timer, the timers firing the wanted event is delayed. You can achieve the purpose you want :)


ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
I'd just create a public variable and give it a value with time(). Each time a form is launched or closed (or gets focus etc) compare time() with that value. If it has been more than 30 minutes execute your shutdown code, otherwise update the variable with the new time().

Brian
 
It is possible to capture the KeyPress and MouseMove of the screen object, just do the following:
Code:
* in Main .PRG:
RELEASE oApp
PUBLIC oApp
oApp = CREATEOBJECT('myApplication')
.
.
.
DEFINE CLASS myApplication AS session
  DataSession = 1 && Default
  SCREEN      = _Screen  && Now you can bind to _SCREEN Events!
  
  PROCEDURE Screen.Resize 
    * Place screen resize code here
  ENDPROC
  PROCEDURE Screen.KeyPress
  LPARAMETERS [nIndex,] nKeyCode, nShiftAltCtrl
    * Place screen KeyPress code here
  ENDPROC
ENDDEFINE
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top