Skip to content

Commit

Permalink
Released Version 11.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
giriraj12000 committed Apr 21, 2021
1 parent d7713b7 commit 7443cfb
Show file tree
Hide file tree
Showing 11 changed files with 570 additions and 34 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
> **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/)
# Version 11.1.0
Release on April 21, 2021

## Enhancements

- Added Proxy Server Feature.

## Added new multiple APIs for better user experience

- Get Profile By Ping.
- Passwordless Login Verification By Email And OTP.
- Passwordless Login Verification By User Name And OTP.

# Version 11.0.1
Release on March 17, 2021

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


# Version 11.0.0
Released on **Aug 21, 2020**
Release on July 28, 2020

## Enhancements

Expand Down
2 changes: 1 addition & 1 deletion 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>11.0.1</version>
<version>11.1.0</version>
<description>LoginRadius java SDK contains registration and social APIs</description>
<url>https://github.com/LoginRadius/java-sdk</url>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import com.loginradius.sdk.util.LoginRadiusSDK;



public class AuthenticationApi {
private static Gson gson =new Gson();

Expand Down Expand Up @@ -654,6 +655,63 @@ public void onFailure(ErrorResponse errorResponse) {
});
}

// <summary>
//
// </summary>
// <param name="clientGuid"></param>
// <param name="emailTemplate"></param>
// <param name="fields"></param>
// <param name="verificationUrl"></param>
// <param name="welcomeEmailTemplate"></param>
// <returns>Response containing User Profile Data and access token</returns>
// 5.16


public void getProfileByPing(String clientGuid, String emailTemplate,
String fields, String verificationUrl, String welcomeEmailTemplate, final AsyncHandler<AccessToken<Identity>> handler) {

if (LoginRadiusValidator.isNullOrWhiteSpace(clientGuid)) {
throw new IllegalArgumentException(LoginRadiusValidator.getValidationMessage("clientGuid"));
}

Map<String, String> queryParameters = new HashMap<String, String>();
queryParameters.put("apiKey", LoginRadiusSDK.getApiKey());
queryParameters.put("clientGuid", clientGuid);

if (!LoginRadiusValidator.isNullOrWhiteSpace(emailTemplate)) {
queryParameters.put("emailTemplate", emailTemplate);
}

if (!LoginRadiusValidator.isNullOrWhiteSpace(fields)) {
queryParameters.put("fields", fields);
}

if (!LoginRadiusValidator.isNullOrWhiteSpace(verificationUrl)) {
queryParameters.put("verificationUrl", verificationUrl);
}

if (!LoginRadiusValidator.isNullOrWhiteSpace(welcomeEmailTemplate)) {
queryParameters.put("welcomeEmailTemplate", welcomeEmailTemplate);
}

String resourcePath = "identity/v2/auth/account/ping";

LoginRadiusRequest.execute("GET", resourcePath, queryParameters, null, new AsyncHandler<String>() {

@Override
public void onSuccess(String response) {
TypeToken<AccessToken<Identity>> typeToken = new TypeToken<AccessToken<Identity>>() {};
AccessToken<Identity> successResponse = JsonDeserializer.deserializeJson(response,typeToken);
handler.onSuccess(successResponse);
}

@Override
public void onFailure(ErrorResponse errorResponse) {
handler.onFailure(errorResponse);
}
});
}

// <summary>
// This API is used to check the email exists or not on your site.
// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,19 @@

package com.loginradius.sdk.api.authentication;

import java.util.HashMap;
import java.util.Map;

import com.loginradius.sdk.helper.*;
import com.loginradius.sdk.util.*;
import com.google.gson.Gson;
import java.util.Iterator;
import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
import com.loginradius.sdk.helper.JsonDeserializer;
import com.loginradius.sdk.helper.LoginRadiusRequest;
import com.loginradius.sdk.helper.LoginRadiusValidator;
import com.loginradius.sdk.models.requestmodels.PasswordLessLoginOtpModel;
import com.loginradius.sdk.models.responsemodels.AccessToken;
import com.loginradius.sdk.models.responsemodels.SMSResponseData;
import com.loginradius.sdk.models.responsemodels.otherobjects.GetResponse;
import com.loginradius.sdk.models.responsemodels.otherobjects.PostResponse;
import com.loginradius.sdk.models.responsemodels.userprofile.Identity;
import com.loginradius.sdk.util.AsyncHandler;
import com.loginradius.sdk.util.ErrorResponse;
import com.loginradius.sdk.util.LoginRadiusSDK;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Map;
import com.loginradius.sdk.models.responsemodels.*;
import com.loginradius.sdk.models.responsemodels.userprofile.*;
import com.loginradius.sdk.models.requestmodels.*;
import com.loginradius.sdk.models.responsemodels.otherobjects.*;


public class PasswordLessLoginApi {
Expand Down Expand Up @@ -263,4 +259,84 @@ public void onFailure(ErrorResponse errorResponse) {
}
});
}

// <summary>
//
// </summary>
// <param name="passwordLessLoginByEmailAndOtpModel"></param>
// <param name="fields"></param>
// <returns>Response containing User Profile Data and access token</returns>
// 9.23


public void passwordlessLoginVerificationByEmailAndOTP(PasswordLessLoginByEmailAndOtpModel passwordLessLoginByEmailAndOtpModel, String fields, final AsyncHandler<AccessToken<Identity>> handler) {

if (passwordLessLoginByEmailAndOtpModel == null) {
throw new IllegalArgumentException(LoginRadiusValidator.getValidationMessage("passwordLessLoginByEmailAndOtpModel"));
}

Map<String, String> queryParameters = new HashMap<String, String>();
queryParameters.put("apiKey", LoginRadiusSDK.getApiKey());

if (!LoginRadiusValidator.isNullOrWhiteSpace(fields)) {
queryParameters.put("fields", fields);
}

String resourcePath = "identity/v2/auth/login/passwordlesslogin/email/verifyotp";

LoginRadiusRequest.execute("POST", resourcePath, queryParameters, gson.toJson(passwordLessLoginByEmailAndOtpModel), new AsyncHandler<String>() {

@Override
public void onSuccess(String response) {
TypeToken<AccessToken<Identity>> typeToken = new TypeToken<AccessToken<Identity>>() {};
AccessToken<Identity> successResponse = JsonDeserializer.deserializeJson(response,typeToken);
handler.onSuccess(successResponse);
}

@Override
public void onFailure(ErrorResponse errorResponse) {
handler.onFailure(errorResponse);
}
});
}

// <summary>
//
// </summary>
// <param name="passwordLessLoginByUserNameAndOtpModel"></param>
// <param name="fields"></param>
// <returns>Response containing User Profile Data and access token</returns>
// 9.24


public void passwordlessLoginVerificationByUserNameAndOTP(PasswordLessLoginByUserNameAndOtpModel passwordLessLoginByUserNameAndOtpModel, String fields, final AsyncHandler<AccessToken<Identity>> handler) {

if (passwordLessLoginByUserNameAndOtpModel == null) {
throw new IllegalArgumentException(LoginRadiusValidator.getValidationMessage("passwordLessLoginByUserNameAndOtpModel"));
}

Map<String, String> queryParameters = new HashMap<String, String>();
queryParameters.put("apiKey", LoginRadiusSDK.getApiKey());

if (!LoginRadiusValidator.isNullOrWhiteSpace(fields)) {
queryParameters.put("fields", fields);
}

String resourcePath = "identity/v2/auth/login/passwordlesslogin/username/verifyotp";

LoginRadiusRequest.execute("POST", resourcePath, queryParameters, gson.toJson(passwordLessLoginByUserNameAndOtpModel), new AsyncHandler<String>() {

@Override
public void onSuccess(String response) {
TypeToken<AccessToken<Identity>> typeToken = new TypeToken<AccessToken<Identity>>() {};
AccessToken<Identity> successResponse = JsonDeserializer.deserializeJson(response,typeToken);
handler.onSuccess(successResponse);
}

@Override
public void onFailure(ErrorResponse errorResponse) {
handler.onFailure(errorResponse);
}
});
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

package com.loginradius.sdk.helper;

import java.io.BufferedReader;
Expand All @@ -22,6 +23,10 @@
import java.util.Map;
import java.util.TimeZone;
import java.util.zip.GZIPInputStream;
import java.net.Proxy;
import java.net.Authenticator;
import java.net.InetSocketAddress;
import java.net.PasswordAuthentication;

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

try {
HttpURLConnection con = (HttpURLConnection) new URL(url).openConnection();
con.setRequestMethod(method);
con.setConnectTimeout(15000); // set timeout to 15 seconds
con.setReadTimeout(15000);
Proxy proxy=null;

if(!LoginRadiusValidator.isNullOrWhiteSpace(LoginRadiusSDK.getProxyHost()) && !LoginRadiusValidator.isNullOrWhiteSpace(LoginRadiusSDK.getProxyPort()) && !LoginRadiusValidator.isNullOrWhiteSpace(LoginRadiusSDK.getProxyUserName()) && !LoginRadiusValidator.isNullOrWhiteSpace(LoginRadiusSDK.getProxyPassword())) {

proxy=setProxy(LoginRadiusSDK.getProxyHost(), Integer.parseInt(LoginRadiusSDK.getProxyPort()), LoginRadiusSDK.getProxyUserName(), LoginRadiusSDK.getProxyPassword());

} else if(!LoginRadiusValidator.isNullOrWhiteSpace(LoginRadiusSDK.getProxyHost()) && !LoginRadiusValidator.isNullOrWhiteSpace(LoginRadiusSDK.getProxyPort())) {

proxy=setProxyWithoutAuthentication(LoginRadiusSDK.getProxyHost(),Integer.parseInt(LoginRadiusSDK.getProxyPort()));

}

URL connectionUrl = new URL(url);
HttpURLConnection con = null;

if (proxy != null) {
con = (HttpURLConnection) connectionUrl.openConnection(proxy);
}else {
con = (HttpURLConnection) connectionUrl.openConnection();
}
con.setRequestMethod(method);

if(LoginRadiusSDK.getConnectionTimeout() != null && LoginRadiusSDK.getReadTimeout() != null) {
con.setConnectTimeout(LoginRadiusSDK.getConnectionTimeout());
con.setReadTimeout(LoginRadiusSDK.getReadTimeout());
}else if(LoginRadiusSDK.getConnectionTimeout() != null ) {
con.setConnectTimeout(LoginRadiusSDK.getConnectionTimeout());
con.setReadTimeout(15000);
}else {
con.setConnectTimeout(15000); // set timeout to 15 seconds
con.setReadTimeout(15000);
}



con.setRequestProperty("Content-Type", "application/json");
con.setRequestProperty("charset", encoding);
con.setRequestProperty("Accept-Encoding", "gzip");
Expand Down Expand Up @@ -208,7 +244,42 @@ private static String getTime() {
calendar.add(Calendar.MINUTE, 60);
return dateFormat.format(calendar.getTime());
}

/**
*
* Method used to add proxy settings with authentication
*
* @param host
* @param port
* @param username
* @param password
*/
private static Proxy setProxy(String host, int port, final String username, final String password) {

Authenticator authenticator = new Authenticator() {

public PasswordAuthentication getPasswordAuthentication() {

return (new PasswordAuthentication(username, password.toCharArray()));
}
};
Authenticator.setDefault(authenticator);

return new Proxy(Proxy.Type.HTTP, new InetSocketAddress(host, port));
}

/**
*
* Method used to add proxy settings without Authentication
*
* @param host
* @param port
*/
public static Proxy setProxyWithoutAuthentication(String host, int port) {

return new Proxy(Proxy.Type.HTTP, new InetSocketAddress(host, port));

}
private static ErrorResponse exception(String error) {
ErrorResponse obj = new ErrorResponse();
switch (code) {
Expand Down
Loading

0 comments on commit 7443cfb

Please sign in to comment.