Compare commits
196 Commits
multitenan
...
master
@ -0,0 +1,79 @@
|
||||
Certificate:
|
||||
Data:
|
||||
Version: 3 (0x2)
|
||||
Serial Number: 16464111046498525641 (0xe47c45c4252121c9)
|
||||
Signature Algorithm: sha1WithRSAEncryption
|
||||
Issuer: C=CZ, ST=Vysocina, O=bukova.info, CN=Josef Rokos/emailAddress=rokos@bukova.info
|
||||
Validity
|
||||
Not Before: Jun 24 09:59:50 2015 GMT
|
||||
Not After : Jun 21 09:59:50 2025 GMT
|
||||
Subject: C=CZ, ST=Vysocina, O=bukova.info, CN=Josef Rokos/emailAddress=rokos@bukova.info
|
||||
Subject Public Key Info:
|
||||
Public Key Algorithm: rsaEncryption
|
||||
Public-Key: (2048 bit)
|
||||
Modulus:
|
||||
00:bc:fb:64:50:5b:58:03:8c:20:1c:77:d3:50:31:
|
||||
94:55:78:d6:05:bb:bc:88:9d:cb:20:b1:8c:ff:ac:
|
||||
fc:97:1a:b1:9c:29:c4:ac:af:ed:3b:de:93:d5:cf:
|
||||
75:3e:d0:05:41:32:bf:12:25:53:60:28:af:ff:3e:
|
||||
3c:3a:4c:52:78:3f:b2:78:b9:c6:2f:fc:0e:44:eb:
|
||||
65:c3:7f:38:2b:ab:88:37:8c:68:55:69:e3:3d:5e:
|
||||
9b:99:25:11:55:06:ab:e8:c1:fa:54:da:5b:e7:9b:
|
||||
3e:3f:39:4f:cf:b3:cb:48:cf:96:02:89:0b:7e:24:
|
||||
c7:00:e9:ce:8d:ea:07:cf:21:f2:89:51:c8:cc:7a:
|
||||
04:e4:68:6f:1c:a8:e0:76:18:40:62:ee:2f:bd:13:
|
||||
64:b7:1e:2e:18:bb:b1:d4:17:d5:fb:1f:07:59:65:
|
||||
46:f0:c4:51:dc:ac:62:ff:31:a8:72:26:a6:1a:88:
|
||||
37:23:82:49:9a:02:d2:39:74:98:71:7f:a4:77:52:
|
||||
3a:ed:22:2e:99:9c:81:2c:48:16:3c:82:7b:af:2c:
|
||||
0d:4b:28:4d:e0:46:7d:b5:b8:ea:3f:e7:5a:5b:4f:
|
||||
d8:06:b2:a3:86:2f:8b:5b:9c:bc:04:2e:64:b6:e1:
|
||||
09:c9:14:6d:54:7e:86:40:7b:66:33:27:33:4a:3d:
|
||||
7c:97
|
||||
Exponent: 65537 (0x10001)
|
||||
X509v3 extensions:
|
||||
X509v3 Subject Key Identifier:
|
||||
EF:9B:88:5C:07:27:79:EA:60:90:5C:7A:28:45:FB:7F:35:E6:CB:3F
|
||||
X509v3 Authority Key Identifier:
|
||||
keyid:EF:9B:88:5C:07:27:79:EA:60:90:5C:7A:28:45:FB:7F:35:E6:CB:3F
|
||||
|
||||
X509v3 Basic Constraints:
|
||||
CA:TRUE
|
||||
Signature Algorithm: sha1WithRSAEncryption
|
||||
08:e9:a4:32:cc:35:7c:66:5a:ea:f2:bd:e6:75:78:81:52:11:
|
||||
22:27:32:c9:ec:91:6e:51:8a:f1:1e:0f:25:8a:e1:64:ba:e4:
|
||||
85:1c:e4:fd:75:f0:26:3d:65:62:16:29:20:4f:5f:d2:66:36:
|
||||
de:2b:bd:7b:96:71:f6:2c:d1:c5:54:69:89:dd:52:20:49:49:
|
||||
b1:ac:09:b4:1e:33:59:0d:89:fd:a4:28:7a:70:96:e5:cb:58:
|
||||
7e:b9:1d:02:7a:33:ee:ad:6a:ad:2c:3c:5e:7d:cc:f5:72:69:
|
||||
51:fd:77:b4:0f:10:fd:9e:c2:1a:04:c5:a9:56:6e:fd:66:9f:
|
||||
b6:1c:f9:d3:68:f4:4f:8c:6c:67:af:f5:e0:a5:30:67:a6:a7:
|
||||
9b:6e:16:89:8a:e5:b4:20:f4:f7:74:f4:9c:ca:5d:c7:2f:e6:
|
||||
30:9d:6b:2e:95:29:c1:e7:aa:d7:d6:59:dc:a9:f0:10:40:02:
|
||||
66:3f:58:a2:38:8c:89:1a:0b:94:1a:e5:80:49:14:44:f4:06:
|
||||
b1:11:1a:cd:ef:76:6a:bf:f8:6f:58:9d:af:a3:6b:9a:8e:bb:
|
||||
6c:10:d6:d8:4e:73:58:20:0b:99:38:41:d4:22:d4:80:0b:09:
|
||||
0d:25:40:3e:66:15:a0:44:4e:d6:59:5a:58:07:e5:4b:62:f1:
|
||||
e9:ae:b6:7c
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDrzCCApegAwIBAgIJAOR8RcQlISHJMA0GCSqGSIb3DQEBBQUAMG4xCzAJBgNV
|
||||
BAYTAkNaMREwDwYDVQQIDAhWeXNvY2luYTEUMBIGA1UECgwLYnVrb3ZhLmluZm8x
|
||||
FDASBgNVBAMMC0pvc2VmIFJva29zMSAwHgYJKoZIhvcNAQkBFhFyb2tvc0BidWtv
|
||||
dmEuaW5mbzAeFw0xNTA2MjQwOTU5NTBaFw0yNTA2MjEwOTU5NTBaMG4xCzAJBgNV
|
||||
BAYTAkNaMREwDwYDVQQIDAhWeXNvY2luYTEUMBIGA1UECgwLYnVrb3ZhLmluZm8x
|
||||
FDASBgNVBAMMC0pvc2VmIFJva29zMSAwHgYJKoZIhvcNAQkBFhFyb2tvc0BidWtv
|
||||
dmEuaW5mbzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALz7ZFBbWAOM
|
||||
IBx301AxlFV41gW7vIidyyCxjP+s/JcasZwpxKyv7Tvek9XPdT7QBUEyvxIlU2Ao
|
||||
r/8+PDpMUng/sni5xi/8DkTrZcN/OCuriDeMaFVp4z1em5klEVUGq+jB+lTaW+eb
|
||||
Pj85T8+zy0jPlgKJC34kxwDpzo3qB88h8olRyMx6BORobxyo4HYYQGLuL70TZLce
|
||||
Lhi7sdQX1fsfB1llRvDEUdysYv8xqHImphqINyOCSZoC0jl0mHF/pHdSOu0iLpmc
|
||||
gSxIFjyCe68sDUsoTeBGfbW46j/nWltP2Aayo4Yvi1ucvAQuZLbhCckUbVR+hkB7
|
||||
ZjMnM0o9fJcCAwEAAaNQME4wHQYDVR0OBBYEFO+biFwHJ3nqYJBceihF+3815ss/
|
||||
MB8GA1UdIwQYMBaAFO+biFwHJ3nqYJBceihF+3815ss/MAwGA1UdEwQFMAMBAf8w
|
||||
DQYJKoZIhvcNAQEFBQADggEBAAjppDLMNXxmWuryveZ1eIFSESInMsnskW5RivEe
|
||||
DyWK4WS65IUc5P118CY9ZWIWKSBPX9JmNt4rvXuWcfYs0cVUaYndUiBJSbGsCbQe
|
||||
M1kNif2kKHpwluXLWH65HQJ6M+6taq0sPF59zPVyaVH9d7QPEP2ewhoExalWbv1m
|
||||
n7Yc+dNo9E+MbGev9eClMGemp5tuFomK5bQg9Pd09JzKXccv5jCday6VKcHnqtfW
|
||||
Wdyp8BBAAmY/WKI4jIkaC5Qa5YBJFET0BrERGs3vdmq/+G9Yna+ja5qOu2wQ1thO
|
||||
c1ggC5k4QdQi1IALCQ0lQD5mFaBETtZZWlgH5Uti8emutnw=
|
||||
-----END CERTIFICATE-----
|
@ -0,0 +1,48 @@
|
||||
package info.bukova.isspst;
|
||||
|
||||
import org.jfree.util.Log;
|
||||
|
||||
public class BooleanUtils
|
||||
{
|
||||
private static final String TAG = BooleanUtils.class.getSimpleName();
|
||||
|
||||
public static boolean isEqualByBooleanValue(Boolean b1, Boolean b2)
|
||||
{
|
||||
boolean bool1 = ((b1 == null) ? false : b1.booleanValue());
|
||||
boolean bool2 = ((b2 == null) ? false : b2.booleanValue());
|
||||
boolean equals = (bool1 == bool2);
|
||||
return equals;
|
||||
}
|
||||
|
||||
public static boolean isEqualByBoolean(Boolean b1, Boolean b2)
|
||||
{
|
||||
if ((b1 == null) && (b2 == null))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if ((b1 != null) && (b2 != null))
|
||||
{
|
||||
return (b1.booleanValue() == b2.booleanValue());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isEqualFilterByBoolean(Boolean value, Boolean filterValue)
|
||||
{
|
||||
if (filterValue == null)
|
||||
{
|
||||
// Show all records
|
||||
return true;
|
||||
}
|
||||
|
||||
if (value == null)
|
||||
{
|
||||
// Fuck!!! Tri-state data (null, false, true)... We need new solution for selecting ALL data
|
||||
Log.warn(TAG + "\nVelky Boolean v databazi... Pozor na filtrovani.");
|
||||
return true;
|
||||
}
|
||||
|
||||
return (value.booleanValue() == filterValue.booleanValue());
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package info.bukova.isspst;
|
||||
|
||||
import info.bukova.isspst.data.DataModel;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
public class CommonUrlResolver implements EntityUrlResolver {
|
||||
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
protected String defaultUrl;
|
||||
|
||||
public CommonUrlResolver() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String entityUrl(Object entity) {
|
||||
if (defaultUrl == null) {
|
||||
this.defaultUrl = request.getRequestURL().toString();
|
||||
this.defaultUrl = defaultUrl.substring(0, defaultUrl.indexOf(request.getServletPath()));
|
||||
}
|
||||
|
||||
if (!DataModel.class.isAssignableFrom(entity.getClass())) {
|
||||
return defaultUrl + "/app";
|
||||
}
|
||||
|
||||
String url = Constants.URL_MAP.get(entity.getClass());
|
||||
|
||||
if (url == null) {
|
||||
return defaultUrl + "/app";
|
||||
}
|
||||
|
||||
return defaultUrl + url + "?select=" + String.valueOf(((DataModel)entity).getId());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package info.bukova.isspst;
|
||||
|
||||
public interface EntityUrlResolver {
|
||||
|
||||
public String entityUrl(Object entity);
|
||||
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package info.bukova.isspst;
|
||||
|
||||
import info.bukova.isspst.data.DataModel;
|
||||
import info.bukova.isspst.services.Service;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.context.support.WebApplicationContextUtils;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ModuleUtils {
|
||||
|
||||
public static List<Module> getActiveModules() {
|
||||
List<Module> modules = new ArrayList<Module>();
|
||||
|
||||
for (Module m : Arrays.asList(Constants.MODULES)) {
|
||||
if (m.isActive()) {
|
||||
modules.add(m);
|
||||
}
|
||||
}
|
||||
|
||||
return modules;
|
||||
}
|
||||
|
||||
public static Module getModule(Class<?> serviceClass) {
|
||||
for (Module m : Constants.MODULES) {
|
||||
if (Arrays.asList(serviceClass.getInterfaces()).contains(m.getServiceClass())) {
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Module getModule(String id) {
|
||||
for (Module m : Constants.MODULES) {
|
||||
if (m.getId().equals(id)) {
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Module getModule(DataModel entity, ServletContext sc) {
|
||||
WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(sc);
|
||||
for (Module m : Constants.MODULES) {
|
||||
Service<?> service;
|
||||
|
||||
try {
|
||||
service = (Service<?>) ctx.getBean(m.getServiceClass());
|
||||
} catch (NoSuchBeanDefinitionException e) {
|
||||
String[] beans = ctx.getBeanNamesForType(m.getServiceClass());
|
||||
|
||||
for (String s : beans) {
|
||||
service = (Service<?>) ctx.getBean(s);
|
||||
|
||||
if (service.getEntityClasses().contains(entity.getClass())) {
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
} catch (ClassCastException e) { //nestandardní moduly neřeší...
|
||||
continue;
|
||||
}
|
||||
|
||||
if (service.getEntityClasses().contains(entity.getClass())) {
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Service<?> getServiceInstance(Module m, ServletContext sc) {
|
||||
WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(sc);
|
||||
|
||||
try {
|
||||
return (Service<?>) ctx.getBean(m.getServiceClass());
|
||||
} catch (NoSuchBeanDefinitionException e) {
|
||||
String[] beans = ctx.getBeanNamesForType(m.getServiceClass());
|
||||
return (Service<?>) ctx.getBean(beans[0]);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isActive(String id) {
|
||||
return getModule(id).isActive();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package info.bukova.isspst;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class RegExUtils {
|
||||
public static List<String> getMatches(String input, String regEx, int group) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
|
||||
if (!StringUtils.isNullOrEmpty(input) && !StringUtils.isNullOrEmpty(regEx)) {
|
||||
Pattern pattern = Pattern.compile(regEx);
|
||||
Matcher matcher = pattern.matcher(input);
|
||||
int groupCount = matcher.groupCount() + 1;
|
||||
|
||||
if ((groupCount >= 0) && (group < groupCount)) {
|
||||
while (matcher.find()) {
|
||||
String item = matcher.group(group);
|
||||
list.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<String> getMatches(String input, String regEx) {
|
||||
return RegExUtils.getMatches(input, regEx, 0);
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package info.bukova.isspst;
|
||||
|
||||
import info.bukova.isspst.data.Requirement;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
public class RequirementUrlResolver implements EntityUrlResolver {
|
||||
|
||||
private String defaultUrl;
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
public RequirementUrlResolver() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String entityUrl(Object entity) {
|
||||
if (!(entity instanceof Requirement)) {
|
||||
return defaultUrl + "/app";
|
||||
}
|
||||
|
||||
if (defaultUrl == null) {
|
||||
this.defaultUrl = request.getRequestURL().toString();
|
||||
this.defaultUrl = defaultUrl.substring(0, defaultUrl.indexOf(request.getServletPath()));
|
||||
}
|
||||
|
||||
Requirement req = (Requirement)entity;
|
||||
|
||||
if (req.getKind() != null && req.getKind() == Constants.REQ_TYPE_MATERIAL) {
|
||||
return defaultUrl + Constants.URL_MAP.get(req.getClass()) + "material/?select=" + String.valueOf(req.getId());
|
||||
} else {
|
||||
return defaultUrl + Constants.URL_MAP.get(req.getClass()) + "services/?select=" + String.valueOf(req.getId());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package info.bukova.isspst;
|
||||
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.context.support.WebApplicationContextUtils;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public class SpringUtils {
|
||||
|
||||
private static WebApplicationContext webCtx(ServletContext sc) {
|
||||
return WebApplicationContextUtils.getRequiredWebApplicationContext(sc);
|
||||
}
|
||||
|
||||
public static Object getBean(String name, ServletContext sc) {
|
||||
return webCtx(sc).getBean(name);
|
||||
}
|
||||
|
||||
public static <T> T getBean(Class<T> clazz, ServletContext sc) {
|
||||
return webCtx(sc).getBean(clazz);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package info.bukova.isspst;
|
||||
|
||||
import info.bukova.isspst.data.TripBillApproval;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public class TripBillAprovalUrlResolver implements EntityUrlResolver {
|
||||
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
@Override
|
||||
public String entityUrl(Object entity) {
|
||||
String defUrl = request.getRequestURL().toString();
|
||||
defUrl = defUrl.substring(0, defUrl.indexOf(request.getServletPath()));
|
||||
|
||||
if (entity instanceof TripBillApproval) {
|
||||
String url = Constants.URL_MAP.get(entity.getClass());
|
||||
|
||||
return defUrl + url + "?select=" + String.valueOf(((TripBillApproval)entity).getId());
|
||||
}
|
||||
|
||||
return defUrl + "/app";
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package info.bukova.isspst;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class UrlResolverHolder {
|
||||
|
||||
private EntityUrlResolver commonResolver;
|
||||
private Map<Class<?>, EntityUrlResolver> resolvers;
|
||||
|
||||
public UrlResolverHolder(EntityUrlResolver common) {
|
||||
this.commonResolver = common;
|
||||
resolvers = new HashMap<Class<?>, EntityUrlResolver>();
|
||||
}
|
||||
|
||||
public void setResolvers(Map<Class<?>, EntityUrlResolver> resolvers) {
|
||||
this.resolvers = resolvers;
|
||||
}
|
||||
|
||||
public EntityUrlResolver resolverFor(Class<?> clazz) {
|
||||
EntityUrlResolver res = resolvers.get(clazz);
|
||||
|
||||
if (res == null) {
|
||||
return commonResolver;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package info.bukova.isspst.dao;
|
||||
|
||||
import info.bukova.isspst.data.DbInfo;
|
||||
|
||||
public interface DbInfoDao extends BaseDao<DbInfo>
|
||||
{
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package info.bukova.isspst.dao;
|
||||
|
||||
import info.bukova.isspst.data.Invoicing;
|
||||
|
||||
public interface InvoicingDao extends BaseDao<Invoicing> {
|
||||
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package info.bukova.isspst.dao;
|
||||
|
||||
import info.bukova.isspst.data.Limit;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public interface LimitDao extends BaseDao<Limit> {
|
||||
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package info.bukova.isspst.dao;
|
||||
|
||||
import info.bukova.isspst.data.RequirementItem;
|
||||
|
||||
public interface RequirementItemDao extends BaseDao<RequirementItem>
|
||||
{
|
||||
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package info.bukova.isspst.dao;
|
||||
|
||||
import info.bukova.isspst.data.Season;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public interface SeasonDao extends BaseDao<Season> {
|
||||
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package info.bukova.isspst.dao;
|
||||
|
||||
import info.bukova.isspst.data.SignedDocument;
|
||||
|
||||
public interface SignedDocumentDao extends BaseDao<SignedDocument> {
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package info.bukova.isspst.dao;
|
||||
|
||||
import info.bukova.isspst.data.TripBillApproval;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public interface TripBillApprovalDao extends BaseDao<TripBillApproval> {
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package info.bukova.isspst.dao.jpa;
|
||||
|
||||
import info.bukova.isspst.dao.DbInfoDao;
|
||||
import info.bukova.isspst.data.DbInfo;
|
||||
|
||||
public class DbInfoDaoJPA extends BaseDaoJPA<DbInfo> implements DbInfoDao
|
||||
{
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package info.bukova.isspst.dao.jpa;
|
||||
|
||||
import info.bukova.isspst.dao.InvoicingDao;
|
||||
import info.bukova.isspst.data.Invoicing;
|
||||
|
||||
public class InvoicingDaoJPA extends BaseDaoJPA<Invoicing> implements InvoicingDao {
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package info.bukova.isspst.dao.jpa;
|
||||
|
||||
import info.bukova.isspst.dao.LimitDao;
|
||||
import info.bukova.isspst.data.Limit;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public class LimitDaoJPA extends BaseDaoJPA<Limit> implements LimitDao {
|
||||
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package info.bukova.isspst.dao.jpa;
|
||||
|
||||
import info.bukova.isspst.dao.RequirementItemDao;
|
||||
import info.bukova.isspst.data.RequirementItem;
|
||||
|
||||
public class RequirementItemDaoJPA extends BaseDaoJPA<RequirementItem> implements RequirementItemDao
|
||||
{
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package info.bukova.isspst.dao.jpa;
|
||||
|
||||
import info.bukova.isspst.dao.SeasonDao;
|
||||
import info.bukova.isspst.data.Season;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public class SeasonDaoJPA extends BaseDaoJPA<Season> implements SeasonDao {
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package info.bukova.isspst.dao.jpa;
|
||||
|
||||
import info.bukova.isspst.dao.SignedDocumentDao;
|
||||
import info.bukova.isspst.data.SignedDocument;
|
||||
|
||||
public class SignedDocumentDaoJPA extends BaseDaoJPA<SignedDocument> implements SignedDocumentDao {
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package info.bukova.isspst.dao.jpa;
|
||||
|
||||
import info.bukova.isspst.dao.TripBillApprovalDao;
|
||||
import info.bukova.isspst.data.TripBillApproval;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public class TripBillApprovalDaoJPA extends BaseDaoJPA<TripBillApproval> implements TripBillApprovalDao {
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package info.bukova.isspst.data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "DBINFO")
|
||||
public class DbInfo extends BaseSimpleData
|
||||
{
|
||||
@Column(name = "VERSION")
|
||||
private long version;
|
||||
|
||||
public DbInfo()
|
||||
{
|
||||
this.version = 0;
|
||||
}
|
||||
|
||||
public long getVersion()
|
||||
{
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(long version)
|
||||
{
|
||||
this.version = version;
|
||||
}
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
package info.bukova.isspst.data;
|
||||
|
||||
import org.hibernate.annotations.Type;
|
||||
import org.hibernate.search.annotations.Analyze;
|
||||
import org.hibernate.search.annotations.Field;
|
||||
import org.hibernate.search.annotations.Index;
|
||||
import org.hibernate.search.annotations.Indexed;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "FILE_CONTENTS")
|
||||
@Indexed
|
||||
public class FileContent {
|
||||
|
||||
@Id
|
||||
@Column(name = "ID")
|
||||
@GeneratedValue
|
||||
private int id;
|
||||
|
||||
@Column(name = "CONTENT")
|
||||
@Type(type = "text")
|
||||
@Field(index = Index.YES, analyze = Analyze.YES)
|
||||
private String plainText;
|
||||
|
||||
@Column(name = "CONTENT_TYPE")
|
||||
private String contentType;
|
||||
|
||||
@Column(name = "PATH_IN_FILESYSTEM")
|
||||
private String pathInFilesystem;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getPlainText() {
|
||||
return plainText;
|
||||
|
||||
}
|
||||
|
||||
public void setPlainText(String content) {
|
||||
this.plainText = content;
|
||||
}
|
||||
|
||||
public String getContentType() {
|
||||
return contentType;
|
||||
}
|
||||
|
||||
public void setContentType(String contentType) {
|
||||
this.contentType = contentType;
|
||||
}
|
||||
|
||||
public String getPathInFilesystem() {
|
||||
return pathInFilesystem;
|
||||
}
|
||||
|
||||
public void setPathInFilesystem(String pathInFilesystem) {
|
||||
this.pathInFilesystem = pathInFilesystem;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof FileContent)) return false;
|
||||
|
||||
FileContent that = (FileContent) o;
|
||||
|
||||
if (id != that.id) return false;
|
||||
if (plainText != null ? !plainText.equals(that.plainText) : that.plainText != null) return false;
|
||||
if (contentType != null ? !contentType.equals(that.contentType) : that.contentType != null) return false;
|
||||
if (pathInFilesystem != null ? !pathInFilesystem.equals(that.pathInFilesystem) : that.pathInFilesystem != null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = id;
|
||||
result = 31 * result + (plainText != null ? plainText.hashCode() : 0);
|
||||
result = 31 * result + (contentType != null ? contentType.hashCode() : 0);
|
||||
result = 31 * result + (pathInFilesystem != null ? pathInFilesystem.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
@ -0,0 +1,152 @@
|
||||
package info.bukova.isspst.data;
|
||||
|
||||
import org.hibernate.annotations.Cascade;
|
||||
import org.hibernate.annotations.CascadeType;
|
||||
import org.hibernate.search.annotations.Analyze;
|
||||
import org.hibernate.search.annotations.Field;
|
||||
import org.hibernate.search.annotations.Index;
|
||||
import org.hibernate.search.annotations.Indexed;
|
||||
import org.hibernate.search.annotations.IndexedEmbedded;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "FILE_METAINFO")
|
||||
@Indexed
|
||||
public class FileMetainfo extends BaseData {
|
||||
|
||||
@Column(name = "FILE_NAME")
|
||||
@Field(index = Index.YES, analyze = Analyze.YES)
|
||||
private String fileName;
|
||||
|
||||
@Column(name = "MODULE_ID")
|
||||
private String moduleId;
|
||||
|
||||
@Column(name = "RECORD_ID")
|
||||
private int recordId;
|
||||
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "CONTENT_ID")
|
||||
@Cascade(CascadeType.SAVE_UPDATE)
|
||||
@IndexedEmbedded
|
||||
private FileContent content;
|
||||
|
||||
@Column(name = "MD5")
|
||||
private String md5;
|
||||
|
||||
@Column(name = "DESCRIPTION")
|
||||
@Field(index = Index.YES, analyze = Analyze.YES)
|
||||
private String description;
|
||||
|
||||
private void ensureContentExists() {
|
||||
if (content == null) {
|
||||
content = new FileContent();
|
||||
}
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
public String getPathInFilesystem() {
|
||||
if (content != null) {
|
||||
return content.getPathInFilesystem();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setPathInFilesystem(String pathInFilesystem) {
|
||||
ensureContentExists();
|
||||
content.setPathInFilesystem(pathInFilesystem);
|
||||
}
|
||||
|
||||
public String getModuleId() {
|
||||
return moduleId;
|
||||
}
|
||||
|
||||
public void setModuleId(String moduleId) {
|
||||
this.moduleId = moduleId;
|
||||
}
|
||||
|
||||
public int getRecordId() {
|
||||
return recordId;
|
||||
}
|
||||
|
||||
public void setRecordId(int recordId) {
|
||||
this.recordId = recordId;
|
||||
}
|
||||
|
||||
public FileContent getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(FileContent content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getMd5() {
|
||||
return md5;
|
||||
}
|
||||
|
||||
public void setMd5(String md5) {
|
||||
this.md5 = md5;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getContentType() {
|
||||
if (content != null) {
|
||||
return content.getContentType();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setContentType(String contentType) {
|
||||
ensureContentExists();
|
||||
content.setContentType(contentType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof FileMetainfo)) return false;
|
||||
|
||||
FileMetainfo that = (FileMetainfo) o;
|
||||
|
||||
if (recordId != that.recordId) return false;
|
||||
if (content != null ? !content.equals(that.content) : that.content != null) return false;
|
||||
if (description != null ? !description.equals(that.description) : that.description != null) return false;
|
||||
if (fileName != null ? !fileName.equals(that.fileName) : that.fileName != null) return false;
|
||||
if (md5 != null ? !md5.equals(that.md5) : that.md5 != null) return false;
|
||||
if (moduleId != null ? !moduleId.equals(that.moduleId) : that.moduleId != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = fileName != null ? fileName.hashCode() : 0;
|
||||
result = 31 * result + (moduleId != null ? moduleId.hashCode() : 0);
|
||||
result = 31 * result + recordId;
|
||||
result = 31 * result + (content != null ? content.hashCode() : 0);
|
||||
result = 31 * result + (md5 != null ? md5.hashCode() : 0);
|
||||
result = 31 * result + (description != null ? description.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
package info.bukova.isspst.data;
|
||||
|
||||
import org.hibernate.annotations.Cascade;
|
||||
import org.hibernate.annotations.LazyCollection;
|
||||
import org.hibernate.annotations.LazyCollectionOption;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Table(name = "INVOICING")
|
||||
public class Invoicing extends BaseData implements Cloneable
|
||||
{
|
||||
|
||||
@OneToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "REQUIREMENT_ID")
|
||||
@Cascade(org.hibernate.annotations.CascadeType.SAVE_UPDATE)
|
||||
private Requirement requirement;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
@LazyCollection(LazyCollectionOption.TRUE)
|
||||
@JoinColumn(name = "INVOICING_ID")
|
||||
private List<InvoicingItem> items;
|
||||
|
||||
@Column(name = "TOTAL_INVOICED", precision = 15, scale = 4)
|
||||
private BigDecimal totalInvoiced;
|
||||
|
||||
@Column(name = "COMPLETED")
|
||||
private boolean completed;
|
||||
|
||||
public Requirement getRequirement() {
|
||||
return requirement;
|
||||
}
|
||||
|
||||
public void setRequirement(Requirement requirement) {
|
||||
this.requirement = requirement;
|
||||
}
|
||||
|
||||
public List<InvoicingItem> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public void setItems(List<InvoicingItem> items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
public BigDecimal getTotalInvoiced() {
|
||||
return totalInvoiced;
|
||||
}
|
||||
|
||||
public void setTotalInvoiced(BigDecimal totalInvoiced) {
|
||||
this.totalInvoiced = totalInvoiced;
|
||||
}
|
||||
|
||||
public boolean isCompleted()
|
||||
{
|
||||
return completed;
|
||||
}
|
||||
|
||||
public void setCompleted(boolean completed)
|
||||
{
|
||||
this.completed = completed;
|
||||
}
|
||||
|
||||
public String getInvoiceNumbers() {
|
||||
String ret = "";
|
||||
for (InvoicingItem invNum : items) {
|
||||
if (!ret.isEmpty()) {
|
||||
ret += ", ";
|
||||
}
|
||||
ret += invNum.getInvoiceNumber();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() throws CloneNotSupportedException
|
||||
{
|
||||
Invoicing cloned = (Invoicing) super.clone();
|
||||
return cloned;
|
||||
}
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package info.bukova.isspst.data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "INVOICING_ITEM")
|
||||
public class InvoicingItem {
|
||||
|
||||
@Id
|
||||
@Column(name = "ID")
|
||||
@GeneratedValue
|
||||
private int id;
|
||||
|
||||
@Column(name = "INVOICE_DATE")
|
||||
private Date invoiceDate;
|
||||
|
||||
@Column(name = "INVOICE_NUMBER")
|
||||
private String invoiceNumber;
|
||||
|
||||
@Column(name = "AMOUNT", precision = 15, scale = 4)
|
||||
private BigDecimal amount;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Date getInvoiceDate() {
|
||||
return invoiceDate;
|
||||
}
|
||||
|
||||
public void setInvoiceDate(Date invoiceDate) {
|
||||
this.invoiceDate = invoiceDate;
|
||||
}
|
||||
|
||||
public String getInvoiceNumber() {
|
||||
return invoiceNumber;
|
||||
}
|
||||
|
||||
public void setInvoiceNumber(String invoiceNumber) {
|
||||
this.invoiceNumber = invoiceNumber;
|
||||
}
|
||||
|
||||
public BigDecimal getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(BigDecimal amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null)
|
||||
{
|
||||
if (obj instanceof InvoicingItem)
|
||||
{
|
||||
InvoicingItem item = (InvoicingItem)obj;
|
||||
|
||||
int thisId = this.getId();
|
||||
int itemId = item.getId();
|
||||
boolean equalsId = (thisId == itemId);
|
||||
|
||||
if (equalsId && (thisId == 0))
|
||||
{
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
return equalsId;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package info.bukova.isspst.data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "LIMITS")
|
||||
public class Limit extends BaseData implements SeasonsAware {
|
||||
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "WORKGROUP_ID")
|
||||
private Workgroup workgroup;
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "SEASON_ID")
|
||||
private Season season;
|
||||
@Column(name = "REQ_LIMIT", precision = 15, scale = 4)
|
||||
private BigDecimal limit;
|
||||
|
||||
public Workgroup getWorkgroup() {
|
||||
return workgroup;
|
||||
}
|
||||
|
||||
public void setWorkgroup(Workgroup workgroup) {
|
||||
this.workgroup = workgroup;
|
||||
}
|
||||
|
||||
public Season getSeason() {
|
||||
return season;
|
||||
}
|
||||
|
||||
public void setSeason(Season season) {
|
||||
this.season = season;
|
||||
}
|
||||
|
||||
public BigDecimal getLimit() {
|
||||
return limit;
|
||||
}
|
||||
|
||||
public void setLimit(BigDecimal limit) {
|
||||
this.limit = limit;
|
||||
}
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package info.bukova.isspst.data;
|
||||
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "SEASON")
|
||||
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
public class Season extends BaseData {
|
||||
@Column(name = "DESCRIPTION")
|
||||
private String description;
|
||||
@Column(name = "VALID_FROM")
|
||||
private Date validFrom;
|
||||
@Column(name = "VALID_TO")
|
||||
private Date validTo;
|
||||
@Column(name = "ACTIVE")
|
||||
private boolean active;
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof Season)) return false;
|
||||
|
||||
Season season = (Season) o;
|
||||
|
||||
if (getId() != season.getId()) return false;
|
||||
if (active != season.active) return false;
|
||||
if (description != null ? !description.equals(season.description) : season.description != null) return false;
|
||||
if (validFrom != null ? !validFrom.equals(season.validFrom) : season.validFrom != null) return false;
|
||||
if (validTo != null ? !validTo.equals(season.validTo) : season.validTo != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = description != null ? description.hashCode() : 0;
|
||||
result = 31 * result + (validFrom != null ? validFrom.hashCode() : 0);
|
||||
result = 31 * result + (validTo != null ? validTo.hashCode() : 0);
|
||||
result = 31 * result + (active ? 1 : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Date getValidFrom() {
|
||||
return validFrom;
|
||||
}
|
||||
|
||||
public void setValidFrom(Date validFrom) {
|
||||
this.validFrom = validFrom;
|
||||
}
|
||||
|
||||
public Date getValidTo() {
|
||||
return validTo;
|
||||
}
|
||||
|
||||
public void setValidTo(Date validTo) {
|
||||
this.validTo = validTo;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
public void setActive(boolean active) {
|
||||
this.active = active;
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package info.bukova.isspst.data;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public interface SeasonsAware {
|
||||
public Season getSeason();
|
||||
}
|
@ -0,0 +1,123 @@
|
||||
package info.bukova.isspst.data;
|
||||
|
||||
import info.bukova.isspst.Constants;
|
||||
import info.bukova.isspst.Module;
|
||||
import info.bukova.isspst.StringUtils;
|
||||
import org.hibernate.annotations.LazyCollection;
|
||||
import org.hibernate.annotations.LazyCollectionOption;
|
||||
import org.hibernate.search.annotations.IndexedEmbedded;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Table(name = "SIGNED_DOCUMENTS")
|
||||
public class SignedDocument extends BaseData {
|
||||
|
||||
@Transient
|
||||
private String agendaName;
|
||||
|
||||
@Column(name = "MODULE_NAME", length = Constants.LEN_TEXT)
|
||||
private String moduleName;
|
||||
|
||||
@Column(name = "RECORD_ID")
|
||||
private int recordId;
|
||||
|
||||
@Column(name = "NUMSER", length = Constants.LEN_TEXT)
|
||||
private String numser;
|
||||
|
||||
@Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION)
|
||||
private String description;
|
||||
|
||||
@Column(name = "SIGN_DATE")
|
||||
private Date signDate;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "signedDocument", orphanRemoval = true)
|
||||
@LazyCollection(LazyCollectionOption.TRUE)
|
||||
@IndexedEmbedded
|
||||
private List<SignedDocumentItem> items;
|
||||
|
||||
public SignedDocument() {
|
||||
}
|
||||
|
||||
public String getModuleName() {
|
||||
return moduleName;
|
||||
}
|
||||
|
||||
public void setModuleName(String moduleName) {
|
||||
this.moduleName = moduleName;
|
||||
}
|
||||
|
||||
public int getRecordId() {
|
||||
return recordId;
|
||||
}
|
||||
|
||||
public void setRecordId(int recordId) {
|
||||
this.recordId = recordId;
|
||||
}
|
||||
|
||||
public String getNumser() {
|
||||
return numser;
|
||||
}
|
||||
|
||||
public void setNumser(String numser) {
|
||||
this.numser = numser;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Date getSignDate() {
|
||||
return signDate;
|
||||
}
|
||||
|
||||
public void setSignDate(Date signDate) {
|
||||
this.signDate = signDate;
|
||||
}
|
||||
|
||||
public String getAgendaName() {
|
||||
if (!StringUtils.isNullOrEmpty(this.agendaName)) {
|
||||
return this.agendaName;
|
||||
}
|
||||
|
||||
if (StringUtils.isNullOrEmpty(this.moduleName)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
for (Module m : Constants.MODULES) {
|
||||
if (this.moduleName.equals(m.getId())) {
|
||||
return m.getName();
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public void setAgendaName(String agendaName) {
|
||||
this.agendaName = agendaName;
|
||||
}
|
||||
|
||||
public List<SignedDocumentItem> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public void setItems(List<SignedDocumentItem> items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
public void addItem(SignedDocumentItem item) {
|
||||
if (items == null) {
|
||||
items = new ArrayList<SignedDocumentItem>();
|
||||
}
|
||||
|
||||
item.setSignedDocument(this);
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
package info.bukova.isspst.data;
|
||||
|
||||
import info.bukova.isspst.Constants;
|
||||
import info.bukova.isspst.reporting.Report;
|
||||
import info.bukova.isspst.reporting.ReportMapping;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "SIGNED_DOCUMENTS_ITEMS")
|
||||
public class SignedDocumentItem {
|
||||
|
||||
@Id
|
||||
@Column(name = "ID")
|
||||
@GeneratedValue
|
||||
private int id;
|
||||
|
||||
@Column(name = "REPORT_ID")
|
||||
private long reportId;
|
||||
|
||||
@Column(name = "REPORT_NAME", length = Constants.LEN_TEXT)
|
||||
private String reportName;
|
||||
|
||||
@Column(name = "FILENAME", length = Constants.LEN_TEXT)
|
||||
private String fileName;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "SIGNED_DOCUMENT_ID")
|
||||
private SignedDocument signedDocument;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public long getReportId() {
|
||||
return reportId;
|
||||
}
|
||||
|
||||
public void setReportId(long reportId) {
|
||||
this.reportId = reportId;
|
||||
}
|
||||
|
||||
public String getReportName() {
|
||||
return reportName;
|
||||
}
|
||||
|
||||
public void setReportName(String reportName) {
|
||||
this.reportName = reportName;
|
||||
}
|
||||
|
||||
public String getActualReportName() {
|
||||
for (ReportMapping rm : Constants.REPORTS) {
|
||||
Report rep = rm.getReport();
|
||||
|
||||
if (this.reportId == rep.getReportId()) {
|
||||
return rep.getName();
|
||||
}
|
||||
}
|
||||
|
||||
return reportName;
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
public SignedDocument getSignedDocument() {
|
||||
return signedDocument;
|
||||
}
|
||||
|
||||
public void setSignedDocument(SignedDocument signedDocument) {
|
||||
this.signedDocument = signedDocument;
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package info.bukova.isspst.data;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
|
||||
@Entity
|
||||
@Table(name = "TRIP_BILL_APPROVAL")
|
||||
public class TripBillApproval extends RequirementBase {
|
||||
|
||||
@OneToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "TRIPBILL_ID")
|
||||
private TripBill bill;
|
||||
@Transient
|
||||
private boolean billForPassenger;
|
||||
@Transient
|
||||
private Date tripDate;
|
||||
|
||||
public boolean isBillForPassenger() {
|
||||
return billForPassenger;
|
||||
}
|
||||
|
||||
public void setBillForPassenger(boolean billForPassenger) {
|
||||
this.billForPassenger = billForPassenger;
|
||||
}
|
||||
|
||||
public Date getTripDate() {
|
||||
return tripDate;
|
||||
}
|
||||
|
||||
public void setTripDate(Date tripDate) {
|
||||
this.tripDate = tripDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNumser() {
|
||||
|
||||
if (bill == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
TripRequirement tr = bill.getRequirement();
|
||||
|
||||
if (tr == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return tr.getNumser();
|
||||
}
|
||||
|
||||
public TripBill getBill() {
|
||||
return bill;
|
||||
}
|
||||
|
||||
public void setBill(TripBill bill) {
|
||||
this.bill = bill;
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package info.bukova.isspst.filters;
|
||||
|
||||
import info.bukova.isspst.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.zkoss.zul.Listbox;
|
||||
import org.zkoss.zul.Listitem;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class BooleanFilterListbox extends Listbox
|
||||
{
|
||||
class TristateBooleanListItem extends TristateBoolean
|
||||
{
|
||||
public TristateBooleanListItem(String text, int value)
|
||||
{
|
||||
this.setText(text);
|
||||
this.setValue(value);
|
||||
}
|
||||
|
||||
private String text;
|
||||
|
||||
public String getText()
|
||||
{
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text)
|
||||
{
|
||||
this.text = text;
|
||||
}
|
||||
}
|
||||
|
||||
public BooleanFilterListbox()
|
||||
{
|
||||
super();
|
||||
|
||||
List<TristateBooleanListItem> list = new ArrayList<TristateBooleanListItem>();
|
||||
list.add(new TristateBooleanListItem(StringUtils.localize("LabelAll"), TristateBoolean.NULL));
|
||||
list.add(new TristateBooleanListItem(StringUtils.localize("LabelNo"), TristateBoolean.FALSE));
|
||||
list.add(new TristateBooleanListItem(StringUtils.localize("LabelYes"), TristateBoolean.TRUE));
|
||||
|
||||
for (int i = 0; i < list.size(); i++)
|
||||
{
|
||||
TristateBooleanListItem triStateItem = (TristateBooleanListItem) list.get(i);
|
||||
this.appendItem(triStateItem.getText(), "");
|
||||
|
||||
Listitem item = this.getItemAtIndex(i);
|
||||
item.setValue((TristateBoolean) triStateItem);
|
||||
}
|
||||
|
||||
this.setSelectedIndex(0);
|
||||
// this.setHflex("1");
|
||||
this.setMold("select");
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
package info.bukova.isspst.filters;
|
||||
|
||||
import info.bukova.isspst.DateTimeUtils;
|
||||
import info.bukova.isspst.StringUtils;
|
||||
import info.bukova.isspst.data.Invoicing;
|
||||
import info.bukova.isspst.data.Requirement;
|
||||
import info.bukova.isspst.data.User;
|
||||
import info.bukova.isspst.data.Workgroup;
|
||||
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.Factory;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.TypeSafeMatcher;
|
||||
|
||||
public class InvoicingFilter implements Filter<Invoicing>
|
||||
{
|
||||
|
||||
private Invoicing condition;
|
||||
|
||||
public InvoicingFilter(Invoicing cond)
|
||||
{
|
||||
this.condition = cond;
|
||||
}
|
||||
|
||||
private static class InvoicingMatcher extends TypeSafeMatcher<Invoicing>
|
||||
{
|
||||
|
||||
private Invoicing condition;
|
||||
|
||||
public InvoicingMatcher(Invoicing cond)
|
||||
{
|
||||
this.condition = cond;
|
||||
|
||||
if (condition.getRequirement() == null) {
|
||||
condition.setRequirement(new Requirement());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeTo(Description desc)
|
||||
{
|
||||
desc.appendText("Invoicing matches");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesSafely(Invoicing item)
|
||||
{
|
||||
boolean foundNumser = StringUtils.isEqualForFilter(item.getRequirement().getNumser(), condition.getRequirement().getNumser());
|
||||
boolean foundReqDate = DateTimeUtils.isEqualByDateForFilter(item.getRequirement().getReqDate(), condition.getRequirement().getReqDate());
|
||||
boolean foundCenter = Workgroup.isEqualByWorkgroupForFilter(item.getRequirement().getCentre(), condition.getRequirement().getCentre());
|
||||
boolean foundWorkgroup = Workgroup.isEqualByWorkgroupForFilter(item.getRequirement().getWorkgroup(), condition.getRequirement().getWorkgroup());
|
||||
boolean foundUser = User.isEqualByUserForFilter(item.getRequirement().getOwnedBy(), condition.getRequirement().getOwnedBy());
|
||||
boolean foundDescription = StringUtils.isEqualForFilter(item.getRequirement().getDescription(), condition.getRequirement().getDescription());
|
||||
return (foundNumser && foundReqDate && foundCenter && foundDescription && foundWorkgroup && foundUser);
|
||||
}
|
||||
|
||||
@Factory
|
||||
public static Matcher<Invoicing> matchBuilding(Invoicing building)
|
||||
{
|
||||
return new InvoicingMatcher(building);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public InvoicingMatcher matcher()
|
||||
{
|
||||
return new InvoicingMatcher(condition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String queryString()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package info.bukova.isspst.filters;
|
||||
|
||||
import info.bukova.isspst.DateTimeUtils;
|
||||
import info.bukova.isspst.StringUtils;
|
||||
import info.bukova.isspst.data.SignedDocument;
|
||||
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.Factory;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.TypeSafeMatcher;
|
||||
|
||||
public class SignedDocumentFilter implements Filter<SignedDocument>
|
||||
{
|
||||
private SignedDocument condition;
|
||||
|
||||
public SignedDocumentFilter(SignedDocument cond)
|
||||
{
|
||||
this.condition = cond;
|
||||
}
|
||||
|
||||
private static class SignedDocumentMatcher extends TypeSafeMatcher<SignedDocument>
|
||||
{
|
||||
private SignedDocument condition;
|
||||
|
||||
public SignedDocumentMatcher(SignedDocument cond)
|
||||
{
|
||||
this.condition = cond;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeTo(Description desc)
|
||||
{
|
||||
desc.appendText("SignedDocument matches");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesSafely(SignedDocument item)
|
||||
{
|
||||
boolean foundAgendaName = StringUtils.isEqualForFilter(item.getAgendaName(), condition.getAgendaName());
|
||||
boolean foundNumSer = StringUtils.isEqualForFilter(item.getNumser(), condition.getNumser());
|
||||
boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription());
|
||||
boolean foundSignDate = DateTimeUtils.isEqualByDateForFilter(item.getSignDate(), condition.getSignDate());
|
||||
return (foundAgendaName && foundNumSer && foundDescription && foundSignDate);
|
||||
}
|
||||
|
||||
@Factory
|
||||
public static Matcher<SignedDocument> matchBuilding(SignedDocument item)
|
||||
{
|
||||
return new SignedDocumentMatcher(item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SignedDocumentMatcher matcher()
|
||||
{
|
||||
return new SignedDocumentMatcher(condition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String queryString()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
package info.bukova.isspst.filters;
|
||||
|
||||
import info.bukova.isspst.BooleanUtils;
|
||||
import info.bukova.isspst.DateTimeUtils;
|
||||
import info.bukova.isspst.StringUtils;
|
||||
import info.bukova.isspst.data.TripBillApproval;
|
||||
import info.bukova.isspst.data.User;
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.Factory;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.TypeSafeMatcher;
|
||||
|
||||
public class TripBillApprovalFilter implements Filter<TripBillApproval>
|
||||
{
|
||||
|
||||
private TripBillApproval condition;
|
||||
|
||||
public TripBillApprovalFilter(TripBillApproval cond)
|
||||
{
|
||||
this.condition = cond;
|
||||
}
|
||||
|
||||
private static class TripBillApprovalMatcher extends TypeSafeMatcher<TripBillApproval>
|
||||
{
|
||||
|
||||
private TripBillApproval condition;
|
||||
|
||||
public TripBillApprovalMatcher(TripBillApproval cond)
|
||||
{
|
||||
this.condition = cond;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeTo(Description desc)
|
||||
{
|
||||
desc.appendText("requirement matches");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesSafely(TripBillApproval item)
|
||||
{
|
||||
if (item.getBill() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean foundNumser = StringUtils.isEqualForFilter(item.getNumser(), condition.getNumser());
|
||||
boolean foundReqDate = DateTimeUtils.isEqualByDateForFilter(item.getBill().getRequirement().getReqDate(), condition.getBill().getRequirement().getReqDate());
|
||||
boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription());
|
||||
boolean foundFrom = StringUtils.isEqualForFilter(item.getBill().getRequirement().getFrom(), condition.getBill().getRequirement().getFrom());
|
||||
boolean foundTo = StringUtils.isEqualForFilter(item.getBill().getRequirement().getTo(), condition.getBill().getRequirement().getTo());
|
||||
boolean foundWorkgroup = (condition.getWorkgroup() == null ||(item.getWorkgroup() != null && item.getWorkgroup().equals(condition.getWorkgroup())));
|
||||
boolean foundCentre = (condition.getCentre() == null || (item.getCentre() != null && item.getCentre().equals(condition.getCentre())));
|
||||
boolean foundOwner = User.isEqualByUserForFilter(item.getBill().getOwnedBy(), condition.getBill().getOwnedBy());
|
||||
boolean foundPaid = BooleanUtils.isEqualByBooleanValue(item.getBill().getPaid(), condition.getBill().getPaid());
|
||||
boolean foundPaidDate = DateTimeUtils.isEqualByDateForFilter(item.getBill().getPaidDate(), condition.getBill().getPaidDate());
|
||||
boolean foundPassenger = (item.getBill().getOwnedBy() != item.getBill().getRequirement().getOwnedBy()) == condition.isBillForPassenger();
|
||||
boolean foundApproveDate = DateTimeUtils.isEqualByDateForFilter(item.getApproveDate(), condition.getApproveDate());
|
||||
boolean foundTripDate = DateTimeUtils.isEqualByDateForFilter(item.getBill().getRequirement().getTripDate(), condition.getTripDate());
|
||||
return foundNumser && foundReqDate && foundDescription && foundFrom && foundTo && foundWorkgroup && foundCentre && foundOwner && foundPaid
|
||||
&& foundPaidDate && foundPassenger && foundApproveDate && foundTripDate;
|
||||
}
|
||||
|
||||
@Factory
|
||||
public static Matcher<TripBillApproval> matchTripRequirement(TripBillApproval building)
|
||||
{
|
||||
return new TripBillApprovalMatcher(building);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TripBillApprovalMatcher matcher()
|
||||
{
|
||||
return new TripBillApprovalMatcher(condition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String queryString()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package info.bukova.isspst.filters;
|
||||
|
||||
import org.jfree.util.Log;
|
||||
|
||||
public class TristateBoolean
|
||||
{
|
||||
private static final String TAG = TristateBoolean.class.getSimpleName();
|
||||
|
||||
public static final int NULL = -1;
|
||||
public static final int FALSE = 0;
|
||||
public static final int TRUE = 1;
|
||||
|
||||
public static final int getValidValue(final int value)
|
||||
{
|
||||
if ((value != TristateBoolean.NULL) && (value != TristateBoolean.FALSE) && (value != TristateBoolean.TRUE))
|
||||
{
|
||||
Log.warn(TAG + "\nBad tristate boolean value.");
|
||||
return TristateBoolean.NULL;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public TristateBoolean()
|
||||
{
|
||||
this.setValue(TristateBoolean.NULL);
|
||||
}
|
||||
|
||||
public TristateBoolean(boolean value)
|
||||
{
|
||||
this.setValue(value ? TristateBoolean.TRUE : TristateBoolean.FALSE);
|
||||
}
|
||||
|
||||
public TristateBoolean(int value)
|
||||
{
|
||||
this.setValue(value);
|
||||
}
|
||||
|
||||
protected int value;
|
||||
|
||||
public int getValue()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(int value)
|
||||
{
|
||||
this.value = TristateBoolean.getValidValue(value);
|
||||
}
|
||||
|
||||
public Boolean getBoolean()
|
||||
{
|
||||
switch (this.value)
|
||||
{
|
||||
case TristateBoolean.FALSE:
|
||||
return new Boolean(false);
|
||||
|
||||
case TristateBoolean.TRUE:
|
||||
return new Boolean(true);
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null)
|
||||
{
|
||||
if (obj instanceof TristateBoolean)
|
||||
{
|
||||
TristateBoolean item = (TristateBoolean) obj;
|
||||
int thisValue = this.getValue();
|
||||
int itemValue = item.getValue();
|
||||
return (thisValue == itemValue);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean equals(int value)
|
||||
{
|
||||
return (this.getValue() == value);
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package info.bukova.isspst.reporting;
|
||||
|
||||
import com.lowagie.text.Rectangle;
|
||||
import com.lowagie.text.pdf.PdfFormField;
|
||||
import com.lowagie.text.pdf.PdfName;
|
||||
import net.sf.jasperreports.engine.JRGenericPrintElement;
|
||||
import net.sf.jasperreports.engine.JRPropertiesMap;
|
||||
import net.sf.jasperreports.engine.export.GenericElementHandler;
|
||||
import net.sf.jasperreports.engine.export.GenericElementHandlerBundle;
|
||||
import net.sf.jasperreports.engine.export.GenericElementPdfHandler;
|
||||
import net.sf.jasperreports.engine.export.JRPdfExporter;
|
||||
import net.sf.jasperreports.engine.export.JRPdfExporterContext;
|
||||
import net.sf.jasperreports.extensions.ExtensionsRegistry;
|
||||
import net.sf.jasperreports.extensions.ExtensionsRegistryFactory;
|
||||
import net.sf.jasperreports.extensions.SingletonExtensionRegistry;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public class SignaturePdfHandler implements GenericElementPdfHandler, GenericElementHandlerBundle, ExtensionsRegistryFactory {
|
||||
|
||||
@Override
|
||||
public ExtensionsRegistry createRegistry(String registryId, JRPropertiesMap properties) {
|
||||
return new SingletonExtensionRegistry<GenericElementHandlerBundle>(GenericElementHandlerBundle.class, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportElement(JRPdfExporterContext exporterContext, JRGenericPrintElement element) {
|
||||
//PdfFormField field = PdfFormField.createSignature(exporterContext.getPdfWriter());
|
||||
PdfFormField field = PdfFormField.createTextField(exporterContext.getPdfWriter(), true, false, 255);
|
||||
Object param = element.getParameterValue("index");
|
||||
String index = param != null ? String.valueOf(param) : null;
|
||||
|
||||
if (index != null) {
|
||||
field.setFieldName("signature-" + index);
|
||||
} else {
|
||||
field.setFieldName("signature");
|
||||
}
|
||||
|
||||
field.put(PdfName.V, exporterContext.getPdfWriter().getPdfIndirectReference());
|
||||
field.setFieldFlags(PdfFormField.FF_READ_ONLY);
|
||||
|
||||
field.setWidget(new Rectangle(element.getX(),
|
||||
exporterContext.getExportedReport().getPageHeight() - element.getY(),
|
||||
element.getX() + element.getWidth(),
|
||||
exporterContext.getExportedReport().getPageHeight() - element.getY() - element.getHeight()), PdfName.HIGHLIGHT);
|
||||
exporterContext.getPdfWriter().addAnnotation(field);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean toExport(JRGenericPrintElement element) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return "urn:sig:sig";
|
||||
}
|
||||
|
||||
@Override
|
||||
public GenericElementHandler getHandler(String elementName, String exporterKey) {
|
||||
if (elementName.equals("signature") && exporterKey.equals(JRPdfExporter.PDF_EXPORTER_KEY)) {
|
||||
return this;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,306 @@
|
||||
package info.bukova.isspst.security;
|
||||
|
||||
import org.springframework.ldap.core.DirContextOperations;
|
||||
import org.springframework.ldap.core.DistinguishedName;
|
||||
import org.springframework.ldap.support.LdapUtils;
|
||||
import org.springframework.security.authentication.AccountExpiredException;
|
||||
import org.springframework.security.authentication.BadCredentialsException;
|
||||
import org.springframework.security.authentication.CredentialsExpiredException;
|
||||
import org.springframework.security.authentication.DisabledException;
|
||||
import org.springframework.security.authentication.LockedException;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.AuthorityUtils;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.security.ldap.SpringSecurityLdapTemplate;
|
||||
import org.springframework.security.ldap.authentication.AbstractLdapAuthenticationProvider;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.naming.AuthenticationException;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.OperationNotSupportedException;
|
||||
import javax.naming.directory.DirContext;
|
||||
import javax.naming.directory.SearchControls;
|
||||
import javax.naming.ldap.InitialLdapContext;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Hashtable;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class AdAuthenticationProvider extends AbstractLdapAuthenticationProvider{
|
||||
private static final Pattern SUB_ERROR_CODE = Pattern.compile(".*data\\s([0-9a-f]{3,4}).*");
|
||||
|
||||
// Error codes
|
||||
private static final int USERNAME_NOT_FOUND = 0x525;
|
||||
private static final int INVALID_PASSWORD = 0x52e;
|
||||
private static final int NOT_PERMITTED = 0x530;
|
||||
private static final int PASSWORD_EXPIRED = 0x532;
|
||||
private static final int ACCOUNT_DISABLED = 0x533;
|
||||
private static final int ACCOUNT_EXPIRED = 0x701;
|
||||
private static final int PASSWORD_NEEDS_RESET = 0x773;
|
||||
private static final int ACCOUNT_LOCKED = 0x775;
|
||||
|
||||
private final String domain;
|
||||
private final String rootDn;
|
||||
private final String url;
|
||||
private final String upnSuffix;
|
||||
private boolean convertSubErrorCodesToExceptions;
|
||||
|
||||
// Only used to allow tests to substitute a mock LdapContext
|
||||
ContextFactory contextFactory = new ContextFactory();
|
||||
|
||||
/**
|
||||
* @param domain the domain for which authentication should take place
|
||||
*/
|
||||
// public ActiveDirectoryLdapAuthenticationProvider(String domain) {
|
||||
// this (domain, null);
|
||||
// }
|
||||
|
||||
/**
|
||||
* @param domain the domain name (may be null or empty)
|
||||
* @param url an LDAP url (or multiple URLs)
|
||||
*/
|
||||
public AdAuthenticationProvider(String domain, String upnSuffix, String url) {
|
||||
Assert.isTrue(StringUtils.hasText(url), "Url cannot be empty");
|
||||
this.domain = StringUtils.hasText(domain) ? domain.toLowerCase() : null;
|
||||
//this.url = StringUtils.hasText(url) ? url : null;
|
||||
this.url = url;
|
||||
this.upnSuffix = upnSuffix;
|
||||
rootDn = this.domain == null ? null : rootDnFromDomain(this.domain);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DirContextOperations doAuthentication(UsernamePasswordAuthenticationToken auth) {
|
||||
String username = auth.getName();
|
||||
String password = (String)auth.getCredentials();
|
||||
|
||||
DirContext ctx = bindAsUser(username, password);
|
||||
|
||||
try {
|
||||
return searchForUser(ctx, username);
|
||||
|
||||
} catch (NamingException e) {
|
||||
logger.error("Failed to locate directory entry for authenticated user: " + username, e);
|
||||
throw badCredentials();
|
||||
} finally {
|
||||
LdapUtils.closeContext(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the user authority list from the values of the {@code memberOf} attribute obtained from the user's
|
||||
* Active Directory entry.
|
||||
*/
|
||||
@Override
|
||||
protected Collection<? extends GrantedAuthority> loadUserAuthorities(DirContextOperations userData, String username, String password) {
|
||||
String[] groups = userData.getStringAttributes("memberOf");
|
||||
|
||||
if (groups == null) {
|
||||
logger.debug("No values for 'memberOf' attribute.");
|
||||
|
||||
return AuthorityUtils.NO_AUTHORITIES;
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("'memberOf' attribute values: " + Arrays.asList(groups));
|
||||
}
|
||||
|
||||
ArrayList<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>(groups.length);
|
||||
|
||||
for (String group : groups) {
|
||||
authorities.add(new SimpleGrantedAuthority(new DistinguishedName(group).removeLast().getValue()));
|
||||
}
|
||||
|
||||
return authorities;
|
||||
}
|
||||
|
||||
private DirContext bindAsUser(String username, String password) {
|
||||
// TODO. add DNS lookup based on domain
|
||||
final String bindUrl = url;
|
||||
|
||||
Hashtable<String,String> env = new Hashtable<String,String>();
|
||||
env.put(Context.SECURITY_AUTHENTICATION, "simple");
|
||||
String bindPrincipal = createBindPrincipal(username);
|
||||
env.put(Context.SECURITY_PRINCIPAL, bindPrincipal);
|
||||
env.put(Context.PROVIDER_URL, bindUrl);
|
||||
env.put(Context.SECURITY_CREDENTIALS, password);
|
||||
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
|
||||
|
||||
try {
|
||||
return contextFactory.createContext(env);
|
||||
} catch (NamingException e) {
|
||||
if ((e instanceof AuthenticationException) || (e instanceof OperationNotSupportedException)) {
|
||||
handleBindException(bindPrincipal, e);
|
||||
throw badCredentials();
|
||||
} else {
|
||||
throw LdapUtils.convertLdapException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void handleBindException(String bindPrincipal, NamingException exception) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Authentication for " + bindPrincipal + " failed:" + exception);
|
||||
}
|
||||
|
||||
int subErrorCode = parseSubErrorCode(exception.getMessage());
|
||||
|
||||
if (subErrorCode > 0) {
|
||||
logger.info("Active Directory authentication failed: " + subCodeToLogMessage(subErrorCode));
|
||||
|
||||
if (convertSubErrorCodesToExceptions) {
|
||||
raiseExceptionForErrorCode(subErrorCode);
|
||||
}
|
||||
} else {
|
||||
logger.debug("Failed to locate AD-specific sub-error code in message");
|
||||
}
|
||||
}
|
||||
|
||||
int parseSubErrorCode(String message) {
|
||||
Matcher m = SUB_ERROR_CODE.matcher(message);
|
||||
|
||||
if (m.matches()) {
|
||||
return Integer.parseInt(m.group(1), 16);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void raiseExceptionForErrorCode(int code) {
|
||||
switch (code) {
|
||||
case PASSWORD_EXPIRED:
|
||||
throw new CredentialsExpiredException(messages.getMessage("LdapAuthenticationProvider.credentialsExpired",
|
||||
"User credentials have expired"));
|
||||
case ACCOUNT_DISABLED:
|
||||
throw new DisabledException(messages.getMessage("LdapAuthenticationProvider.disabled",
|
||||
"User is disabled"));
|
||||
case ACCOUNT_EXPIRED:
|
||||
throw new AccountExpiredException(messages.getMessage("LdapAuthenticationProvider.expired",
|
||||
"User account has expired"));
|
||||
case ACCOUNT_LOCKED:
|
||||
throw new LockedException(messages.getMessage("LdapAuthenticationProvider.locked",
|
||||
"User account is locked"));
|
||||
}
|
||||
}
|
||||
|
||||
String subCodeToLogMessage(int code) {
|
||||
switch (code) {
|
||||
case USERNAME_NOT_FOUND:
|
||||
return "User was not found in directory";
|
||||
case INVALID_PASSWORD:
|
||||
return "Supplied password was invalid";
|
||||
case NOT_PERMITTED:
|
||||
return "User not permitted to logon at this time";
|
||||
case PASSWORD_EXPIRED:
|
||||
return "Password has expired";
|
||||
case ACCOUNT_DISABLED:
|
||||
return "Account is disabled";
|
||||
case ACCOUNT_EXPIRED:
|
||||
return "Account expired";
|
||||
case PASSWORD_NEEDS_RESET:
|
||||
return "User must reset password";
|
||||
case ACCOUNT_LOCKED:
|
||||
return "Account locked";
|
||||
}
|
||||
|
||||
return "Unknown (error code " + Integer.toHexString(code) +")";
|
||||
}
|
||||
|
||||
private BadCredentialsException badCredentials() {
|
||||
return new BadCredentialsException(messages.getMessage(
|
||||
"LdapAuthenticationProvider.badCredentials", "Bad credentials"));
|
||||
}
|
||||
|
||||
private DirContextOperations searchForUser(DirContext ctx, String username) throws NamingException {
|
||||
SearchControls searchCtls = new SearchControls();
|
||||
searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);
|
||||
|
||||
String searchFilter = "(&(objectClass=user)(userPrincipalName={0}))";
|
||||
|
||||
final String bindPrincipal = createBindPrincipal(username);
|
||||
final String searchDn = createSearchDn(username);
|
||||
|
||||
String searchRoot = rootDn != null ? rootDn : searchRootFromPrincipal(bindPrincipal);
|
||||
|
||||
DirContextOperations ctxOp;
|
||||
|
||||
try {
|
||||
ctxOp = SpringSecurityLdapTemplate.searchForSingleEntryInternal(ctx, searchCtls, searchRoot, searchFilter,
|
||||
new Object[]{searchDn});
|
||||
|
||||
if (ctxOp != null) {
|
||||
return ctxOp;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.warn("UPN " + searchDn + " not found. Falling back to search with domain UPN suffix.");
|
||||
}
|
||||
|
||||
return SpringSecurityLdapTemplate.searchForSingleEntryInternal(ctx, searchCtls, searchRoot, searchFilter,
|
||||
new Object[]{bindPrincipal});
|
||||
}
|
||||
|
||||
private String searchRootFromPrincipal(String bindPrincipal) {
|
||||
int atChar = bindPrincipal.lastIndexOf('@');
|
||||
|
||||
if (atChar < 0) {
|
||||
logger.debug("User principal '" + bindPrincipal + "' does not contain the domain, and no domain has been configured");
|
||||
throw badCredentials();
|
||||
}
|
||||
|
||||
return rootDnFromDomain(bindPrincipal.substring(atChar+ 1, bindPrincipal.length()));
|
||||
}
|
||||
|
||||
private String rootDnFromDomain(String domain) {
|
||||
String[] tokens = StringUtils.tokenizeToStringArray(domain, ".");
|
||||
StringBuilder root = new StringBuilder();
|
||||
|
||||
for (String token : tokens) {
|
||||
if (root.length() > 0) {
|
||||
root.append(',');
|
||||
}
|
||||
root.append("dc=").append(token);
|
||||
}
|
||||
|
||||
return root.toString();
|
||||
}
|
||||
|
||||
String createBindPrincipal(String username) {
|
||||
if (domain == null || username.toLowerCase().endsWith(domain)) {
|
||||
return username;
|
||||
}
|
||||
|
||||
return username + "@" + domain;
|
||||
}
|
||||
|
||||
String createSearchDn(String username) {
|
||||
if (upnSuffix == null) {
|
||||
return createBindPrincipal(username);
|
||||
}
|
||||
|
||||
return username + "@" + upnSuffix;
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, a failed authentication (LDAP error 49) will result in a {@code BadCredentialsException}.
|
||||
* <p>
|
||||
* If this property is set to {@code true}, the exception message from a failed bind attempt will be parsed
|
||||
* for the AD-specific error code and a {@link CredentialsExpiredException}, {@link DisabledException},
|
||||
* {@link AccountExpiredException} or {@link LockedException} will be thrown for the corresponding codes. All
|
||||
* other codes will result in the default {@code BadCredentialsException}.
|
||||
*
|
||||
* @param convertSubErrorCodesToExceptions {@code true} to raise an exception based on the AD error code.
|
||||
*/
|
||||
public void setConvertSubErrorCodesToExceptions(boolean convertSubErrorCodesToExceptions) {
|
||||
this.convertSubErrorCodesToExceptions = convertSubErrorCodesToExceptions;
|
||||
}
|
||||
|
||||
static class ContextFactory {
|
||||
DirContext createContext(Hashtable<?,?> env) throws NamingException {
|
||||
return new InitialLdapContext(env, null);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package info.bukova.isspst.security;
|
||||
|
||||
public enum AuthMethod {
|
||||
|
||||
DATABASE,
|
||||
LDAP,
|
||||
AD
|
||||
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package info.bukova.isspst.services;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public class HqlDataFilter {
|
||||
private String where;
|
||||
private String orderBy;
|
||||
private Map<String, Object> params;
|
||||
private Class<?> dataClass;
|
||||
|
||||
public HqlDataFilter() {
|
||||
params = new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
public HqlDataFilter(String where) {
|
||||
this();
|
||||
this.where = where;
|
||||
}
|
||||
|
||||
public HqlDataFilter(String where, String orderBy) {
|
||||
this(where);
|
||||
this.orderBy = orderBy;
|
||||
}
|
||||
|
||||
public String getWhere() {
|
||||
return where;
|
||||
}
|
||||
|
||||
public void setWhere(String where) {
|
||||
this.where = where;
|
||||
}
|
||||
|
||||
public String getOrderBy() {
|
||||
return orderBy;
|
||||
}
|
||||
|
||||
public void setOrderBy(String orderBy) {
|
||||
this.orderBy = orderBy;
|
||||
}
|
||||
|
||||
public void setParam(String key, Object value) {
|
||||
params.put(key, value);
|
||||
}
|
||||
|
||||
public Object getParam(String key) {
|
||||
return params.get(key);
|
||||
}
|
||||
|
||||
public Set<String> getParamKeys() {
|
||||
return params.keySet();
|
||||
}
|
||||
|
||||
public void andFilter(String filter) {
|
||||
if (where == null || where.isEmpty()) {
|
||||
where = filter;
|
||||
} else {
|
||||
where += " and (" + filter + ")";
|
||||
}
|
||||
}
|
||||
|
||||
public void orFilter(String filter) {
|
||||
if (where == null ||where.isEmpty()) {
|
||||
where = filter;
|
||||
} else {
|
||||
where += " or (" + filter + ")";
|
||||
}
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
where = "";
|
||||
orderBy = "";
|
||||
params.clear();
|
||||
}
|
||||
|
||||
public Class<?> getDataClass() {
|
||||
return dataClass;
|
||||
}
|
||||
|
||||
public void setDataClass(Class<?> dataClass) {
|
||||
this.dataClass = dataClass;
|
||||
}
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package info.bukova.isspst.services;
|
||||
|
||||
import org.hibernate.Query;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public class HqlUtils {
|
||||
|
||||
public static String buildHql(String select, HqlDataFilter filter) {
|
||||
if (select.toLowerCase().contains("where")
|
||||
|| select.toLowerCase().contains("order by")) {
|
||||
throw new IsspstException("Use add*() methods instead.");
|
||||
}
|
||||
|
||||
String hql = addWhere(select, filter, "");
|
||||
return addOrderBy(hql, filter);
|
||||
}
|
||||
|
||||
public static String addAndWhere(String hql, HqlDataFilter filter) {
|
||||
if (!checkWhere(filter)) {
|
||||
return hql;
|
||||
}
|
||||
|
||||
return addWhere(hql, filter, "and");
|
||||
}
|
||||
|
||||
public static String addOrWhere(String hql, HqlDataFilter filter) {
|
||||
if (!checkWhere(filter)) {
|
||||
return hql;
|
||||
}
|
||||
|
||||
return addWhere(hql, filter, "or");
|
||||
}
|
||||
|
||||
public static String addOrderBy(String hql, HqlDataFilter filter) {
|
||||
if (filter == null || filter.getOrderBy() == null || filter.getOrderBy().isEmpty()) {
|
||||
return hql;
|
||||
}
|
||||
|
||||
if (!hql.contains("order by")) {
|
||||
hql += " order by ";
|
||||
}
|
||||
|
||||
hql += filter.getOrderBy();
|
||||
return hql;
|
||||
}
|
||||
|
||||
public static void addParameters(Query query, HqlDataFilter filter) {
|
||||
if (filter == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (String key : filter.getParamKeys()) {
|
||||
if (filter.getParam(key) instanceof Collection<?>) {
|
||||
query.setParameterList(key, (Collection) filter.getParam(key));
|
||||
} else {
|
||||
query.setParameter(key, filter.getParam(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean checkWhere(HqlDataFilter filter) {
|
||||
return filter != null && filter.getWhere() != null && !filter.getWhere().isEmpty();
|
||||
}
|
||||
|
||||
private static String addWhere(String hql, HqlDataFilter filter, String operator) {
|
||||
if (hql.toLowerCase().contains("where") && hql.toLowerCase().contains("order by")) {
|
||||
String[] split = hql.split("order by");
|
||||
hql = split[0] + " " + operator + " (" + filter.getWhere() + ") order by " + split[1];
|
||||
return hql;
|
||||
}
|
||||
|
||||
if (hql.toLowerCase().contains("where")) {
|
||||
hql += " " + operator + " (" + filter.getWhere() + ")";
|
||||
return hql;
|
||||
}
|
||||
|
||||
if (hql.toLowerCase().contains("order by")) {
|
||||
String[] split = hql.split("order by");
|
||||
hql = split[0] + " where (" + filter.getWhere() + ") order by " + split[1];
|
||||
return hql;
|
||||
}
|
||||
|
||||
hql += " where (" + filter.getWhere() + ")";
|
||||
return hql;
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package info.bukova.isspst.services;
|
||||
|
||||
public class ModuleNotActiveException extends IsspstException {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -1219763294556500698L;
|
||||
|
||||
public ModuleNotActiveException() {
|
||||
super("Module deactivated");
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue