FileDocCategorySizeDatePackage
ListSecurityMapCommand.javaAPI DocGlassfish v2 API6421Fri May 04 22:25:12 BST 2007com.sun.enterprise.cli.commands

ListSecurityMapCommand

public class ListSecurityMapCommand extends GenericCommand

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

        StringTokenizer optionTokenizer   = new StringTokenizer((String)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;
            
           MBeanServerConnection mbsc = getMBeanServerConnection(getHost(), getPort(), 
                                    getUser(), getPassword());
        try { 
	     ArrayList list  =(ArrayList)mbsc.invoke(new ObjectName(objectName), 
					     operationName, params, types);
             
             Iterator iterator= list.iterator();
             while (iterator.hasNext()){
                map = (String[]) iterator.next();
                    CLILogger.getInstance().printMessage(" ====================================");
                    CLILogger.getInstance().printMessage(" Security Map Name is :"  +map[0]);
                    CLILogger.getInstance().printMessage(" =====================================");
                    if(map[1] != null)
                        principals = getOptionsList(map[1]);
                    if(map[2] != null)    
                        usergroups = getOptionsList(map[2]);
                        
                    if(principals != null){ 
                        CLILogger.getInstance().printMessage("Principals for Security Map :"+  map[0] +"  are :");
                        for(int i = 0;i<principals.length;i++)
                            CLILogger.getInstance().printMessage("<principal>  "  +principals[i]);  
                    }
                   CLILogger.getInstance().printMessage("\n");
                   if(usergroups != null ){
                   CLILogger.getInstance().printMessage("UserGroups for Security Map :"+ map[0] +"  are :");
                        for(int i = 0;i<usergroups.length;i++)
                            CLILogger.getInstance().printMessage("<user-group>  "+usergroups[i]);  
                    }
                    CLILogger.getInstance().printMessage("\n");
                    if(map[3] != null){
                        String username = map[3];
                        CLILogger.getInstance().printMessage("Backend Principal User Name for :"+map[0] +"  is  :"+username);
                        CLILogger.getInstance().printMessage(" \n");
                    }
                    if(map[4] != null){
                        String password = map[4];
                        CLILogger.getInstance().printMessage("Backend Principal Password for :"+map[0] +"  is  :"+password);
                        CLILogger.getInstance().printMessage("\n");
                    }

                    
                    }     
                 
	    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();