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

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

public final class PacketCableTFTPFile
extends DOCSISTFTPFile

Look at EDCS-192364 for design of this data structure. Packet Cable TFTP file. This class provides an implementation of a TFTPFile interface for static or dynamic Packet Cable files. This file provides for the ability to build a Packet Cable 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 encryption of the TFTPFile.

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 PacketCableTFTPFile dynamically.

See Also:
AbstractTFTPFile, TFTPFile, OptionValue, MTAKeys, Serialized Form

Constructor Summary
PacketCableTFTPFile()
          No-arg constructor.
PacketCableTFTPFile(byte[] fileBytes)
          Use this constructor when no filename tag is used and the configuration file bytes is known at construction time.
PacketCableTFTPFile(String filename)
          Use this constructor when the filename is known at construction time, but the configuration file contents are created later.
PacketCableTFTPFile(String filename, byte[] fileBytes)
          Use this constructor when the filename and configuration file bytes are known at construction time.
 
Method Summary
 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()
          Specialization of the normal DOCSIS file binary generation.
 byte[] getConfigFileHash(String macstr, byte[] informData, CSRCProperties csrcProp)
          Called on receipt of IM_MTA_SECINFO_REQ.
 byte[] getFile()
          Get the configuration file to be delivered to the device.
 byte[] getKeyMaterial()
          Gets the key material
 int getLocale()
          Get the locale.
 String getStaticFilename()
          Gets the static filename
 int hashCode()
          Returns the hashcode for this PacketCableTFTPFile.
 boolean isBasicProvModeFile()
          Get the BASIC file mode indicator.
 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.
 void setBasicProvModeFile(boolean b)
          Set the BASIC mode file indicator.
 void setKeyMaterial(byte[] keyMaterial)
          Sets the key material
 void setLocale(int locale)
          Set the locale.
 void setStaticFilename(String staticFilename)
          Sets the static filename
 void writeExternal(ObjectOutput out)
          Externalizable interface.
 
Methods inherited from class com.cisco.provisioning.cpe.extensions.configuration.DOCSISTFTPFile
add, add, calcCMTSmicUsingMD5, calcCMTSmicUsingMMH, catByteArrays, clear, getOptionValueList, size, validate
 
Methods inherited from class com.cisco.provisioning.cpe.extensions.configuration.AbstractTFTPFile
getFilename, getProperties, getProperty, setProperty, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PacketCableTFTPFile

public PacketCableTFTPFile()
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.


PacketCableTFTPFile

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

Parameters:
filename -

PacketCableTFTPFile

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

Parameters:
fileBytes -

PacketCableTFTPFile

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

Parameters:
filename -
fileBytes -
Method Detail

getFile

public byte[] getFile()
Get the configuration file to be delivered to the device. This method is invoked by the DPE when the TFTP file is requested by the device. If dynamic file mixing is required then the mix() method must be invoked prior to this method.

Specified by:
getFile in interface TFTPFile
Overrides:
getFile in class AbstractTFTPFile
Returns:
the configuration file

getConfigFileHash

public byte[] getConfigFileHash(String macstr,
                                byte[] informData,
                                CSRCProperties csrcProp)
Called on receipt of IM_MTA_SECINFO_REQ. Get the file hash to be delivered to the device. This method is invoked by the DPE when the file hash is requested by the SNMP Service.

Parameters:
macstr -
informData -
csrcProp -
Returns:
the configuration file

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
Overrides:
mix in class DOCSISTFTPFile
Parameters:
ipAddress - of the device requesting the TFTP file
csrcProp - relevant to mixing operation
Throws:
InvalidConfigException - if any errors are encountered during the mixing.

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 DOCSISTFTPFile
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.

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 DOCSISTFTPFile
Returns:
String

hashCode

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

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

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 DOCSISTFTPFile
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 DOCSISTFTPFile
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 DOCSISTFTPFile
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 DOCSISTFTPFile
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 DOCSISTFTPFile
Parameters:
in - the input stream to write to
decoder - the decoder to use

setStaticFilename

public void setStaticFilename(String staticFilename)
Sets the static filename

Parameters:
staticFilename -

getStaticFilename

public String getStaticFilename()
Gets the static filename

Returns:
static filename

setKeyMaterial

public void setKeyMaterial(byte[] keyMaterial)
Sets the key material

Parameters:
keyMaterial -

getKeyMaterial

public byte[] getKeyMaterial()
Gets the key material

Returns:
key material

generate

public void generate()
              throws InvalidConfigException
Specialization of the normal DOCSIS file binary generation. Base class is first called to perform binary generation. If the file is intended for PacketCable BASIC device, the SHA1 hash of the file is calculated and inserted via a TLV 11 placed just before the end of file TLV.

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

isBasicProvModeFile

public boolean isBasicProvModeFile()
Get the BASIC file mode indicator.

Returns:
true if the file is in basic mode, otherwise false is returned if the file is in secure mode.

setBasicProvModeFile

public void setBasicProvModeFile(boolean b)
Set the BASIC mode file indicator.

Parameters:
b -

setLocale

public void setLocale(int locale)
Set the locale.

Parameters:
locale -

getLocale

public int getLocale()
Get the locale.

Returns:
The local