class AWSCertRecordStoreFactory implements CertRecordStoreFactory {

    @Override
    public CertRecordStore create(PrivateKeyStore keyStore) {
        
        rdsUser = System.getProperty(ZTSConsts.ZTS_PROP_AWS_RDS_USER);
        rdsIamRole = System.getProperty(ZTSConsts.ZTS_PROP_AWS_RDS_IAM_ROLE);
        rdsMaster = System.getProperty(ZTSConsts.ZTS_PROP_AWS_RDS_MASTER_INSTANCE);
        rdsPort = Integer.parseInt(System.getProperty(ZTSConsts.ZTS_PROP_AWS_RDS_MASTER_PORT, "3306"));
        
        final String rdsEngine = System.getProperty(ZTSConsts.ZTS_PROP_AWS_RDS_ENGINE, "mysql");
        final String rdsDatabase = System.getProperty(ZTSConsts.ZTS_PROP_AWS_RDS_DATABASE, "zts_store");

        final String jdbcStore = String.format("jdbc:%s://%s:%d/%s", rdsEngine, rdsMaster, rdsPort, rdsDatabase);
        String rdsToken = getAuthToken(rdsMaster, rdsPort, rdsUser, rdsIamRole);
        
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Connecting to {} with auth token {}", jdbcStore, rdsToken);
        }

        mysqlConnectionProperties.setProperty(ZTSConsts.DB_PROP_VERIFY_SERVER_CERT,
                System.getProperty(ZTSConsts.ZTS_PROP_CERT_JDBC_VERIFY_SERVER_CERT, "true"));
        mysqlConnectionProperties.setProperty(ZTSConsts.DB_PROP_USE_SSL,
                System.getProperty(ZTSConsts.ZTS_PROP_CERT_JDBC_USE_SSL, "true"));
        mysqlConnectionProperties.setProperty(ZTSConsts.DB_PROP_USER, rdsUser);
        mysqlConnectionProperties.setProperty(ZTSConsts.DB_PROP_PASSWORD, rdsToken);
        
        PoolableDataSource dataSource = DataSourceFactory.create(jdbcStore, mysqlConnectionProperties);
        
        long credsRefreshTime = Integer.parseInt(System.getProperty(ZTSConsts.ZTS_PROP_AWS_RDS_CREDS_REFRESH_TIME, "300"));

        ScheduledExecutorService scheduledThreadPool = Executors.newScheduledThreadPool(1);
        scheduledThreadPool.scheduleAtFixedRate(new CredentialsUpdater(), credsRefreshTime,
                credsRefreshTime, TimeUnit.SECONDS);
        
        return new JDBCCertRecordStore(dataSource);
    }

}