home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************\
- * *
- * 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 9/3/96 by IntraBuilder Samples Group *
- * $Revision: 1.5 $ *
- * *
- * 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 09/03/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) {
- height = 27.2941;
- left = 0;
- top = 0.2941;
- width = 87;
- title = "Security Administration";
- onServerLoad = class::Form_onServerLoad;
- }
-
-
- with (this.rule1 = new Rule(this)){
- left = 2;
- top = 7;
- size = 2;
- right = 82;
- pageno = 0;
- }
-
-
- with (this.rule2 = new Rule(this)){
- left = 2;
- top = 18;
- size = 2;
- right = 82;
- pageno = 0;
- }
-
-
- with (this.rule3 = new Rule(this)){
- left = 2;
- top = 25;
- size = 2;
- right = 82;
- pageno = 0;
- }
-
-
- with (this.userButton = new Button(this)){
- left = 2;
- top = 8;
- width = 20;
- text = "Users";
- onServerClick = class::userButton_onServerClick;
- }
-
-
- with (this.groupButton = new Button(this)){
- left = 22;
- top = 8;
- width = 20;
- text = "Groups";
- onServerClick = class::groupButton_onServerClick;
- }
-
-
- with (this.resourceButton = new Button(this)){
- left = 42;
- top = 8;
- width = 20;
- text = "Resources";
- onServerClick = class::resourceButton_onServerClick;
- }
-
-
- with (this.policyButton = new Button(this)){
- left = 62;
- top = 8;
- width = 20;
- text = "Policies";
- onServerClick = class::policyButton_onServerClick;
- }
-
-
- with (this.entitySelect = new ListBox(this)){
- height = 6;
- left = 2;
- top = 10;
- width = 80;
- }
-
-
- with (this.newButton = new Button(this)){
- left = 2;
- top = 16;
- width = 20;
- text = "Add New";
- onServerClick = class::newButton_onServerClick;
- }
-
-
- with (this.copyButton = new Button(this)){
- left = 22;
- top = 16;
- width = 20;
- text = "Add Copy";
- onServerClick = class::copyButton_onServerClick;
- }
-
-
- with (this.updateButton = new Button(this)){
- left = 42;
- top = 16;
- width = 20;
- text = "Update";
- onServerClick = class::updateButton_onServerClick;
- }
-
-
- with (this.deleteButton = new Button(this)){
- left = 62;
- top = 16;
- width = 20;
- text = "Delete";
- onServerClick = class::deleteButton_onServerClick;
- }
-
-
- with (this.HomePageLinkImage = new Image(this)){
- height = 4.8235;
- left = 2;
- top = 19;
- width = 13.6667;
- dataSource = "filename HOMEPG31.GIF";
- alignment = 4;
- pageno = 0;
- onImageClick = class::link_to_home_page;
- }
-
-
- with (this.HomePageLinkHTML = new HTML(this)){
- height = 1;
- left = 22;
- top = 19;
- width = 60;
- color = "black";
- fontBold = false;
- text = "<A HREF='/ibapps/index.htm'>Return to Home Page</A>";
- pageno = 0;
- }
-
-
- with (this.failedHTML = new HTML(this)){
- height = 4;
- left = 2;
- top = 7;
- width = 80;
- color = "black";
- text = "Security Manager Administration failed to load. Notify the system administrator.";
- pageno = 2;
- }
-
-
- with (this.backButton2 = new Button(this)){
- left = 2;
- top = 12;
- width = 10.5;
- text = "Back";
- pageno = 2;
- onServerClick = {;this.form.pageno=1};
- }
-
-
- with (this.GeneratedHTML1 = new GeneratedHTML(this)){
- height = 1;
- left = 2;
- top = 26;
- width = 80;
- pageno = 0;
- }
-
-
- with (this.whichEntity = new Hidden(this)){
- left = 40;
- top = 4;
- value = 0;
- }
-
-
- function Form_onServerLoad()
- {
- this.whichEntity.value = 0; // 0 = user
- 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(" - "));
- 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);
- }
-
- }
-