@Override
    public boolean verify(final Host host, final PublicKey key) throws BackgroundException {
        if(null == database) {
            log.warn(String.format("Missing database %s", database));
            return super.verify(host, key);
        }
        final KeyType type = KeyType.fromKey(key);
        if(type == KeyType.UNKNOWN) {
            return false;
        }
        boolean foundApplicableHostEntry = false;
        for(OpenSSHKnownHosts.KnownHostEntry entry : database.entries()) {
            try {
                if(entry.appliesTo(type, format(host))) {
                    foundApplicableHostEntry = true;
                    if(entry.verify(key)) {
                        return true;
                    }
                }
            }
            catch(IOException e) {
                log.error(String.format("Failure verifying host key entry %s. %s", entry, e.getMessage()));
                return false;
            }
        }
        if(foundApplicableHostEntry) {
            try {
                return this.isChangedKeyAccepted(host, key);
            }
            catch(ConnectionCanceledException | ChecksumException e) {
                return false;
            }
        }
        try {
            return this.isUnknownKeyAccepted(host, key);
        }
        catch(ConnectionCanceledException | ChecksumException e) {
            return false;
        }
    }
@Test
    public void testReadFailure() throws Exception {
        final AtomicBoolean unknown = new AtomicBoolean();
        final OpenSSHHostKeyVerifier v = new OpenSSHHostKeyVerifier(new Local("/t") {
            @Override
            public InputStream getInputStream() throws AccessDeniedException {
                throw new AccessDeniedException("t");
            }
        }) {
            @Override
            protected boolean isUnknownKeyAccepted(final Host hostname, final PublicKey key) {
                unknown.set(true);
                return true;
            }

            @Override
            protected boolean isChangedKeyAccepted(final Host hostname, final PublicKey key) {
                return false;
            }
        };
        final PublicKey key = SecurityUtils.getKeyFactory("RSA").generatePublic(new RSAPublicKeySpec(new BigInteger("a19f65e93926d9a2f5b52072db2c38c54e6cf0113d31fa92ff827b0f3bec609c45ea84264c88e64adba11ff093ed48ee0ed297757654b0884ab5a7e28b3c463bc9074b32837a2b69b61d914abf1d74ccd92b20fa44db3b31fb208c0dd44edaeb4ab097118e8ee374b6727b89ad6ce43f1b70c5a437ccebc36d2dad8ae973caad15cd89ae840fdae02cae42d241baef8fda8aa6bbaa54fd507a23338da6f06f61b34fb07d560e63fbce4a39c073e28573c2962cedb292b14b80d1b4e67b0465f2be0e38526232d0a7f88ce91a055fde082038a87ed91f3ef5ff971e30ea6cccf70d38498b186621c08f8fdceb8632992b480bf57fc218e91f2ca5936770fe9469", 16),
            new BigInteger("23", 16)));
        assertTrue(v.verify(new Host(new SFTPProtocol(), "h", 22), key));
        assertTrue(unknown.get());
    }