KeyStore ts = SSLUtil.getInitializedKeyStore(trustStorePath, trustStorePassword, trustStoreType);
final TrustManagerFactory tmf = TrustManagerFactory
.getInstance(trustManagerFactoryAlgorithm);
tmf.init(ts);
final Collection<TrustManager> trustManagersCol = new ArrayList<TrustManager>();
final QpidMultipleTrustManager mulTrustManager = new QpidMultipleTrustManager();
TrustManager[] delegateManagers = tmf.getTrustManagers();
for (TrustManager tm : delegateManagers)
{
if (tm instanceof X509TrustManager)
{
if (_peersOnly)
{
// truststore is supposed to trust only clients which peers certificates
// are directly in the store. CA signing will not be considered.
mulTrustManager.addTrustManager(new QpidPeersOnlyTrustManager(ts, (X509TrustManager) tm));
}
else
{
mulTrustManager.addTrustManager((X509TrustManager) tm);
}
}
else
{
trustManagersCol.add(tm);
}
}
if (! mulTrustManager.isEmpty())
{
trustManagersCol.add(mulTrustManager);
}
if (trustManagersCol.isEmpty())