home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1997 May
/
Pcwk0597.iso
/
borland
/
ib
/
setups
/
intrabld
/
data.z
/
SMADMIN.JFM
< prev
next >
Wrap
Text File
|
1996-12-11
|
14KB
|
441 lines
/****************************************************************************\
* *
* SmAdmin.jfm -- Security Administration Form *
* *
* This form is part of the security administration prebuilt business *
* solution. This is the main adminstration form. It allows you to define *
* users, groups resources and policies. Your applications can then be *
* secured. See the Phone Book application for an example of using the *
* security system. *
* *
* Dependencies: secur21.gif *
* homepg31.gif *
* apps\shared\controls.cc *
* *
* Updated 11/13/96 by IntraBuilder Samples Group *
* $Revision: 1.11 $ *
* *
* Copyright (c) 1996, Borland International, Inc. All rights reserved. *
* *
\****************************************************************************/
#include "SECURITY.H"
_sys.scripts.load(SM_CLASS_LOCATION + "SECURITY.JS");
// create form reference for this form
var f = new smadminForm();
f.security = new SecurityManagerAdmin();
// create security object and login
_sys.scripts.load("smlogin.jfm");
var login = new smloginForm();
login.security = f.security;
login.nextForm = f;
login.open();
return;
// {End Header} Do not remove this comment//
// Generated on 11/13/96
//
var f = new smadminForm();
f.open();
class smadminForm extends SecurityForm from "SMADMIN.JCF" {
_sys.scripts.load(_sys.env.home() + "APPS\\SHARED\\CONTROLS.CC")
with (this) {
preRender = class::Form_preRender;
onServerLoad = class::Form_onServerLoad;
color = "fff7c4";
height = 14.6667;
left = 0;
top = 0;
width = 76;
title = "Security Administration";
}
with (this.rule1 = new Rule(this)){
top = 4;
size = 2;
right = 74;
pageno = 0;
}
with (this.rule2 = new Rule(this)){
top = 13;
size = 2;
right = 74;
pageno = 0;
}
with (this.rule3 = new Rule(this)){
top = 17.5;
size = 2;
right = 74;
pageno = 0;
}
with (this.userButton = new Button(this)){
onServerClick = class::userButton_onServerClick;
top = 4.5;
width = 14;
text = "Users";
}
with (this.groupButton = new Button(this)){
onServerClick = class::groupButton_onServerClick;
left = 18;
top = 4.5;
width = 14;
text = "Groups";
}
with (this.resourceButton = new Button(this)){
onServerClick = class::resourceButton_onServerClick;
left = 36;
top = 4.5;
width = 14;
text = "Resources";
}
with (this.policyButton = new Button(this)){
onServerClick = class::policyButton_onServerClick;
left = 54;
top = 4.5;
width = 14;
text = "Policies";
}
with (this.entitySelect = new ListBox(this)){
height = 5;
top = 6;
width = 74;
}
with (this.newButton = new Button(this)){
onServerClick = class::newButton_onServerClick;
top = 11.5;
width = 14;
text = "Add...";
}
with (this.copyButton = new Button(this)){
onServerClick = class::copyButton_onServerClick;
left = 18;
top = 11.5;
width = 14;
text = "Copy...";
}
with (this.updateButton = new Button(this)){
onServerClick = class::updateButton_onServerClick;
left = 36;
top = 11.5;
width = 14;
text = "Update...";
}
with (this.deleteButton = new Button(this)){
onServerClick = class::deleteButton_onServerClick;
left = 54;
top = 11.5;
width = 14;
text = "Delete";
}
with (this.HomePageLinkImage = new Image(this)){
onImageClick = class::link_to_home_page;
height = 3.4167;
top = 13.5;
width = 10.25;
dataSource = "filename HOMEPG31.GIF";
alignment = 4;
pageno = 0;
}
with (this.HomePageLinkHTML = new HTML(this)){
height = 1;
left = 12;
top = 13.5;
width = 62;
color = "black";
text = "<A HREF='/ibapps/index.htm'>Return to Home Page</A>";
pageno = 0;
}
with (this.failedHTML = new HTML(this)){
height = 4;
top = 5;
width = 74;
color = "black";
text = "Security Manager Administration failed to load. Notify the system administrator.";
pageno = 2;
}
with (this.backButton2 = new Button(this)){
onServerClick = {;this.form.pageno=1};
top = 10;
width = 10.5;
text = "Back";
pageno = 2;
}
with (this.GeneratedHTML1 = new GeneratedHTML(this)){
height = 1;
top = 18;
width = 74;
pageno = 0;
}
with (this.whichEntity = new Hidden(this)){
left = 20;
top = 2;
value = 0;
}
function Form_onServerLoad()
{
// this.whichEntity.value = 0; // 0 = user
this.fillSelect(this);
}
function Form_preRender()
{
this.fillSelect(this);
}
function fillSelect(formRef)
{
var form = formRef;
form.entityArray = new Array();
var tmpArray = new AssocArray();
try {
// get the assoc array depending on which entity is selected
switch (parseInt(form.whichEntity.value)) {
case 0: // user
tmpArray = form.security.getAllUsers();
break;
case 1: // group
tmpArray = form.security.getAllGroups();
break;
case 2: // resource
tmpArray = form.security.getAllResources();
break;
default: // policy
tmpArray = form.security.getAllPolicies();
break;
}
// fill the entityArray with the contents of the AssocArray
var entity = "";
for (var i = 0; i<tmpArray.count(); i++) {
entity = (i==0) ? tmpArray.firstKey : tmpArray.nextKey(entity);
form.entityArray.add(entity + " - " +
((tmpArray[entity]==null) ? "" : tmpArray[entity]));
}
// sort the resulting array
form.entityArray.sort();
// assign array to the select control
form.entitySelect.options = "array form.entityArray";
}
catch (Exception e) {
form.failedHTML.text = "Error loading security information: "
+ e.message + " (" + e.code + ")";
form.backButton2.visible = false;
form.pageno = 2;
}
}
function newButton_onServerClick()
{
// store entity name
var entityName = false;
var entityObj = null;
// load the appropriate administration form
switch (parseInt(this.form.whichEntity.value)) {
case 0: // user
entityObj = this.form.security.getUserObject(entityName);
_sys.scripts.load("smuadmin.jfm");
var f = new smuadminForm();
break;
case 1: // group
entityObj = this.form.security.getGroupObject(entityName);
_sys.scripts.load("smgadmin.jfm");
var f = new smgadminForm();
break;
case 2: // resource
entityObj = this.form.security.getResourceObject(entityName);
_sys.scripts.load("smradmin.jfm");
var f = new smradminForm();
break;
default: // policy
entityObj = this.form.security.getPolicyObject(entityName);
_sys.scripts.load("smpadmin.jfm");
var f = new smpadminForm();
break;
}
// set the necessary properties
f.copyEntity = false;
f.entity = entityObj;
f.security = this.form.security;
f.callingForm = this.form;
f.open();
}
function copyButton_onServerClick()
{
// store entity name
var entityName = this.form.entitySelect.value;
entityName = entityName.substring(0, entityName.indexOf(" -"));
if (entityName.length > 0) {
var entityObj = null;
// load the appropriate administration form
switch (parseInt(this.form.whichEntity.value)) {
case 0: // user
entityObj = this.form.security.getUserObject(entityName);
_sys.scripts.load("smuadmin.jfm");
var f = new smuadminForm();
break;
case 1: // group
entityObj = this.form.security.getGroupObject(entityName);
_sys.scripts.load("smgadmin.jfm");
var f = new smgadminForm();
break;
case 2: // resource
entityObj = this.form.security.getResourceObject(entityName);
_sys.scripts.load("smradmin.jfm");
var f = new smradminForm();
break;
default: // policy
entityObj = this.form.security.getPolicyObject(entityName);
_sys.scripts.load("smpadmin.jfm");
var f = new smpadminForm();
break;
}
// set the necessary properties
f.copyEntity = true;
f.entity = entityObj;
f.security = this.form.security;
f.callingForm = this.form;
f.open();
}
}
function updateButton_onServerClick()
{
// store entity name
var entityName = this.form.entitySelect.value;
entityName = entityName.substring(0, entityName.indexOf(" -"));
_sys.scriptOut.writeln(":" + entityName + ":");
if (entityName.length > 0) {
var entityObj = null;
// load the appropriate administration form
switch (parseInt(this.form.whichEntity.value)) {
case 0: // user
entityObj = this.form.security.getUserObject(entityName);
_sys.scripts.load("smuadmin.jfm");
var f = new smuadminForm();
break;
case 1: // group
entityObj = this.form.security.getGroupObject(entityName);
_sys.scripts.load("smgadmin.jfm");
var f = new smgadminForm();
break;
case 2: // resource
entityObj = this.form.security.getResourceObject(entityName);
_sys.scripts.load("smradmin.jfm");
var f = new smradminForm();
break;
default: // policy
entityObj = this.form.security.getPolicyObject(entityName);
_sys.scripts.load("smpadmin.jfm");
var f = new smpadminForm();
break;
}
// set the necessary properties
f.copyEntity = false;
f.entity = entityObj;
f.security = this.form.security;
f.callingForm = this.form;
f.open();
}
}
function deleteButton_onServerClick()
{
// store entity name
var entityName = this.form.entitySelect.value;
entityName = entityName.substring(0, entityName.indexOf(" -"));
try {
// delete the entity
if (entityName.length > 0) {
// delete the entity
switch (parseInt(this.form.whichEntity.value)) {
case 0: // user
this.form.security.deleteUser(entityName);
break;
case 1: // group
this.form.security.deleteGroup(entityName);
break;
case 2: // resource
this.form.security.deleteResource(entityName);
break;
default: // policy
this.form.security.deletePolicy(entityName);
break;
}
}
// update the list of entities
this.form.fillSelect(this.form);
}
catch (Exception e) {
this.form.failedHTML.text = "Error during delete: " + e.message +
" (" + e.code + ")";
this.form.pageno = 2;
}
}
function link_to_home_page()
{
location.href="/ibapps/index.htm";
}
function userButton_onServerClick()
{
this.form.whichEntity.value = 0;
this.form.fillSelect(this.form);
}
function groupButton_onServerClick()
{
this.form.whichEntity.value = 1;
this.form.fillSelect(this.form);
}
function resourceButton_onServerClick()
{
this.form.whichEntity.value = 2;
this.form.fillSelect(this.form);
}
function policyButton_onServerClick()
{
this.form.whichEntity.value = 3;
this.form.fillSelect(this.form);
}
}