home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1997 May
/
Pcwk0597.iso
/
borland
/
ib
/
setups
/
intrabld
/
data.z
/
SECURITY.JCF
< prev
next >
Wrap
Text File
|
1996-12-11
|
4KB
|
154 lines
/****************************************************************************\
* *
* Security.jcf - Custom Security Form Classes *
* *
* Updated 11/07/96 by IntraBuilder Samples Group *
* $Revision: 1.15 $ *
* *
* Copyright (c) 1996, Borland International, Inc. All rights reserved. *
* *
\****************************************************************************/
#include "security.h"
//
// smLoginForm
//
// You need to set two custom properties of this form:
//
// security - assign a SecurityManager object
// nextForm - assign a form reference. This form is opened after
// a successful login.
//
class smLoginForm extends Form custom {
with (this) {
onServerSubmit = class::Form_onServerSubmit;
height = 10;
left = 0;
top = 0;
width = 60;
title = "Security Manager";
}
with (this.userNameHTML = new HTML(this)){
height = 1;
top = 5;
width = 16;
color = "black";
text = "User name";
}
with (this.userNameText = new Text(this)){
left = 16;
top = 5;
width = 20;
value = "";
}
with (this.passwordHTML = new HTML(this)){
height = 1;
top = 6;
width = 16;
color = "black";
text = "Password";
}
with (this.passwordText = new Password(this)){
left = 16;
top = 6;
width = 20;
value = "";
}
with (this.submitButton = new Button(this)){
onServerClick = class::submitButton_onServerClick;
top = 8;
width = 10.5;
text = "Submit";
}
with (this.clearButton = new Button(this)){
onClick = {;this.form.userNameText.value = this.form.passwordText.value = ''};
left = 14;
top = 8;
width = 10.5;
text = "Clear";
}
with (this.failedHTML = new HTML(this)){
height = 1;
top = 5;
width = 50;
color = "black";
text = "<h2>Login Failed</h2>";
pageno = 2;
}
with (this.messageHTML = new HTML(this)){
height = 2;
top = 6;
width = 50;
color = "black";
text = "message";
pageno = 2;
}
with (this.backButton = new Button(this)){
onServerClick = {;this.form.passwordText.value = "" ;this.form.pageno = 1};
top = 8;
width = 14;
text = "Back";
pageno = 2;
}
function submitButton_onServerClick()
{
this.form.Form_onServerSubmit(true,this.form);
}
function Form_onServerSubmit(notForm, formRef)
{
var form = notForm ? formRef : this;
try {
form.security.login(form.userNameText.value,form.passwordText.value);
// blank out password
form.passwordText.value = "";
// launch next form
try {
form.nextForm.open();
form.release();
}
catch (Exception e) {
try {
// try to close the errant form
form.nextForm.close();
form.nextForm.release();
}
catch (Exception e) {
// do nothing
}
form.messageHTML.text = "Login Error:<br>" + e.message;
form.pageno = 2;
}
}
catch (SmException e) {
// test for error conditions and return error form
if ((e.code == SM_ERROR_INVALID_USERNAME) ||
(e.code == SM_ERROR_INVALID_PASSWORD))
form.messageHTML.text = " Invalid user name or password ";
else
form.messageHTML.text = e.message + " (" + e.code + ")";
form.pageno = 2;
}
}
}