Hi,
While integrating with JIRA using the Java Rest client, I got a socket timeout issue. Based on the discussion on this forum, I tried to create my own Authentication Handler. But I am not sure, what attributes to set in Builder Object. Can you please help us with this?
import org.apache.commons.codec.binary.Base64;
import com.atlassian.httpclient.api.Request.Builder;
import com.atlassian.jira.rest.client.api.AuthenticationHandler;
public class JiraCustomHandler implements AuthenticationHandler {
private final String username;
private final String password;
public JiraCustomHandler(String username, String password) {
this.username = username;
this.password = password;
}
@Override
public void configure(Builder builder) {
builder.setAttribute("PROPERTY_CONNECT_TIMEOUT", "22000");
builder.setHeader("Authorization", "Basic " + encodeCredentials());
}
private String encodeCredentials() {
byte[] credentials = (this.username + ':' + this.password).getBytes();
return new String(Base64.encodeBase64(credentials));
}
}