public String authenticate(Credentials credentials, HttpMethod method) throws
            AuthenticationException {
        if (credentials == null) {
            throw new IllegalArgumentException("Cred is null.");
        }
        String resp = "";
        NTCredentials cre = null;
        try {
            cre = (NTCredentials) credentials;
        } catch (ClassCastException ex) {
            throw new AuthenticationException("This is not NTLM cred.");
        }
        switch (stage) {
        case DEFAULT: //Type1𑗂
            resp = EncodingUtil.getAsciiString
                   (Base64.encodeBase64(getType1Msg(
                           cre)));
            stage = Stage.TYPE1_SENT;
            break;
        case TYPE1_SENT:
            throw new AuthenticationException("Has not received Type2 msg.");
        case TYPE2_RECV: //Type3
            resp = EncodingUtil.getAsciiString
                   (Base64.encodeBase64(getType3Msg(cre)));
            stage = Stage.TYPE3_SENT;
            break;
        case TYPE3_SENT:
        default:
            throw new AuthenticationException("Authentication finished.");
        }
        return "NTLM " + resp;
    }