FileDocCategorySizeDatePackage
CreateSecurityMapCommand.javaAPI DocGlassfish v2 API5489Fri May 04 22:25:08 BST 2007com.sun.enterprise.cli.commands

CreateSecurityMapCommand

public class CreateSecurityMapCommand extends SecurityMapCommand

Fields Summary
Constructors Summary
Methods Summary
private java.lang.String[]getListOfValues(java.lang.String sOptions)

        StringTokenizer optionTokenizer   = new StringTokenizer(sOptions,",");
        int             size            = optionTokenizer.countTokens();
        String []       sOptionsList = new String[size];
        for (int ii=0; ii<size; ii++){
            sOptionsList[ii] = optionTokenizer.nextToken();
        } 
        return sOptionsList;
   
public voidrunCommand()
An abstract method that Executes the command

throws
CommandException

        if (!validateOptions())
            throw new CommandValidationException("Validation failed");
        
        
           String objectName = getObjectName();
            Object[] params = getParamsInfo();
            String operationName = getOperationName();
            String[] types = getTypesInfo();    
            String[] map = null;            
            String[] principals = null;
            String[] usergroups = null;
            AttributeList list = null;
    
             list =(AttributeList) params[0];
             if(list != null){
                int s = list.size();
                int i = 0 ;
                for(i=0;i<s;i++)
                {
                    Attribute attribute =(Attribute)list.get(i);
                    if(attribute.getName().equalsIgnoreCase("principal"))
                    {
                        String principal = (String)attribute.getValue();
                        principals  =((String[]) getListOfValues(principal));
                        list.set(i,new Attribute("principal",principals));
                     }
                     if ((attribute.getName().equalsIgnoreCase("user_group")))
                     {
                         String usergroup = (String)attribute.getValue();
                         usergroups = ((String[])getListOfValues(usergroup));
                         list.set(i,new Attribute("user_group",usergroups));
                    }
                       
                }    
            }
               
             
           MBeanServerConnection mbsc = getMBeanServerConnection(getHost(), getPort(), 
                                    getUser(), getPassword());
        try 
        { 
	     ObjectName object  =(ObjectName)mbsc.invoke(new ObjectName(objectName), 
				     operationName, params, types);
             CLILogger.getInstance().printDetailMessage(getLocalizedString(
						       "CommandSuccessful",
            					       new Object[] {name}));
        }
        catch(Exception e)
        { 
    
	    if (e.getLocalizedMessage() != null)
		CLILogger.getInstance().printDetailMessage(e.getLocalizedMessage());
            throw new CommandException(getLocalizedString("CommandUnSuccessful",
						     new Object[] {name} ), e);
        }        
    
public booleanvalidateOptions()

        return super.validateOptions();