com.cisco.provisioning.cpe.extensions.configuration
Class DOCSISTFTPFile

java.lang.Object
  extended by com.cisco.provisioning.cpe.extensions.configuration.AbstractTFTPFile
      extended by com.cisco.provisioning.cpe.extensions.configuration.DOCSISTFTPFile
All Implemented Interfaces:
com.cisco.csrc.encode.Encodable, com.cisco.csrc.util.Displayable, TFTPFile, Externalizable, Serializable
Direct Known Subclasses:
CableHomeTFTPFile, PacketCableTFTPFile

public class DOCSISTFTPFile
extends AbstractTFTPFile

DOCSIS TFTP file. This class provides an implementation of a TFTPFile interface for named or unamed DOCSIS files. This file provides for the ability to build a DOCSIS file dynamically by adding top-level OptionValue instances. During the generation() method the OptionValue instances are processed into a binary configuration. The mix() method provides for the dynamic mixing of a DOCSIS configuration file (TFTP Modem address, TFTP timestamp address, CMTS MIC, and CM MIC). The mix algorithm is controlled by the presence of device-specific properties in either the DOCSISTFTPFile properties map or global properties set in the map given on the mix() method invocation.

The properties that influence the mixing are defined in the Prov API constants interface DocsisDefaultsKeys:

Multiple constructors are provided, but the expected use case is that the null-arg constructor is used, followed by multiple calls to the add() method to build the DOCSISTFTPFile dynamically.

See Also:
AbstractTFTPFile, TFTPFile, OptionValue, Serialized Form

Constructor Summary
DOCSISTFTPFile()
          No-arg constructor.
DOCSISTFTPFile(byte[] fileBytes)
          Use this constructor when no filename tag is used and the configuration file bytes is known at construction time.
DOCSISTFTPFile(String filename)
          Use this constructor when the filename is known at construction time, but the configuration file contents are created later.
DOCSISTFTPFile(String filename, byte[] fileBytes)
          Use this constructor when the filename and configuration file bytes are known at construction time.
 
Method Summary
 void add(List<OptionValue> optionValueList)
          Add the option values contained in the given list to the DOCSIS configuration.
 void add(OptionValue optionValue)
          Add the specified option value to the DOCSIS configuration.
static byte[] calcCMTSmicUsingMD5(byte[] key, byte[] data)
          Calculate the HMAC-MD5 digest (the CMTS MIC).
static byte[] calcCMTSmicUsingMMH(byte[] secret, byte[] data)
          Calculate the MMH digest for extended CMTS MIC.
static byte[] catByteArrays(byte[] one, byte[] two)
          Concatanate two byte arrays returning a third
 void clear()
          Clear the OptionValue list.
 void decode(ByteArrayInputStream in, com.cisco.csrc.encode.DataDecoder decoder)
          Decodes object's data and sets object's variables.
 void display(PrintWriter output, String prefix, List<String> options, boolean verbose)
          Display the contents of this object for debugging.
 void encode(ByteArrayOutputStream out, com.cisco.csrc.encode.DataEncoder encoder)
          Encodes object's data.
 boolean equals(Object object)
          Indicates whether some other object is "equal to" this one.
 void generate()
          Perform post-processing on DOCSIS configuration data.
 List<OptionValue> getOptionValueList()
          Get the list of OptionValue objects in this DOCSISTFTPFile.
 int hashCode()
          Returns the hashcode for this DOCSISTFTPFile.
 void mix(String ipAddress, CSRCProperties csrcProp)
          Perform DPE mixing.
 String paramString()
          Returns a string representing the state of the TFTPFile object.
 void readExternal(ObjectInput in)
          Externalizable interface.
 int size()
          Get the number of OptionValue objects in the DOCSISTFTPFile.
 void validate()
          Validate the TFTP file.
 void writeExternal(ObjectOutput out)
          Externalizable interface.
 
Methods inherited from class com.cisco.provisioning.cpe.extensions.configuration.AbstractTFTPFile
getFile, getFilename, getProperties, getProperty, setProperty, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DOCSISTFTPFile

public DOCSISTFTPFile()
No-arg constructor. Not all TFTPFile objects will have a filename tag or know their configuration file data at construction time. It is expected that addtional methods will be provided by the subclass to create the configuration data.


DOCSISTFTPFile

public DOCSISTFTPFile(String filename)
Use this constructor when the filename is known at construction time, but the configuration file contents are created later.

Parameters:
filename -

DOCSISTFTPFile

public DOCSISTFTPFile(byte[] fileBytes)
Use this constructor when no filename tag is used and the configuration file bytes is known at construction time.

Parameters:
fileBytes -

DOCSISTFTPFile

public DOCSISTFTPFile(String filename,
                      byte[] fileBytes)
Use this constructor when the filename and configuration file bytes are known at construction time.

Parameters:
filename -
fileBytes -
Method Detail

add

public void add(OptionValue optionValue)
Add the specified option value to the DOCSIS configuration. Only top-level DOCSIS option values can be added to the configuration.

Parameters:
optionValue - option value
Throws:
IllegalArgumentException - if OptionValue is null or if OptionValue is not a top-level option

add

public void add(List<OptionValue> optionValueList)
Add the option values contained in the given list to the DOCSIS configuration. This is a convenience method to allow the caller to build a list of option value instances and add them to the DOCSIS configuration in one step. The list must contain only OptionValue instances and each of those OptionValue instances may only be a top level option.

Parameters:
optionValueList - list of option values
Throws:
IllegalArgumentException - if list is null, list contains something other than top-level OptionValue instances

size

public int size()
Get the number of OptionValue objects in the DOCSISTFTPFile.

Returns:
number of OptionValue objects.

clear

public void clear()
Clear the OptionValue list. This removes all OptionValue objects from the DOCSISTFTPFile.


getOptionValueList

public List<OptionValue> getOptionValueList()
Get the list of OptionValue objects in this DOCSISTFTPFile. The List is write-through to the list of OptionValue objects contained in the DOCSISTFTPFile. Use synchronization on iteration of the list.

Returns:
List of OptionValue objects, or null if no OptionValue objects defined

validate

public void validate()
              throws InvalidConfigException
Validate the TFTP file. This method implements any validation of the TFTP file that is required during RDU configuration generation. Optional.

Specified by:
validate in interface TFTPFile
Specified by:
validate in class AbstractTFTPFile
Throws:
InvalidConfigException - if any errors are encountered during the validation.

generate

public void generate()
              throws InvalidConfigException
Perform post-processing on DOCSIS configuration data. Required interface. For DOCSIS configuration the generate() method causes the binary DOCSIS configuration to be generated. This involves iterating over the OptionValue instances and constructing the top-level TLV's for option values that have sub-options. Subsequent calls to getBinaryConfiguration() will retreive a binary BLOB containing the DOCSIS configuration binary.

Specified by:
generate in interface TFTPFile
Specified by:
generate in class AbstractTFTPFile
Throws:
InvalidConfigException - if any errors are encountered during the generation.

mix

public void mix(String ipAddress,
                CSRCProperties csrcProp)
         throws InvalidConfigException
Perform DPE mixing. This method is invoked prior to the file being sent to the device. Perform any mixing operations required. Optional.

Specified by:
mix in interface TFTPFile
Specified by:
mix in class AbstractTFTPFile
Parameters:
ipAddress - of the device requesting the TFTP file
csrcProp - relevant to mixing operation
Throws:
InvalidConfigException - if any errors are encountered during the mixing.

paramString

public String paramString()
Returns a string representing the state of the TFTPFile object. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null.

Overrides:
paramString in class AbstractTFTPFile
Returns:
String

display

public void display(PrintWriter output,
                    String prefix,
                    List<String> options,
                    boolean verbose)
Display the contents of this object for debugging.

The output from this method is expected to be easier to read, with possibly less detail than is produced by toString. The output can be multi-line if that makes it easier to read.

Specified by:
display in interface com.cisco.csrc.util.Displayable
Overrides:
display in class AbstractTFTPFile
Parameters:
output - the resulting output is written to this parameter.
prefix - string to output before each line, usually blanks to indent this output to show association with parent object.
options - list of string options to control output.
verbose - true indicates detailed output desired.

hashCode

public int hashCode()
Returns the hashcode for this DOCSISTFTPFile.

Overrides:
hashCode in class AbstractTFTPFile
Returns:
the hashcode for this DOCSISTFTPFile.

equals

public boolean equals(Object object)
Indicates whether some other object is "equal to" this one. We override this method to compare all the fields of DHCPData.

Overrides:
equals in class AbstractTFTPFile
Parameters:
object - to compare
Returns:
true if equal

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Externalizable interface. The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays. The readExternal method must read the values in the same sequence and with the same types as were written by writeExternal.

Specified by:
readExternal in interface Externalizable
Overrides:
readExternal in class AbstractTFTPFile
Parameters:
in - the stream to read data from in order to restore the object
Throws:
IOException - if I/O errors occur
ClassNotFoundException - If the class for an object being restored cannot be found.

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Externalizable interface. The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.

Specified by:
writeExternal in interface Externalizable
Overrides:
writeExternal in class AbstractTFTPFile
Parameters:
out - the stream to write the object to
Throws:
IOException - Includes any I/O exceptions that may occur

encode

public void encode(ByteArrayOutputStream out,
                   com.cisco.csrc.encode.DataEncoder encoder)
Encodes object's data.

Specified by:
encode in interface com.cisco.csrc.encode.Encodable
Overrides:
encode in class AbstractTFTPFile
Parameters:
out - the output stream to write to
encoder - the encoder to use

decode

public void decode(ByteArrayInputStream in,
                   com.cisco.csrc.encode.DataDecoder decoder)
Decodes object's data and sets object's variables.

Specified by:
decode in interface com.cisco.csrc.encode.Encodable
Overrides:
decode in class AbstractTFTPFile
Parameters:
in - the input stream to write to
decoder - the decoder to use

catByteArrays

public static byte[] catByteArrays(byte[] one,
                                   byte[] two)
Concatanate two byte arrays returning a third

Parameters:
one - the first byte array
two - the second byte array
Returns:
a new array containing both arrays one and two, in that order.

calcCMTSmicUsingMMH

public static byte[] calcCMTSmicUsingMMH(byte[] secret,
                                         byte[] data)
Calculate the MMH digest for extended CMTS MIC. DOCSIS 3.0 MMH-MAC keyed hash algorithm, according to the DOCSIS 3.0 Security Spec (CM-SP-SECv3.0-IO5-070803).

Parameters:
secret - the shared secret key.
data - the data to be processed.
Returns:
the MMH digest.
Throws:
InvalidKeyException
NoSuchAlgorithmException
NoSuchProviderException

calcCMTSmicUsingMD5

public static byte[] calcCMTSmicUsingMD5(byte[] key,
                                         byte[] data)
                                  throws InvalidKeyException,
                                         NoSuchAlgorithmException,
                                         NoSuchProviderException
Calculate the HMAC-MD5 digest (the CMTS MIC). See RFC 2104, "HMAC: Keyed-Hashing for Message Authentication". Note: current impelementation requires key to be less than 64 bytes. Keys > 64 bytes will generate an InvalidKeyException.

Parameters:
key - the shared secret key.
data - the data to be processed.
Returns:
the HMAC-MD5 digest.
Throws:
InvalidKeyException
NoSuchAlgorithmException
NoSuchProviderException