Java Authentication

For a Java-based CCM application, the client certificate, key pair, and root CA The Certificate Authority (CA) issues and manages security credentials and public keys for message encryption in a networks environment. certificate must be in a keystore and a truststore that are accessible to the Java application. If a dedicated truststore is not passed in parameter, the default Java truststore is used to verify the chain of trust. Smart card-based authentication can also be implemented using the Java PKCS#11 interface and ActivID ActivClient.

Sample Authentication Code

The following sample of authentication code illustrates a Java-based CCM application:

Copy
/****************************************************** 
Client certificate and key pair are read out of a P12.
The Root CA Certificate is read out of a JKS keystore.
*******************************************************/
KeyStore    keyStore = KeyStore.getInstance("PKCS12", "SunJSSE");
KeyStore    trustStore    = KeyStore.getInstance("jks", "SUN");
InputStream inputStream = new FileInputStream(client);
keyStore.load(inputStream, pwd.toCharArray());
inputStream.close(); trustStore.load(null, null); inputStream = new FileInputStream(CA);
Certificate caCert = CertificateFactory.getInstance( "X.509").generateCertificate(inputStream);
trustStore.setCertificateEntry("cert-0", caCert);
inputStream.close();
Map config = new HashMap();
config.put(CCMConstants.CONFIG_KEYSTORE, keyStore); config.put(CCMConstants.CONFIG_KEYSTORE_PWD, pwd); config.put(CCMConstants.CONFIG_TRUSTSTORE, trustStore); config.put(CCMConstants.CONFIG_HOST_NAME, host); config.put(CCMConstants.CONFIG_HOST_PORT, port);
userMgr = UserManagerFactory.newInstance(config);
userMgr.openSession(null);
userMgr.getVersion();