Search in sources :

Example 1 with HttpTransportClient

use of org.stepik.api.client.HttpTransportClient in project intellij-plugins by StepicOrg.

the class StepikAuthManager method initStepikApiClient.

@NotNull
private static synchronized StepikApiClient initStepikApiClient() {
    String osName = System.getProperty("os.name");
    String jre = System.getProperty("java.version");
    String userAgent = String.format("Stepik Union/%s (%s) StepikApiClient/%s %s/%s JRE/%s", getVersion(), osName, StepikApiClient.getVersion(), getCurrentProduct(), getCurrentProductVersion(), jre);
    logger.info(userAgent);
    HttpConfigurable instance = HttpConfigurable.getInstance();
    StepikApiClient client;
    if (instance.USE_HTTP_PROXY) {
        logger.info(String.format("Uses proxy: Host = %s, Port = %s", instance.PROXY_HOST, instance.PROXY_PORT));
        HttpTransportClient transportClient;
        transportClient = HttpTransportClient.getInstance(instance.PROXY_HOST, instance.PROXY_PORT, userAgent);
        client = new StepikApiClient(transportClient);
    } else {
        client = new StepikApiClient(userAgent);
    }
    long lastUserId = getLastUser();
    TokenInfo tokenInfo = getTokenInfo(lastUserId, client);
    client.setTokenInfo(tokenInfo);
    return client;
}
Also used : StepikApiClient(org.stepik.api.client.StepikApiClient) HttpConfigurable(com.intellij.util.net.HttpConfigurable) HttpTransportClient(org.stepik.api.client.HttpTransportClient) TokenInfo(org.stepik.api.objects.auth.TokenInfo) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

HttpConfigurable (com.intellij.util.net.HttpConfigurable)1 NotNull (org.jetbrains.annotations.NotNull)1 HttpTransportClient (org.stepik.api.client.HttpTransportClient)1 StepikApiClient (org.stepik.api.client.StepikApiClient)1 TokenInfo (org.stepik.api.objects.auth.TokenInfo)1