class VaultSecurityManager implements SecurityManager {

    @Override
    public Object authenticate(Properties properties) throws AuthenticationFailedException {
        String username = properties.getProperty("security-username");
        Assert.hasText(username, "Missing username");
        LOG.info("authenticate: username={}", username);

        String password = properties.getProperty("security-password");
        Assert.hasText(password, "Missing password");
        LOG.trace("authenticate: username={}, password={}", username, password);

        VaultResponse vaultResponse = vaultTemplate.read(readPath + username);

        if (vaultResponse == null) {
            throw new AuthenticationFailedException(username);
        }

        String actualPassword = (String) vaultResponse.getData().get("password");
        LOG.trace("authenticate: username={}, password={}, actualPassword={}", username, password, actualPassword);

        if (!password.equals(actualPassword)) {
            throw new AuthenticationFailedException(username);
        }

        return new UsernamePrincipal(username);
    }

}

class VaultSecurityManagerTest {

    private VaultSecurityManager vaultSecurityManager;
    @Mock
    private VaultTemplate vaultTemplate;

    @Test
    void authenticate_success() {

        String username = "some-user";
        String password = "some-password";

        VaultResponse vaultResponse = mock(VaultResponse.class);
        Map<String, Object> data = new HashMap<>();
        data.put("password", password);
        when(vaultResponse.getData()).thenReturn(data);
        when(vaultTemplate.read(anyString())).thenReturn(vaultResponse);

        Properties props = new Properties();
        props.setProperty("security-username",username);
        props.setProperty("security-password",password);
        vaultSecurityManager.authenticate(props);
    }

}