Skip to content

Commit

Permalink
Release Version 11.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
indrasen715 committed Oct 10, 2021
1 parent a693c86 commit 839d702
Show file tree
Hide file tree
Showing 12 changed files with 578 additions and 28 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
> **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.3.0
Release on October 10, 2021


## Enhancements

- Added JWT Login feature in SDK demo

## Added new multiple APIs for better user experience
- JWT token by Access Token
- JWT token by Email and Password
- JWT token by Username and Password
- JWT token by Phone and Password

# Version 11.2.0
Release on September 7, 2021

Expand Down
3 changes: 2 additions & 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.2.0</version>
<version>11.3.0</version>
<name>LoginRadius-CustomerIdentity-JavaSDK</name>
<description>LoginRadius Java SDK</description>
<url>https://github.com/LoginRadius/java-sdk</url>
Expand Down Expand Up @@ -55,6 +55,7 @@
</dependency>
</dependencies>


<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
/*
*
* Created by LoginRadius Development Team
Copyright 2019 LoginRadius Inc. All rights reserved.
*/

package com.loginradius.sdk.api.cloud;

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

import com.google.gson.Gson;
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.SsoAuthenticationModel;
import com.loginradius.sdk.models.responsemodels.SsoJwtResponseData;
import com.loginradius.sdk.util.AsyncHandler;
import com.loginradius.sdk.util.ErrorResponse;
import com.loginradius.sdk.util.LoginRadiusSDK;


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

public SsoJwtApi(){
if (!LoginRadiusSDK.validate()){
throw new LoginRadiusSDK.InitializeException();
}
}



// <summary>
// This API is used to get the JWT token by access token.
// </summary>
// <param name="accessToken">Uniquely generated identifier key by LoginRadius that is activated after successful authentication.</param>
// <param name="jwtAppName">Jwt App Name</param>
// <returns>Response containing Definition Complete SsoJwtResponseData data</returns>

public void jwtTokenByAccessToken(String accessToken, String jwtAppName,final AsyncHandler<SsoJwtResponseData> handler) {

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

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

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

String resourcePath = "sso/jwt/api/token";

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

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

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

// <summary>
// This API is used to get a JWT token by Email and Password.
// </summary>
// <param name="ssoAuthenticationModel">Model Class containing Definition of payload for SSO Jwt Cloud Api</param>
// <param name="accessToken">Uniquely generated identifier key by LoginRadius that is activated after successful authentication.</param>
// <param name="jwtAppName">Jwt App Name</param>
// <returns>Response containing Definition Complete SsoJwtResponseData data</returns>

public void jwtTokenByEmail(SsoAuthenticationModel ssoAuthenticationModel, String jwtAppName,String emailTemplate,String loginUrl, String verificationUrl,final AsyncHandler<SsoJwtResponseData> handler) {

if (ssoAuthenticationModel == null) {
throw new IllegalArgumentException(LoginRadiusValidator.getValidationMessage("ssoAuthenticationModel"));
}
if (LoginRadiusValidator.isNullOrWhiteSpace(jwtAppName)) {
throw new IllegalArgumentException(LoginRadiusValidator.getValidationMessage("jwtAppName"));
}

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

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

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

if (!LoginRadiusValidator.isNullOrWhiteSpace(verificationUrl)) {
queryParameters.put("verificationurl", verificationUrl);
}
String resourcePath = "sso/jwt/api/login";

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

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

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

// <summary>
// This API is used to get a JWT token by UserName and Password.
// </summary>
// <param name="ssoAuthenticationModel">Model Class containing Definition of payload for SSO Jwt Cloud Api</param>
// <param name="accessToken">Uniquely generated identifier key by LoginRadius that is activated after successful authentication.</param>
// <param name="jwtAppName">Jwt App Name</param>
// <returns>Response containing Definition Complete SsoJwtResponseData data</returns>

public void jwtTokenByUserName(SsoAuthenticationModel ssoAuthenticationModel, String jwtAppName, String emailTemplate,String loginUrl, String verificationUrl, final AsyncHandler<SsoJwtResponseData> handler) {


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

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

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

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

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

if (!LoginRadiusValidator.isNullOrWhiteSpace(verificationUrl)) {
queryParameters.put("verificationurl", verificationUrl);
}
String resourcePath = "sso/jwt/api/login";

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

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

@Override
public void onFailure(ErrorResponse errorResponse) {
handler.onFailure(errorResponse);
}
});
}
// <summary>
// This API is used to get a JWT token by Phone and Password.
// </summary>
// <param name="ssoAuthenticationModel">Model Class containing Definition of payload for SSO Jwt Cloud Api</param>
// <param name="accessToken">Uniquely generated identifier key by LoginRadius that is activated after successful authentication.</param>
// <param name="jwtAppName">Jwt App Name</param>
// <returns>Response containing Definition Complete SsoJwtResponseData data</returns>

public void jwtTokenByPhone(SsoAuthenticationModel ssoAuthenticationModel,String jwtAppName,String emailTemplate,String loginUrl, String verificationUrl,final AsyncHandler<SsoJwtResponseData> handler) {

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

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

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


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

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

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

String resourcePath = "sso/jwt/api/login";

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

@Override
public void onSuccess(String response) {
TypeToken<SsoJwtResponseData> typeToken = new TypeToken<SsoJwtResponseData>() {};
SsoJwtResponseData 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
Expand Up @@ -62,6 +62,9 @@ public static void execute(String method, String resourcePath, Map<String, Strin
if (resourcePath.equals("ciam/appinfo")) {
serviceUrl = LoginRadiusSDK.getConfigDomain() + "/" + resourcePath;
}
if (resourcePath.contains("sso/")) {
serviceUrl = LoginRadiusSDK.getCloudDomain() + "/" + resourcePath;
}
if (params.containsKey("sott")) {
sott = params.get("sott");
params.remove("sott");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
*
* Created by LoginRadius Development Team
Copyright 2019 LoginRadius Inc. All rights reserved.
*/

package com.loginradius.sdk.models.requestmodels;
import com.google.gson.annotations.SerializedName;

// <summary>
// Model Class containing Definition of payload for SSO JWT Cloud API
// </summary>
public class SsoAuthenticationModel {


@SerializedName("email")
private String email;

@SerializedName("username")
private String username ;

@SerializedName("phone")
private String phone;


@SerializedName("password")
private String password;



// <summary>
// user's email
// </summary>
public String getEmail() {
return email;
}
// <summary>
// user's email
// </summary>
public void setEmail(String email) {
this.email = email;
}
// <summary>
// user's username
// </summary>
public String getUserName() {
return username;
}
// <summary>
// user's username
// </summary>
public void setUserName(String username) {
this.username = username;
}
// <summary>
// user's phone
// </summary>
public String getPhone() {
return phone;
}
// <summary>
// user's phone
// </summary>
public void setPhone(String phone) {
this.phone = phone;
}
// <summary>
// Password for the email
// </summary>
public String getPassword() {
return password;
}
// <summary>
// Password for the email
// </summary>
public void setPassword(String password) {
this.password = password;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
*
* Created by LoginRadius Development Team
Copyright 2019 LoginRadius Inc. All rights reserved.
*/

package com.loginradius.sdk.models.responsemodels;

import com.google.gson.annotations.SerializedName;

// <summary>
// Response containing Definition of Jwt Response Data
// </summary>
public class SsoJwtResponseData {

@SerializedName("signature")
private String signature;

public String getSignature() {
return signature;
}

public void setSignature(String signature) {
this.signature = signature;
}

}
Loading

0 comments on commit 839d702

Please sign in to comment.