TaskExecutor executor = CurrentThreadTaskExecutor.newStartedInstance();
when(broker.getObjectFactory()).thenReturn(_factory);
when(broker.getModel()).thenReturn(_factory.getModel());
when(broker.getTaskExecutor()).thenReturn(executor);
final FileKeyStore keyStore =
createKeyStore(attributes, broker);
assertNotNull("Key store configured object is not created", keyStore);
assertEquals(attributes.get(ConfiguredObject.ID), keyStore.getId());
//verify we can retrieve the actual password using the method
Subject.doAs(SecurityManager.getSubjectWithAddedSystemRights(), new PrivilegedAction<Object>()
{
@Override
public Object run()
{
assertNotNull(keyStore.getPassword());
assertEquals(TestSSLConstants.BROKER_TRUSTSTORE_PASSWORD, keyStore.getPassword());
//verify that we haven't configured the key store with the actual dummy password value
assertFalse(AbstractConfiguredObject.SECURED_STRING_VALUE.equals(keyStore.getPassword()));
return null;
}
});
// Verify the remaining attributes, including that the password value returned
// via getAttribute is actually the dummy value and not the real password
attributesCopy.put(FileKeyStore.PASSWORD, AbstractConfiguredObject.SECURED_STRING_VALUE);
for (Map.Entry<String, Object> attribute : attributesCopy.entrySet())
{
Object attributeValue = keyStore.getAttribute(attribute.getKey());
assertEquals("Unexpected value of attribute '" + attribute.getKey() + "'", attribute.getValue(), attributeValue);
}
}