class OAuthBearerSaslServer implements SaslServer {

    @Override
    public byte[] evaluateResponse(byte[] response) throws SaslException, SaslAuthenticationException {
        if (response.length == 1 && response[0] == OAuthBearerSaslClient.BYTE_CONTROL_A && errorMessage != null) {
            if (log.isDebugEnabled())
                log.debug("Received %x01 response from client after it received our error");
            throw new SaslAuthenticationException(errorMessage);
        }
        errorMessage = null;
        String responseMsg = new String(response, StandardCharsets.UTF_8);
        Matcher matcher = CLIENT_INITIAL_RESPONSE_PATTERN.matcher(responseMsg);
        if (!matcher.matches()) {
            if (log.isDebugEnabled())
                log.debug(INVALID_OAUTHBEARER_CLIENT_FIRST_MESSAGE);
            throw new SaslException(INVALID_OAUTHBEARER_CLIENT_FIRST_MESSAGE);
        }
        String authzid = matcher.group("authzid");
        String authorizationId = authzid != null ? authzid : "";
        if (!"bearer".equalsIgnoreCase(matcher.group("scheme"))) {
            String msg = String.format("Invalid scheme in OAUTHBEARER client first message: %s",
                    matcher.group("scheme"));
            if (log.isDebugEnabled())
                log.debug(msg);
            throw new SaslException(msg);
        }
        String tokenValue = matcher.group("token");
        return process(tokenValue, authorizationId);
    }

    public  OAuthBearerSaslServer(CallbackHandler callbackHandler);

}