when(broker.getObjectFactory()).thenReturn(factory);
when(broker.getModel()).thenReturn(factory.getModel());
TaskExecutor executor = new CurrentThreadTaskExecutor();
when(broker.getTaskExecutor()).thenReturn(executor);
final FileTrustStore trustStore = new FileTrustStoreImpl(attributes, broker);
trustStore.open();
assertNotNull("Trust store configured object is not created", trustStore);
assertEquals(id, trustStore.getId());
Subject.doAs(SecurityManager.getSubjectWithAddedSystemRights(), new PrivilegedAction<Object>()
{
@Override
public Object run()
{
//verify we can retrieve the actual password using the method
assertEquals(TestSSLConstants.BROKER_TRUSTSTORE_PASSWORD, trustStore.getPassword());
assertNotNull(trustStore.getPassword());
//verify that we haven't configured the trust store with the actual dummy password value
assertFalse(AbstractConfiguredObject.SECURED_STRING_VALUE.equals(trustStore.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(FileTrustStore.PASSWORD, AbstractConfiguredObject.SECURED_STRING_VALUE);
for (Map.Entry<String, Object> attribute : attributesCopy.entrySet())
{
Object attributeValue = trustStore.getAttribute(attribute.getKey());
assertEquals("Unexpected value of attribute '" + attribute.getKey() + "'", attribute.getValue(), attributeValue);
}
}