Merge branch 'develop' into feature/JDK11
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
This commit is contained in:
@@ -355,11 +355,6 @@
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||
<artifactId>jackson-dataformat-csv</artifactId>
|
||||
@@ -567,7 +562,7 @@
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt-jackson</artifactId>
|
||||
<version>0.11.5</version>
|
||||
<scope>runtime</scope>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!--Expiring Map-->
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
package it.integry.ems.user.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import it.integry.ems_model.annotation.SqlField;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.ALWAYS)
|
||||
public class UserDTO {
|
||||
|
||||
@SqlField("user_name")
|
||||
@@ -26,6 +33,18 @@ public class UserDTO {
|
||||
@SqlField("e_mail")
|
||||
private String email;
|
||||
|
||||
@SqlField("Last_access_datetime")
|
||||
private LocalDateTime lastAccessDatetime;
|
||||
|
||||
@SqlField("password_endtime")
|
||||
private LocalDateTime passwordEndtime;
|
||||
|
||||
@SqlField("cod_lang")
|
||||
private String codLang;
|
||||
|
||||
@SqlField("flag_password_expiring")
|
||||
private Character flagPasswordExpiring;
|
||||
|
||||
@SqlField("is_password_expired")
|
||||
private boolean passwordExpired;
|
||||
|
||||
@@ -44,10 +63,20 @@ public class UserDTO {
|
||||
@SqlField("is_web")
|
||||
private boolean web;
|
||||
|
||||
@SqlField("profile_db")
|
||||
private String profileDb;
|
||||
|
||||
private List<String> availableProfiles;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
@JsonProperty("user_name")
|
||||
public String getUsernameAlias() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public UserDTO setUsername(String username) {
|
||||
this.username = username;
|
||||
return this;
|
||||
@@ -57,6 +86,11 @@ public class UserDTO {
|
||||
return keyGroup;
|
||||
}
|
||||
|
||||
@JsonProperty("key_group")
|
||||
public Integer getKeyGroupAlias() {
|
||||
return keyGroup;
|
||||
}
|
||||
|
||||
public UserDTO setKeyGroup(Integer keyGroup) {
|
||||
this.keyGroup = keyGroup;
|
||||
return this;
|
||||
@@ -66,6 +100,11 @@ public class UserDTO {
|
||||
return fullname;
|
||||
}
|
||||
|
||||
@JsonProperty("full_name")
|
||||
public String getFullnameAlias() {
|
||||
return fullname;
|
||||
}
|
||||
|
||||
public UserDTO setFullname(String fullname) {
|
||||
this.fullname = fullname;
|
||||
return this;
|
||||
@@ -75,11 +114,72 @@ public class UserDTO {
|
||||
return email;
|
||||
}
|
||||
|
||||
@JsonProperty("e_mail")
|
||||
public String getEmailAlias() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public UserDTO setEmail(String email) {
|
||||
this.email = email;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LocalDateTime getLastAccessDatetime() {
|
||||
return lastAccessDatetime;
|
||||
}
|
||||
|
||||
@JsonProperty("Last_access_datetime")
|
||||
public LocalDateTime getLastAccessDatetimeAlias() {
|
||||
return lastAccessDatetime;
|
||||
}
|
||||
|
||||
public UserDTO setLastAccessDatetime(LocalDateTime lastAccessDatetime) {
|
||||
this.lastAccessDatetime = lastAccessDatetime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LocalDateTime getPasswordEndtime() {
|
||||
return passwordEndtime;
|
||||
}
|
||||
|
||||
@JsonProperty("password_endtime")
|
||||
public LocalDateTime getPasswordEndtimeAlias() {
|
||||
return passwordEndtime;
|
||||
}
|
||||
|
||||
public UserDTO setPasswordEndtime(LocalDateTime passwordEndtime) {
|
||||
this.passwordEndtime = passwordEndtime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodLang() {
|
||||
return codLang;
|
||||
}
|
||||
|
||||
@JsonProperty("cod_lang")
|
||||
public String getCodLangAlias() {
|
||||
return codLang;
|
||||
}
|
||||
|
||||
public UserDTO setCodLang(String codLang) {
|
||||
this.codLang = codLang;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Character getFlagPasswordExpiring() {
|
||||
return flagPasswordExpiring;
|
||||
}
|
||||
|
||||
@JsonProperty("flag_password_expiring")
|
||||
public Character getFlagPasswordExpiringAlias() {
|
||||
return flagPasswordExpiring;
|
||||
}
|
||||
|
||||
public UserDTO setFlagPasswordExpiring(Character flagPasswordExpiring) {
|
||||
this.flagPasswordExpiring = flagPasswordExpiring;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isPasswordExpired() {
|
||||
return passwordExpired;
|
||||
}
|
||||
@@ -93,6 +193,11 @@ public class UserDTO {
|
||||
return userCode;
|
||||
}
|
||||
|
||||
@JsonProperty("user_code")
|
||||
public String getUserCodeAlias() {
|
||||
return userCode;
|
||||
}
|
||||
|
||||
public UserDTO setUserCode(String userCode) {
|
||||
this.userCode = userCode;
|
||||
return this;
|
||||
@@ -102,6 +207,11 @@ public class UserDTO {
|
||||
return codMdep;
|
||||
}
|
||||
|
||||
@JsonProperty("cod_mdep")
|
||||
public String getCodMdepAlias() {
|
||||
return codMdep;
|
||||
}
|
||||
|
||||
public UserDTO setCodMdep(String codMdep) {
|
||||
this.codMdep = codMdep;
|
||||
return this;
|
||||
@@ -151,4 +261,31 @@ public class UserDTO {
|
||||
this.passwordHash = passwordHash;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getProfileDb() {
|
||||
return profileDb;
|
||||
}
|
||||
|
||||
@JsonProperty("profile_db")
|
||||
public String getProfileDbAlias() {
|
||||
return profileDb;
|
||||
}
|
||||
|
||||
public UserDTO setProfileDb(String profileDb) {
|
||||
this.profileDb = profileDb;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<String> getAvailableProfiles() {
|
||||
if (availableProfiles == null) {
|
||||
availableProfiles = new ArrayList<>();
|
||||
}
|
||||
|
||||
return availableProfiles;
|
||||
}
|
||||
|
||||
public UserDTO setAvailableProfiles(List<String> availableProfiles) {
|
||||
this.availableProfiles = availableProfiles;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,6 +205,8 @@ public class UserCacheService {
|
||||
" su.e_mail,\n" +
|
||||
" su.last_access_datetime,\n" +
|
||||
" su.password_endtime,\n" +
|
||||
" su.cod_lang,\n" +
|
||||
" su.flag_password_expiring,\n" +
|
||||
" CAST(IIF(su.destruction_datetime IS NOT NULL AND\n" +
|
||||
" DATEDIFF(DAY, su.destruction_datetime, GETDATE()) > 0 AND su.flag_password_expiring = 'S', 1,\n" +
|
||||
" 0) AS BIT) AS is_password_expired,\n" +
|
||||
@@ -212,7 +214,8 @@ public class UserCacheService {
|
||||
" wd.cod_mdep,\n" +
|
||||
" CAST(IIF(ISNULL(su.flag_attivo, 'N') = 'S', 1, 0) AS BIT) AS is_attivo,\n" +
|
||||
" CAST(IIF(su.flag_intra_user = 'S' OR su.flag_dba = 'S', 1, 0) AS BIT) AS is_internal,\n" +
|
||||
" CAST(IIF(su.flag_intra_user = 'S' OR su.flag_extra_user = 'S', 1, 0) AS BIT) AS is_web\n" +
|
||||
" CAST(IIF(su.flag_intra_user = 'S' OR su.flag_extra_user = 'S', 1, 0) AS BIT) AS is_web,\n" +
|
||||
" '" + advancedDataSource.getDataSource().getDbName() + "' AS profile_db\n" +
|
||||
"FROM " + StbUser.ENTITY + " su " +
|
||||
" LEFT OUTER JOIN wtb_clie wc ON su.user_name = wc.user_name\n" +
|
||||
" LEFT OUTER JOIN wtb_depo wd ON su.user_name = wd.user_name\n" +
|
||||
|
||||
@@ -63,8 +63,7 @@ public class AuthController {
|
||||
|
||||
@RequestMapping(value = "/me", method = RequestMethod.GET)
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
public ServiceRestResponse user(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String profileDb) throws Exception {
|
||||
public ServiceRestResponse user(@RequestParam(CommonConstants.PROFILE_DB) String profileDb) {
|
||||
return ServiceRestResponse.createPositiveResponse(authService.getUserDetails());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package it.integry.security.jwt;
|
||||
|
||||
import io.jsonwebtoken.*;
|
||||
import io.jsonwebtoken.jackson.io.JacksonSerializer;
|
||||
import it.integry.ems.json.ResponseJSONObjectMapper;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.security.cache.SecretKeyCacheComponent;
|
||||
@@ -64,6 +65,7 @@ public class AccessTokenProvider implements InitializingBean {
|
||||
.signWith(this.secretKeyCacheComponent.getKey(dbName), SignatureAlgorithm.HS256)
|
||||
.setExpiration(Date.from(Instant.now().plusSeconds(this.getAccessTokenExpiryDurationInSeconds())))
|
||||
.setIssuer(ISSUER)
|
||||
.serializeToJsonWith(new JacksonSerializer<>(jsonObjectMapper))
|
||||
.compact();
|
||||
}
|
||||
|
||||
|
||||
@@ -151,17 +151,15 @@ public class AuthService {
|
||||
}
|
||||
|
||||
|
||||
public StbUser getUserDetails() throws SQLException, IOException, PrimaryDatabaseNotPresentException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
||||
public UserDTO getUserDetails() {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
if (authentication == null || authentication instanceof AnonymousAuthenticationToken) {
|
||||
|
||||
if (!authentication.isAuthenticated()) {
|
||||
throw new NotAuthorizedException("Devi effettuare la login prima di procedere");
|
||||
}
|
||||
final AuthTokenDetails authTokenDetails = (AuthTokenDetails) authentication.getDetails();
|
||||
|
||||
UserDTO userData = authTokenDetails.getUserDTO();
|
||||
AuthTokenDetails authTokenDetails = (AuthTokenDetails) authentication.getDetails();
|
||||
|
||||
String sql = Query.format("SELECT * FROM " + StbUser.ENTITY + " WHERE user_name = {}", userData.getUsername());
|
||||
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), sql, StbUser.class);
|
||||
return authTokenDetails.getUserDTO();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ public class SteUPController {
|
||||
@RequestParam String md5User) {
|
||||
ServiceRestResponse response = new ServiceRestResponse();
|
||||
try {
|
||||
response.setJsonObject(steUPService.complete(activityId, md5User));
|
||||
steUPService.complete(activityId, md5User);
|
||||
response.setEsito(EsitoType.OK);
|
||||
|
||||
} catch (IspezioneCompletataException e) {
|
||||
|
||||
@@ -25,6 +25,7 @@ import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.system.service.SystemService;
|
||||
import it.integry.ems.user.dto.UserDTO;
|
||||
import it.integry.ems.utility.UtilityDebug;
|
||||
import it.integry.ems.utility.UtilityDirs;
|
||||
import it.integry.ems.utility.UtilityFile;
|
||||
@@ -86,10 +87,10 @@ public class SteUPService {
|
||||
|
||||
|
||||
|
||||
private HashMap<String, Object> authUser(String md5User) throws Exception {
|
||||
HashMap<String, Object> loggedUser = authUserFromRequest(md5User);
|
||||
private UserDTO authUser(String md5User) throws Exception {
|
||||
UserDTO loggedUser = authUserFromRequest(md5User);
|
||||
if (loggedUser != null) {
|
||||
int keyGroup = Integer.parseInt(loggedUser.get("key_group").toString());
|
||||
int keyGroup = Integer.parseInt(loggedUser.getKeyGroup().toString());
|
||||
if (!(this.isGroupRilevatore(keyGroup) || this.isGroupTecnico(keyGroup))) {
|
||||
throw new Exception("Tipo utente non abilitato");
|
||||
}
|
||||
@@ -97,7 +98,7 @@ public class SteUPService {
|
||||
return loggedUser;
|
||||
}
|
||||
|
||||
private HashMap<String, Object> authUserFromRequest(String md5User) throws Exception {
|
||||
private UserDTO authUserFromRequest(String md5User) throws Exception {
|
||||
String userName = requestDataDTO.getUsername();
|
||||
String password = requestDataDTO.getPassword();
|
||||
String profileDB = requestDataDTO.getProfileDB();
|
||||
@@ -128,13 +129,13 @@ public class SteUPService {
|
||||
public HashMap<String, Object> login(String profileDb, String md5User) throws Exception {
|
||||
HashMap<String, Object> toReturn = new HashMap<>();
|
||||
|
||||
HashMap<String, Object> loggedUser = this.authUser(md5User);
|
||||
String userName = loggedUser.get("user_name").toString();
|
||||
Integer keyGroup = Integer.valueOf(loggedUser.get("key_group").toString());
|
||||
UserDTO loggedUser = this.authUser(md5User);
|
||||
String userName = loggedUser.getUsername();
|
||||
Integer keyGroup = Integer.valueOf(loggedUser.getKeyGroup().toString());
|
||||
|
||||
HashMap<String, Object> userData = new HashMap<>();
|
||||
userData.put("full_name", loggedUser.get("full_name").toString());
|
||||
userData.put("profile_db", loggedUser.get("profile_db").toString());
|
||||
userData.put("full_name", loggedUser.getFullname());
|
||||
userData.put("profile_db", loggedUser.getProfileDb());
|
||||
userData.put("key_group", keyGroup);
|
||||
toReturn.put("user", userData);
|
||||
|
||||
@@ -285,9 +286,9 @@ public class SteUPService {
|
||||
|
||||
public void setIndiceGradimento(String activityId, String codJfas, Integer indiceGradimento) throws Exception {
|
||||
Integer maxValue = 10;
|
||||
HashMap<String, Object> loggedUser = this.authUserFromRequest(null);
|
||||
String userName = loggedUser.get("user_name").toString();
|
||||
int keyGroup = Integer.parseInt(loggedUser.get("key_group").toString());
|
||||
UserDTO loggedUser = this.authUserFromRequest(null);
|
||||
String userName = loggedUser.getUsername();
|
||||
int keyGroup = Integer.parseInt(loggedUser.getKeyGroup().toString());
|
||||
|
||||
HashMap<String, Object> ispezione = this.getDatiIspezione(activityId);
|
||||
String userNameRilevatore = ispezione.get("user_creator").toString();
|
||||
@@ -328,10 +329,8 @@ public class SteUPService {
|
||||
}
|
||||
}
|
||||
|
||||
public HashMap<String, Object> complete(String activityId, String md5User) throws Exception {
|
||||
HashMap<String, Object> toReturn = new HashMap<>();
|
||||
|
||||
HashMap<String, Object> loggedUser;
|
||||
public void complete(String activityId, String md5User) throws Exception {
|
||||
UserDTO loggedUser;
|
||||
if (UtilityString.nullIfBlank(md5User) != null) { // RICHIESTA DA APP
|
||||
loggedUser = this.authUser(md5User);
|
||||
|
||||
@@ -339,8 +338,8 @@ public class SteUPService {
|
||||
loggedUser = this.authUserFromRequest(null);
|
||||
}
|
||||
|
||||
String userName = loggedUser.get("user_name").toString();
|
||||
int keyGroup = Integer.parseInt(loggedUser.get("key_group").toString());
|
||||
String userName = loggedUser.getUsername();
|
||||
int keyGroup = Integer.parseInt(loggedUser.getKeyGroup().toString());
|
||||
|
||||
HashMap<String, Object> ispezione = this.getDatiIspezione(activityId);
|
||||
String userNameRilevatore = ispezione.get("user_creator").toString();
|
||||
@@ -371,7 +370,6 @@ public class SteUPService {
|
||||
} else {
|
||||
throw new Exception("Utente non valido");
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
private String getEmailPv(String userNamePv) throws Exception {
|
||||
@@ -463,8 +461,8 @@ public class SteUPService {
|
||||
|
||||
if (UtilityString.isNullOrEmpty(activityTypeId))
|
||||
throw new Exception("Motivazione attività non presente");
|
||||
HashMap<String, Object> loggedUser = this.authUser(md5User);
|
||||
String userNameCreator = loggedUser.get("user_name").toString();
|
||||
UserDTO loggedUser = this.authUser(md5User);
|
||||
String userNameCreator = loggedUser.getUsername();
|
||||
String userNamePv = this.getUserNamePv(codMdep);
|
||||
boolean flag_isNewIspezione = false;
|
||||
LocalDate now = UtilityLocalDate.getNow();
|
||||
|
||||
@@ -9,6 +9,7 @@ import it.integry.ems.order.ordify.dto.OrdifySospesoDTO;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.system.service.SystemService;
|
||||
import it.integry.ems.user.dto.UserDTO;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.entity.CtbPart;
|
||||
import it.integry.ems_model.entity.WdtbNewCliOrd;
|
||||
@@ -46,11 +47,11 @@ public class OrdifyService {
|
||||
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
|
||||
private HashMap<String, Object> authMd5User(String md5User) throws Exception {
|
||||
private UserDTO authMd5User(String md5User) throws Exception {
|
||||
String profileDB = multiDBTransactionManager.getPrimaryDatasource().getProfile();
|
||||
HashMap<String, Object> userInfo = systemService.login("", "", md5User, profileDB);
|
||||
UserDTO userInfo = systemService.login("", "", md5User, profileDB);
|
||||
if (userInfo != null) {
|
||||
int keyGroup = Integer.parseInt(userInfo.get("key_group").toString());
|
||||
int keyGroup = Integer.parseInt(userInfo.getKeyGroup().toString());
|
||||
if (!(this.isGroupAgenti(keyGroup) || this.isGroupIspettori(keyGroup) || this.isGroupClienti(keyGroup))) {
|
||||
throw new Exception("Tipo utente non abilitato");
|
||||
}
|
||||
@@ -76,12 +77,12 @@ public class OrdifyService {
|
||||
public List<HashMap<String, Object>> importOrdini(String md5User, final OrdifyOrdineDTO[] ordiniList) throws Exception {
|
||||
List<HashMap<String, Object>> returnList = new ArrayList<>();
|
||||
try {
|
||||
HashMap<String, Object> userInfo = this.authMd5User(md5User);
|
||||
String userName = userInfo.get("user_name").toString();
|
||||
String fullName = userInfo.get("full_name").toString();
|
||||
String codVage = userInfo.get("user_code").toString();
|
||||
UserDTO userInfo = this.authMd5User(md5User);
|
||||
String userName = userInfo.getUsername();
|
||||
String fullName = userInfo.getFullname();
|
||||
String codVage = userInfo.getUserCode();
|
||||
String flagElaborato = "N";
|
||||
int keyGroup = Integer.parseInt(userInfo.get("key_group").toString());
|
||||
int keyGroup = Integer.parseInt(userInfo.getKeyGroup().toString());
|
||||
|
||||
if (codVage == null && keyGroup == AGENTI.getValue()) {
|
||||
throw new Exception("Agente non pervenuto");
|
||||
@@ -275,9 +276,6 @@ public class OrdifyService {
|
||||
}
|
||||
|
||||
public Object paymentOnDelivery(String md5User, OrdifySospesoDTO docSospeso) throws Exception {
|
||||
|
||||
HashMap<String, Object> userInfo = this.authMd5User(md5User);
|
||||
|
||||
Calendar dataDoc = Calendar.getInstance();
|
||||
dataDoc.setTime(docSospeso.getDataDocAsDate());
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.system.service.SystemService;
|
||||
import it.integry.ems.user.UserSession;
|
||||
import it.integry.ems.user.dto.UserDTO;
|
||||
import it.integry.ems.utility.UtilityEntity;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.coollection.Coollection;
|
||||
@@ -118,9 +119,9 @@ public class PvmService {
|
||||
|
||||
public List<OrdChkConsDTO> chkDisponibilitaCons(Date dataCons, String citta) throws Exception {
|
||||
String profileDb = null;
|
||||
HashMap<String, Object> userData = systemService.login(requestDataDTO.getUsername(), requestDataDTO.getPassword(), "", profileDb);
|
||||
UserDTO userData = systemService.login(requestDataDTO.getUsername(), requestDataDTO.getPassword(), "", profileDb);
|
||||
|
||||
profileDb = (String) userData.get("profile_db");
|
||||
profileDb = userData.getProfileDb();
|
||||
multiDBTransactionManager.addConnection(profileDb);
|
||||
Connection conn = multiDBTransactionManager.getDatabaseDataSource(profileDb).getConnection();
|
||||
|
||||
|
||||
@@ -248,7 +248,7 @@ public class SystemService {
|
||||
String md5User = xPath.compile("//MD5_USER").evaluate(params);
|
||||
String profileDB = xPath.compile("//PROFILE_DB").evaluate(params);
|
||||
|
||||
HashMap<String, Object> userData = this.login(username, password, md5User, profileDB);
|
||||
UserDTO userData = this.login(username, password, md5User, profileDB);
|
||||
|
||||
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
|
||||
@@ -261,32 +261,32 @@ public class SystemService {
|
||||
rootElement.appendChild(user);
|
||||
|
||||
Attr attrcodMart = doc.createAttribute("USER_NAME");
|
||||
Object value = userData.get("user_name");
|
||||
Object value = userData.getUsername();
|
||||
attrcodMart.setValue(value == null ? "" : value.toString());
|
||||
user.setAttributeNode(attrcodMart);
|
||||
|
||||
Element node = doc.createElement("KEY_GROUP");
|
||||
value = userData.get("key_group");
|
||||
value = userData.getKeyGroup();
|
||||
node.setTextContent(value == null ? "" : value.toString());
|
||||
user.appendChild(node);
|
||||
|
||||
node = doc.createElement("FULL_NAME");
|
||||
value = userData.get("full_name");
|
||||
value = userData.getFullname();
|
||||
node.setTextContent(value == null ? "" : value.toString());
|
||||
user.appendChild(node);
|
||||
|
||||
node = doc.createElement("USER_CODE");
|
||||
value = userData.get("user_code");
|
||||
value = userData.getUserCode();
|
||||
node.setTextContent(value == null ? "" : value.toString());
|
||||
user.appendChild(node);
|
||||
|
||||
node = doc.createElement("COD_MDEP");
|
||||
value = userData.get("cod_mdep");
|
||||
value = userData.getCodMdep();
|
||||
node.setTextContent(value == null ? "" : value.toString());
|
||||
user.appendChild(node);
|
||||
|
||||
node = doc.createElement("PROFILE_DB");
|
||||
value = userData.get("profile_db");
|
||||
value = userData.getProfileDb();
|
||||
node.setTextContent(value == null ? "" : value.toString());
|
||||
user.appendChild(node);
|
||||
|
||||
@@ -301,48 +301,20 @@ public class SystemService {
|
||||
return false;
|
||||
}
|
||||
|
||||
public HashMap<String, Object> login(String username, String password, String md5User, String profileDB) throws Exception {
|
||||
HashMap<String, Object> userData = null;
|
||||
public UserDTO login(String username, String password, String md5User, String profileDB) throws Exception {
|
||||
UserDTO foundUser = null;
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(profileDB)) { // SELEZIONE DB DIRETTO
|
||||
String dbName = settingsModel.getDbNameFromProfileDb(profileDB);
|
||||
UserDTO foundUser = null;
|
||||
|
||||
//MD5 utilizzato da Ordify
|
||||
if (UtilityString.isNullOrEmpty(password) && !UtilityString.isNullOrEmpty(md5User)) {
|
||||
foundUser = userCacheService.retrieveUser(dbName, md5User);
|
||||
} else
|
||||
} else {
|
||||
foundUser = userCacheService.retrieveUser(dbName, username, password, requestDataDTO.getApplication());
|
||||
|
||||
if (foundUser != null && foundUser.isAttivo()) {
|
||||
String sql = Query.format("SELECT * FROM " + StbUser.ENTITY + " WHERE user_name = {}", foundUser.getUsername());
|
||||
StbUser stbUser;
|
||||
try (MultiDBTransactionManager mdb = new MultiDBTransactionManager(profileDB)) {
|
||||
stbUser = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(mdb.getPrimaryConnection(), sql, StbUser.class);
|
||||
}
|
||||
|
||||
StbUser finalStbUser = stbUser;
|
||||
UserDTO finalFoundUser = foundUser;
|
||||
userData = new HashMap<String, Object>() {{
|
||||
put("flag_attivo", finalFoundUser.isAttivo() ? "S" : "N");
|
||||
put("user_name", finalFoundUser.getUsername());
|
||||
put("fullName", finalFoundUser.getFullname());
|
||||
put("full_name", finalFoundUser.getFullname());
|
||||
put("cod_lang", finalStbUser.getCodLang());
|
||||
put("cod_mdep", finalFoundUser.getCodMdep());
|
||||
put("profile_db", profileDB);
|
||||
put("password_endtime", finalStbUser.getPasswordEndtime());
|
||||
put("user_code", finalFoundUser.getUserCode());
|
||||
put("e_mail", finalFoundUser.getEmail());
|
||||
put("flag_password_expiring", finalStbUser.getFlagPasswordExpiring());
|
||||
put("Last_access_datetime", finalStbUser.getLastAccessDatetime());
|
||||
put("key_group", finalFoundUser.getKeyGroup());
|
||||
}};
|
||||
}
|
||||
} else {
|
||||
|
||||
List<String> profiles = null;
|
||||
profiles = userCacheService.retrieveProfilesOfUser(username, password, requestDataDTO.getApplication());
|
||||
List<String> profiles = userCacheService.retrieveProfilesOfUser(username, password, requestDataDTO.getApplication());
|
||||
|
||||
if (profiles.isEmpty()) {
|
||||
// SELEZIONE CICLICA IN TUTTI I DB SPECIFICATI
|
||||
@@ -359,11 +331,9 @@ public class SystemService {
|
||||
.toList();
|
||||
}
|
||||
|
||||
List<String> profilesWhereUserFound = new ArrayList<>();
|
||||
for (String profile : profiles) {
|
||||
String dbName = settingsModel.getDbNameFromProfileDb(profile);
|
||||
|
||||
UserDTO foundUser = null;
|
||||
//MD5 utilizzato da Ordikids
|
||||
if (UtilityString.isNullOrEmpty(password) && !UtilityString.isNullOrEmpty(md5User)) {
|
||||
foundUser = userCacheService.retrieveUser(dbName, md5User);
|
||||
@@ -373,58 +343,30 @@ public class SystemService {
|
||||
if (foundUser == null || !foundUser.isAttivo())
|
||||
continue;
|
||||
|
||||
profilesWhereUserFound.add(profile);
|
||||
|
||||
String sql = Query.format("SELECT * FROM " + StbUser.ENTITY + " WHERE user_name = {}", foundUser.getUsername());
|
||||
StbUser stbUser;
|
||||
try (MultiDBTransactionManager mdb = new MultiDBTransactionManager(profile)) {
|
||||
stbUser = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(mdb.getPrimaryConnection(), sql, StbUser.class);
|
||||
if (!foundUser.getAvailableProfiles().contains(profile)) {
|
||||
foundUser.getAvailableProfiles().add(profile);
|
||||
}
|
||||
|
||||
StbUser finalStbUser = stbUser;
|
||||
UserDTO finalFoundUser = foundUser;
|
||||
userData = new HashMap<String, Object>() {{
|
||||
put("flag_attivo", finalFoundUser.isAttivo() ? "S" : "N");
|
||||
put("user_name", finalFoundUser.getUsername());
|
||||
put("fullName", finalFoundUser.getFullname());
|
||||
put("full_name", finalFoundUser.getFullname());
|
||||
put("cod_lang", finalStbUser.getCodLang());
|
||||
put("cod_mdep", finalFoundUser.getCodMdep());
|
||||
put("profile_db", profile);
|
||||
put("password_endtime", finalStbUser.getPasswordEndtime());
|
||||
put("user_code", finalFoundUser.getUserCode());
|
||||
put("e_mail", finalFoundUser.getEmail());
|
||||
put("flag_password_expiring", finalStbUser.getFlagPasswordExpiring());
|
||||
put("Last_access_datetime", finalStbUser.getLastAccessDatetime());
|
||||
put("key_group", finalFoundUser.getKeyGroup());
|
||||
|
||||
}};
|
||||
|
||||
}
|
||||
|
||||
if (userData != null) {
|
||||
userData.put("availableProfiles", profilesWhereUserFound);
|
||||
}
|
||||
}
|
||||
|
||||
if (userData == null) {
|
||||
if (foundUser == null) {
|
||||
throw new Exception("Credenziali non valide");
|
||||
|
||||
} else if (!this.isUtenteAttivo(userData)) {
|
||||
} else if (!foundUser.isAttivo()) {
|
||||
throw new Exception("Utente non attivo");
|
||||
|
||||
} else {
|
||||
StbUser stbUser = new StbUser();
|
||||
|
||||
stbUser.setOperation(OperationType.UPDATE);
|
||||
stbUser.setUserName((String) userData.get("user_name"));
|
||||
stbUser.setUserName(foundUser.getUsername());
|
||||
stbUser.setLastAccessDatetime(UtilityLocalDate.getNowTime());
|
||||
multiDBTransactionManager.setPrimaryDs((String) userData.get("profile_db"));
|
||||
requestDataDTO.setUsername((String) userData.get("user_name"));
|
||||
|
||||
multiDBTransactionManager.setPrimaryDs(foundUser.getProfileDb());
|
||||
requestDataDTO.setUsername(foundUser.getUsername());
|
||||
entityProcessor.processEntity(stbUser, true, multiDBTransactionManager);
|
||||
multiDBTransactionManager.commitAll();
|
||||
}
|
||||
|
||||
return userData;
|
||||
return foundUser;
|
||||
}
|
||||
|
||||
public List<UserWPasswordDTO> getActiveUsers() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user