Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/

package com.iemr.admin.controller.version;

import java.util.Map;
Expand All @@ -33,6 +34,11 @@
import com.iemr.admin.service.version.VersionService;

import io.swagger.v3.oas.annotations.Operation;
import java.io.IOException;
import java.io.InputStream;
import java.util.LinkedHashMap;
import java.util.Properties;
import org.springframework.http.MediaType;

@RestController
public class VersionController {
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/iemr/admin/data/employeemaster/M_User1.java
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ public void setSignatureStatus(String signatureStatus) {
@Expose
@Column(name = "failed_attempt", insertable = false)
private Integer failedAttempt;
@Expose
@Column(name = "lock_timestamp", insertable = false)
private Timestamp lockTimestamp;
public M_User1() {
// TODO Auto-generated constructor stub
}
Expand All @@ -251,6 +254,14 @@ public void setFailedAttempt(Integer failedAttempt) {
this.failedAttempt = failedAttempt;
}

public Timestamp getLockTimestamp() {
return lockTimestamp;
}

public void setLockTimestamp(Timestamp lockTimestamp) {
this.lockTimestamp = lockTimestamp;
}

public Integer getUserID() {
return userID;
}
Expand Down
36 changes: 36 additions & 0 deletions src/main/java/com/iemr/admin/data/employeemaster/V_Showuser.java
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,18 @@ public class V_Showuser {
@Column(name="DistrictID")
private Integer districtID;

@Expose
@Transient
private Integer failedAttempt;

@Expose
@Transient
private Timestamp lockTimestamp;

@Expose
@Transient
private Boolean lockedDueToFailedAttempts;




Expand Down Expand Up @@ -922,6 +934,30 @@ public void setDistrictID(Integer districtID) {
this.districtID = districtID;
}

public Integer getFailedAttempt() {
return failedAttempt;
}

public void setFailedAttempt(Integer failedAttempt) {
this.failedAttempt = failedAttempt;
}

public Timestamp getLockTimestamp() {
return lockTimestamp;
}

public void setLockTimestamp(Timestamp lockTimestamp) {
this.lockTimestamp = lockTimestamp;
}

public Boolean getLockedDueToFailedAttempts() {
return lockedDueToFailedAttempts;
}

public void setLockedDueToFailedAttempts(Boolean lockedDueToFailedAttempts) {
this.lockedDueToFailedAttempts = lockedDueToFailedAttempts;
}




Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
package com.iemr.admin.repo.employeemaster;

import java.util.ArrayList;
import java.util.List;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
Expand Down Expand Up @@ -87,4 +88,6 @@ M_User1 checkingEmpDetails(@Param("userName") String userName, @Param("aadhaarNo
ArrayList<M_User1> getempByDesiganation(@Param("designationID") Integer designationID,@Param("serviceProviderID") Integer serviceProviderID);

M_User1 findByUserID(Integer userID);

List<M_User1> findByUserIDIn(List<Integer> userIDs);
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.spec.InvalidKeySpecException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
Expand All @@ -44,6 +45,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
Expand Down Expand Up @@ -117,7 +119,10 @@

private static HttpUtils httpUtils = new HttpUtils();

private String common_url = ConfigProperties.getPropertyByName("common-url");
@Value("${common-url}")
private String common_url;

Check warning on line 123 in src/main/java/com/iemr/admin/service/employeemaster/EmployeeMasterServiceImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this field "common_url" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.

See more on https://sonarcloud.io/project/issues?id=PSMRI_Admin-API&issues=AZ5JxXR6BuF9TxiN_MvJ&open=AZ5JxXR6BuF9TxiN_MvJ&pullRequest=132

// private String common_url = ConfigProperties.getPropertyByName("common-url");

Check warning on line 125 in src/main/java/com/iemr/admin/service/employeemaster/EmployeeMasterServiceImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This block of commented-out lines of code should be removed.

See more on https://sonarcloud.io/project/issues?id=PSMRI_Admin-API&issues=AZ5JxXR6BuF9TxiN_MvK&open=AZ5JxXR6BuF9TxiN_MvK&pullRequest=132

private final String COMMON_BASE_URL = "common-url";

Expand Down Expand Up @@ -538,7 +543,7 @@
ObjectMapper objectMapper = new ObjectMapper();
Set<String> resultSet = new HashSet<String>();
HttpEntity<Object> request = RestTemplateUtil.createRequestEntity(campaignName, authToken);
String url = configProperties.getPropertyByName("common-url") + configProperties.getPropertyByName("create-feedback");
String url = common_url +"/" + configProperties.getPropertyByName("create-feedback");

Check warning on line 546 in src/main/java/com/iemr/admin/service/employeemaster/EmployeeMasterServiceImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Change this instance-reference to a static reference.

See more on https://sonarcloud.io/project/issues?id=PSMRI_Admin-API&issues=AZ5JxXR6BuF9TxiN_MvL&open=AZ5JxXR6BuF9TxiN_MvL&pullRequest=132

ResponseEntity<String> responseStr = restTemplate.exchange(url, HttpMethod.POST, request, String.class);
OutputResponse response = objectMapper.readValue(responseStr.getBody(), OutputResponse.class);
Expand Down Expand Up @@ -781,7 +786,8 @@
logger.info("EmployeeMasterServiceImpl.createUserInCallCentre - start");
if (ENABLE_CTI_USER_CREATION) {
String UserCreateAPIURL = "";
String ctiServer = configProperties.getPropertyByName("common-url");
// String ctiServer = configProperties.getPropertyByName("common-url");

Check warning on line 789 in src/main/java/com/iemr/admin/service/employeemaster/EmployeeMasterServiceImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This block of commented-out lines of code should be removed.

See more on https://sonarcloud.io/project/issues?id=PSMRI_Admin-API&issues=AZ5JxXR6BuF9TxiN_MvM&open=AZ5JxXR6BuF9TxiN_MvM&pullRequest=132
String ctiServer=common_url;
UserCreateAPIURL = ctiServer + configProperties.getPropertyByName("create-update-users-url");
HashMap<String, Object> headers = new HashMap<String, Object>();
JSONObject request = new JSONObject();
Expand Down Expand Up @@ -815,7 +821,8 @@

if (ENABLE_CTI_USER_CREATION) {
String UserCreateAPIURL = "";
String ctiServer = configProperties.getPropertyByName("common-url");
// String ctiServer = configProperties.getPropertyByName("common-url");

Check warning on line 824 in src/main/java/com/iemr/admin/service/employeemaster/EmployeeMasterServiceImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This block of commented-out lines of code should be removed.

See more on https://sonarcloud.io/project/issues?id=PSMRI_Admin-API&issues=AZ5JxXR6BuF9TxiN_MvN&open=AZ5JxXR6BuF9TxiN_MvN&pullRequest=132
String ctiServer=common_url;
UserCreateAPIURL = ctiServer + configProperties.getPropertyByName("create-update-users-url");
HashMap<String, Object> headers = new HashMap<String, Object>();
JSONObject request = new JSONObject();
Expand Down Expand Up @@ -1307,8 +1314,36 @@

@Override
public ArrayList<V_Showuser> getEmployeeDetails4(Integer serviceProviderID) {
ArrayList<V_Showuser> users = v_ShowuserRepo.EmployeeDetails4(serviceProviderID);
if (users.isEmpty()) {
return users;
}

ArrayList<Integer> userIDs = new ArrayList<Integer>(users.size());
for (V_Showuser user : users) {
userIDs.add(user.getUserID());
}

Map<Integer, M_User1> userRecords = new HashMap<Integer, M_User1>();
for (M_User1 userRecord : employeeMasterRepoo.findByUserIDIn(userIDs)) {
userRecords.put(userRecord.getUserID(), userRecord);
}

for (V_Showuser user : users) {
enrichAccountLockState(user, userRecords.get(user.getUserID()));
}
return users;
}

private void enrichAccountLockState(V_Showuser user, M_User1 userRecord) {
if (userRecord == null) {
return;
}

return v_ShowuserRepo.EmployeeDetails4(serviceProviderID);
Timestamp lockTimestamp = userRecord.getLockTimestamp();
user.setFailedAttempt(userRecord.getFailedAttempt() != null ? userRecord.getFailedAttempt() : 0);
user.setLockTimestamp(lockTimestamp);
user.setLockedDueToFailedAttempts(Boolean.TRUE.equals(userRecord.getDeleted()) && lockTimestamp != null);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

Expand All @@ -34,15 +35,31 @@
import com.iemr.admin.utils.mapper.InputMapper;
import com.iemr.admin.utils.response.OutputResponse;

import jakarta.annotation.PostConstruct;

@Service
public class EncryptUserPassword123 {
private static HttpUtils utils = new HttpUtils();
private static String commonBaseURL = ConfigProperties.getPropertyByName("common-url");
private static String encryptPasswordURL = commonBaseURL
+ ConfigProperties.getPropertyByName("encrypt-password-url");
// private static String commonBaseURL =
// ConfigProperties.getPropertyByName("common-url");

Check warning on line 44 in src/main/java/com/iemr/admin/service/provideronboard/EncryptUserPassword123.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This block of commented-out lines of code should be removed.

See more on https://sonarcloud.io/project/issues?id=PSMRI_Admin-API&issues=AZ5JxXRCBuF9TxiN_MvH&open=AZ5JxXRCBuF9TxiN_MvH&pullRequest=132

@Value("${common-url}")
private String commonBaseURL;

// private String encryptPasswordURL = commonBaseURL + "/"
// + ConfigProperties.getPropertyByName("encrypt-password-url");

Check warning on line 50 in src/main/java/com/iemr/admin/service/provideronboard/EncryptUserPassword123.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This block of commented-out lines of code should be removed.

See more on https://sonarcloud.io/project/issues?id=PSMRI_Admin-API&issues=AZ5JxXRCBuF9TxiN_MvI&open=AZ5JxXRCBuF9TxiN_MvI&pullRequest=132

private Logger logger = LoggerFactory.getLogger(this.getClass().getName());

private String encryptPasswordURL;

@PostConstruct
public void init() {
encryptPasswordURL = commonBaseURL + "/" +
ConfigProperties.getPropertyByName("encrypt-password-url");
logger.info("commonBaseURL=" + encryptPasswordURL);
}

@Async
public OutputResponse encryptUserCredentials(M_User data) {
JSONObject request = new JSONObject();
Expand Down
26 changes: 23 additions & 3 deletions src/main/java/com/iemr/admin/service/user/EncryptUserPassword.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

Expand All @@ -33,15 +34,34 @@
import com.iemr.admin.utils.mapper.InputMapper;
import com.iemr.admin.utils.response.OutputResponse;

import jakarta.annotation.PostConstruct;

@Service
public class EncryptUserPassword {
private static HttpUtils utils = new HttpUtils();
private static String commonBaseURL = ConfigProperties.getPropertyByName("common-url");
private static String encryptPasswordURL = commonBaseURL
+ ConfigProperties.getPropertyByName("encrypt-password-url");

@Value("${common-url}")
private String commonBaseURL;

// @Value("${encrypt-password-url}")
// private String encryptPasswordEndpoint;

Check warning on line 47 in src/main/java/com/iemr/admin/service/user/EncryptUserPassword.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This block of commented-out lines of code should be removed.

See more on https://sonarcloud.io/project/issues?id=PSMRI_Admin-API&issues=AZ5JxXSTBuF9TxiN_MvO&open=AZ5JxXSTBuF9TxiN_MvO&pullRequest=132

// private static String commonBaseURL =
// ConfigProperties.getPropertyByName("common-url");

Check warning on line 50 in src/main/java/com/iemr/admin/service/user/EncryptUserPassword.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This block of commented-out lines of code should be removed.

See more on https://sonarcloud.io/project/issues?id=PSMRI_Admin-API&issues=AZ5JxXSTBuF9TxiN_MvP&open=AZ5JxXSTBuF9TxiN_MvP&pullRequest=132
// private String encryptPasswordURL = commonBaseURL + "/" +
// ConfigProperties.getPropertyByName("encrypt-password-url");

private Logger logger = LoggerFactory.getLogger(this.getClass().getName());

private String encryptPasswordURL;

@PostConstruct
public void init() {
encryptPasswordURL = commonBaseURL + "/" +
ConfigProperties.getPropertyByName("encrypt-password-url");
logger.info("commonBaseURL" + encryptPasswordURL);
}

@Async
public OutputResponse encryptUserCredentials(M_User1 data) {
JSONObject request = new JSONObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

public class JwtUserIdValidationFilter implements Filter {

private static final String HEALTH_ENDPOINT = "/health";
private static final String VERSION_ENDPOINT = "/version";

private final JwtAuthenticationUtil jwtAuthenticationUtil;
private final Logger logger = LoggerFactory.getLogger(this.getClass().getName());
private final String allowedOrigins;
Expand Down Expand Up @@ -98,7 +101,9 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo
|| path.startsWith(contextPath + "/swagger-ui")
|| path.startsWith(contextPath + "/v3/api-docs")
|| path.startsWith(contextPath + "/user/refreshToken")
|| path.startsWith(contextPath + "/public")) {
|| path.startsWith(contextPath + "/public")
|| path.equals(contextPath + HEALTH_ENDPOINT)
|| path.equals(contextPath + VERSION_ENDPOINT)) {
logger.info("Skipping filter for path: " + path);
filterChain.doFilter(servletRequest, servletResponse);
return;
Expand Down
24 changes: 20 additions & 4 deletions src/main/java/com/iemr/admin/utils/config/ConfigProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,27 @@
public static String getPropertyByName(String propertyName) {
String result = null;
try {
if (properties == null) {
initalizeProperties();
// if (properties == null) {

Check warning on line 121 in src/main/java/com/iemr/admin/utils/config/ConfigProperties.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This block of commented-out lines of code should be removed.

See more on https://sonarcloud.io/project/issues?id=PSMRI_Admin-API&issues=AZ5JxXTcBuF9TxiN_MvQ&open=AZ5JxXTcBuF9TxiN_MvQ&pullRequest=132
// initalizeProperties();
// }
// // result = environment.getProperty(propertyName);
// result = properties.getProperty(propertyName);

if (environment != null)
{
result = environment.getProperty(propertyName);
}
if (result == null)
{
if (properties == null)
{
initalizeProperties();
}
result = properties.getProperty(propertyName).trim();
} else
{
result = result.trim();
}
// result = environment.getProperty(propertyName);
result = properties.getProperty(propertyName);
} catch (Exception e) {
logger.error(propertyName + " retrival failed.", e);
}
Expand Down
Loading