Skip to content

Commit

Permalink
version 4.2.2
Browse files Browse the repository at this point in the history
Added gzip Accept-Encoding HTTPS header in requests sent to an LoginRadius server
  • Loading branch information
Agarwal-Sudhanshu committed Mar 26, 2019
1 parent 2bcf57b commit 74ed6ec
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 19 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
> **LoginRadius Java SDK Change Log** provides information regarding what has changed, more specifically what changes, improvements and bug fix has been made to the SDK. For more details please refer to the [LoginRadius API Documention(https://github.com/LoginRadius/java-sdk)
### Version 4.2.2
Released on **March 26, 2019**
##### Enhancements

- Added gzip Accept-Encoding HTTPS header in requests sent to an LoginRadius server

### Version 4.2.1
Released on **November 23, 2018**
##### Enhancements
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Use the following dependency in your project:
<dependency>
<groupId>com.loginradius.sdk</groupId>
<artifactId>java-sdk</artifactId>
<version>4.2.1</version>
<version>4.2.2</version>
</dependency>
```
Expand All @@ -37,7 +37,7 @@ the latest version and download the jar files.

## Documentation

[Getting Started](https://docs.loginradius.com/api/v2/sdk-libraries/java-library) - Everything you need to begin using this SDK.
[Getting Started](https://www.loginradius.com/docs/api/v2/deployment/sdk-libraries/java-library) - Everything you need to begin using this SDK.



Expand Down
2 changes: 1 addition & 1 deletion demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<dependency>
<groupId>com.loginradius.sdk</groupId>
<artifactId>java-sdk</artifactId>
<version>4.2.1</version>
<version>4.2.2</version>
</dependency>
</dependencies>

Expand Down
2 changes: 1 addition & 1 deletion sdk/LoginRadius-JavaSDK/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.loginradius.sdk</groupId>
<artifactId>java-sdk</artifactId>
<version>4.2.1</version>
<version>4.2.2</version>
<description>LoginRadius Java SDK</description>
<url>https://github.com/LoginRadius/java-sdk</url>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
import java.util.zip.GZIPInputStream;

import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;

Expand Down Expand Up @@ -68,7 +70,7 @@ public RestResponse get(String serviceUrl, Map<String, String> params) {
con.setReadTimeout(150000);
con.setRequestProperty("Content-Type", "application/json");
con.setRequestProperty("charset", "utf-8");

con.setRequestProperty("Accept-Encoding", "gzip");
if (authorization != "") {
con.setRequestProperty("Authorization", "Bearer " + authorization);
}
Expand All @@ -81,9 +83,18 @@ public RestResponse get(String serviceUrl, Map<String, String> params) {
con.setRequestProperty("X-LoginRadius-ApiSecret", apiSecret);
}
con.setDoOutput(true);

BufferedReader br = new BufferedReader(new InputStreamReader(
con.getResponseCode() / 100 == 2 ? con.getInputStream() : con.getErrorStream()));

BufferedReader br;
if ("gzip".equals(con.getContentEncoding())) {
br = new BufferedReader(new InputStreamReader(
con.getResponseCode() / 100 == 2 ? new GZIPInputStream(con.getInputStream()) : con.getErrorStream()));

}
else {
br = new BufferedReader(new InputStreamReader(
con.getResponseCode() / 100 == 2 ? con.getInputStream() : con.getErrorStream()));

}
String output;
while ((output = br.readLine()) != null) {
response.setResponse(output);
Expand Down Expand Up @@ -119,7 +130,7 @@ public RestResponse post(String serviceUrl, Map<String, String> getParams, Strin
sott = getParams.get("sott");
getParams.remove("sott");
}
if (getParams.containsKey("access_token")) {
if (getParams.containsKey("access_token") && serviceUrl.contains("/auth")) {
authorization = getParams.get("access_token");
getParams.remove("access_token");

Expand All @@ -139,7 +150,7 @@ public RestResponse post(String serviceUrl, Map<String, String> getParams, Strin
con.setReadTimeout(150000);
con.setRequestProperty("Content-Type", "application/json");
con.setRequestProperty("charset", "utf-8");

con.setRequestProperty("Accept-Encoding", "gzip");
if (sott != "") {
con.setRequestProperty("X-LoginRadius-Sott", sott);
}
Expand Down Expand Up @@ -168,8 +179,17 @@ public RestResponse post(String serviceUrl, Map<String, String> getParams, Strin
body.flush();
body.close();

BufferedReader br = new BufferedReader(new InputStreamReader(
con.getResponseCode() / 100 == 2 ? con.getInputStream() : con.getErrorStream()));
BufferedReader br;
if ("gzip".equals(con.getContentEncoding())) {
br = new BufferedReader(new InputStreamReader(
con.getResponseCode() / 100 == 2 ? new GZIPInputStream(con.getInputStream()) : con.getErrorStream()));

}
else {
br = new BufferedReader(new InputStreamReader(
con.getResponseCode() / 100 == 2 ? con.getInputStream() : con.getErrorStream()));

}
String output;
while ((output = br.readLine()) != null) {
response.setResponse(output);
Expand Down Expand Up @@ -202,7 +222,7 @@ public RestResponse post(String serviceUrl, Map<String, String> getParams, Strin

public RestResponse put(String serviceUrl, Map<String, String> getParams, String payload) {

if (getParams.containsKey("access_token")) {
if (getParams.containsKey("access_token") && serviceUrl.contains("/auth")) {
authorization = getParams.get("access_token");
getParams.remove("access_token");
}
Expand All @@ -221,6 +241,7 @@ public RestResponse put(String serviceUrl, Map<String, String> getParams, String
con.setReadTimeout(150000);
con.setRequestProperty("Content-Type", "application/json");
con.setRequestProperty("charset", "utf-8");
con.setRequestProperty("Accept-Encoding", "gzip");
con.setDoOutput(true);
if (authorization != "") {
con.setRequestProperty("Authorization", "Bearer " + authorization);
Expand All @@ -244,8 +265,17 @@ public RestResponse put(String serviceUrl, Map<String, String> getParams, String
body.flush();
body.close();

BufferedReader br = new BufferedReader(new InputStreamReader(
con.getResponseCode() / 100 == 2 ? con.getInputStream() : con.getErrorStream()));
BufferedReader br;
if ("gzip".equals(con.getContentEncoding())) {
br = new BufferedReader(new InputStreamReader(
con.getResponseCode() / 100 == 2 ? new GZIPInputStream(con.getInputStream()) : con.getErrorStream()));

}
else {
br = new BufferedReader(new InputStreamReader(
con.getResponseCode() / 100 == 2 ? con.getInputStream() : con.getErrorStream()));

}
String output;
while ((output = br.readLine()) != null) {
response.setResponse(output);
Expand Down Expand Up @@ -279,7 +309,7 @@ public RestResponse put(String serviceUrl, Map<String, String> getParams, String

public RestResponse delete(String serviceUrl, Map<String, String> getParams, String payload) {

if (getParams.containsKey("access_token")) {
if (getParams.containsKey("access_token") && serviceUrl.contains("/auth")) {
authorization = getParams.get("access_token");
getParams.remove("access_token");
}
Expand All @@ -298,6 +328,7 @@ public RestResponse delete(String serviceUrl, Map<String, String> getParams, Str
con.setReadTimeout(150000);
con.setRequestProperty("Content-Type", "application/json");
con.setRequestProperty("charset", "utf-8");
con.setRequestProperty("Accept-Encoding", "gzip");
con.setDoOutput(true);
if (authorization != "") {
con.setRequestProperty("Authorization", "Bearer " + authorization);
Expand All @@ -321,9 +352,18 @@ public RestResponse delete(String serviceUrl, Map<String, String> getParams, Str
body.write(payload);
body.flush();
body.close();

BufferedReader br = new BufferedReader(new InputStreamReader(
con.getResponseCode() / 100 == 2 ? con.getInputStream() : con.getErrorStream()));

BufferedReader br;
if ("gzip".equals(con.getContentEncoding())) {
br = new BufferedReader(new InputStreamReader(
con.getResponseCode() / 100 == 2 ? new GZIPInputStream(con.getInputStream()) : con.getErrorStream()));

}
else {
br = new BufferedReader(new InputStreamReader(
con.getResponseCode() / 100 == 2 ? con.getInputStream() : con.getErrorStream()));

}
String output;
while ((output = br.readLine()) != null) {
response.setResponse(output);
Expand Down

0 comments on commit 74ed6ec

Please sign in to comment.