Commit c15a4c88 authored by Portal User's avatar Portal User
Browse files

Initial commit

parent 30f098c3
/target/
.classpath
.settings
.project
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ib</groupId>
<artifactId>EuroAct</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>EuroAct Maven Webapp</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<war.filename>EuroAct</war.filename>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<build.timestamp>${maven.build.timestamp}</build.timestamp>
<maven.build.timestamp.format>ddMMYY(HH:mm)</maven.build.timestamp.format>
<poi.version>5.0.0</poi.version>
<open-pdf.version>1.3.24</open-pdf.version>
</properties>
<profiles>
<profile>
<id>development</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<kg.datasource>euroactDSLocal</kg.datasource>
</properties>
</profile>
<profile>
<id>production</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<kg.excludedResources>/WEB-INF/euroact-ds.xml</kg.excludedResources>
<kg.datasource>euroactDS</kg.datasource>
</properties>
</profile>
</profiles>
<repositories>
<repository>
<id>prime-repo</id>
<name>PrimeFaces Maven Repository</name>
<url>http://repository.primefaces.org</url>
<layout>default</layout>
</repository>
<repository>
<id>AsposeJavaAPI</id>
<name>Aspose Java API</name>
<url>https://repository.aspose.com/repo/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.ib.system</groupId>
<artifactId>SystemX</artifactId>
<version>0.1</version>
<!-- <scope>compile</scope>
<type>jar</type> -->
<scope>system</scope>
<systemPath>${project.basedir}/src/main/webapp/WEB-INF/lib/SystemX-0.1.jar</systemPath>
</dependency>
<dependency>
<groupId>com.ib.indexui</groupId>
<artifactId>IndexUIx</artifactId>
<version>0.1</version>
<!-- <scope>compile</scope>
<type>jar</type> -->
<scope>system</scope>
<systemPath>${project.basedir}/src/main/webapp/WEB-INF/lib/IndexUIx-0.1.jar</systemPath>
</dependency>
<dependency>
<groupId>com.oracle.ojdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>19.3.0.0</version>
<exclusions>
<!-- Additional jar required to access Oracle Wallets from Java -->
<exclusion>
<groupId>com.oracle.ojdbc</groupId>
<artifactId>oraclepki</artifactId>
</exclusion>
<exclusion>
<groupId>com.oracle.ojdbc</groupId>
<artifactId>osdt_cert</artifactId>
</exclusion>
<exclusion>
<groupId>com.oracle.ojdbc</groupId>
<artifactId>osdt_core</artifactId>
</exclusion>
<!-- Java APIs for subscribing to RAC events via ONS; simplefan policy
and javadoc -->
<exclusion>
<groupId>com.oracle.ojdbc</groupId>
<artifactId>simplefan</artifactId>
</exclusion>
<!-- For use by the pure Java client-side Oracle Notification Services
(ONS) daemon -->
<exclusion>
<groupId>com.oracle.ojdbc</groupId>
<artifactId>ons</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.oracle.database.nls</groupId>
<artifactId>orai18n</artifactId>
<version>19.3.0.0</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>8.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.4.10.Final</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search-orm</artifactId>
<version>5.11.5.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search-elasticsearch</artifactId>
<version>5.11.5.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.26</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>10.0.7</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/webapp/WEB-INF/lib/primefaces-10.0.7.jar</systemPath>
</dependency>
<dependency>
<groupId>org.primefaces.extensions</groupId>
<artifactId>primefaces-extensions</artifactId>
<version>10.0.7</version>
<exclusions>
<exclusion> <!-- това не ни трябва -->
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</exclusion>
<exclusion> <!-- това ще се вземе от wildfly -->
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</exclusion>
<exclusion>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Data Exporter -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>${poi.version}</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>${poi.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>batik-all</artifactId>
</exclusion>
<exclusion>
<groupId>de.rototor.pdfbox</groupId>
<artifactId>graphics2d</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.santuario</groupId>
<artifactId>xmlsec</artifactId>
</exclusion>
<exclusion>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
</exclusion>
<exclusion>
<groupId>com.github.virtuald</groupId>
<artifactId>curvesapi</artifactId>
</exclusion>
<exclusion>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.github.librepdf</groupId>
<artifactId>openpdf</artifactId>
<version>${open-pdf.version}</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itext7-core</artifactId>
<version>7.1.12</version>
<type>pom</type>
<exclusions>
<exclusion>
<groupId>com.itextpdf</groupId>
<artifactId>font-asian</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>2.1.7</version>
<exclusions>
<exclusion>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk14</artifactId>
</exclusion>
<exclusion>
<groupId>org.bouncycastle</groupId>
<artifactId>bcmail-jdk14</artifactId>
</exclusion>
<exclusion>
<groupId>org.bouncycastle</groupId>
<artifactId>bctsp-jdk14</artifactId>
</exclusion>
<exclusion>
<groupId>bouncycastle</groupId>
<artifactId>bcmail-jdk14</artifactId>
</exclusion>
<exclusion>
<groupId>bouncycastle</groupId>
<artifactId>bcprov-jdk14</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.17</version>
</dependency>
-->
<dependency>
<groupId>org.primefaces.extensions</groupId>
<artifactId>all-themes</artifactId>
<version>1.0.8</version>
<exclusions>
<exclusion>
<groupId>org.primefaces.themes</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.omnifaces</groupId>
<artifactId>omnifaces</artifactId>
<version>3.11.2</version>
</dependency>
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-words</artifactId>
<version>20.8</version>
<classifier>jdk17</classifier>
<exclusions>
<exclusion>
<groupId>org.jogamp.jogl</groupId>
<artifactId>jogl-all-main</artifactId>
</exclusion>
<exclusion>
<groupId>org.jogamp.gluegen</groupId>
<artifactId>gluegen-rt-main</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.199</version>
<scope>compile</scope>
<!-- <scope>test</scope> само докато се разработва, защото като се използва
кеша от сървъра и има повече системни се смесват данните -->
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.6.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/net.lingala.zip4j/zip4j -->
<dependency>
<groupId>net.lingala.zip4j</groupId>
<artifactId>zip4j</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.2.10</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- <dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2.11</version>
</dependency> -->
</dependencies>
<build>
<finalName>${war.filename}</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<pluginManagement><!-- lock down plugins versions to avoid using Maven
defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<webResources>
<resource>
<!-- за да се сетнат нещата свързани с дейтасорсовете от ${prop.file}
в случая се сетва и името на вара в дейта сорса когато е в девелопмент режим -->
<directory>src/main/webapp</directory>
<include>**/euroact-ds.xml</include>
<filtering>true</filtering>
</resource>
<resource>
<!-- за да се сетне билд версията -->
<directory>src/main/webapp</directory>
<include>**/main.xhtml</include>
<filtering>true</filtering>
</resource>
</webResources>
<packagingExcludes>WEB-INF/classes/jboss-log4j.xml,${kg.excludedResources}
</packagingExcludes>
</configuration>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
package com.ib.euroact.auth;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.TreeSet;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.servlet.ServletContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ib.euroact.db.dao.AdmUsersDAO;
import com.ib.euroact.db.dto.AdmUsers;
import com.ib.euroact.system.EuroConstants;
import com.ib.euroact.system.SystemData;
import com.ib.euroact.system.UserData;
import com.ib.system.ActiveUser;
import com.ib.system.BaseUserData;
import com.ib.system.auth.DBCredential;
import com.ib.system.auth.EAuthCredential;
import com.ib.system.auth.IBIdentityStore;
import com.ib.system.db.JPA;
import com.ib.system.db.dto.SystemClassif;
import com.ib.system.exceptions.AuthenticationException;
import com.ib.system.exceptions.DbErrorException;
import com.ib.system.utils.SysClassifUtils;
/**
* Основния клас за логване на птребител!!! Цялата идея в в Java Securoty-to JAAS
*
* see com.ib.cc.config.ApplicationConfig
*
* @author krasi
*
*/
@ApplicationScoped
public class EuroActIdentityStore extends IBIdentityStore {
static final Logger LOGGER = LoggerFactory.getLogger(EuroActIdentityStore.class);
SystemData systemData=null;
@Inject
private ServletContext servletContext;
@Override
protected Optional<BaseUserData> findUserDB(DBCredential credential) throws AuthenticationException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("findUser(String userName=" + credential.getCaller() + ", String password=" + credential.getPasswordAsString()
+" - start");
}
// Правим проверка за коректност на входните параметри !
if (credential== null ||credential.getCaller() == null || credential.getPasswordAsString() == null)
throw new AuthenticationException(AuthenticationException.CODE_USER_UNKNOWN,1);
// Временна променлива, с която ще работим
AdmUsers tempUser = null;
String username = credential.getCaller();
String password = credential.getPasswordAsString();
AdmUsersDAO userDAO = new AdmUsersDAO(ActiveUser.DEFAULT);
UserData userData=null ;
try {
// String isHasheActive = sd.getSettingsValue("isHashingActive");
// LOGGER.info("isHasheActive="+isHasheActive);
tempUser = userDAO.validateUser(username, password);
if (tempUser != null) {
userData=loadUserData(tempUser, null);
}else {
throw new AuthenticationException(AuthenticationException.CODE_USER_UNKNOWN,1);
}
} catch (DbErrorException e) {
LOGGER.error(e.getMessage(), e);
throw new AuthenticationException("Грешка при извличане на обект от БД", -1);
} catch (AuthenticationException e) {
LOGGER.error(e.getMessage(), e);
throw e;
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
throw new AuthenticationException("Неочаквана грешка !", -1);
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("findUser(String userName=" + credential.getCaller() + ", String password=" + credential.getPasswordAsString()
+" - end");
}
if (userData!=null) {
return Optional.of(userData);
}else {
return Optional.empty();
}
}
@Override
protected Optional<BaseUserData> findUserEAuth(EAuthCredential credential) throws AuthenticationException {
EAuthCredential eAuthCredential = credential;
try {
AdmUsers admUser = JPA.getUtil().getEntityManager().find(AdmUsers.class, eAuthCredential.getUserId());
return Optional.of(loadUserData(admUser, null));
} catch (DbErrorException e) {
throw new AuthenticationException(1, eAuthCredential.getUserId());
}
}
public UserData loadUserData(AdmUsers user, Long lang) throws DbErrorException {
if (user == null) {
return null;
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("loadUserData - start");
}
AdmUsersDAO dao = new AdmUsersDAO(ActiveUser.DEFAULT);
if (lang == null){
lang = Long.valueOf(EuroConstants.CODE_DEFAULT_LANG);
}
String names = "";
if (user.getIme() != null) {
names += user.getIme();
}
if (user.getPrezime() != null) {
names += " " + user.getPrezime();
}
if (user.getFamilia() != null) {
names += " " + user.getFamilia();
}
names = names.trim();
UserData userData = new UserData(user.getId(), user.getLogin_name(), names);
TreeSet<Integer> tmpRolesAsSet = dao.loadUserRolesNew(user.getId(), getSystemData());
List<SystemClassif> modules = new ArrayList<SystemClassif>();
/*************************************************
* 3.Сега ще добавим всички деца и всички родители на всеки избран код
*/
TreeSet<Integer> allRolesAsSet = new TreeSet<Integer>();
List<SystemClassif> classif = getSystemData().getSysClassification(EuroConstants.CODE_SYSCLASS_MENU, new Date(), lang.intValue());
for (Integer role : tmpRolesAsSet) {
if (allRolesAsSet.contains(role.intValue())) {
continue;
}
allRolesAsSet.add(role.intValue());
SystemClassif curItem = null;
for (SystemClassif tekItem : classif) {
if (tekItem.getCode() == role.intValue()) {
</