|
static boolean | isValid (HttpServletRequest request) |
|
- Author
- Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g
Definition at line 41 of file ElephantPost.java.
◆ ElephantPost()
org.turro.http.ElephantPost.ElephantPost |
( |
String |
serverUrl | ) |
|
Definition at line 46 of file ElephantPost.java.
47 this.serverUrl = serverUrl;
48 parameters =
new HashMap<>();
◆ addParameter()
void org.turro.http.ElephantPost.addParameter |
( |
String |
name, |
|
|
String |
value |
|
) |
| |
◆ doPost()
Definition at line 55 of file ElephantPost.java.
56 if(serverUrl ==
null || parameters.isEmpty()) {
59 List<NameValuePair> nvps =
new ArrayList<>();
60 for(String key : parameters.keySet()) {
61 String value = parameters.get(key);
62 if(!Strings.isBlank(value)) {
63 nvps.add(
new BasicNameValuePair(key, value));
66 nvps.add(
new BasicNameValuePair(
"skey", Secrets.getSecret(
"key=post")));
67 HttpPost httpPost =
new HttpPost(serverUrl);
68 httpPost.setEntity(
new UrlEncodedFormEntity(nvps));
69 try (CloseableHttpClient closeableClient = (CloseableHttpClient) HttpClients.createDefault()) {
70 try (CloseableHttpResponse closeableResponse = (CloseableHttpResponse) closeableClient.execute(httpPost)) {
71 HttpEntity resEntity = closeableResponse.getEntity();
72 return ElephantResponse.getResponse(resEntity);
◆ isValid()
static boolean org.turro.http.ElephantPost.isValid |
( |
HttpServletRequest |
request | ) |
|
|
static |
Definition at line 77 of file ElephantPost.java.
78 return Secrets.getSecret(
"key=post").equals(request.getParameter(
"skey"));
The documentation for this class was generated from the following file: