if (myRealm == null) { myRealm = (String) creds[0]; }
    public void authenticate(SVNRepositoryImpl repository, ISVNCredentials credentials) throws SVNException {        String failureReason = null;        Object[] items = read("[((*W)?S)]", null);        List mechs = SVNReader.getList(items, 0);        if (mechs == null || mechs.size() == 0) {            return;        }        for (int i = 0; i < mechs.size(); i++) {            String mech = (String) mechs.get(i);            if ("EXTERNAL".equals(mech)) {                write("(w(s))", new Object[] { mech, credentials.getName()});                failureReason = readAuthResponse(repository);                if (failureReason == null) {                    return;                }            } else if ("ANONYMOUS".equals(mech)) {                 write("(w())", new Object[] { mech });                failureReason = readAuthResponse(repository);                if (failureReason == null) {                    return;                }            } else if ("CRAM-MD5".equals(mech)) {                CramMD5 authenticator = new CramMD5();                if (credentials == null) {                    throw new SVNAuthenticationException("authentication failed, no credentials");                }                write("(w())", new Object[] { mech });                while (true) {                    authenticator.setUserCredentials(credentials);                    items = read("(W(?B))", null);                    if (SUCCESS.equals(items[0])) {                        // should it be here?                        if (!myIsCredentialsReceived) {                            Object[] creds = read("[(S?S)]", null);                            if (creds != null && creds.length == 2 && creds[0] != null && creds[1] != null) {                                repository.updateCredentials((String) creds[0], (String) creds[1]);                            }                            myIsCredentialsReceived = true;                        }                        return;                    } else if (FAILURE.equals(items[0])) {                        failureReason = new String((byte[]) items[1]);                        throw new SVNAuthenticationException("authentication failed: " + failureReason);                    } else if (STEP.equals(items[0])) {                        byte[] response = authenticator.buildChallengeReponse((byte[]) items[1]);                        try {                            getOutputStream().write(response);                        } catch (IOException e) {                            throw new SVNException(e);                        } finally {		                        getOutputStream().log();                        }                    }                }            } else {                failureReason = mech + " authorization requested, but not supported";            }        }        throw new SVNException(failureReason);    }