FileDocCategorySizeDatePackage
MIDletSuiteVerifier.javaAPI DocphoneME MR2 API (J2ME)3722Wed May 02 18:00:08 BST 2007com.sun.midp.main

MIDletSuiteVerifier

public class MIDletSuiteVerifier extends Object
This class is designed to provide the functionality needed for MIDlet suite classes verification and the methods to control that the verified suite hasn't been changed since the verification moment.

Fields Summary
static final int
CHUNK_SIZE
Size of the verification portion
Constructors Summary
Methods Summary
public static native booleancheckJarHash(java.lang.String jarPath, byte[] hashValue)
Compare hash value of the JAR with provided hash value.

param
jarPath path to JAR file
param
hashValue hash value to compare with
return
true if JAR has hash value equal to the provided one, otherwise false
throws
IOException

public static native byte[]getJarHash(java.lang.String jarPath)
Evaluate hash value for the JAR package

param
jarPath JAR package path
return
hash value for JAR package

static native voiduseClassVerifier(boolean verifier)
Disable or enable class verifier for the current Isolate

param
verifier true to enable, false to disable verifier

static booleanverifyJar(java.lang.String jarPath)
Verify classes within JAR package

param
jarPath path to the JAR package within file system
return
true if all classes were verified successfully, false otherwise


                                  
        
        return Util.verify(jarPath, CHUNK_SIZE);
    
public static byte[]verifySuiteClasses(int suiteId, com.sun.midp.midletsuite.MIDletSuiteStorage suiteStorage)
Verify suite classes and return hash value of the suite JAR, throws Error in the case of unsuccessful class verification

param
suiteId id of the suite whose classes are to be verified
param
suiteStorage suite storage instance
return
hash value of the successfully verified JAR package, or null if class verification wasn't done by some reason, e.g. it was scheduled to be started later
throws
Error, IOException


        String jarPath = suiteStorage.getMidletSuiteJarPath(suiteId);
        if (verifyJar(jarPath)) {
            return getJarHash(jarPath);
        } else {
            /**
             * Class verification failure is a serious problem, it's
             * up to caller how to handle it and proceed with further
             * execution.
             */
            throw new java.lang.Error();
        }