com.flagstone.transform
Class Protect

java.lang.Object
  extended by com.flagstone.transform.Protect
All Implemented Interfaces:
Copyable<MovieTag>, SWFEncodeable, MovieTag

public final class Protect
extends Object
implements MovieTag

Protect marks a file as not-readable, preventing the file from being loaded into an editor.

From Flash 4, a password field was added. In order to load a file in Macromedia's flash editor tool a password must be entered and the MD5 hash must match the value stored in the password field.

IMPORTANT: this form of protection only works with Macromedia's Flash Authoring tool. Any application that parses Flash files can choose to ignore or delete this data structure therefore it is not safe to use this to protect the contents of a Flash file.

Transform will parse all Flash files containing the Protect data structure. Since the encoded data is can be removed by trivial scripts the level of copy-protection offered is minimal. Indeed the use of the Protect mechanism in Flash movies may lead to a false sense of security, putting proprietary information at risk. Sensitive information should not be included in Flash movies.


Constructor Summary
Protect()
          Creates a Protect object with no password - Flash versions 1 to 3 only.
Protect(Protect object)
          Creates and initialises a Protect object using the password copied from another Protect object.
Protect(String pass)
          Creates a Protect object with the specified password - used for file with Flash version 4 and above.
Protect(SWFDecoder coder)
          Creates and initialises a Protect object using values encoded in the Flash binary format.
 
Method Summary
 Protect copy()
          Creates a complete copy of this object.
 void encode(SWFEncoder coder, Context context)
          Encode an object to the Flash binary format.
 String getPassword()
          Get the MD5 password hash.
 int prepareToEncode(Context context)
          Prepare an object for encoding, returning the expected size of an object when it is encoded.
 void setPassword(String aString)
          Sets the MD5 encrypted password.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Protect

public Protect(SWFDecoder coder)
        throws IOException
Creates and initialises a Protect object using values encoded in the Flash binary format.

Parameters:
coder - an SWFDecoder object that contains the encoded Flash data.
Throws:
IOException - if an error occurs while decoding the data.

Protect

public Protect()
Creates a Protect object with no password - Flash versions 1 to 3 only.


Protect

public Protect(String pass)
Creates a Protect object with the specified password - used for file with Flash version 4 and above.

Parameters:
pass - the string defining the password. Must not be null.

Protect

public Protect(Protect object)
Creates and initialises a Protect object using the password copied from another Protect object.

Parameters:
object - a Protect object from which the password will be copied.
Method Detail

getPassword

public String getPassword()
Get the MD5 password hash. This may be null if the object was decoded from a file containing Flash version 2 or 3.

Returns:
the MD5 hash of the password used to protect the file.

setPassword

public void setPassword(String aString)
Sets the MD5 encrypted password.

Parameters:
aString - the string defining the password. Must not be null.

copy

public Protect copy()
Creates a complete copy of this object.

Specified by:
copy in interface Copyable<MovieTag>
Returns:
a deep-copy of this object. New instances of mutable objects are copied and immutable instances are shared.

toString

public String toString()

Overrides:
toString in class Object

prepareToEncode

public int prepareToEncode(Context context)
Prepare an object for encoding, returning the expected size of an object when it is encoded. This method also used to initialise variables, such as offsets and flags that will be used when the object is encoded. Generally the method returns the size in bytes, however when called on objects that use bit fields such as shapes the methods will return the size in bits.

Specified by:
prepareToEncode in interface SWFEncodeable
Parameters:
context - an Context that allows information to be passed between objects to control how they are initialised for encoding.
Returns:
the size of the object when it is encoded.

encode

public void encode(SWFEncoder coder,
                   Context context)
            throws IOException
Encode an object to the Flash binary format.

Specified by:
encode in interface SWFEncodeable
Parameters:
coder - an SWFEncoder object.
context - an Context that allows information to be passed between objects to control how they are initialised for encoding.
Throws:
IOException - if an error occurs while encoding the object.


Copyright © 2002-2010 Flagstone Software Ltd.. All Rights Reserved.