class AuthenticationServiceV1 {

    protected String getLocalizedMessage(Request request, Exception exception) {
        AcceptLanguageHeader languages = null;
        try {
            languages = request.getHeaders().get(AcceptLanguageHeader.class);
        } catch (MalformedHeaderException e) {
            DEBUG.warning("Could not parse accept language header", e);
        }
        String message = null;
        L10NMessage localizedException = null;
        if (exception instanceof L10NMessage) {
            localizedException = (L10NMessage) exception;
        } else if (exception.getCause() instanceof L10NMessage) {
            localizedException = (L10NMessage) exception.getCause();
        }
        if (localizedException != null) {
            if (languages == null) {
                message = localizeMessage(localizedException, Locale.getDefaultLocale());
            } else {
                for (java.util.Locale language : languages.getLocales().getLocales()) {
                    message = localizeMessage(localizedException, language);
                    if (message != null) {
                        break;
                    }
                }
            }
        }
        if (message == null) {
            message = exception.getMessage();
        }
        return message;
    }

    @Inject public  AuthenticationServiceV1(RestAuthenticationHandler restAuthenticationHandler);

}