private void materializeCertificates(ApplicationId appId, String user, String userFolder,
ByteBuffer keyStore, String keyStorePass,
ByteBuffer trustStore, String trustStorePass) throws IOException {
if (context.getApplications().containsKey(appId)) {
LOG.debug("Application reference exists, certificates should have " +
"already been materialized");
return;
}
if (keyStore == null || trustStore == null || (keyStore.capacity() == 0)
|| (trustStore.capacity() == 0)) {
throw new IOException("RPC TLS is enabled but keyStore or trustStore " + "supplied is either null or empty");
}
if (keyStorePass != null && !keyStorePass.isEmpty()
&& trustStorePass != null && !trustStorePass.isEmpty()) {
try {
context.getCertificateLocalizationService().materializeCertificates(user, appId.toString(), userFolder,
keyStore, keyStorePass, trustStore, trustStorePass);
} catch (InterruptedException ex) {
LOG.error(ex, ex);
throw new IOException(ex);
}
}
}