RTView® 
User Guide


Custom Role Manager

The following is an example of a Java class named MyRoleManager.java:

//*************************************************************************
//
// SL-GMS Graphical Modeling Application, RTView Package
// MyRoleManager.java
// Copyright (c) 1998-2006 Sherrill-Lubinski Corporation. All Rights Reserved.
// May 2005
//
//*************************************************************************

import com.sl.gmsjrtview.*;
import java.util.*;

/** The MyRoleManager class provides a custom role manager class.
 *  <P>
 */

public class MyRoleManager extends GmsCustomRoleManager
{

//***********************************************************************
// ACTIVATE METHOD

/** Activate the role manager. Subclasses should overwrite this method to
 *  perform any initialization necessary to implement the isAllowed() method.
 *  This method should return true if initialization was successful, otherwise
 *  return false. RTView will exit if this method returns false.
 *  <P>
 */

public boolean activate ()
{
 return true;
}

//***********************************************************************
// GET SUBSTITUTIONS METHOD

/** This method should return substitutions to set on the RTView
 *  application when the specified role is logged in. If this role does not
 *  have any associated substitutions, this method should return null.
 *  Otherwise, return a pair of Vectors. Both Vectors must be the same length,
 *  with the first Vector containing the substutition strings and the second
 *  Vector containing the corresponding substitution values.
 * <P>
 */
 

public Vector[] getSubstitutions (String role)
{
        if (role.equals("role1")) {
                Vector subStrs = new Vector();
                Vector subVals = new Vector();
                subStrs.addElement("role1sub1");
                subVals.addElement("role1value1");
                subStrs.addElement("role1sub2");
                subVals.addElement("role1value2");
                return new Vector[] {subStrs, subVals};
 

        } else if (role.equals("role4")) {
                Vector subStrs = new Vector();
                Vector subVals = new Vector();
                subStrs.addElement("role4sub1");
                subVals.addElement("role4value1");
                subStrs.addElement("role4sub2");
                subVals.addElement("role4value2");
                return new Vector[] {subStrs, subVals};
 

        } else
                return null;
}

//***********************************************************************
// IS ALLOWED METHOD

/** Returns true if the specified display is allowed, otherwise return
 *  false. Subclasses should overwrite this method to return the appropriate
 *  value based on the displayName and for the specified role.
 *  <P>
 */

public boolean isAllowed (String displayName, String role)
{

 System.out.println("isAllowed role: " + role +
      " display: " + displayName);
 if (role == null || displayName == null)
  return false;
 if (role.equals("admin"))
  return true;

 if (displayName.equals("title_panel") ||
    displayName.equals("operations"))
  return true;

 if (role.equals("role1")) {
  if (displayName.equals("ems_administration") ||
   displayName.startsWith("manage"))
   return false;
  else
   return true;
 }
 if (role.equals("role2")) {
  if (displayName.startsWith("manage") &&
   !displayName.equals("manage_routes"))
   return false;
  else
   return true;
 }
 if (role.equals("role3")) {
  if (displayName.equals("ems_administration") ||
   displayName.startsWith("manage"))
   return true;
  else
   return false;
 }
 if (role.equals("role4")) {
  if (displayName.equals("ems_monitoring") ||
   displayName.equals("ems_allservers_api") ||
   displayName.equals("ems_server_info") ||
   displayName.equals("host_details"))
   return true;
  else
   return false;

 }
 return false;
}

}
   


 
SL, SL-GMS, GMS, RTView, SL Corporation, and the SL logo are trademarks or registered trademarks of Sherrill-Lubinski Corporation in the United States and other countries. Copyright © 1998-2012 Sherrill-Lubinski Corporation. All Rights Reserved.

 

JMS, JMX and Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. They are mentioned in this document for identification purposes only. 

 

Third Party Notice Requirements