| .. | .. |
|---|
| 8 | 8 | import java.security.NoSuchAlgorithmException; |
|---|
| 9 | 9 | import java.security.cert.CertificateException; |
|---|
| 10 | 10 | import java.security.cert.X509Certificate; |
|---|
| 11 | +import java.util.Map; |
|---|
| 11 | 12 | |
|---|
| 12 | 13 | import net.curisit.securis.beans.RequestBean; |
|---|
| 13 | 14 | import net.curisit.securis.utils.JsonUtils; |
|---|
| .. | .. |
|---|
| 79 | 80 | } |
|---|
| 80 | 81 | |
|---|
| 81 | 82 | public <T> T executePost(String command, Class<T> returnType, RequestBean req) throws SeCurisException { |
|---|
| 83 | + return executePost(command, returnType, req, null); |
|---|
| 84 | + } |
|---|
| 85 | + |
|---|
| 86 | + public <T> T executePost(String command, Class<T> returnType, RequestBean req, Map<String, String> headers) throws SeCurisException { |
|---|
| 82 | 87 | HttpPost postRequest = new HttpPost(String.format("%s/%s", serverUrl, command)); |
|---|
| 83 | 88 | postRequest.addHeader("accept", JSON_MEDIA_TYPE); |
|---|
| 84 | | - |
|---|
| 85 | 89 | postRequest.addHeader("content-type", JSON_MEDIA_TYPE); |
|---|
| 90 | + |
|---|
| 91 | + if (headers != null) { |
|---|
| 92 | + for (String header : headers.keySet()) { |
|---|
| 93 | + String headerValue = headers.get(header); |
|---|
| 94 | + postRequest.addHeader(header, headerValue); |
|---|
| 95 | + } |
|---|
| 96 | + } |
|---|
| 97 | + |
|---|
| 86 | 98 | try { |
|---|
| 87 | 99 | postRequest.setEntity(new StringEntity(JsonUtils.toJSON(req))); |
|---|
| 88 | 100 | } catch (UnsupportedEncodingException | SeCurisException e1) { |
|---|