SandMark version 3.0


sandmark.watermark.ct.embed
Class Embedder

java.lang.Object
  |
  +--sandmark.watermark.ct.embed.Embedder

public class Embedder
extends java.lang.Object

The sandmark.watermark.ct.embed.Embedder class contains methods for adding watermarking code to Java bytecode.


Field Summary
(package private)  Forest callForest
           
(package private)  ClassFileCollection cfc
           
(package private)  Encoder encoder
           
(package private)  java.util.Properties props
           
(package private)  Stats statistics
           
(package private)  TracePoint[] traceData
           
 
Constructor Summary
Embedder(java.util.Properties props, TracePoint[] traceData)
           
 
Method Summary
(package private)  MethodID[] allMethods()
          Get all the methods in the program.
(package private)  Graph constructGraph(java.util.Properties props)
          Construct and return a graph embedding the value WM_Encode_Watermark using encoding DWM_CT_Encode_Encoding.
(package private)  void embedClass(ClassFileCollection cfc, de.fub.bytecode.classfile.JavaClass watermarkClass, EmbedData[] embedData, MethodID[] methods, java.util.Properties props)
          Add the watermark class to the cfc, and embed calls to it based on the embedding information in 'embedData'.
(package private)  EmbedData[] findEmbedding(de.fub.bytecode.classfile.JavaClass classFile, TracePoint[] traceData)
          Decide where the methods in the watermark class should be called in the application: Get the methods that build the watermark.
 EmbedData[] getEmbedding()
          Compute the locations where calls to the watermarking routines should be inserted.
 void saveByteCode()
          Add calls to the graph-building routines to the program to be watermarked.
 void saveCallForest(java.lang.String dotFileBaseName)
          Write the dot files for the call forest graphs.
 void saveGraph(java.lang.String dotFileName)
          Write the Java source for the watermark class.
 void saveSource(java.lang.String sourceFileName)
          Write the Java source for the watermark class.
 java.lang.String source()
          Get the Java source for the watermark class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

props

java.util.Properties props

traceData

TracePoint[] traceData

cfc

ClassFileCollection cfc

encoder

Encoder encoder

callForest

Forest callForest

statistics

Stats statistics
Constructor Detail

Embedder

public Embedder(java.util.Properties props,
                TracePoint[] traceData)
         throws java.lang.Exception
Parameters:
props - global property list
traceData - a vector of annotation points that were hit during tracing

Reads properties:

Method Detail

allMethods

MethodID[] allMethods()
                throws java.io.IOException
Get all the methods in the program. Used for testing.

java.io.IOException

saveByteCode

public void saveByteCode()
                  throws java.lang.Exception
Add calls to the graph-building routines to the program to be watermarked.
  1. Get the bytecode that encodes the watermark,
  2. find the trace locations in the program where calls to the watermark-building code should be inserted,
  3. embed the calls at the appropriate locations, and
  4. save the resulting new, watermarked, program.

java.lang.Exception

getEmbedding

public EmbedData[] getEmbedding()
                         throws java.lang.Exception
Compute the locations where calls to the watermarking routines should be inserted.

java.lang.Exception

source

public java.lang.String source()
Get the Java source for the watermark class.


saveSource

public void saveSource(java.lang.String sourceFileName)
                throws java.lang.Exception
Write the Java source for the watermark class.

Parameters:
sourceFileName - The name of the file to be written.
java.lang.Exception

saveGraph

public void saveGraph(java.lang.String dotFileName)
               throws java.lang.Exception
Write the Java source for the watermark class.

java.lang.Exception

saveCallForest

public void saveCallForest(java.lang.String dotFileBaseName)
                    throws java.lang.Exception
Write the dot files for the call forest graphs.

Parameters:
dotFileBaseName - The base name (without the .dot extension) of the files to be written.
java.lang.Exception

findEmbedding

EmbedData[] findEmbedding(de.fub.bytecode.classfile.JavaClass classFile,
                          TracePoint[] traceData)
                    throws java.lang.Exception
Decide where the methods in the watermark class should be called in the application:
  1. Get the methods that build the watermark. There's one method per graph component.
  2. Distribute calls to these methods among the available trace points.

Parameters:
classFile - The class that builds the watermark graph.
traceData - Location of trace points hit during the tracing run.

java.lang.Exception

embedClass

void embedClass(ClassFileCollection cfc,
                de.fub.bytecode.classfile.JavaClass watermarkClass,
                EmbedData[] embedData,
                MethodID[] methods,
                java.util.Properties props)
          throws java.lang.Exception
Add the watermark class to the cfc, and embed calls to it based on the embedding information in 'embedData'. There are several steps:
  1. Replace the 'mark()'-calls in the original program with calls to the watermark-building methods. Only some 'mark()'-calls will be replaced, namely those indicated by 'embedData'.
  2. In case we are passing graph handles in extra method arguments we need to create those formal arguments and add the extra actual arguments.
  3. We need to create storage (arrays, vectors, hashtables, etc) to store the handles to watermark graph components.
  4. We delete all remaining 'mark()'-calls.
  5. Finally, we add the watermark class to class file collection.

Parameters:
cfc - The application to be watermarked.
watermarkClass - The class that builds the watermark graph.
embedData - Where in the cfc calls to watermarkClass should be embedded.
methods - The methods to which formal parameters should be added to pass around storage containers.
java.lang.Exception

constructGraph

Graph constructGraph(java.util.Properties props)
               throws java.lang.Exception
Construct and return a graph embedding the value WM_Encode_Watermark using encoding DWM_CT_Encode_Encoding.

Parameters:
props - The property collection.

props contains at least:

java.lang.Exception

SandMark version 3.0

Wed Jan 29 10:30:05 MST 2003