JDBCCertRecordStoreFactory implements CertRecordStoreFactory { @Override public CertRecordStore create(PrivateKeyStore keyStore) { final String jdbcStore = System.getProperty(ZTSConsts.ZTS_PROP_CERT_JDBC_STORE); final String jdbcUser = System.getProperty(ZTSConsts.ZTS_PROP_CERT_JDBC_USER); final String password = System.getProperty(ZTSConsts.ZTS_PROP_CERT_JDBC_PASSWORD, ""); final String jdbcAppName = System.getProperty(ZTSConsts.ZTS_PROP_CERT_JDBC_APP_NAME, JDBC); String jdbcPassword = keyStore.getApplicationSecret(jdbcAppName, password); Properties props = new Properties(); props.setProperty(ZTSConsts.DB_PROP_USER, jdbcUser); props.setProperty(ZTSConsts.DB_PROP_PASSWORD, jdbcPassword); props.setProperty(ZTSConsts.DB_PROP_VERIFY_SERVER_CERT, System.getProperty(ZTSConsts.ZTS_PROP_CERT_JDBC_VERIFY_SERVER_CERT, "false")); props.setProperty(ZTSConsts.DB_PROP_USE_SSL, System.getProperty(ZTSConsts.ZTS_PROP_CERT_JDBC_USE_SSL, "false")); PoolableDataSource src = DataSourceFactory.create(jdbcStore, props); JDBCCertRecordStore certStore = new JDBCCertRecordStore(src); int opTimeout = Integer.parseInt(System.getProperty(ZTSConsts.ZTS_PROP_CERT_OP_TIMEOUT, "10")); certStore.setOperationTimeout(opTimeout); return certStore; }  @Override CertRecordStore create(PrivateKeyStore keyStore);  }
@Test public void testCreate() { System.setProperty(ZTSConsts.ZTS_PROP_CERT_JDBC_STORE, "jdbc:mysql: System.setProperty(ZTSConsts.ZTS_PROP_CERT_JDBC_USER, "user"); System.setProperty(ZTSConsts.ZTS_PROP_CERT_JDBC_PASSWORD, "password"); PrivateKeyStore keyStore = Mockito.mock(PrivateKeyStore.class); Mockito.doReturn("password").when(keyStore).getApplicationSecret("jdbc", "password"); JDBCCertRecordStoreFactory factory = new JDBCCertRecordStoreFactory(); CertRecordStore store = factory.create(keyStore); assertNotNull(store); }