public int read(byte[] b) throws IOException {
        int n = source.read(b);

        String msg = convert(b, n);

        if (msg.indexOf("username:") >= 0) {
            String username = System.getProperty("telnet.username");
            if (username != null) {
                this.write(new String(username + "\n").getBytes());
            }
        }
        if (msg.indexOf("password:") >= 0) {
            String password = System.getProperty("telnet.password");
            if (password != null && consumed == false) {
                this.write(new String(password + "\n").getBytes());
                consumed = true;
            }
        }
        return n;
    }