SilverStream
Application Server 3.5

com.sssw.rts.adminapi
Interface AgiAdmExpressionMgr


public interface AgiAdmExpressionMgr

Implemented by objects that manage the handling of SilverStream security expressions.


Method Summary
 String getExpressionFromUsersAndGroups(Enumeration users, Enumeration groups)
          Given a list of users and a list of groups, construct a security expression that corresponds to the lists.
 Enumeration getUsersAndGroupsFromExpression(AgiAdmElement element, String expression)
          Render the list of users and groups from the given security expression Return null if the expression is not a simple list of users and groups, otherwise return an enumeration of AgiAdmUser's and AgiAdmGroups.
 boolean verifySecurityExpression(AgiAdmElement element, String expression)
          Check whether the specified security expression is valid for the given element.
 

Method Detail

getExpressionFromUsersAndGroups

public String getExpressionFromUsersAndGroups(Enumeration users,
                                              Enumeration groups)
                                       throws AgoUnrecoverableSystemException,
                                              AgoSecurityException
Given a list of users and a list of groups, construct a security expression that corresponds to the lists.
Parameters:
users - an enumeration of AgiAdmUsers
groups - an enumeration of AgiAdmGroups
Usage:
Either one or the other list may be null, but not both.
Example:
 // Get an Expression Manager.
 AgiAdmExpressionMgr exprMgr = AgAdmin.getExpressionMgrObject();
 Vector users = new Vector();
 Vector groups = new Vector();
 
 // Create a list of users.
 AgiAdmUser user1 = (AgiAdmUser)server.getElement("user1", AgiAdmUser.SILVERUSER, null);
 AgiAdmUser user2 = (AgiAdmUser)server.getElement("user2", AgiAdmUser.SILVERUSER, null);
 users.addElement(user1);
 users.addElement(user2);
 
 // Create a list of groups.
 AgiAdmGroup group1 = (AgiAdmGroup)server.getElement("group1", AgiAdmGroup.SILVERGROUP, null);
 AgiAdmGroup group2 = (AgiAdmGroup)server.getElement("group2", AgiAdmGroup.SILVERGROUP, null);
 groups.addElement(group1);
 groups.addElement(group2);
 
 // Construct a SilverStream security expression from the two lists.
 String expression = exprMgr.getExpressionFromUsersAndGroups(users.elements(), groups.elements());
 
See Also:
AgiAdmUser, AgiAdmGroup

getUsersAndGroupsFromExpression

public Enumeration getUsersAndGroupsFromExpression(AgiAdmElement element,
                                                   String expression)
                                            throws AgoUnrecoverableSystemException,
                                                   AgoSecurityException
Render the list of users and groups from the given security expression Return null if the expression is not a simple list of users and groups, otherwise return an enumeration of AgiAdmUser's and AgiAdmGroups.
Parameters:
element - the element for which the expression is being rendered
expression - security expression
Example:
 // Get an element for which we will attempt to render an expression.
 Hashtable info = new Hashtable();
 info.put(AgiAdmServer.INFO_DATABASE_NAME, "database");
 AgiAdmDesignElement el = (AgiAdmDesignElement)server.getElement("myForm", AgiAdmDesignElement.FORM, info);
 // Define an expression that is to be rendered.
 String expression = 
 	"userID() in (userID('administrator'),userID('BRILLIANT\\Administrator'))";
 // Try to get the list of users and groups.
 Enumeration e = exprMgr.getUsersAndGroupsFromExpression(
 	el, expression);
 // Go through the list to look at the user and group information.
 if (e == null)
 {
 	System.out.println("Not a simple list.");
 	// ... any other code for handling this case
 }
 else
 {
 	while(e.hasMoreElements())
 	{
 		AgiAdmElement el = (AgiAdmElement)e.nextElement();
 		if (el instanceof AgiAdmUser)
 		{
 			System.out.println("User " + el.getName());
 			// ... any other processing
 		}
 		else if (el instanceof AgiAdmGroup)
 		{
 			System.out.println("Group " + el.getName());
 			// ... any other processing
 		}
 	}
 }
 
See Also:
AgiAdmElement

verifySecurityExpression

public boolean verifySecurityExpression(AgiAdmElement element,
                                        String expression)
                                 throws AgoUnrecoverableSystemException,
                                        AgoSecurityException
Check whether the specified security expression is valid for the given element.
Parameters:
element - the element for which the expression is being checked
expression - the expression
Returns:
true if expression is valid, false if not
Example:
 // Get an element for which the expression is to be verified.
 Hashtable info = new Hashtable();
 info.put(AgiAdmServer.INFO_DATABASE_NAME, "database");
 AgiAdmDesignElement el = (AgiAdmDesignElement)server.getElement("myForm", AgiAdmDesignElement.FORM, info);
 // Define an expression that is to be verified.
 String expression = 
 	"userID() in (userID('administrator'),userID('BRILLIANT\\Administrator'))";
 // Verify the expression.
 boolean isExprOK = exprMgr.verifySecurityExpression(
 	el, expression);
 
See Also:
AgiAdmElement

SilverStream
Application Server 3.5