Skip to content

Commit 1c70881

Browse files
committed
Release Version 11.3.1
Release Version 11.3.1
1 parent eb46cda commit 1c70881

File tree

8 files changed

+170
-31
lines changed

8 files changed

+170
-31
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +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
33

4+
# Version 11.3.1
5+
Release on January 28, 2022
6+
7+
8+
## Enhancements
9+
10+
- Added a feature to add ApiKey and ApiSecret directly in LoginRadius manual SOTT generation method.
11+
- Code optimization for better performance.
12+
- Added Licence and Contribution Guideline files.
13+
14+
## Breaking Changes
15+
16+
For developers migrating from v11.3.0, there will be 1 minor breaking change in terms of SDK implementation. In this version, we have added a feature to add ApiKey & ApiSecret directly into the manual SOTT generation method `getSott()`.
17+
418
# Version 11.3.0
519
Release on October 10, 2021
620

CONTRIBUTING.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Contributing
2+
3+
[Java SDK](https://github.com/LoginRadius/java-sdk) is [MIT](LICENSE) licensed and accepts contributions via GitHub pull requests. This document outlines some of the conventions on development workflow, commit message formatting, contact points, and other resources to make it easier to get your contribution accepted.
4+
5+
## Getting Started
6+
7+
- Fork the repository on GitHub.
8+
- If you find any bug or Improvement in our existing code-base, please create a pull request as mentioned in Contribution Flow.
9+
10+
## Contribution Flow
11+
12+
This is a rough outline of what a contributor's workflow looks like:
13+
14+
- Create a separate branch from the `dev` branch to base your work.
15+
- Make commits of logical units.
16+
- Make sure your commit messages are in the proper format (see below).
17+
- Push your changes to a topic branch in your fork of the repository.
18+
- Submit a pull request to the original repository.
19+
- **Please ensure that you raise a PR on the `dev` branch instead of `master`.**
20+
21+
#### Commit Messages
22+
23+
Please follow the below format while writing commit messages:
24+
25+
```
26+
title: One line description about your change
27+
<Blank Line>
28+
description: An optional description of your changes.
29+
```
30+
31+
Thanks for your contributions!
32+
33+
## Code of Conduct
34+
35+
### Our Pledge
36+
37+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
38+
39+
### Our Responsibilities
40+
41+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2022 LoginRadius Inc.
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

LoginRadius-JavaSDK/pom.xml

Lines changed: 7 additions & 7 deletions
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.3.0</version>
9+
<version>11.3.1</version>
1010
<name>LoginRadius-CustomerIdentity-JavaSDK</name>
1111
<description>LoginRadius Java SDK</description>
1212
<url>https://github.com/LoginRadius/java-sdk</url>
@@ -38,7 +38,7 @@
3838
<dependency>
3939
<groupId>com.google.code.gson</groupId>
4040
<artifactId>gson</artifactId>
41-
<version>2.2.4</version>
41+
<version>2.8.9</version>
4242
</dependency>
4343

4444

@@ -82,7 +82,7 @@
8282
<plugin>
8383
<groupId>org.sonatype.plugins</groupId>
8484
<artifactId>nexus-staging-maven-plugin</artifactId>
85-
<version>1.6.3</version>
85+
<version>1.6.8</version>
8686
<extensions>true</extensions>
8787
<configuration>
8888
<serverId>ossrh</serverId>
@@ -93,10 +93,10 @@
9393
<plugin>
9494
<groupId>org.apache.maven.plugins</groupId>
9595
<artifactId>maven-compiler-plugin</artifactId>
96-
<version>2.3.2</version>
96+
<version>3.9.0</version>
9797
<configuration>
98-
<source>1.6</source>
99-
<target>1.6</target>
98+
<source>16</source>
99+
<target>16</target>
100100
</configuration>
101101
</plugin>
102102
<plugin>
@@ -116,7 +116,7 @@
116116
<groupId>org.apache.maven.plugins</groupId>
117117
<artifactId>maven-javadoc-plugin</artifactId>
118118
<configuration>
119-
<source>8</source>
119+
<source>16</source>
120120
<show>public</show>
121121
<nohelp>true</nohelp>
122122
<author>true</author>

LoginRadius-JavaSDK/src/main/java/com/loginradius/sdk/util/Sott.java

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,41 +31,43 @@
3131
import javax.crypto.spec.PBEKeySpec;
3232
import javax.crypto.spec.SecretKeySpec;
3333

34+
import com.loginradius.sdk.helper.LoginRadiusValidator;
3435
import com.loginradius.sdk.models.responsemodels.otherobjects.ServiceInfoModel;
3536

3637
public class Sott {
3738

3839
private static String initVector = "tu89geji340t89u2";
3940

40-
public static String getSott(ServiceInfoModel service) throws java.lang.Exception {
41-
String secret = LoginRadiusSDK.getApiSecret();
42-
String key = LoginRadiusSDK.getApiKey();
41+
// <summary>
42+
// Generate SOTT Manually.
43+
// </summary>
44+
// <param name="service">ServiceInfoModel Model Class containing Definition of payload for SOTT</param>
45+
// <param name="apiKey">LoginRadius Api Key.</param>
46+
// <param name="apiSecret">LoginRadius Api Secret.</param>
47+
// <returns>Sott data</returns>
48+
49+
public static String getSott(ServiceInfoModel service,String apiKey,String apiSecret) throws java.lang.Exception {
50+
String secret = !LoginRadiusValidator.isNullOrWhiteSpace(apiSecret)? apiSecret:LoginRadiusSDK.getApiSecret();
51+
String key = !LoginRadiusValidator.isNullOrWhiteSpace(apiKey)? apiKey:LoginRadiusSDK.getApiKey();
4352
String token = null;
44-
if (service != null && service.getSott().getStartTime() != null && service.getSott().getEndTime() != null) {
53+
54+
if (service != null && !LoginRadiusValidator.isNullOrWhiteSpace(service.getSott().getStartTime()) && !LoginRadiusValidator.isNullOrWhiteSpace(service.getSott().getEndTime()) ) {
4555
String plaintext = service.getSott().getStartTime() + "#" + key + "#" + service.getSott().getEndTime();
46-
token = encrypt(plaintext, secret);
47-
} else if (service != null && service.getSott().getTimeDifference() != null
48-
&& !service.getSott().getTimeDifference().equals("")) {
49-
TimeZone timeZone = TimeZone.getTimeZone("UTC");
50-
Calendar calendar = Calendar.getInstance(timeZone);
51-
DateFormat dateFormat = new SimpleDateFormat("yyyy/M/d H:m:s", Locale.US);
52-
dateFormat.setTimeZone(timeZone);
53-
String plaintext = dateFormat.format(calendar.getTime()) + "#" + key + "#";
54-
int time = Integer.parseInt(service.getSott().getTimeDifference());
55-
calendar.add(Calendar.MINUTE, time);
56-
plaintext += dateFormat.format(calendar.getTime());
57-
token = encrypt(plaintext, secret);
56+
token = encrypt(plaintext, secret);
5857
} else {
58+
59+
String timeDifference =(service!=null && !LoginRadiusValidator.isNullOrWhiteSpace(service.getSott().getTimeDifference())) ?service.getSott().getTimeDifference():"10";
5960
TimeZone timeZone = TimeZone.getTimeZone("UTC");
6061
Calendar calendar = Calendar.getInstance(timeZone);
6162
DateFormat dateFormat = new SimpleDateFormat("yyyy/M/d H:m:s", Locale.US);
6263
dateFormat.setTimeZone(timeZone);
6364
String plaintext = dateFormat.format(calendar.getTime()) + "#" + key + "#";
64-
calendar.add(Calendar.MINUTE, 10);
65+
calendar.add(Calendar.MINUTE, Integer.parseInt(timeDifference));
6566
plaintext += dateFormat.format(calendar.getTime());
6667
token = encrypt(plaintext, secret);
68+
6769
}
68-
70+
6971
String finalToken = token + "*" + createMd5(token);
7072
return finalToken;
7173
}

README.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Use the following dependency in your project:
2727
<dependency>
2828
<groupId>com.loginradius.sdk</groupId>
2929
<artifactId>java-sdk</artifactId>
30-
<version>11.3.0</version>
30+
<version>11.3.1</version>
3131
</dependency>
3232
3333
```
@@ -7777,6 +7777,45 @@ System.out.println(error.getDescription());
77777777

77787778
<br>
77797779

7780+
### Generate SOTT Manually
7781+
7782+
SOTT is a secure one-time token that can be created using the API key, API secret, and a timestamp ( start time and end time ). You can manually create a SOTT using the following util function.
7783+
7784+
```
7785+
ServiceSottInfo serviceSottInfo=new ServiceSottInfo();
7786+
7787+
// You can pass the start and end time interval and the SOTT will be valid for this time duration.
7788+
7789+
serviceSottInfo.setStartTime("2021-01-10 07:10:42"); // Valid Start Date with Date and time
7790+
7791+
serviceSottInfo.setEndTime("2023-01-15 07:20:42"); // Valid End Date with Date and time
7792+
7793+
// Or you can pass the time difference in minutes for setting up the validity of SOTT, if you do not pass the time difference then the default value is 10 minutes
7794+
7795+
serviceSottInfo.setTimeDifference("20"); // (Optional) The time difference will be used to set the expiration time of SOTT, If you do not pass time difference then the default expiration time of SOTT is 10 minutes.
7796+
7797+
7798+
ServiceInfoModel service=new ServiceInfoModel();
7799+
7800+
service.setSott(serviceSottInfo);
7801+
7802+
7803+
//The LoginRadius API key and primary API secret can be passed additionally, If the credentials will not be passed then this SOTT function will pick the API credentials from the SDK configuration.
7804+
7805+
String apiKey="";//(Optional) LoginRadius Api Key.
7806+
7807+
String apiSecret="";//(Optional) LoginRadius Api Secret (Only Primary Api Secret is used to generate the SOTT manually).
7808+
7809+
try {
7810+
String sottResponse = Sott.getSott(service,apiKey,apiSecret);
7811+
System.out.println("sott = " + sottResponse);
7812+
7813+
} catch (Exception e) {
7814+
e.printStackTrace();
7815+
7816+
}
7817+
7818+
```
77807819

77817820
### Demo
77827821
We have a demo web application using the Java SDK, which includes the following features:

demo/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
<parent>
1414
<groupId>org.springframework.boot</groupId>
1515
<artifactId>spring-boot-starter-parent</artifactId>
16-
<version>1.5.6.RELEASE</version>
16+
<version>2.6.3</version>
1717
<relativePath/> <!-- lookup parent from repository -->
1818
</parent>
1919

2020
<properties>
2121
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2222
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
23-
<java.version>1.8</java.version>
23+
<java.version>16</java.version>
2424
</properties>
2525

2626
<dependencies>
@@ -42,7 +42,7 @@
4242
<dependency>
4343
<groupId>com.google.code.gson</groupId>
4444
<artifactId>gson</artifactId>
45-
<version>2.2.4</version>
45+
<version>2.8.9</version>
4646
</dependency>
4747
<dependency>
4848
<groupId>commons-codec</groupId>
@@ -52,7 +52,7 @@
5252
<dependency>
5353
<groupId>com.loginradius.sdk</groupId>
5454
<artifactId>java-sdk</artifactId>
55-
<version>11.3.0</version>
55+
<version>11.3.1</version>
5656
</dependency>
5757
</dependencies>
5858

demo/src/main/java/com/demo/LoginRadiusService.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
import com.loginradius.sdk.models.responsemodels.otherobjects.DeleteResponse;
4545
import com.loginradius.sdk.models.responsemodels.otherobjects.PostResponse;
4646
import com.loginradius.sdk.models.responsemodels.otherobjects.RoleModel;
47+
import com.loginradius.sdk.models.responsemodels.otherobjects.ServiceInfoModel;
48+
import com.loginradius.sdk.models.responsemodels.otherobjects.ServiceSottInfo;
4749
import com.loginradius.sdk.models.responsemodels.otherobjects.UserProfilePostResponse;
4850
import com.loginradius.sdk.models.responsemodels.userprofile.Identity;
4951
import com.loginradius.sdk.util.AsyncHandler;
@@ -663,8 +665,30 @@ private String decodeJWTBody(String jwtToken)
663665
return body;
664666
}
665667
private String getSott() {
668+
ServiceSottInfo serviceSottInfo=new ServiceSottInfo();
669+
670+
// You can pass the start and end time interval and the SOTT will be valid for this time duration.
671+
672+
serviceSottInfo.setStartTime(""); // Valid Start Date with Date and time
673+
674+
serviceSottInfo.setEndTime(""); // Valid End Date with Date and time
675+
676+
// Or you can pass the time difference in minutes for setting up the validity of SOTT, if you do not pass the time difference then the default value is 10 minutes
677+
678+
serviceSottInfo.setTimeDifference("20"); // (Optional) The time difference will be used to set the expiration time of SOTT, If you do not pass time difference then the default expiration time of SOTT is 10 minutes.
679+
680+
681+
ServiceInfoModel service=new ServiceInfoModel();
682+
683+
service.setSott(serviceSottInfo);
684+
685+
686+
//The LoginRadius API key and primary API secret can be passed additionally, If the credentials will not be passed then this SOTT function will pick the API credentials from the SDK configuration.
687+
String apiKey="";//(Optional) LoginRadius Api Key.
688+
String apiSecret="";//(Optional) LoginRadius Api Secret (Only Primary Api Secret is used to generate the SOTT manually).
689+
666690
try {
667-
return Sott.getSott(null);
691+
return Sott.getSott(service,apiKey,apiSecret);
668692
} catch (Exception e) {
669693
return "";
670694
}

0 commit comments

Comments
 (0)