| java.lang.Object java.util.Hashtable java.util.Properties com.sun.midp.installer.JadProperties com.sun.midp.jadtool.AppDescriptor
AppDescriptor | public class AppDescriptor extends JadProperties (Code) | | Java API for signing MIDletSuites.
AppDescriptor is an extension of the Properties class which provides
additional methods for adding message digest and certificate
properties as well as signing the app descriptor file and verifying
a signed app descriptor file.
|
Field Summary | |
public static int | CERT Index of the cert in arrays returned by getAllCerts. | final public static String | CP_ATTR App Descriptor key for . | final public static String | JAR_SIGNATURE App Descriptor key for . | final public static String | JAR_SIZE App Descriptor key for . | final public static String | JAR_URL App Descriptor key for . | public static int | KEY Index of the key in arrays returned by getAllCerts. | final public static String | SEP_ATTR App Descriptor key for . | final public static String | SIGN_ALG SHA1 with RSA constant. |
Method Summary | |
public void | addCert(String alias, int chainNum, int certNum) Retrieves a certificate out of a KeyStore and adds it
to the app descriptor as:
content_provider.certificate-1-1:
Instance variable keystore must not be null,
and should have been set by loadKeyStore
before this method is called. | public void | addJarSignature(String alias, char[] keypass) Adds a Base64 encoded signature of the jar file at the URL
specified by the MIDlet-Jar-URL key in the app descriptor.
load and loadKeyStore must be
call before this method.
The line in the app descriptor corresponding to this
insertion will look like this:
MIDlet-Jar-RSA-SHA1:j3zKCv6eud2Ubkw80XjpNb7tk5s...
If a MIDlet-Jar-RSA-SHA1 property already exists it will
be replaced.
Parameters: alias - Alias of the signing key in the keystore. Parameters: keypass - Password to access the signing (private) key. exception: AppDescriptorException - JAR URL or content providercertificate wasnot found in the app descriptor. exception: MalformedURLException - The URL corresponding to the MIDlet-Jar-URL key could not be parsed. exception: IOException - error reading the JAR exception: NoSuchAlgorithmException - If SHA1 or RSA need bygetEncodedSig could not be found in aninstalled JCA provider. | public void | addJarSignature(String alias, char[] keypass, InputStream jarStream) Adds a Base64 encoded signature of the jar file provided in
an input stream to the app descriptor.
The line in the app descriptor corresponding to this
insertion will look like this:
MIDlet-Jar-RSA-SHA1:j3zKCv6eud2Ubkw80XjpNb7tk5s...
If a MIDlet-Jar-RSA-SHA1 property already exists it will
be replaced.
Parameters: alias - Alias of the signing key in the keystore. Parameters: keypass - Password to access the signing (private) key. Parameters: jarStream - stream to read the jar file from exception: IOException - If there is a problem reading the input stream. exception: NoSuchAlgorithmException - If SHA1 or RSA need bygetEncodedSig could not be found in aninstalled JCA provider. | static String | createFingerprint(byte[] certificateBytes, String algorithm) createFingerprint - A helper function used by
getdigest .
createFingerprint , given a certificated encoded
as a byte array will compute a "fingerprint", or Message
Digest of the certificate using the selected algorithm
type.
A fingerprint is meant to be human readable, and is thus
returned as a hex string separated at byte boundaries by
a delimiter ":".
Parameters: certificateBytes - - a certificate encoded as a byte array Parameters: algorithm - - The name of a digest algorithm to use, e.g. | public Vector | getAllCerts() Returns all X509Certificate objects from the app descriptor. | public X509Certificate | getCert(int chainNum, int certNum) Returns an X509Certificate object from the app descriptor property
chosen by certnum , or
null if that certificate does not exist in the descriptor. | public X509Certificate | getCertAttribute(int chainNum, int certNum) Returns an X509Certificate object from the app descriptor property
chosen by certnum , or
null if that certificate does not exist in the descriptor. | public String | getCertDigest(int chainNum, int certNum, String alg) Returns a message digest of a certificate in "human readable"
from from the app descriptor property
chosen by certnum , or
null if that certificate does not exist in the descriptor.
After finding the chosen property in the app descriptor,
decodes it from Base64 into a byte-encoded certificate and then
creates a readable digest String based on that data.
Parameters: chainNum - number of the certificate chain Parameters: certNum - number of the certificate in the chain Parameters: alg - A Digest algorithm to use, e.g. | public synchronized void | load(InputStream inputJad, String encoding) Used to input a stored app descriptor into an AppDescriptor
instance from a stream. | public synchronized void | loadKeyStore(InputStream ksfile, char[] storepass) Provides a KeyStore instance for use by this AppDescriptor
object. | public synchronized void | store(OutputStream outputJad, String encoding) Used to store an app descriptor instance into a jad file
through an output stream. | public synchronized void | storeKeyStore(String ksfname, char[] storepass) Store a the keystore in the descriptor in a file. |
CERT | public static int CERT(Code) | | Index of the cert in arrays returned by getAllCerts.
|
CP_ATTR | final public static String CP_ATTR(Code) | | App Descriptor key for .
|
JAR_SIGNATURE | final public static String JAR_SIGNATURE(Code) | | App Descriptor key for .
|
JAR_SIZE | final public static String JAR_SIZE(Code) | | App Descriptor key for .
|
JAR_URL | final public static String JAR_URL(Code) | | App Descriptor key for .
|
KEY | public static int KEY(Code) | | Index of the key in arrays returned by getAllCerts.
|
SEP_ATTR | final public static String SEP_ATTR(Code) | | App Descriptor key for .
|
SIGN_ALG | final public static String SIGN_ALG(Code) | | SHA1 with RSA constant.
|
AppDescriptor | public AppDescriptor()(Code) | | Default constructor
|
addCert | public void addCert(String alias, int chainNum, int certNum) throws CertificateException, KeyStoreException, AppDescriptorException(Code) | | Retrieves a certificate out of a KeyStore and adds it
to the app descriptor as:
content_provider.certificate-1-1:
Instance variable keystore must not be null,
and should have been set by loadKeyStore
before this method is called.
Parameters: alias - Alias of the chosen certificate in the keystore Parameters: chainNum - number of the chain to add certificate to Parameters: certNum - number of the certificate in the chain to replace it,or 0 to add the certificate at the end of the chain exception: KeyStoreException - If there is an error with the keystore. exception: CertificateException - If there is a problem with theencoding of the certificate. exception: AppDescriptorException - If the KeyStore has not been initialized (keystore is null) |
createFingerprint | static String createFingerprint(byte[] certificateBytes, String algorithm) throws NoSuchAlgorithmException(Code) | | createFingerprint - A helper function used by
getdigest .
createFingerprint , given a certificated encoded
as a byte array will compute a "fingerprint", or Message
Digest of the certificate using the selected algorithm
type.
A fingerprint is meant to be human readable, and is thus
returned as a hex string separated at byte boundaries by
a delimiter ":".
Parameters: certificateBytes - - a certificate encoded as a byte array Parameters: algorithm - - The name of a digest algorithm to use, e.g. "SHA1" or "MD5" the fingerprint in String form. exception: NoSuchAlgorithmException - Thrown if the digestalgorithm could not be found. |
getAllCerts | public Vector getAllCerts() throws CertificateException(Code) | | Returns all X509Certificate objects from the app descriptor.
After finding a certificate property in the app descriptor,
decodes it from Base64 into a byte-encoded certificate and then
creates the X509 format certificate from that opaque data.
Vector of object arrays, each containing key, and aX509Certificate object |
getCert | public X509Certificate getCert(int chainNum, int certNum) throws CertificateException(Code) | | Returns an X509Certificate object from the app descriptor property
chosen by certnum , or
null if that certificate does not exist in the descriptor.
After finding the chosen property in the app descriptor,
decodes it from Base64 into a byte-encoded certificate and then
creates the X509 format certificate from that opaque data.
Parameters: chainNum - number of the certificate chain Parameters: certNum - number of the certificate in the chain an X509Certificate object or null if the certificate isnot in the JAD exception: CertificateException - If there is a format problem withthe certificate |
getCertAttribute | public X509Certificate getCertAttribute(int chainNum, int certNum) throws CertificateException(Code) | | Returns an X509Certificate object from the app descriptor property
chosen by certnum , or
null if that certificate does not exist in the descriptor.
After finding the chosen property in the app descriptor,
decodes it from Base64 into a byte-encoded certificate and then
creates the X509 format certificate from that opaque data.
Parameters: chainNum - number of the certificate chain Parameters: certNum - number of the certificate in the chain an X509Certificate object or null if the certificate isnot in the JAD exception: CertificateException - If there is a format problem withthe certificate |
getCertDigest | public String getCertDigest(int chainNum, int certNum, String alg) throws NoSuchAlgorithmException(Code) | | Returns a message digest of a certificate in "human readable"
from from the app descriptor property
chosen by certnum , or
null if that certificate does not exist in the descriptor.
After finding the chosen property in the app descriptor,
decodes it from Base64 into a byte-encoded certificate and then
creates a readable digest String based on that data.
Parameters: chainNum - number of the certificate chain Parameters: certNum - number of the certificate in the chain Parameters: alg - A Digest algorithm to use, e.g. "SHA1" or "MD5". A message digest of a certificate in hex as a String ornull if the certificate is not in the JAD. exception: NoSuchAlgorithmException - Thrown if the digestalgorithm could not be found. |
load | public synchronized void load(InputStream inputJad, String encoding) throws UnsupportedEncodingException, IOException, InvalidJadException(Code) | | Used to input a stored app descriptor into an AppDescriptor
instance from a stream. The input stream will be converted
to Unicode using encoding if it is specified.
If encoding is not specified, a default
encoding of type "UTF8" escapes will be used.
Overrides Properties.load
Parameters: inputJad - App descriptor input stream. Parameters: encoding - Encoding of the inputJad stream. exception: IOException - If an error occurs while loading the inputJad stream. exception: UnsupportedEncodingException - If the given encodingtype is not supported. exception: InvalidJadException - If the JAD has a format error |
loadKeyStore | public synchronized void loadKeyStore(InputStream ksfile, char[] storepass) throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException, Exception(Code) | | Provides a KeyStore instance for use by this AppDescriptor
object. (The default KeyStore type from the Java security
properties file is used. This should be type "JKS", and is
the only supported keystore format.)
This KeyStore is required by the addcert ,
sign , signcert , and verify
methods. If any of these methods is called before
loadKeyStore an exception will be thrown.
Parameters: ksfile - The input stream stream to load a KeyStore from. Parameters: storepass - The password to unlock the KeyStore, can be null. exception: KeyStoreException - The default keystore provider typeis not available in any of the provider packages searched. exception: IOException - Thrown if there is a problem parsing the input stream or loading its data. exception: CertificateException - Thrown if there is trouble loadingcertificates into the KeyStore exception: NoSuchAlgorithmException - Thrown if the algorithmneeded to verify the KeyStore cannot be found. |
store | public synchronized void store(OutputStream outputJad, String encoding) throws UnsupportedEncodingException, IOException(Code) | | Used to store an app descriptor instance into a jad file
through an output stream. The internal Unicode stream
will be converted to an output format using
encoding if it is specified.
If encoding is not specified, a default
encoding of type Ascii with Unicode escapes will be used.
Overrides Properties.store
Parameters: outputJad - App descriptor output stream. Parameters: encoding - Encoding of the outputJad stream. exception: IOException - If an error occurs while writing the inputJad stream. exception: UnsupportedEncodingException - If the given encodingtype is not supported. |
|
|