com.foxsmart.csu.config.global
Class EnableComponent

java.lang.Object
  extended by com.foxsmart.csu.config.CiscoRouterConfigParser
      extended by com.foxsmart.csu.config.CiscoRouterConfigComponent
          extended by com.foxsmart.csu.config.global.EnableComponent
All Implemented Interfaces:
MultiLineComponent, java.io.Serializable

public class EnableComponent
extends CiscoRouterConfigComponent
implements MultiLineComponent

The Enable class represents enable password parameters.

See Also:
Serialized Form

Field Summary
static java.lang.String ENABLE
           
static java.lang.String LAST_RESORT
           
static java.lang.String LAST_RESORT_PASSWORD
          Enable by giving the local enable password.
static java.lang.String LAST_RESORT_SUCCEED
          Enable without further question.
static java.lang.String LEVEL
           
static java.lang.Integer MAX_ENABLE_LEVEL
          The maximum enable level.
static java.lang.Integer MIN_ENABLE_LEVEL
          The minimum enable level.
static java.lang.String PASSWORD
           
static java.lang.String SECRET
           
static java.lang.String SUCCEED
           
static java.lang.String USE_TACACS
           
 
Fields inherited from class com.foxsmart.csu.config.CiscoRouterConfigComponent
commentComponent, componentMap, log, parentComponent
 
Fields inherited from class com.foxsmart.csu.config.CiscoRouterConfigParser
NO, tokenIndex
 
Constructor Summary
EnableComponent()
          Constructs an Enable object.
 
Method Summary
 java.util.List buildFromIos(java.util.List configLines)
          Parse and populate the specific CiscoRouterComponent object based on the passed in individual lines of the IOS configuration.
 Commands generateDeleteIos(CiscoRouterConfig updatedCiscoRouterConfig)
          Generates the IOS configuration commands to delete this component.
 Commands generateIos()
          Returns the IOS configuration commands for this component.
 java.lang.String getLastResortAction()
          Gets the last resort action.
 GlobalEncryptionPassword getPassword(int enableLevel)
          Gets standard "password" information for a specified enable level.
 GlobalEncryptionPassword getSecret(int enableLevel)
          Gets "secret" information for a specified enable level.
 boolean getUseTacacs()
          Gets whether TACACS will be used to check enable passwords.
 boolean lastResortPassword()
          Determines if the last resort action is "password".
 boolean lastResortSucceed()
          Determines if the last resort action is "succeed".
 boolean lastResortUndefined()
          Determines if the last resort action is not defined.
 void setLastResortAction(java.lang.String action)
          Sets the last resort option when no TACACS servers respond.
 void setPassword(int enableLevel, GlobalEncryptionPassword globalEncryptionPassword)
          Sets a "password" for a specified enable level.
 void setSecret(int enableLevel, GlobalEncryptionPassword globalEncryptionPassword)
          Sets a "secret" password for a specified enable level.
 void setUseTacacs(boolean useTacacs)
          Sets whether TACACS will be used to check enable passwords.
 void validate()
          Validates this object to ensure it contains a valid IOS configuration.
static boolean validEnableLevel(java.lang.String enableLevel)
          Determines whether the passed in enable level is valid or not.
 
Methods inherited from class com.foxsmart.csu.config.CiscoRouterConfigComponent
addComponent, addComponent, checkComponentType, deleteOldConfigWhenUpdating, dumpComponents, generateChildrenUpdateConfiglet, generateCompositeIos, generateCompositeIos, generateIos, generateIos, generateIos, generateMultiLineUpdateConfiglet, generateUpdateCompositeIos, generateUpdateIos, generateUpdateIos, getAllComponents, getCiscoRouterConfig, getComment, getComponentClassName, getComponentClassName, getComponentKeys, getComponents, getComponents, getDeferredDelete, getFirstComponent, getFirstComponent, getParentComponent, getTotalComponents, getTotalComponents, getUpdateConfiglet, instantiateComponent, instantiateComponent, isValid, removeAllComponents, removeAllComponents, removeAllComponents, removeComponent, removeComponent, removeComponent, requiresCommentSeparator, setComment, setParentComponent, validateChildren
 
Methods inherited from class com.foxsmart.csu.config.CiscoRouterConfigParser
checkExists, checkLineComplete, checkNotEmpty, checkRange, checkTokenCount, checkTokenCount, checkTokenMatch, checkTokenMatch, decrementTokenIndex, generateCommands, getBigDecimalNumberFromString, getDoubleNumberFromString, getEnum, getHexadecimalNumberFromString, getIntegerNumberFromString, getIpAddressFromString, getLine, getLongNumberFromString, getMacAddressFromString, getNextOptionalToken, getNextToken, getToken, getTokenIndex, getTokens, getTotalIndentedLines, getTotalLines, incrementTokenIndex, invalidConfiguration, invalidTokenFound, isEmpty, moreIndentedLines, moreLines, moreTokens, removeLines, resetTokenIndex, setTokenIndex, tokensLeft
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ENABLE

public static final java.lang.String ENABLE
See Also:
Constant Field Values

LAST_RESORT

public static final java.lang.String LAST_RESORT
See Also:
Constant Field Values

LEVEL

public static final java.lang.String LEVEL
See Also:
Constant Field Values

PASSWORD

public static final java.lang.String PASSWORD
See Also:
Constant Field Values

SECRET

public static final java.lang.String SECRET
See Also:
Constant Field Values

SUCCEED

public static final java.lang.String SUCCEED
See Also:
Constant Field Values

USE_TACACS

public static final java.lang.String USE_TACACS
See Also:
Constant Field Values

MIN_ENABLE_LEVEL

public static final java.lang.Integer MIN_ENABLE_LEVEL
The minimum enable level.


MAX_ENABLE_LEVEL

public static final java.lang.Integer MAX_ENABLE_LEVEL
The maximum enable level.


LAST_RESORT_PASSWORD

public static final java.lang.String LAST_RESORT_PASSWORD
Enable by giving the local enable password.

See Also:
Constant Field Values

LAST_RESORT_SUCCEED

public static final java.lang.String LAST_RESORT_SUCCEED
Enable without further question.

See Also:
Constant Field Values
Constructor Detail

EnableComponent

public EnableComponent()
Constructs an Enable object.

Method Detail

setUseTacacs

public void setUseTacacs(boolean useTacacs)
Sets whether TACACS will be used to check enable passwords. This feature is off by default.

Parameters:
useTacacs - If true, TACACS will be used or false if not.

getUseTacacs

public boolean getUseTacacs()
Gets whether TACACS will be used to check enable passwords.

Returns:
The TACACS flag.

setLastResortAction

public void setLastResortAction(java.lang.String action)
                         throws InvalidConfigurationException
Sets the last resort option when no TACACS servers respond. Use one of the last resort constants specified in this file: LAST_RESORT_PASSWORD or LAST_RESORT_SUCCEED to specify the value. Set to null to specify no last resort action.

Parameters:
action - The last resort action.
Throws:
InvalidConfigurationException - if the specified parameter is invalid.

getLastResortAction

public java.lang.String getLastResortAction()
Gets the last resort action.

Returns:
The last resort action.

lastResortPassword

public boolean lastResortPassword()
Determines if the last resort action is "password".

Returns:
True if the last resort action is password or false if not.

lastResortSucceed

public boolean lastResortSucceed()
Determines if the last resort action is "succeed".

Returns:
True if the last resort action is succeed or false if not.

lastResortUndefined

public boolean lastResortUndefined()
Determines if the last resort action is not defined.

Returns:
True if the last resort action is undefined or false if not.

setPassword

public void setPassword(int enableLevel,
                        GlobalEncryptionPassword globalEncryptionPassword)
                 throws InvalidConfigurationException
Sets a "password" for a specified enable level. This method is left here for backward compatibility. The setSecret method is the preferred method for setting passwords. Non-secret passwords can only be specified for level 15. If any other level is specified, this method will delegate to the setSecret method.

Parameters:
enableLevel - The enable level for the password. Must be between 1 and 15.
globalEncryptionPassword - The password and its associated encryption type. The encryption type must be 0 or 7. This parameter can be null to clear out any password information associated with the enable level.
Throws:
InvalidConfigurationException - if any of the parameters are invalid.

getPassword

public GlobalEncryptionPassword getPassword(int enableLevel)
Gets standard "password" information for a specified enable level. If there is no password information defined, null will be returned.

Parameters:
enableLevel - the enable level to get the password for.
Returns:
The password and encryption information.

setSecret

public void setSecret(int enableLevel,
                      GlobalEncryptionPassword globalEncryptionPassword)
               throws InvalidConfigurationException
Sets a "secret" password for a specified enable level. Use the setPassword for non-secret passwords although this method is preferred.

Parameters:
enableLevel - The enable level for the password. Must be between 1 and 15.
globalEncryptionPassword - The password and its associated encryption type. The encryption type must be 0 or 5. This parameter can be null to clear out any password information associated with the enable level.
Throws:
InvalidConfigurationException - if any of the parameters are invalid.

getSecret

public GlobalEncryptionPassword getSecret(int enableLevel)
Gets "secret" information for a specified enable level. If there is no password information defined, null will be returned.

Parameters:
enableLevel - the enable level to get the secret information for.
Returns:
The password and encryption information.

buildFromIos

public java.util.List buildFromIos(java.util.List configLines)
                            throws InvalidConfigurationException
Description copied from class: CiscoRouterConfigComponent
Parse and populate the specific CiscoRouterComponent object based on the passed in individual lines of the IOS configuration. The passed in configuration lines should represent the first line in the configuration that applies to the specific component. The component should use all lines needed by its specific part of the configuration and return a List with the remaining lines that are not part of the component's configuration.

Specified by:
buildFromIos in class CiscoRouterConfigComponent
Parameters:
configLines - The list of IOS configuration lines.
Returns:
The rest of the lines that were not parsed by the component.
Throws:
InvalidConfigurationException - if the IOS configuration can not be parsed for any reason.
See Also:
CiscoRouterConfigComponent

validate

public void validate()
              throws InvalidConfigurationException
Description copied from class: CiscoRouterConfigComponent
Validates this object to ensure it contains a valid IOS configuration.

Specified by:
validate in class CiscoRouterConfigComponent
Throws:
InvalidConfigurationException - if the configuration is invalid.
See Also:
CiscoRouterConfigComponent

validEnableLevel

public static boolean validEnableLevel(java.lang.String enableLevel)
Determines whether the passed in enable level is valid or not. A valid enable level is a number between 1 and 15.

Parameters:
enableLevel - The enable level to validate.
Returns:
True if the level is valid or false if not.

generateIos

public Commands generateIos()
                     throws InvalidConfigurationException
Description copied from class: CiscoRouterConfigComponent
Returns the IOS configuration commands for this component.

Specified by:
generateIos in class CiscoRouterConfigComponent
Returns:
The IOS configuration string as a list of Command objects. To generate a configlet from the list of Command objects, use Command.getConfiglet().
Throws:
InvalidConfigurationException - if the IOS configuration is invalid and the IOS string can not be generated. The validate() method is used to determine if the configuration is valid.
See Also:
CiscoRouterConfigComponent

generateDeleteIos

public Commands generateDeleteIos(CiscoRouterConfig updatedCiscoRouterConfig)
                           throws InvalidConfigurationException
Description copied from class: CiscoRouterConfigComponent
Generates the IOS configuration commands to delete this component. This is the default implementation that generates a "no" statement followed by the generateIos() string for non CompositeComponents or generateHeaderIos() for CompositeComponents. Specific components may choose to override this method if this implementation is incorrect. The "no" keyword is placed where the first character of the command is located. For example, if the IOS command is " length 255", then the returned command will be " no length 255" (and not "no length 255").

Note that this implementation will call the getDeferredDelete method on the component and set the "deferred flag" on the returned Commands with its returned value.

Specified by:
generateDeleteIos in interface MultiLineComponent
Overrides:
generateDeleteIos in class CiscoRouterConfigComponent
Parameters:
updatedCiscoRouterConfig - the updated Cisco router configuration.
Returns:
The generated IOS string to deleted the component.
Throws:
InvalidConfigurationException - if the IOS configuration is invalid and the IOS string can not be generated. The validate() method is used to determine if the configuration is valid.
See Also:
CiscoRouterConfigComponent


Copyright © 2005-2008 Fox Smart, Inc. All Rights Reserved.