Methods Summary |
---|
public static X509Certificate | createCertificate(PublicKeyInfo keyInfo)Creates an {@link X509Certificate} using the given public key
information.
if (keyInfo == null) {
return null;
}
try {
X509Certificate cert;
cert = new X509Certificate((byte)1, // fixed at version 1
new byte[0],
keyInfo.getOwner(),
keyInfo.getOwner(), // issuer same as subject
keyInfo.getNotBefore(),
keyInfo.getNotAfter(),
keyInfo.getModulus(),
keyInfo.getExponent(),
null, // we don't use finger prints
0);
return cert;
} catch (Exception e) {
return null;
}
|
public X509Certificate[] | getCertificates(java.lang.String subjectName)Returns the certificate(s) corresponding to a
subject name string.
Vector keys;
X509Certificate[] certs;
keys = findKeys(subjectName);
if (keys == null) {
return null;
}
certs = new X509Certificate[keys.size()];
for (int i = 0; i < keys.size(); i++) {
certs[i] = createCertificate((PublicKeyInfo)keys.elementAt(i));
}
return certs;
|
public static com.sun.midp.publickeystore.WebPublicKeyStore | getTrustedKeyStore()Provides the keystore of resident public keys for
security domain owners and other CA's.
return trustedKeyStore;
|
public static void | initSecurityToken(SecurityToken token)Initializes the security domain for this class, so it can
perform actions that a normal MIDlet Suite cannot.
if (classSecurityToken == null) {
classSecurityToken = token;
}
|
public static void | loadCertificateAuthorities()Load the certificate authorities for the MIDP RI from storage
into the SSL keystore.
RandomAccessStream storage;
InputStream tks;
WebPublicKeyStore ks;
if (trustedKeyStore != null) {
return;
}
try {
storage = new RandomAccessStream(classSecurityToken);
storage.connect(File.getStorageRoot() + "_main.ks",
Connector.READ);
tks = storage.openInputStream();
} catch (Exception e) {
System.out.println("Could not open the trusted key store, " +
"cannot authenticate HTTPS servers");
return;
}
try {
ks = new com.sun.midp.publickeystore.WebPublicKeyStore(tks);
} catch (Exception e) {
System.out.println("Corrupt key store file, " +
"cannot authenticate HTTPS servers");
e.printStackTrace();
return;
} finally {
try {
storage.disconnect();
} catch (Exception e) {
// nothing we can do.
}
}
WebPublicKeyStore.setTrustedKeyStore(ks);
|
private static void | setTrustedKeyStore(com.sun.midp.publickeystore.WebPublicKeyStore keyStore)Establish the given keystore as the system trusted keystore.
This is a one-shot method, it will only set the trusted keystore
it there is no keystore set. For security purposes only
read-only PublicKeyStores should be set.
if (trustedKeyStore != null) {
return;
}
trustedKeyStore = keyStore;
SSLStreamConnection.setTrustedCertStore(keyStore);
SSLStreamConnection.lockTrustedCertStore();
|