in client/src/main/java/org/apache/qpid/client/security/DynamicSaslRegistrar.java [69:148]
public static ProviderRegistrationResult registerSaslProviders()
{
_logger.debug("public static void registerSaslProviders(): called");
ProviderRegistrationResult result = ProviderRegistrationResult.FAILED;
// Open the SASL properties file, using the default name is one is not specified.
String filename = System.getProperty(FILE_PROPERTY);
InputStream is =
FileUtils.openFileOrDefaultResource(filename, DEFAULT_RESOURCE_NAME,
DynamicSaslRegistrar.class.getClassLoader());
try
{
Properties props = new Properties();
props.load(is);
_logger.debug("props = " + props);
Map<String, Class<? extends SaslClientFactory>> factories = parseProperties(props);
if (factories.size() > 0)
{
// Ensure we are used before the defaults
JCAProvider qpidProvider = new JCAProvider(factories);
if (Security.insertProviderAt(qpidProvider, 1) == -1)
{
Provider registeredProvider = findProvider(JCAProvider.QPID_CLIENT_SASL_PROVIDER_NAME);
if (registeredProvider == null)
{
result = ProviderRegistrationResult.FAILED;
_logger.error("Unable to load custom SASL providers.");
}
else if (registeredProvider.equals(qpidProvider))
{
result = ProviderRegistrationResult.EQUAL_ALREADY_REGISTERED;
_logger.debug("Custom SASL provider is already registered with equal properties.");
}
else
{
result = ProviderRegistrationResult.DIFFERENT_ALREADY_REGISTERED;
_logger.warn("Custom SASL provider was already registered with different properties.");
if (_logger.isDebugEnabled())
{
_logger.debug("Custom SASL provider " + registeredProvider + " properties: " + new HashMap<Object, Object>(registeredProvider));
}
}
}
else
{
result = ProviderRegistrationResult.SUCCEEDED;
_logger.info("Additional SASL providers successfully registered.");
}
}
else
{
result = ProviderRegistrationResult.NO_SASL_FACTORIES;
_logger.warn("No additional SASL factories found to register.");
}
}
catch (IOException e)
{
result = ProviderRegistrationResult.FAILED;
_logger.error("Error reading properties: " + e, e);
}
finally
{
if (is != null)
{
try
{
is.close();
}
catch (IOException e)
{
_logger.error("Unable to close properties stream: " + e, e);
}
}
}
return result;
}