package com.alienvault.otx.connect.internal;

import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.client.ClientHttpRequest;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;

import java.io.IOException;
import java.net.URI;

/**
 * Internal utility class to set the authorization header used for the OTX API
 * authentication.
 */
public class HeaderSettingRequestFactory extends SimpleClientHttpRequestFactory {
    private static final String SDK_USER_AGENT = "OTX Java SDK/1.0/"+System.getProperty("java.version");
    private String apiKey;

    public HeaderSettingRequestFactory(String apiKey) {
        this.apiKey = apiKey;
    }

    @Override
    public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IOException {
        ClientHttpRequest request = super.createRequest(uri, httpMethod);
        request.getHeaders().add("X-OTX-API-KEY",apiKey);
        request.getHeaders().add(HttpHeaders.USER_AGENT,SDK_USER_AGENT);
        return request;
    }
}

@@ -614,28 +614,171 @@
 T = 
-%22OTX Java SDK/1.0/%22+
+String.format(%22%25s/%25s/%25s%22,%0A            System.getProperty(%22otx.sdk.project%22, %22OTX Java SDK%22),%0A            System.getProperty(%22otx.sdk.version%22, %221.0%22),%0A            
 Syst
@@ -807,16 +807,17 @@
 ersion%22)
+)
 ;%0A    pr

Add system properties to allow override of SDK User Agent