/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2007-2009 Sun Microsystems, Inc.
* Portions Copyright 2011 ForgeRock AS
*/
/**
* This class is handling user Admin CLI.
*/
{
// Strings used in property help.
/**
* The subcommand Parser.
*/
/**
* The enumeration containing the different subCommand names.
*/
private enum SubCommandNameEnum
{
/**
* The create-admin-user subcommand.
*/
/**
* The delete-admin-user subcommand.
*/
/**
* The list-admin-user subcommand.
*/
/**
* The list-admin-user-properties subcommand.
*/
/**
* The get-admin-user-properties subcommand.
*/
/**
* The set-admin-user-properties subcommand.
*/
// String representation of the value.
// Private constructor.
{
}
/**
* {@inheritDoc}
*/
{
return name;
}
// A lookup table for resolving a unit from its name.
static
{
{
}
}
{
}
}
/**
* The create-admin-user subcommand.
*/
/**
* The 'userID' argument of the 'create-admin-user' subcommand.
*/
/**
* The 'set' argument of the 'create-admin-user' subcommand.
*/
/**
* The delete-admin-user subcommand.
*/
/**
* The 'userID' argument of the 'delete-admin-user' subcommand.
*/
/**
* The list-admin-user subcommand.
*/
/**
* The get-admin-user-properties subcommand.
*/
/**
* The 'userID' argument of the 'get-admin-user-properties' subcommand.
*/
/**
* The set-admin-user-properties subcommand.
*/
/**
* The 'userID' argument of the 'set-admin-user-properties' subcommand.
*/
/**
* The 'set' argument of the 'set-admin-user-properties' subcommand.
*/
/**
* The list-admin-user-properties subcommand.
*/
/**
* Association between ADSContext enum and properties.
*/
/**
* List of read-only server properties.
*/
/**
* The subcommand list.
*/
/**
* Indicates whether this subCommand should be hidden in the usage
* information.
*/
private boolean isHidden;
/**
* The subcommand group name.
*/
/**
* {@inheritDoc}
*/
{
return subCommands;
}
/**
* {@inheritDoc}
*/
public boolean isHidden()
{
return isHidden;
}
/**
* {@inheritDoc}
*/
{
return groupName;
}
/**
* {@inheritDoc}
*/
{
isHidden = false;
groupName = "admin-user";
// create-admin-user subcommand.
OPTION_SHORT_SET, OPTION_LONG_SET, false, true, true,
// delete-admin-user subcommand.
// list-admin-user subcommand.
// get-admin-user-properties subcommand.
// set-admin-user-properties subcommand.
OPTION_SHORT_SET, OPTION_LONG_SET, false, true, true,
// list-admin-user-properties subcommand.
// Create association between ADSContext enum and server
// properties
// Server properties are mapped to Argument.
/**
* The ID used to identify the user.
*/
{
}
/**
* The PASSWORD used to identify the user.
*/
{
// TODO : Allow file based password
}
/**
* The DESCRIPTION used to identify the user.
*/
{
}
/**
* The ADMINISTRATOR_DN used to identify the user.
*/
{
}
/**
* The PRIVILEGE associated to the user.
*/
{
}
}
/**
* {@inheritDoc}
*/
{
}
/**
* {@inheritDoc}
*/
throws ADSContextException, ArgumentException
{
try
{
// -----------------------
// create-admin-user subcommand.
// -----------------------
{
{
return CANNOT_CONNECT_TO_ADS;
}
}
else
// -----------------------
// delete-admin-user subcommand.
// -----------------------
{
{
return CANNOT_CONNECT_TO_ADS;
}
}
else
// -----------------------
// list-admin-user subcommand.
// -----------------------
{
{
return CANNOT_CONNECT_TO_ADS;
}
{
// print out server ID
}
}
else
// -----------------------
// get-admin-user-properties subcommand.
// -----------------------
{
{
return CANNOT_CONNECT_TO_ADS;
}
.getValues();
{
{
continue;
}
// print out the Admin User ID
{
{
continue;
}
}
}
}
else
// -----------------------
// set-admin-user-properties subcommand.
// -----------------------
{
// if the ID is specify in the --set list, it may mean that
// the user wants to rename the serverID
// replace the serverID in the map
.getValue());
{
return CANNOT_CONNECT_TO_ADS;
}
}
else
// -----------------------
// list-admin-user-properties subcommand.
// -----------------------
{
{
{
continue;
}
{
.getDefaultValue());
}
else
{
}
}
}
// -----------------------
// ERROR
// -----------------------
else
{
// Should never occurs: If we are here, it means that the code
// to handle to subcommand is not yet written.
}
}
catch (ADSContextException e)
{
{
try
{
}
catch (NamingException x)
{
}
}
throw e;
}
// Close the connection, if needed
{
try
{
}
catch (NamingException x)
{
}
}
// return part
return returnCode;
}
/**
* Translate a Set properties a to a MAP.
*
* @param propertySetArgument
* The input set argument.
* @param createCall
* Indicates if we should check the presence of mandatory
* properties and add root privileges.
* @return The created map.
* @throws ArgumentException
* If error error occurs during set parsing.
*/
throws ArgumentException
{
boolean rootPrivileges = false ;
{
// Parse the property "property:value".
if (sep < 0)
{
}
if (sep == 0)
{
}
{
}
// Check that propName is a known prop.
if (adminUserProperty == null)
{
throw new ArgumentException(message);
}
// Check that propName is not hidden.
{
throw new ArgumentException(message);
}
// Check the property Syntax.
{
throw new ArgumentException(message);
}
{
// Check if 'root' privilege is requested, or
// if it's a valid privilege
{
rootPrivileges = true ;
}
else
{
{
}
{
throw new ArgumentException(message);
}
}
}
// Add the value to the argument.
// add to the map.
if (arg.isMultiValued())
{
}
else
{
}
}
// If we are not in the create admin user, just return the
// provided atributes.
if (! createCall)
{
return map ;
}
// Here, we are in the create case.
// If privileges was not provided by the user, set the default value
{
rootPrivileges = true ;
}
// If we have root privilege, translate it to the corresponding
// list of privileges associated to 'root' user.
if (rootPrivileges)
{
{
}
}
{
{
continue;
}
if (map.containsKey(s))
{
continue ;
}
if ( ! arg.isRequired())
{
continue ;
}
// If we are here, it means that the argument is required
// but not yet is the map. Check if we have a default value.
{
throw new ArgumentException(message);
}
else
{
}
}
return map;
}
//Compute the options field.
{
StringBuilder b = new StringBuilder();
{
}
else
{
}
if (arg.isRequired())
{
b.append('m');
}
else
{
b.append('-');
}
if (arg.isMultiValued())
{
b.append('-');
}
else
{
b.append('s');
}
return b.toString();
}
}