Skip to content

Commit 7443cfb

Browse files
committed
Released Version 11.1.0
1 parent d7713b7 commit 7443cfb

File tree

11 files changed

+570
-34
lines changed

11 files changed

+570
-34
lines changed

CHANGELOG.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
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://www.loginradius.com/docs/api/v2/deployment/sdk-libraries/java-library/)
22
3+
# Version 11.1.0
4+
Release on April 21, 2021
5+
6+
## Enhancements
7+
8+
- Added Proxy Server Feature.
9+
10+
## Added new multiple APIs for better user experience
11+
12+
- Get Profile By Ping.
13+
- Passwordless Login Verification By Email And OTP.
14+
- Passwordless Login Verification By User Name And OTP.
15+
316
# Version 11.0.1
417
Release on March 17, 2021
518

@@ -10,7 +23,7 @@ Release on March 17, 2021
1023

1124

1225
# Version 11.0.0
13-
Released on **Aug 21, 2020**
26+
Release on July 28, 2020
1427

1528
## Enhancements
1629

LoginRadius-JavaSDK/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.loginradius.sdk</groupId>
88
<artifactId>java-sdk</artifactId>
9-
<version>11.0.1</version>
9+
<version>11.1.0</version>
1010
<description>LoginRadius java SDK contains registration and social APIs</description>
1111
<url>https://github.com/LoginRadius/java-sdk</url>
1212

LoginRadius-JavaSDK/src/main/java/com/loginradius/sdk/api/authentication/AuthenticationApi.java

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import com.loginradius.sdk.util.LoginRadiusSDK;
4646

4747

48+
4849
public class AuthenticationApi {
4950
private static Gson gson =new Gson();
5051

@@ -654,6 +655,63 @@ public void onFailure(ErrorResponse errorResponse) {
654655
});
655656
}
656657

658+
// <summary>
659+
//
660+
// </summary>
661+
// <param name="clientGuid"></param>
662+
// <param name="emailTemplate"></param>
663+
// <param name="fields"></param>
664+
// <param name="verificationUrl"></param>
665+
// <param name="welcomeEmailTemplate"></param>
666+
// <returns>Response containing User Profile Data and access token</returns>
667+
// 5.16
668+
669+
670+
public void getProfileByPing(String clientGuid, String emailTemplate,
671+
String fields, String verificationUrl, String welcomeEmailTemplate, final AsyncHandler<AccessToken<Identity>> handler) {
672+
673+
if (LoginRadiusValidator.isNullOrWhiteSpace(clientGuid)) {
674+
throw new IllegalArgumentException(LoginRadiusValidator.getValidationMessage("clientGuid"));
675+
}
676+
677+
Map<String, String> queryParameters = new HashMap<String, String>();
678+
queryParameters.put("apiKey", LoginRadiusSDK.getApiKey());
679+
queryParameters.put("clientGuid", clientGuid);
680+
681+
if (!LoginRadiusValidator.isNullOrWhiteSpace(emailTemplate)) {
682+
queryParameters.put("emailTemplate", emailTemplate);
683+
}
684+
685+
if (!LoginRadiusValidator.isNullOrWhiteSpace(fields)) {
686+
queryParameters.put("fields", fields);
687+
}
688+
689+
if (!LoginRadiusValidator.isNullOrWhiteSpace(verificationUrl)) {
690+
queryParameters.put("verificationUrl", verificationUrl);
691+
}
692+
693+
if (!LoginRadiusValidator.isNullOrWhiteSpace(welcomeEmailTemplate)) {
694+
queryParameters.put("welcomeEmailTemplate", welcomeEmailTemplate);
695+
}
696+
697+
String resourcePath = "identity/v2/auth/account/ping";
698+
699+
LoginRadiusRequest.execute("GET", resourcePath, queryParameters, null, new AsyncHandler<String>() {
700+
701+
@Override
702+
public void onSuccess(String response) {
703+
TypeToken<AccessToken<Identity>> typeToken = new TypeToken<AccessToken<Identity>>() {};
704+
AccessToken<Identity> successResponse = JsonDeserializer.deserializeJson(response,typeToken);
705+
handler.onSuccess(successResponse);
706+
}
707+
708+
@Override
709+
public void onFailure(ErrorResponse errorResponse) {
710+
handler.onFailure(errorResponse);
711+
}
712+
});
713+
}
714+
657715
// <summary>
658716
// This API is used to check the email exists or not on your site.
659717
// </summary>

LoginRadius-JavaSDK/src/main/java/com/loginradius/sdk/api/authentication/PasswordLessLoginApi.java

Lines changed: 91 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,19 @@
66

77
package com.loginradius.sdk.api.authentication;
88

9-
import java.util.HashMap;
10-
import java.util.Map;
11-
9+
import com.loginradius.sdk.helper.*;
10+
import com.loginradius.sdk.util.*;
1211
import com.google.gson.Gson;
12+
import java.util.Iterator;
13+
import com.google.gson.JsonObject;
1314
import com.google.gson.reflect.TypeToken;
14-
import com.loginradius.sdk.helper.JsonDeserializer;
15-
import com.loginradius.sdk.helper.LoginRadiusRequest;
16-
import com.loginradius.sdk.helper.LoginRadiusValidator;
17-
import com.loginradius.sdk.models.requestmodels.PasswordLessLoginOtpModel;
18-
import com.loginradius.sdk.models.responsemodels.AccessToken;
19-
import com.loginradius.sdk.models.responsemodels.SMSResponseData;
20-
import com.loginradius.sdk.models.responsemodels.otherobjects.GetResponse;
21-
import com.loginradius.sdk.models.responsemodels.otherobjects.PostResponse;
22-
import com.loginradius.sdk.models.responsemodels.userprofile.Identity;
23-
import com.loginradius.sdk.util.AsyncHandler;
24-
import com.loginradius.sdk.util.ErrorResponse;
25-
import com.loginradius.sdk.util.LoginRadiusSDK;
15+
import java.util.HashMap;
16+
import java.util.Map.Entry;
17+
import java.util.Map;
18+
import com.loginradius.sdk.models.responsemodels.*;
19+
import com.loginradius.sdk.models.responsemodels.userprofile.*;
20+
import com.loginradius.sdk.models.requestmodels.*;
21+
import com.loginradius.sdk.models.responsemodels.otherobjects.*;
2622

2723

2824
public class PasswordLessLoginApi {
@@ -263,4 +259,84 @@ public void onFailure(ErrorResponse errorResponse) {
263259
}
264260
});
265261
}
262+
263+
// <summary>
264+
//
265+
// </summary>
266+
// <param name="passwordLessLoginByEmailAndOtpModel"></param>
267+
// <param name="fields"></param>
268+
// <returns>Response containing User Profile Data and access token</returns>
269+
// 9.23
270+
271+
272+
public void passwordlessLoginVerificationByEmailAndOTP(PasswordLessLoginByEmailAndOtpModel passwordLessLoginByEmailAndOtpModel, String fields, final AsyncHandler<AccessToken<Identity>> handler) {
273+
274+
if (passwordLessLoginByEmailAndOtpModel == null) {
275+
throw new IllegalArgumentException(LoginRadiusValidator.getValidationMessage("passwordLessLoginByEmailAndOtpModel"));
276+
}
277+
278+
Map<String, String> queryParameters = new HashMap<String, String>();
279+
queryParameters.put("apiKey", LoginRadiusSDK.getApiKey());
280+
281+
if (!LoginRadiusValidator.isNullOrWhiteSpace(fields)) {
282+
queryParameters.put("fields", fields);
283+
}
284+
285+
String resourcePath = "identity/v2/auth/login/passwordlesslogin/email/verifyotp";
286+
287+
LoginRadiusRequest.execute("POST", resourcePath, queryParameters, gson.toJson(passwordLessLoginByEmailAndOtpModel), new AsyncHandler<String>() {
288+
289+
@Override
290+
public void onSuccess(String response) {
291+
TypeToken<AccessToken<Identity>> typeToken = new TypeToken<AccessToken<Identity>>() {};
292+
AccessToken<Identity> successResponse = JsonDeserializer.deserializeJson(response,typeToken);
293+
handler.onSuccess(successResponse);
294+
}
295+
296+
@Override
297+
public void onFailure(ErrorResponse errorResponse) {
298+
handler.onFailure(errorResponse);
299+
}
300+
});
301+
}
302+
303+
// <summary>
304+
//
305+
// </summary>
306+
// <param name="passwordLessLoginByUserNameAndOtpModel"></param>
307+
// <param name="fields"></param>
308+
// <returns>Response containing User Profile Data and access token</returns>
309+
// 9.24
310+
311+
312+
public void passwordlessLoginVerificationByUserNameAndOTP(PasswordLessLoginByUserNameAndOtpModel passwordLessLoginByUserNameAndOtpModel, String fields, final AsyncHandler<AccessToken<Identity>> handler) {
313+
314+
if (passwordLessLoginByUserNameAndOtpModel == null) {
315+
throw new IllegalArgumentException(LoginRadiusValidator.getValidationMessage("passwordLessLoginByUserNameAndOtpModel"));
316+
}
317+
318+
Map<String, String> queryParameters = new HashMap<String, String>();
319+
queryParameters.put("apiKey", LoginRadiusSDK.getApiKey());
320+
321+
if (!LoginRadiusValidator.isNullOrWhiteSpace(fields)) {
322+
queryParameters.put("fields", fields);
323+
}
324+
325+
String resourcePath = "identity/v2/auth/login/passwordlesslogin/username/verifyotp";
326+
327+
LoginRadiusRequest.execute("POST", resourcePath, queryParameters, gson.toJson(passwordLessLoginByUserNameAndOtpModel), new AsyncHandler<String>() {
328+
329+
@Override
330+
public void onSuccess(String response) {
331+
TypeToken<AccessToken<Identity>> typeToken = new TypeToken<AccessToken<Identity>>() {};
332+
AccessToken<Identity> successResponse = JsonDeserializer.deserializeJson(response,typeToken);
333+
handler.onSuccess(successResponse);
334+
}
335+
336+
@Override
337+
public void onFailure(ErrorResponse errorResponse) {
338+
handler.onFailure(errorResponse);
339+
}
340+
});
341+
}
266342
}

LoginRadius-JavaSDK/src/main/java/com/loginradius/sdk/helper/LoginRadiusRequest.java

Lines changed: 75 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
package com.loginradius.sdk.helper;
23

34
import java.io.BufferedReader;
@@ -22,6 +23,10 @@
2223
import java.util.Map;
2324
import java.util.TimeZone;
2425
import java.util.zip.GZIPInputStream;
26+
import java.net.Proxy;
27+
import java.net.Authenticator;
28+
import java.net.InetSocketAddress;
29+
import java.net.PasswordAuthentication;
2530

2631
import javax.crypto.Mac;
2732
import javax.crypto.spec.SecretKeySpec;
@@ -82,10 +87,41 @@ public static void execute(String method, String resourcePath, Map<String, Strin
8287
private static String LoginRadiusRequestRunner(String method, String url, String payload) {
8388

8489
try {
85-
HttpURLConnection con = (HttpURLConnection) new URL(url).openConnection();
86-
con.setRequestMethod(method);
87-
con.setConnectTimeout(15000); // set timeout to 15 seconds
88-
con.setReadTimeout(15000);
90+
Proxy proxy=null;
91+
92+
if(!LoginRadiusValidator.isNullOrWhiteSpace(LoginRadiusSDK.getProxyHost()) && !LoginRadiusValidator.isNullOrWhiteSpace(LoginRadiusSDK.getProxyPort()) && !LoginRadiusValidator.isNullOrWhiteSpace(LoginRadiusSDK.getProxyUserName()) && !LoginRadiusValidator.isNullOrWhiteSpace(LoginRadiusSDK.getProxyPassword())) {
93+
94+
proxy=setProxy(LoginRadiusSDK.getProxyHost(), Integer.parseInt(LoginRadiusSDK.getProxyPort()), LoginRadiusSDK.getProxyUserName(), LoginRadiusSDK.getProxyPassword());
95+
96+
} else if(!LoginRadiusValidator.isNullOrWhiteSpace(LoginRadiusSDK.getProxyHost()) && !LoginRadiusValidator.isNullOrWhiteSpace(LoginRadiusSDK.getProxyPort())) {
97+
98+
proxy=setProxyWithoutAuthentication(LoginRadiusSDK.getProxyHost(),Integer.parseInt(LoginRadiusSDK.getProxyPort()));
99+
100+
}
101+
102+
URL connectionUrl = new URL(url);
103+
HttpURLConnection con = null;
104+
105+
if (proxy != null) {
106+
con = (HttpURLConnection) connectionUrl.openConnection(proxy);
107+
}else {
108+
con = (HttpURLConnection) connectionUrl.openConnection();
109+
}
110+
con.setRequestMethod(method);
111+
112+
if(LoginRadiusSDK.getConnectionTimeout() != null && LoginRadiusSDK.getReadTimeout() != null) {
113+
con.setConnectTimeout(LoginRadiusSDK.getConnectionTimeout());
114+
con.setReadTimeout(LoginRadiusSDK.getReadTimeout());
115+
}else if(LoginRadiusSDK.getConnectionTimeout() != null ) {
116+
con.setConnectTimeout(LoginRadiusSDK.getConnectionTimeout());
117+
con.setReadTimeout(15000);
118+
}else {
119+
con.setConnectTimeout(15000); // set timeout to 15 seconds
120+
con.setReadTimeout(15000);
121+
}
122+
123+
124+
89125
con.setRequestProperty("Content-Type", "application/json");
90126
con.setRequestProperty("charset", encoding);
91127
con.setRequestProperty("Accept-Encoding", "gzip");
@@ -208,7 +244,42 @@ private static String getTime() {
208244
calendar.add(Calendar.MINUTE, 60);
209245
return dateFormat.format(calendar.getTime());
210246
}
247+
248+
/**
249+
*
250+
* Method used to add proxy settings with authentication
251+
*
252+
* @param host
253+
* @param port
254+
* @param username
255+
* @param password
256+
*/
257+
private static Proxy setProxy(String host, int port, final String username, final String password) {
258+
259+
Authenticator authenticator = new Authenticator() {
260+
261+
public PasswordAuthentication getPasswordAuthentication() {
262+
263+
return (new PasswordAuthentication(username, password.toCharArray()));
264+
}
265+
};
266+
Authenticator.setDefault(authenticator);
267+
268+
return new Proxy(Proxy.Type.HTTP, new InetSocketAddress(host, port));
269+
}
270+
271+
/**
272+
*
273+
* Method used to add proxy settings without Authentication
274+
*
275+
* @param host
276+
* @param port
277+
*/
278+
public static Proxy setProxyWithoutAuthentication(String host, int port) {
279+
280+
return new Proxy(Proxy.Type.HTTP, new InetSocketAddress(host, port));
211281

282+
}
212283
private static ErrorResponse exception(String error) {
213284
ErrorResponse obj = new ErrorResponse();
214285
switch (code) {

0 commit comments

Comments
 (0)