<commit_before>package org.entitypedia.games.common.client;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import oauth.signpost.OAuthConsumer;
import oauth.signpost.basic.DefaultOAuthConsumer;
import oauth.signpost.exception.OAuthCommunicationException;
import oauth.signpost.exception.OAuthExpectationFailedException;
import oauth.signpost.exception.OAuthMessageSignerException;
import org.entitypedia.games.common.exceptions.ExceptionDetails;
import org.entitypedia.games.common.exceptions.WordGameException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.*;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Date;

/**
 * @author <a rel="author" href="http://autayeu.com/"><NAME></a>
 */
public abstract class WordGameClient implements IWordGameClient {

    private static final Logger log = LoggerFactory.getLogger(WordGameClient.class);

    protected final static String CHARSET = "UTF-8";
    protected static final TypeReference<Long> LONG_TYPE_REFERENCE = new TypeReference<Long>() {
    };
    protected static final TypeReference<Date> DATE_TYPE_REFERENCE = new TypeReference<Date>() {
    };
    protected static final TypeReference<Boolean> BOOLEAN_TYPE_REFERENCE = new TypeReference<Boolean>() {
    };
    protected static final TypeReference<Double> DOUBLE_TYPE_REFERENCE = new TypeReference<Double>() {
    };

    protected String apiEndpoint = "http://localhost:9080/<game>/webapi/";

    protected final OAuthConsumer consumer;
    protected final ObjectMapper mapper = new ObjectMapper();

    protected boolean signConnection = true;

    public WordGameClient(String apiEndpoint, String uid, String password) {
        this.apiEndpoint = apiEndpoint;
        consumer = new DefaultOAuthConsumer(uid, password);
        mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);<commit_msg>3-legged OAuth support in game client<commit_after>package org.entitypedia.games.common.client;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import oauth.signpost.OAuthConsumer;
import oauth.signpost.basic.DefaultOAuthConsumer;
import oauth.signpost.exception.OAuthCommunicationException;
import oauth.signpost.exception.OAuthExpectationFailedException;
import oauth.signpost.exception.OAuthMessageSignerException;
import org.entitypedia.games.common.exceptions.ExceptionDetails;
import org.entitypedia.games.common.exceptions.WordGameException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.*;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Date;

/**
 * @author <a rel="author" href="http://autayeu.com/"><NAME></a>
 */
public abstract class WordGameClient implements IWordGameClient {

    private static final Logger log = LoggerFactory.getLogger(WordGameClient.class);

    protected final static String CHARSET = "UTF-8";
    protected static final TypeReference<Long> LONG_TYPE_REFERENCE = new TypeReference<Long>() {
    };
    protected static final TypeReference<Date> DATE_TYPE_REFERENCE = new TypeReference<Date>() {
    };
    protected static final TypeReference<Boolean> BOOLEAN_TYPE_REFERENCE = new TypeReference<Boolean>() {
    };
    protected static final TypeReference<Double> DOUBLE_TYPE_REFERENCE = new TypeReference<Double>() {
    };

    protected String apiEndpoint = "http://localhost:9080/<game>/webapi/";

    protected final OAuthConsumer consumer;
    protected final ObjectMapper mapper = new ObjectMapper();

    protected boolean signConnection = true;

    public WordGameClient(String apiEndpoint, String uid, String password) {
        this.apiEndpoint = apiEndpoint;
        consumer = new DefaultOAuthConsumer(uid, password);
        mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    }

    public WordGameClient(String apiEndpoint, String uid, String password, String token, String tokenSecret) {
        this.apiEndpoint = apiEndpoint;
        consumer = new DefaultOAuthConsumer(uid, password);
        consumer.setTokenWithSecret(token, tokenSecret);
        mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
{'fraction_non_alphanumeric': 0.09382397245534754, 'fraction_numerical': 0.0032278889606197547, 'mean_word_length': 5.4110344827586205, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7151702', 'n_tokens_mistral': 1316, 'n_tokens_neox': 1266, 'n_words': 272}