Skip to content

Commit 839d702

Browse files
committed
Release Version 11.3.0
1 parent a693c86 commit 839d702

File tree

12 files changed

+578
-28
lines changed

12 files changed

+578
-28
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
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+
4+
# Version 11.3.0
5+
Release on October 10, 2021
6+
7+
8+
## Enhancements
9+
10+
- Added JWT Login feature in SDK demo
11+
12+
## Added new multiple APIs for better user experience
13+
- JWT token by Access Token
14+
- JWT token by Email and Password
15+
- JWT token by Username and Password
16+
- JWT token by Phone and Password
17+
318
# Version 11.2.0
419
Release on September 7, 2021
520

LoginRadius-JavaSDK/pom.xml

Lines changed: 2 additions & 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.2.0</version>
9+
<version>11.3.0</version>
1010
<name>LoginRadius-CustomerIdentity-JavaSDK</name>
1111
<description>LoginRadius Java SDK</description>
1212
<url>https://github.com/LoginRadius/java-sdk</url>
@@ -55,6 +55,7 @@
5555
</dependency>
5656
</dependencies>
5757

58+
5859
<distributionManagement>
5960
<snapshotRepository>
6061
<id>ossrh</id>
Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
/*
2+
*
3+
* Created by LoginRadius Development Team
4+
Copyright 2019 LoginRadius Inc. All rights reserved.
5+
*/
6+
7+
package com.loginradius.sdk.api.cloud;
8+
9+
import java.util.HashMap;
10+
import java.util.Map;
11+
12+
import com.google.gson.Gson;
13+
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.SsoAuthenticationModel;
18+
import com.loginradius.sdk.models.responsemodels.SsoJwtResponseData;
19+
import com.loginradius.sdk.util.AsyncHandler;
20+
import com.loginradius.sdk.util.ErrorResponse;
21+
import com.loginradius.sdk.util.LoginRadiusSDK;
22+
23+
24+
public class SsoJwtApi {
25+
private static Gson gson =new Gson();
26+
27+
public SsoJwtApi(){
28+
if (!LoginRadiusSDK.validate()){
29+
throw new LoginRadiusSDK.InitializeException();
30+
}
31+
}
32+
33+
34+
35+
// <summary>
36+
// This API is used to get the JWT token by access token.
37+
// </summary>
38+
// <param name="accessToken">Uniquely generated identifier key by LoginRadius that is activated after successful authentication.</param>
39+
// <param name="jwtAppName">Jwt App Name</param>
40+
// <returns>Response containing Definition Complete SsoJwtResponseData data</returns>
41+
42+
public void jwtTokenByAccessToken(String accessToken, String jwtAppName,final AsyncHandler<SsoJwtResponseData> handler) {
43+
44+
if (LoginRadiusValidator.isNullOrWhiteSpace(accessToken)) {
45+
throw new IllegalArgumentException(LoginRadiusValidator.getValidationMessage("accessToken"));
46+
}
47+
48+
if (LoginRadiusValidator.isNullOrWhiteSpace(jwtAppName)) {
49+
throw new IllegalArgumentException(LoginRadiusValidator.getValidationMessage("jwtAppName"));
50+
}
51+
52+
Map<String, String> queryParameters = new HashMap<String, String>();
53+
queryParameters.put("apiKey", LoginRadiusSDK.getApiKey());
54+
queryParameters.put("access_token", accessToken);
55+
queryParameters.put("jwtapp", jwtAppName);
56+
57+
String resourcePath = "sso/jwt/api/token";
58+
59+
LoginRadiusRequest.execute("GET", resourcePath, queryParameters,null,new AsyncHandler<String>() {
60+
61+
@Override
62+
public void onSuccess(String response) {
63+
TypeToken<SsoJwtResponseData> typeToken = new TypeToken<SsoJwtResponseData>() {};
64+
SsoJwtResponseData successResponse = JsonDeserializer.deserializeJson(response,typeToken);
65+
handler.onSuccess(successResponse);
66+
}
67+
68+
@Override
69+
public void onFailure(ErrorResponse errorResponse) {
70+
handler.onFailure(errorResponse);
71+
}
72+
});
73+
}
74+
75+
// <summary>
76+
// This API is used to get a JWT token by Email and Password.
77+
// </summary>
78+
// <param name="ssoAuthenticationModel">Model Class containing Definition of payload for SSO Jwt Cloud Api</param>
79+
// <param name="accessToken">Uniquely generated identifier key by LoginRadius that is activated after successful authentication.</param>
80+
// <param name="jwtAppName">Jwt App Name</param>
81+
// <returns>Response containing Definition Complete SsoJwtResponseData data</returns>
82+
83+
public void jwtTokenByEmail(SsoAuthenticationModel ssoAuthenticationModel, String jwtAppName,String emailTemplate,String loginUrl, String verificationUrl,final AsyncHandler<SsoJwtResponseData> handler) {
84+
85+
if (ssoAuthenticationModel == null) {
86+
throw new IllegalArgumentException(LoginRadiusValidator.getValidationMessage("ssoAuthenticationModel"));
87+
}
88+
if (LoginRadiusValidator.isNullOrWhiteSpace(jwtAppName)) {
89+
throw new IllegalArgumentException(LoginRadiusValidator.getValidationMessage("jwtAppName"));
90+
}
91+
92+
Map<String, String> queryParameters = new HashMap<String, String>();
93+
queryParameters.put("apiKey", LoginRadiusSDK.getApiKey());
94+
queryParameters.put("jwtapp", jwtAppName);
95+
96+
if (!LoginRadiusValidator.isNullOrWhiteSpace(emailTemplate)) {
97+
queryParameters.put("emailTemplate", emailTemplate);
98+
}
99+
100+
if (!LoginRadiusValidator.isNullOrWhiteSpace(loginUrl)) {
101+
queryParameters.put("loginUrl", loginUrl);
102+
}
103+
104+
if (!LoginRadiusValidator.isNullOrWhiteSpace(verificationUrl)) {
105+
queryParameters.put("verificationurl", verificationUrl);
106+
}
107+
String resourcePath = "sso/jwt/api/login";
108+
109+
LoginRadiusRequest.execute("POST", resourcePath, queryParameters,gson.toJson(ssoAuthenticationModel),new AsyncHandler<String>() {
110+
111+
@Override
112+
public void onSuccess(String response) {
113+
TypeToken<SsoJwtResponseData> typeToken = new TypeToken<SsoJwtResponseData>() {};
114+
SsoJwtResponseData successResponse = JsonDeserializer.deserializeJson(response,typeToken);
115+
handler.onSuccess(successResponse);
116+
}
117+
118+
@Override
119+
public void onFailure(ErrorResponse errorResponse) {
120+
handler.onFailure(errorResponse);
121+
}
122+
});
123+
}
124+
125+
// <summary>
126+
// This API is used to get a JWT token by UserName and Password.
127+
// </summary>
128+
// <param name="ssoAuthenticationModel">Model Class containing Definition of payload for SSO Jwt Cloud Api</param>
129+
// <param name="accessToken">Uniquely generated identifier key by LoginRadius that is activated after successful authentication.</param>
130+
// <param name="jwtAppName">Jwt App Name</param>
131+
// <returns>Response containing Definition Complete SsoJwtResponseData data</returns>
132+
133+
public void jwtTokenByUserName(SsoAuthenticationModel ssoAuthenticationModel, String jwtAppName, String emailTemplate,String loginUrl, String verificationUrl, final AsyncHandler<SsoJwtResponseData> handler) {
134+
135+
136+
if (ssoAuthenticationModel == null) {
137+
throw new IllegalArgumentException(LoginRadiusValidator.getValidationMessage("ssoAuthenticationModel"));
138+
}
139+
140+
if (LoginRadiusValidator.isNullOrWhiteSpace(jwtAppName)) {
141+
throw new IllegalArgumentException(LoginRadiusValidator.getValidationMessage("jwtAppName"));
142+
}
143+
144+
Map<String, String> queryParameters = new HashMap<String, String>();
145+
queryParameters.put("apiKey", LoginRadiusSDK.getApiKey());
146+
queryParameters.put("jwtapp", jwtAppName);
147+
148+
if (!LoginRadiusValidator.isNullOrWhiteSpace(emailTemplate)) {
149+
queryParameters.put("emailTemplate", emailTemplate);
150+
}
151+
152+
if (!LoginRadiusValidator.isNullOrWhiteSpace(loginUrl)) {
153+
queryParameters.put("loginUrl", loginUrl);
154+
}
155+
156+
if (!LoginRadiusValidator.isNullOrWhiteSpace(verificationUrl)) {
157+
queryParameters.put("verificationurl", verificationUrl);
158+
}
159+
String resourcePath = "sso/jwt/api/login";
160+
161+
LoginRadiusRequest.execute("POST", resourcePath, queryParameters,gson.toJson(ssoAuthenticationModel),new AsyncHandler<String>() {
162+
163+
@Override
164+
public void onSuccess(String response) {
165+
TypeToken<SsoJwtResponseData> typeToken = new TypeToken<SsoJwtResponseData>() {};
166+
SsoJwtResponseData successResponse = JsonDeserializer.deserializeJson(response,typeToken);
167+
handler.onSuccess(successResponse);
168+
}
169+
170+
@Override
171+
public void onFailure(ErrorResponse errorResponse) {
172+
handler.onFailure(errorResponse);
173+
}
174+
});
175+
}
176+
// <summary>
177+
// This API is used to get a JWT token by Phone and Password.
178+
// </summary>
179+
// <param name="ssoAuthenticationModel">Model Class containing Definition of payload for SSO Jwt Cloud Api</param>
180+
// <param name="accessToken">Uniquely generated identifier key by LoginRadius that is activated after successful authentication.</param>
181+
// <param name="jwtAppName">Jwt App Name</param>
182+
// <returns>Response containing Definition Complete SsoJwtResponseData data</returns>
183+
184+
public void jwtTokenByPhone(SsoAuthenticationModel ssoAuthenticationModel,String jwtAppName,String emailTemplate,String loginUrl, String verificationUrl,final AsyncHandler<SsoJwtResponseData> handler) {
185+
186+
if (ssoAuthenticationModel == null) {
187+
throw new IllegalArgumentException(LoginRadiusValidator.getValidationMessage("ssoAuthenticationModel"));
188+
}
189+
190+
if (LoginRadiusValidator.isNullOrWhiteSpace(jwtAppName)) {
191+
throw new IllegalArgumentException(LoginRadiusValidator.getValidationMessage("jwtAppName"));
192+
}
193+
194+
Map<String, String> queryParameters = new HashMap<String, String>();
195+
queryParameters.put("apiKey", LoginRadiusSDK.getApiKey());
196+
queryParameters.put("jwtapp", jwtAppName);
197+
198+
199+
if (!LoginRadiusValidator.isNullOrWhiteSpace(emailTemplate)) {
200+
queryParameters.put("emailTemplate", emailTemplate);
201+
}
202+
203+
if (!LoginRadiusValidator.isNullOrWhiteSpace(loginUrl)) {
204+
queryParameters.put("loginUrl", loginUrl);
205+
}
206+
207+
if (!LoginRadiusValidator.isNullOrWhiteSpace(verificationUrl)) {
208+
queryParameters.put("verificationurl", verificationUrl);
209+
}
210+
211+
String resourcePath = "sso/jwt/api/login";
212+
213+
LoginRadiusRequest.execute("POST", resourcePath, queryParameters,gson.toJson(ssoAuthenticationModel),new AsyncHandler<String>() {
214+
215+
@Override
216+
public void onSuccess(String response) {
217+
TypeToken<SsoJwtResponseData> typeToken = new TypeToken<SsoJwtResponseData>() {};
218+
SsoJwtResponseData successResponse = JsonDeserializer.deserializeJson(response,typeToken);
219+
handler.onSuccess(successResponse);
220+
}
221+
222+
@Override
223+
public void onFailure(ErrorResponse errorResponse) {
224+
handler.onFailure(errorResponse);
225+
}
226+
});
227+
}
228+
229+
230+
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ public static void execute(String method, String resourcePath, Map<String, Strin
6262
if (resourcePath.equals("ciam/appinfo")) {
6363
serviceUrl = LoginRadiusSDK.getConfigDomain() + "/" + resourcePath;
6464
}
65+
if (resourcePath.contains("sso/")) {
66+
serviceUrl = LoginRadiusSDK.getCloudDomain() + "/" + resourcePath;
67+
}
6568
if (params.containsKey("sott")) {
6669
sott = params.get("sott");
6770
params.remove("sott");
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/*
2+
*
3+
* Created by LoginRadius Development Team
4+
Copyright 2019 LoginRadius Inc. All rights reserved.
5+
6+
*/
7+
8+
package com.loginradius.sdk.models.requestmodels;
9+
import com.google.gson.annotations.SerializedName;
10+
11+
// <summary>
12+
// Model Class containing Definition of payload for SSO JWT Cloud API
13+
// </summary>
14+
public class SsoAuthenticationModel {
15+
16+
17+
@SerializedName("email")
18+
private String email;
19+
20+
@SerializedName("username")
21+
private String username ;
22+
23+
@SerializedName("phone")
24+
private String phone;
25+
26+
27+
@SerializedName("password")
28+
private String password;
29+
30+
31+
32+
// <summary>
33+
// user's email
34+
// </summary>
35+
public String getEmail() {
36+
return email;
37+
}
38+
// <summary>
39+
// user's email
40+
// </summary>
41+
public void setEmail(String email) {
42+
this.email = email;
43+
}
44+
// <summary>
45+
// user's username
46+
// </summary>
47+
public String getUserName() {
48+
return username;
49+
}
50+
// <summary>
51+
// user's username
52+
// </summary>
53+
public void setUserName(String username) {
54+
this.username = username;
55+
}
56+
// <summary>
57+
// user's phone
58+
// </summary>
59+
public String getPhone() {
60+
return phone;
61+
}
62+
// <summary>
63+
// user's phone
64+
// </summary>
65+
public void setPhone(String phone) {
66+
this.phone = phone;
67+
}
68+
// <summary>
69+
// Password for the email
70+
// </summary>
71+
public String getPassword() {
72+
return password;
73+
}
74+
// <summary>
75+
// Password for the email
76+
// </summary>
77+
public void setPassword(String password) {
78+
this.password = password;
79+
}
80+
81+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
*
3+
* Created by LoginRadius Development Team
4+
Copyright 2019 LoginRadius Inc. All rights reserved.
5+
6+
*/
7+
8+
package com.loginradius.sdk.models.responsemodels;
9+
10+
import com.google.gson.annotations.SerializedName;
11+
12+
// <summary>
13+
// Response containing Definition of Jwt Response Data
14+
// </summary>
15+
public class SsoJwtResponseData {
16+
17+
@SerializedName("signature")
18+
private String signature;
19+
20+
public String getSignature() {
21+
return signature;
22+
}
23+
24+
public void setSignature(String signature) {
25+
this.signature = signature;
26+
}
27+
28+
}

0 commit comments

Comments
 (0)