home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 8 / CDACTUAL8.iso / progs / ite / ite10d1.exe / DATA.Z / SMADMIN.JFM < prev    next >
Encoding:
Text File  |  1996-09-07  |  13.2 KB  |  444 lines

  1. /****************************************************************************\
  2. *                                                                            *
  3. * SmAdmin.jfm  --  Security Administration Form                              *
  4. *                                                                            *
  5. * This form is part of the security administration prebuilt business         *
  6. * solution. This is the main adminstration form. It allows you to define     *
  7. * users, groups resources and policies. Your applications can then be        *
  8. * secured. See the Phone Book application for an example of using the        *
  9. * security system.                                                           *
  10. *                                                                            *
  11. * Dependencies:  secur21.gif                                                 *
  12. *                homepg31.gif                                                *
  13. *                apps\shared\controls.cc                                     *
  14. *                                                                            *
  15. * Updated 9/3/96 by IntraBuilder Samples Group                               *
  16. * $Revision:   1.5  $                                                        *
  17. *                                                                            *
  18. * Copyright (c) 1996, Borland International, Inc. All rights reserved.       *
  19. *                                                                            *
  20. \****************************************************************************/
  21. #include "SECURITY.H"
  22. _sys.scripts.load(SM_CLASS_LOCATION + "SECURITY.JS");
  23. // create form reference for this form
  24. var f = new smadminForm();
  25. f.security = new SecurityManagerAdmin();
  26.  
  27. // create security object and login
  28. _sys.scripts.load("smlogin.jfm");
  29. var login = new smloginForm();
  30. login.security = f.security;
  31. login.nextForm = f;
  32. login.open();
  33. return;
  34. // {End Header} Do not remove this comment//
  35. // Generated on 09/03/96
  36. //
  37. var f = new smadminForm();
  38. f.open();
  39. class smadminForm extends SecurityForm from "SMADMIN.JCF" {
  40.    _sys.scripts.load(_sys.env.home() + "APPS\\SHARED\\CONTROLS.CC")
  41.    with (this) {
  42.       height = 27.2941;
  43.       left = 0;
  44.       top = 0.2941;
  45.       width = 87;
  46.       title = "Security Administration";
  47.       onServerLoad = class::Form_onServerLoad;
  48.    }
  49.  
  50.  
  51.    with (this.rule1 = new Rule(this)){
  52.       left = 2;
  53.       top = 7;
  54.       size = 2;
  55.       right = 82;
  56.       pageno = 0;
  57.    }
  58.  
  59.  
  60.    with (this.rule2 = new Rule(this)){
  61.       left = 2;
  62.       top = 18;
  63.       size = 2;
  64.       right = 82;
  65.       pageno = 0;
  66.    }
  67.  
  68.  
  69.    with (this.rule3 = new Rule(this)){
  70.       left = 2;
  71.       top = 25;
  72.       size = 2;
  73.       right = 82;
  74.       pageno = 0;
  75.    }
  76.  
  77.  
  78.    with (this.userButton = new Button(this)){
  79.       left = 2;
  80.       top = 8;
  81.       width = 20;
  82.       text = "Users";
  83.       onServerClick = class::userButton_onServerClick;
  84.    }
  85.  
  86.  
  87.    with (this.groupButton = new Button(this)){
  88.       left = 22;
  89.       top = 8;
  90.       width = 20;
  91.       text = "Groups";
  92.       onServerClick = class::groupButton_onServerClick;
  93.    }
  94.  
  95.  
  96.    with (this.resourceButton = new Button(this)){
  97.       left = 42;
  98.       top = 8;
  99.       width = 20;
  100.       text = "Resources";
  101.       onServerClick = class::resourceButton_onServerClick;
  102.    }
  103.  
  104.  
  105.    with (this.policyButton = new Button(this)){
  106.       left = 62;
  107.       top = 8;
  108.       width = 20;
  109.       text = "Policies";
  110.       onServerClick = class::policyButton_onServerClick;
  111.    }
  112.  
  113.  
  114.    with (this.entitySelect = new ListBox(this)){
  115.       height = 6;
  116.       left = 2;
  117.       top = 10;
  118.       width = 80;
  119.    }
  120.  
  121.  
  122.    with (this.newButton = new Button(this)){
  123.       left = 2;
  124.       top = 16;
  125.       width = 20;
  126.       text = "Add New";
  127.       onServerClick = class::newButton_onServerClick;
  128.    }
  129.  
  130.  
  131.    with (this.copyButton = new Button(this)){
  132.       left = 22;
  133.       top = 16;
  134.       width = 20;
  135.       text = "Add Copy";
  136.       onServerClick = class::copyButton_onServerClick;
  137.    }
  138.  
  139.  
  140.    with (this.updateButton = new Button(this)){
  141.       left = 42;
  142.       top = 16;
  143.       width = 20;
  144.       text = "Update";
  145.       onServerClick = class::updateButton_onServerClick;
  146.    }
  147.  
  148.  
  149.    with (this.deleteButton = new Button(this)){
  150.       left = 62;
  151.       top = 16;
  152.       width = 20;
  153.       text = "Delete";
  154.       onServerClick = class::deleteButton_onServerClick;
  155.    }
  156.  
  157.  
  158.    with (this.HomePageLinkImage = new Image(this)){
  159.       height = 4.8235;
  160.       left = 2;
  161.       top = 19;
  162.       width = 13.6667;
  163.       dataSource = "filename HOMEPG31.GIF";
  164.       alignment = 4;
  165.       pageno = 0;
  166.       onImageClick = class::link_to_home_page;
  167.    }
  168.  
  169.  
  170.    with (this.HomePageLinkHTML = new HTML(this)){
  171.       height = 1;
  172.       left = 22;
  173.       top = 19;
  174.       width = 60;
  175.       color = "black";
  176.       fontBold = false;
  177.       text = "<A HREF='/ibapps/index.htm'>Return to Home Page</A>";
  178.       pageno = 0;
  179.    }
  180.  
  181.  
  182.    with (this.failedHTML = new HTML(this)){
  183.       height = 4;
  184.       left = 2;
  185.       top = 7;
  186.       width = 80;
  187.       color = "black";
  188.       text = "Security Manager Administration failed to load. Notify the system administrator.";
  189.       pageno = 2;
  190.    }
  191.  
  192.  
  193.    with (this.backButton2 = new Button(this)){
  194.       left = 2;
  195.       top = 12;
  196.       width = 10.5;
  197.       text = "Back";
  198.       pageno = 2;
  199.       onServerClick = {;this.form.pageno=1};
  200.    }
  201.  
  202.  
  203.    with (this.GeneratedHTML1 = new GeneratedHTML(this)){
  204.       height = 1;
  205.       left = 2;
  206.       top = 26;
  207.       width = 80;
  208.       pageno = 0;
  209.    }
  210.  
  211.  
  212.    with (this.whichEntity = new Hidden(this)){
  213.       left = 40;
  214.       top = 4;
  215.       value = 0;
  216.    }
  217.  
  218.  
  219.    function Form_onServerLoad()
  220.    {
  221.       this.whichEntity.value = 0;   // 0 = user
  222.       this.fillSelect(this);
  223.    }
  224.  
  225.    function fillSelect(formRef)
  226.    {
  227.       var form = formRef;
  228.       form.entityArray = new Array();
  229.       var tmpArray = new AssocArray();
  230.       try {
  231.          // get the assoc array depending on which entity is selected
  232.          switch (parseInt(form.whichEntity.value)) {
  233.          case 0:    // user
  234.             tmpArray = form.security.getAllUsers();
  235.             break;
  236.          case 1:    // group
  237.             tmpArray = form.security.getAllGroups();
  238.             break;
  239.          case 2:    // resource
  240.             tmpArray = form.security.getAllResources();
  241.             break;
  242.          default:   // policy
  243.             tmpArray = form.security.getAllPolicies();
  244.             break;
  245.          }
  246.          // fill the entityArray with the contents of the AssocArray
  247.          var entity = "";
  248.          for (var i = 0; i<tmpArray.count(); i++) {
  249.             entity = (i==0) ? tmpArray.firstKey : tmpArray.nextKey(entity);
  250.             form.entityArray.add(entity + " - " + 
  251.                             ((tmpArray[entity]==null) ? "" : tmpArray[entity]));
  252.          }
  253.          // sort the resulting array
  254.          form.entityArray.sort();
  255.          // assign array to the select control
  256.          form.entitySelect.options = "array form.entityArray";
  257.       }
  258.       catch (Exception e) {
  259.          form.failedHTML.text = "Error loading security information: " 
  260.                                 + e.message + " (" + e.code + ")";
  261.          form.backButton2.visible = false;
  262.          form.pageno = 2;
  263.       }
  264.    }
  265.  
  266.    function newButton_onServerClick()
  267.    {
  268.       // store entity name
  269.       var entityName = false;
  270.       var entityObj  = null;
  271.       // load the appropriate administration form
  272.       switch (parseInt(this.form.whichEntity.value)) {
  273.       case 0:    // user
  274.          entityObj = this.form.security.getUserObject(entityName);
  275.          _sys.scripts.load("smuadmin.jfm");
  276.          var f = new smuadminForm();
  277.          break;
  278.       case 1:    // group
  279.          entityObj = this.form.security.getGroupObject(entityName);
  280.          _sys.scripts.load("smgadmin.jfm");
  281.          var f = new smgadminForm();
  282.          break;
  283.       case 2:    // resource
  284.          entityObj = this.form.security.getResourceObject(entityName);
  285.          _sys.scripts.load("smradmin.jfm");
  286.          var f = new smradminForm();
  287.          break;
  288.       default:    // policy
  289.          entityObj = this.form.security.getPolicyObject(entityName);
  290.          _sys.scripts.load("smpadmin.jfm");
  291.          var f = new smpadminForm();
  292.          break;
  293.       }
  294.       // set the necessary properties
  295.       f.copyEntity  = false;
  296.       f.entity      = entityObj;
  297.       f.security    = this.form.security;
  298.       f.callingForm = this.form;
  299.       f.open();
  300.    }
  301.  
  302.    function copyButton_onServerClick()
  303.    {
  304.       // store entity name
  305.       var entityName = this.form.entitySelect.value;
  306.       entityName = entityName.substring(0, entityName.indexOf(" - "));
  307.       if (entityName.length > 0) {
  308.          var entityObj  = null;
  309.          // load the appropriate administration form
  310.          switch (parseInt(this.form.whichEntity.value)) {
  311.          case 0:    // user
  312.             entityObj = this.form.security.getUserObject(entityName);
  313.             _sys.scripts.load("smuadmin.jfm");
  314.             var f = new smuadminForm();
  315.             break;
  316.           case 1:    // group
  317.             entityObj = this.form.security.getGroupObject(entityName);
  318.             _sys.scripts.load("smgadmin.jfm");
  319.             var f = new smgadminForm();
  320.             break;
  321.          case 2:    // resource
  322.             entityObj = this.form.security.getResourceObject(entityName);
  323.             _sys.scripts.load("smradmin.jfm");
  324.             var f = new smradminForm();
  325.             break;
  326.          default:    // policy
  327.             entityObj = this.form.security.getPolicyObject(entityName);
  328.             _sys.scripts.load("smpadmin.jfm");
  329.             var f = new smpadminForm();
  330.             break;
  331.          }
  332.          // set the necessary properties
  333.          f.copyEntity  = true;
  334.          f.entity      = entityObj;
  335.          f.security    = this.form.security;
  336.          f.callingForm = this.form;
  337.          f.open();
  338.       }
  339.    }
  340.  
  341.    function updateButton_onServerClick()
  342.    {
  343.       // store entity name
  344.       var entityName = this.form.entitySelect.value;
  345.       entityName = entityName.substring(0, entityName.indexOf(" - "));
  346.       if (entityName.length > 0) {
  347.          var entityObj  = null;
  348.          // load the appropriate administration form
  349.          switch (parseInt(this.form.whichEntity.value)) {
  350.          case 0:    // user
  351.             entityObj = this.form.security.getUserObject(entityName);
  352.             _sys.scripts.load("smuadmin.jfm");
  353.             var f = new smuadminForm();
  354.             break;
  355.          case 1:    // group
  356.             entityObj = this.form.security.getGroupObject(entityName);
  357.             _sys.scripts.load("smgadmin.jfm");
  358.             var f = new smgadminForm();
  359.             break;
  360.          case 2:    // resource
  361.             entityObj = this.form.security.getResourceObject(entityName);
  362.             _sys.scripts.load("smradmin.jfm");
  363.             var f = new smradminForm();
  364.             break;
  365.          default:    // policy
  366.             entityObj = this.form.security.getPolicyObject(entityName);
  367.             _sys.scripts.load("smpadmin.jfm");
  368.             var f = new smpadminForm();
  369.             break;
  370.          }
  371.          // set the necessary properties
  372.          f.copyEntity  = false;
  373.          f.entity      = entityObj;
  374.          f.security    = this.form.security;
  375.          f.callingForm = this.form;
  376.          f.open();
  377.       }
  378.    }
  379.  
  380.    function deleteButton_onServerClick()
  381.    {
  382.       // store entity name
  383.       var entityName = this.form.entitySelect.value;
  384.       entityName = entityName.substring(0, entityName.indexOf(" - "));
  385.       try {
  386.          // delete the entity
  387.          if (entityName.length > 0) {
  388.             // delete the entity
  389.             switch (parseInt(this.form.whichEntity.value)) {
  390.             case 0:    // user
  391.                this.form.security.deleteUser(entityName);
  392.                break;
  393.             case 1:    // group
  394.                this.form.security.deleteGroup(entityName);
  395.                break;
  396.             case 2:    // resource
  397.                this.form.security.deleteResource(entityName);
  398.                break;
  399.             default:   // policy
  400.                this.form.security.deletePolicy(entityName);
  401.                break;
  402.             }
  403.          }
  404.          // update the list of entities
  405.          this.form.fillSelect(this.form);
  406.       }
  407.       catch (Exception e) {
  408.          this.form.failedHTML.text = "Error during delete: " + e.message + 
  409.                                      " (" + e.code + ")";
  410.          this.form.pageno = 2;
  411.       }
  412.    }
  413.  
  414.    function link_to_home_page()
  415.    {
  416.       location.href="/ibapps/index.htm";
  417.    }
  418.  
  419.    function userButton_onServerClick()
  420.    {
  421.       this.form.whichEntity.value = 0;
  422.       this.form.fillSelect(this.form);
  423.    }
  424.  
  425.    function groupButton_onServerClick()
  426.    {
  427.       this.form.whichEntity.value = 1;
  428.       this.form.fillSelect(this.form);
  429.    }
  430.  
  431.    function resourceButton_onServerClick()
  432.    {
  433.       this.form.whichEntity.value = 2;
  434.       this.form.fillSelect(this.form);
  435.    }
  436.  
  437.    function policyButton_onServerClick()
  438.    {
  439.       this.form.whichEntity.value = 3;
  440.       this.form.fillSelect(this.form);
  441.    }
  442.  
  443. }
  444.