Working with key stores in memory
The toolkit can hold key stores in memory for situations where you prefer not to save credentials and certificates in a file.
See a full example in the following folder.
etjava\examples\source\com\entrust\toolkit\examples\keystoreInMemoryLoading credentials for memory
Create a key store and load credentials from a data structure in memory – for example, a bit array.
java.security.KeyStore.KeyStore keyStore = KeyStore.getInstance("Entrust");keyStore.load(new ByteArrayInputStream(byteArray), password.toCharArray());Adding certificates
Add a trusted certificate to the key store.
keyStore.setCertificate("Bob", cert);Where "Bob" is the certificate alias, and cert is the certificate as an instance of the following class.
java.security.cert.CertificateRetrieving certificates
Use the certificate aliases to retrieve certificates from the key store.
X509Certificate caCert = (X509Certificate)keyStore.getCertificate("CA");X509Certificate encCert = (X509Certificate)keyStore.getCertificate("encryption");X509Certificate signCert = (X509Certificate)keyStore.getCertificate("signing");X509Certificate signCert = (X509Certificate)keyStore.getCertificate("Bob");Writing the key store
Write the key store to a ByteArrayInputStream.
ByteArrayOutputStream anotherBaos = new ByteArrayOutputStream();keyStore.store(anotherBaos, password.getStringBuffer().toString().toCharArray());