|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.ibm.team.git.build.hjplugin.http.HttpUtils
public class HttpUtils
Collection of methods to handle authentication and providing the response back. For a GET, the caller supplies uri and gets JSON back. For a PUT, the caller supplies uri & any stream data.
| Nested Class Summary | |
|---|---|
static class |
HttpUtils.RtcHttpResult
|
| Constructor Summary | |
|---|---|
HttpUtils()
|
|
| Method Summary | |
|---|---|
static org.apache.http.client.protocol.HttpClientContext |
createHttpContext()
Creates and returns a new HttpContext with a new cookie store, for use with the singleton HTTP_CLIENT. |
static org.apache.http.impl.client.CloseableHttpClient |
getClient()
Because the creation of the SSLConnectionSocketFactory is expensive (reads from disk the certs file) we will cache the client. |
static HttpUtils.RtcHttpResult |
performGet(String serverURI,
String uri,
String userId,
String password,
int timeout,
org.apache.http.client.protocol.HttpClientContext httpContext,
hudson.model.TaskListener listener)
Perform GET request against an RTC server |
static HttpUtils.RtcHttpResult |
performPost(String serverURI,
String uri,
String userId,
String password,
int timeout,
List<org.apache.http.NameValuePair> params,
hudson.model.TaskListener listener,
org.apache.http.client.protocol.HttpClientContext httpContext)
|
static org.apache.http.client.protocol.HttpClientContext |
performPut(String serverURI,
String uri,
String userId,
String password,
int timeout,
net.sf.json.JSONObject json,
org.apache.http.client.protocol.HttpClientContext httpContext,
hudson.model.TaskListener listener)
Perform PUT request against an RTC server |
static void |
validateCredentials(String serverURI,
String userId,
String password,
int timeout,
org.apache.http.client.protocol.HttpClientContext httpContext)
Only used to test connection. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public HttpUtils()
| Method Detail |
|---|
public static HttpUtils.RtcHttpResult performPost(String serverURI,
String uri,
String userId,
String password,
int timeout,
List<org.apache.http.NameValuePair> params,
hudson.model.TaskListener listener,
org.apache.http.client.protocol.HttpClientContext httpContext)
throws IOException,
org.apache.http.auth.InvalidCredentialsException,
GeneralSecurityException
IOException
org.apache.http.auth.InvalidCredentialsException
GeneralSecurityException
public static HttpUtils.RtcHttpResult performGet(String serverURI,
String uri,
String userId,
String password,
int timeout,
org.apache.http.client.protocol.HttpClientContext httpContext,
hudson.model.TaskListener listener)
throws IOException,
org.apache.http.auth.InvalidCredentialsException,
GeneralSecurityException
serverURI - The RTC serveruri - The relative URI for the GET. It is expected it is already
encoded if necessary.userId - The userId to authenticate aspassword - The password to authenticate withtimeout - The timeout period for the connection (in seconds)httpContext - The context from the login if cycle is being managed by the
caller Otherwise null and this call will handle
the login.listener - The listener to report errors to. May be null
IOException - Thrown if things go wrong
org.apache.http.auth.InvalidCredentialsException
GeneralSecurityException
public static org.apache.http.client.protocol.HttpClientContext performPut(String serverURI,
String uri,
String userId,
String password,
int timeout,
net.sf.json.JSONObject json,
org.apache.http.client.protocol.HttpClientContext httpContext,
hudson.model.TaskListener listener)
throws IOException,
org.apache.http.auth.InvalidCredentialsException,
GeneralSecurityException
serverURI - The RTC serveruri - The relative URI for the PUT. It is expected that it is
already encoded if necessary.userId - The userId to authenticate aspassword - The password to authenticate withtimeout - The timeout period for the connection (in seconds)json - The JSON object to put to the RTC serverhttpContext - The context from the login if cycle is being managed by the
caller Otherwise null and this call will handle
the login.listener - The listener to report errors to. May be null if
there is no listener.
IOException - Thrown if things go wrong
org.apache.http.auth.InvalidCredentialsException
GeneralSecurityException
public static void validateCredentials(String serverURI,
String userId,
String password,
int timeout,
org.apache.http.client.protocol.HttpClientContext httpContext)
throws IOException,
GeneralSecurityException,
org.apache.http.auth.InvalidCredentialsException
serverURI - The RTC serveruserId - The userId to authenticate aspassword - The password to authenticate withtimeout - The timeout period for the connection (in seconds)
IOException - Thrown if things go wrong
org.apache.http.auth.InvalidCredentialsException - if authentication fails
GeneralSecurityException
public static org.apache.http.impl.client.CloseableHttpClient getClient()
throws GeneralSecurityException
GeneralSecurityExceptionpublic static org.apache.http.client.protocol.HttpClientContext createHttpContext()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||