Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add api key support to rally interface #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/main/java/com/rallydev/lookback/LookbackApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class LookbackApi {
protected String proxyUserName;
protected String proxyPassword;
protected HttpClient client;
protected String apikey;


/**
Expand Down Expand Up @@ -170,6 +171,14 @@ public LookbackApi setServer(String server) {
return this;
}

/**
* Set the API key to be used for authentication. If used, do not set username and password.
* @param key - The api key generated by Rally.
*/
public void setApiKey(String key) {
this.apikey = key;
}

/**
* Set the proxy server you wish to communicate through.
* @param server - The proxy server you wish to use, must include the protocol (e.g. http://myproxy:8080 )
Expand Down Expand Up @@ -248,6 +257,9 @@ private LookbackResult buildLookbackResult(HttpResponse response) throws IOExcep

private HttpUriRequest createRequest(String requestJson) throws IOException {
HttpPost post = new HttpPost(buildUrl());
if (this.apikey != null) {
post.setHeader("zsessionid", this.apikey);
}
post.setEntity(new StringEntity(requestJson, "UTF-8"));
return post;
}
Expand Down