Java Jira Rest Client Socket Timeout Issue - 5.2.4

Udhayakumar Uthamarajan November 30, 2022

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));
}

}

0 answers

Suggest an answer

Log in or Sign up to answer