From 6f325b5fdbfa8831a92d8f94b681e0cceab273f4 Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Sat, 12 Aug 2023 02:29:10 +0100 Subject: [PATCH] init --- build.gradle | 5 + mydatabase.mv.db | Bin 0 -> 24576 bytes mydatabase.trace.db | 382 ++++++++++++++++++ .../software/SPDF/SPdfApplication.java | 2 + .../software/SPDF/config/AppConfig.java | 11 + .../SPDF/config/CleanUrlInterceptor.java | 6 +- .../SPDF/controller/api/UserController.java | 28 ++ .../controller/web/GeneralWebController.java | 21 + .../software/SPDF/model/Authority.java | 52 +++ .../stirling/software/SPDF/model/User.java | 62 +++ .../SPDF/repository/AuthorityRepository.java | 12 + .../SPDF/repository/UserRepository.java | 12 + src/main/resources/application.properties | 15 +- src/main/resources/messages_en_GB.properties | 9 + .../resources/templates/fragments/navbar.html | 43 ++ src/main/resources/templates/home.html | 3 + src/main/resources/templates/login.html | 58 +++ 17 files changed, 718 insertions(+), 3 deletions(-) create mode 100644 mydatabase.mv.db create mode 100644 mydatabase.trace.db create mode 100644 src/main/java/stirling/software/SPDF/controller/api/UserController.java create mode 100644 src/main/java/stirling/software/SPDF/model/Authority.java create mode 100644 src/main/java/stirling/software/SPDF/model/User.java create mode 100644 src/main/java/stirling/software/SPDF/repository/AuthorityRepository.java create mode 100644 src/main/java/stirling/software/SPDF/repository/UserRepository.java create mode 100644 src/main/resources/templates/login.html diff --git a/build.gradle b/build.gradle index 5e95460f..23fa8fd6 100644 --- a/build.gradle +++ b/build.gradle @@ -48,7 +48,12 @@ dependencies { implementation 'org.yaml:snakeyaml:2.1' implementation 'org.springframework.boot:spring-boot-starter-web:3.1.2' implementation 'org.springframework.boot:spring-boot-starter-thymeleaf:3.1.2' + implementation 'org.springframework.boot:spring-boot-starter-security:3.1.2' testImplementation 'org.springframework.boot:spring-boot-starter-test:3.1.2' + implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5:3.1.2.RELEASE' + implementation "org.springframework.boot:spring-boot-starter-data-jpa" + implementation "com.h2database:h2" + // https://mvnrepository.com/artifact/org.apache.pdfbox/jbig2-imageio implementation group: 'org.apache.pdfbox', name: 'jbig2-imageio', version: '3.0.4' implementation 'commons-io:commons-io:2.13.0' diff --git a/mydatabase.mv.db b/mydatabase.mv.db new file mode 100644 index 0000000000000000000000000000000000000000..aab84074cda225de298492153178d5a3242b5ee1 GIT binary patch literal 24576 zcmeI3O>^708OKREjupplXEL*w9y(mbd2v^(;j2h$dRR)LEY`A=CFvwOX~DO|6It@e za%%5s5B&(e?5(}_&{Hq{5N%KGt<#Uvg5VqULR(hsZaWKSh9pQ3c<{#~5I^8ayT+HD z;n@99{gcbr3z1|qA0T}uT}xP0E!44wkRr+pokJzloVEQgaBTspbA(SUI0bmL|!aP zK5zl2f}$L_oT|u9QE?PCd=_1(EW8K+FY&AhFC0NtMNm|Efd?YI18Wpq+4GC4S5;V5 z2#Np%fRi|>=mW=Rd08w5A~a1@m8av$yUKgMa{BRnI-d9yQThQrrjc;Pp}6xdg1 z{$1rM&($@(th|n5GkgzK7*@8|0xq=V>e*aoXqY+vbz)MI>%nH^Z}YjQu%t@;YU*o~ z3Ajq$TBRZPVC2RFWaKKf&$nZFt2YW%fudK6{PiH)Omq>G~X0Or`Qefp; z|6WByey-P`H+0611%DoJm^%Vzd-dViG5x@w_#@Zf3x7UeuJX!}KLsc^MQ!YD^=bNN z)I&I)RyZj-RX4*FkB$O5O6VBfm(jI?jw(7j=;)%OhmQWk5jgcLgI#nw8F~I?h2wUx zlo};q140*kjGn**Y*l&9AxUyHwps4dC&O-4p0?w0=^{D989NAt8#d$dYdX@wSO ziFRn0mJ6Iz;Hnf=`2Mj{pdL|=&|C!iv6o)?=~b|G3V&6V6YpU-_o#5uiH}ZFbaJDU z_eVOO)o@-M+bEW!ShgnmA&%VbuZ4q$i1quL1wQX+bgVUZ|>Yo zMw7Fdxfx$oRX4LYnyN+Sfgefenrm(xHaE_$7 ziNP{S6`I?Lr>C4GOJb5>dDpA%h%%~bCcyz#OrLNLd>KwEzN4t}Kj8T*ihg6GNk)M& z(U}~G0z?6#z$YuP$lpuj={a7Ng{tJ-8AZnhZ6{yK`7aNgq29>59pIN$DvO=-}@t^SjvSqDXx#KFhe&+@LcliGu;eWUsK=?mghgkyh z@#-`V@;^TQe>lVcPD=f5dgZOf|4t5{;&i$i|5q33l#>GmWIT;82jD#IVm$3EgH??G z-Pm4!j;C|&&FB9Rrf2tN;NpcUVD@6m0l2-`_6_GI)3+S{&s$$vi~p}*VaYRb>5>ZK z|7dy|^M8~`kRMewlSueKHiGc~CzA~+fG9u|xJiLU{>I@s{r~i;q&RSkS-m&@pC8FF z{=fa2c-Dk;biO;o;r{>TUmtu!ZSGKXVdKH(!>!_@?Z-RR=gjlBmTof*Q`c;LP(L<0 zO@`;h5>wj!4ISNOjxF6}j26@F*^K_yuxyJdSz3v)w2sZZ@I1~Hc{Y$eM|EY^d%?6d ztIfRd9Z_&RAPFj``m)MM2S^A)HoM8x`%F`BX~(cVn#CARy=xnGpRx3> zkM(W?FVX5-wth57o(!r2^fH-m4C)P09*CSG59+$q8q`He6a`s;ZG#nt%5{%BopNMD zVphMzG}@Y}HEbyGYt8H%-Gi6BB<;ufLgBmGk)D@rd;b~pboVswro<+!{p(q4*_vrH zZw$N5a7)ZG1F z~TUP)qD&y2)b`PT|9mcD?^Nj!DFOInBRUmf?=zSwFiucag5uwxvs(xKgJ9Sl(3 z8~i9W0{zG=re&CxypBLI{!;d<^>t9DI{y0skd}99BSau znvPykx6BmY?ZI)baR@(&sXiwiCUD+Ss3f2eV zcqqSWPxXr{v&|bOuaAPuaj!l8V79dJsPfu8svnqF)l*pDldXRic42{0dGJQz`^|4Q z@GWMLf+Yr=fOf~CloZ886UAaSF>g>5{ks;77lK>OfBFu3 zEKL9T32NZA@d~+3y-#P#Iw#MW*5UsfR#@=P!To*dl1jw?xt$YL6?aZtZ?ylP7(w_S z`5-wE1&9LosX)U28GqyOobf*k`JcT<{-2NJT8aM`*TkbBxU30jbk<$-zeD(+@c+%L z6@>q1SCL{4i`H&3)?5zmg#VMpH+-Rm@c;FT8|(1@-|m|K|FyvX&J6!!8_VfRfWH?1 z=kX~{r!!m3xyTm5;7r?;NuKf1k`k d$|edB1@1(MVStore.java:469) + at org.h2.mvstore.MVStore$Builder.open(MVStore.java:4082) + at org.h2.mvstore.db.Store.(Store.java:136) + at org.h2.engine.Database.(Database.java:324) + at org.h2.engine.Engine.openSession(Engine.java:92) + at org.h2.engine.Engine.openSession(Engine.java:222) + at org.h2.engine.Engine.createSession(Engine.java:201) + at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:338) + at org.h2.jdbc.JdbcConnection.(JdbcConnection.java:122) + at org.h2.Driver.connect(Driver.java:59) + at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138) + at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:359) + at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201) + at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:470) + at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561) + at com.zaxxer.hikari.pool.HikariPool.(HikariPool.java:100) + at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112) + at org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration.getConnectionUrl(H2ConsoleAutoConfiguration.java:94) + at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) + at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) + at java.base/java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:395) + at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258) + at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258) + at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:510) + at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) + at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575) + at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260) + at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616) + at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:622) + at java.base/java.util.stream.ReferencePipeline.toList(ReferencePipeline.java:627) + at org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration.logDataSources(H2ConsoleAutoConfiguration.java:86) + at org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration.lambda$h2Console$0(H2ConsoleAutoConfiguration.java:69) + at org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration.withThreadContextClassLoader(H2ConsoleAutoConfiguration.java:78) + at org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration.h2Console(H2ConsoleAutoConfiguration.java:69) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:139) + at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:655) + at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:647) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1332) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1162) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:560) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520) + at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) + at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) + at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) + at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:205) + at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:210) + at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:201) + at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addServletContextInitializerBeans(ServletContextInitializerBeans.java:96) + at org.springframework.boot.web.servlet.ServletContextInitializerBeans.(ServletContextInitializerBeans.java:85) + at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getServletContextInitializerBeans(ServletWebServerApplicationContext.java:261) + at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.selfInitialize(ServletWebServerApplicationContext.java:235) + at org.springframework.boot.web.embedded.tomcat.TomcatStarter.onStartup(TomcatStarter.java:52) + at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4886) + at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) + at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1328) + at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1318) + at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) + at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) + at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145) + at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:866) + at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:846) + at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) + at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1328) + at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1318) + at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) + at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) + at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145) + at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:866) + at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:241) + at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) + at org.apache.catalina.core.StandardService.startInternal(StandardService.java:428) + at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) + at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:918) + at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) + at org.apache.catalina.startup.Tomcat.start(Tomcat.java:485) + at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:123) + at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.(TomcatWebServer.java:104) + at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:489) + at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:211) + at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:183) + at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:161) + at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:602) + at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) + at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) + at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:436) + at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) + at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) + at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) + at stirling.software.SPDF.SPdfApplication.main(SPdfApplication.java:53) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:50) +Caused by: org.h2.jdbc.JdbcSQLNonTransientException: General error: "org.h2.mvstore.MVStoreException: The file is locked: C:/Users/systo/git/Stirling-PDF/mydatabase.mv.db [2.1.214/7]" [50000-214] + at org.h2.message.DbException.getJdbcSQLException(DbException.java:554) + at org.h2.message.DbException.getJdbcSQLException(DbException.java:477) + ... 103 more +Caused by: org.h2.mvstore.MVStoreException: The file is locked: C:/Users/systo/git/Stirling-PDF/mydatabase.mv.db [2.1.214/7] + at org.h2.mvstore.DataUtils.newMVStoreException(DataUtils.java:1004) + at org.h2.mvstore.FileStore.open(FileStore.java:178) + at org.h2.mvstore.FileStore.open(FileStore.java:128) + at org.h2.mvstore.MVStore.(MVStore.java:452) + ... 97 more +2023-08-12 00:40:10 database: flush +org.h2.message.DbException: General error: "org.h2.mvstore.MVStoreException: The file is locked: C:/Users/systo/git/Stirling-PDF/mydatabase.mv.db [2.1.214/7]" [50000-214] + at org.h2.message.DbException.get(DbException.java:212) + at org.h2.message.DbException.convert(DbException.java:395) + at org.h2.mvstore.db.Store.lambda$new$0(Store.java:125) + at org.h2.mvstore.MVStore.handleException(MVStore.java:3318) + at org.h2.mvstore.MVStore.panic(MVStore.java:593) + at org.h2.mvstore.MVStore.(MVStore.java:469) + at org.h2.mvstore.MVStore$Builder.open(MVStore.java:4082) + at org.h2.mvstore.db.Store.(Store.java:136) + at org.h2.engine.Database.(Database.java:324) + at org.h2.engine.Engine.openSession(Engine.java:92) + at org.h2.engine.Engine.openSession(Engine.java:222) + at org.h2.engine.Engine.createSession(Engine.java:201) + at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:338) + at org.h2.jdbc.JdbcConnection.(JdbcConnection.java:122) + at org.h2.Driver.connect(Driver.java:59) + at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138) + at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:359) + at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201) + at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:470) + at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561) + at com.zaxxer.hikari.pool.HikariPool.(HikariPool.java:100) + at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112) + at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) + at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:316) + at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:152) + at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:34) + at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:119) + at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:264) + at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:239) + at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:216) + at org.hibernate.boot.model.relational.Database.(Database.java:45) + at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.getDatabase(InFlightMetadataCollectorImpl.java:230) + at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.(InFlightMetadataCollectorImpl.java:198) + at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:166) + at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1380) + at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1451) + at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:75) + at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:376) + at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) + at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) + at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:352) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1817) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1766) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:598) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520) + at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) + at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) + at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) + at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) + at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1155) + at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) + at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:608) + at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) + at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) + at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:436) + at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) + at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) + at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) + at stirling.software.SPDF.SPdfApplication.main(SPdfApplication.java:53) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:50) +Caused by: org.h2.jdbc.JdbcSQLNonTransientException: General error: "org.h2.mvstore.MVStoreException: The file is locked: C:/Users/systo/git/Stirling-PDF/mydatabase.mv.db [2.1.214/7]" [50000-214] + at org.h2.message.DbException.getJdbcSQLException(DbException.java:554) + at org.h2.message.DbException.getJdbcSQLException(DbException.java:477) + ... 64 more +Caused by: org.h2.mvstore.MVStoreException: The file is locked: C:/Users/systo/git/Stirling-PDF/mydatabase.mv.db [2.1.214/7] + at org.h2.mvstore.DataUtils.newMVStoreException(DataUtils.java:1004) + at org.h2.mvstore.FileStore.open(FileStore.java:178) + at org.h2.mvstore.FileStore.open(FileStore.java:128) + at org.h2.mvstore.MVStore.(MVStore.java:452) + ... 58 more +2023-08-12 00:40:34 database: flush +org.h2.message.DbException: General error: "org.h2.mvstore.MVStoreException: The file is locked: C:/Users/systo/git/Stirling-PDF/mydatabase.mv.db [2.1.214/7]" [50000-214] + at org.h2.message.DbException.get(DbException.java:212) + at org.h2.message.DbException.convert(DbException.java:395) + at org.h2.mvstore.db.Store.lambda$new$0(Store.java:125) + at org.h2.mvstore.MVStore.handleException(MVStore.java:3318) + at org.h2.mvstore.MVStore.panic(MVStore.java:593) + at org.h2.mvstore.MVStore.(MVStore.java:469) + at org.h2.mvstore.MVStore$Builder.open(MVStore.java:4082) + at org.h2.mvstore.db.Store.(Store.java:136) + at org.h2.engine.Database.(Database.java:324) + at org.h2.engine.Engine.openSession(Engine.java:92) + at org.h2.engine.Engine.openSession(Engine.java:222) + at org.h2.engine.Engine.createSession(Engine.java:201) + at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:338) + at org.h2.jdbc.JdbcConnection.(JdbcConnection.java:122) + at org.h2.Driver.connect(Driver.java:59) + at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138) + at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:359) + at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201) + at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:470) + at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561) + at com.zaxxer.hikari.pool.HikariPool.(HikariPool.java:100) + at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112) + at org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration.getConnectionUrl(H2ConsoleAutoConfiguration.java:94) + at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) + at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) + at java.base/java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:395) + at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258) + at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258) + at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:510) + at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) + at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575) + at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260) + at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616) + at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:622) + at java.base/java.util.stream.ReferencePipeline.toList(ReferencePipeline.java:627) + at org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration.logDataSources(H2ConsoleAutoConfiguration.java:86) + at org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration.lambda$h2Console$0(H2ConsoleAutoConfiguration.java:69) + at org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration.withThreadContextClassLoader(H2ConsoleAutoConfiguration.java:78) + at org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration.h2Console(H2ConsoleAutoConfiguration.java:69) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:139) + at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:655) + at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:647) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1332) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1162) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:560) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520) + at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) + at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) + at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) + at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:205) + at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:210) + at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:201) + at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addServletContextInitializerBeans(ServletContextInitializerBeans.java:96) + at org.springframework.boot.web.servlet.ServletContextInitializerBeans.(ServletContextInitializerBeans.java:85) + at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getServletContextInitializerBeans(ServletWebServerApplicationContext.java:261) + at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.selfInitialize(ServletWebServerApplicationContext.java:235) + at org.springframework.boot.web.embedded.tomcat.TomcatStarter.onStartup(TomcatStarter.java:52) + at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4886) + at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) + at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1328) + at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1318) + at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) + at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) + at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145) + at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:866) + at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:846) + at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) + at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1328) + at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1318) + at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) + at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) + at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145) + at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:866) + at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:241) + at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) + at org.apache.catalina.core.StandardService.startInternal(StandardService.java:428) + at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) + at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:918) + at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) + at org.apache.catalina.startup.Tomcat.start(Tomcat.java:485) + at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:123) + at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.(TomcatWebServer.java:104) + at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:489) + at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:211) + at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:183) + at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:161) + at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:602) + at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) + at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) + at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:436) + at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) + at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) + at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) + at stirling.software.SPDF.SPdfApplication.main(SPdfApplication.java:53) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:50) +Caused by: org.h2.jdbc.JdbcSQLNonTransientException: General error: "org.h2.mvstore.MVStoreException: The file is locked: C:/Users/systo/git/Stirling-PDF/mydatabase.mv.db [2.1.214/7]" [50000-214] + at org.h2.message.DbException.getJdbcSQLException(DbException.java:554) + at org.h2.message.DbException.getJdbcSQLException(DbException.java:477) + ... 103 more +Caused by: org.h2.mvstore.MVStoreException: The file is locked: C:/Users/systo/git/Stirling-PDF/mydatabase.mv.db [2.1.214/7] + at org.h2.mvstore.DataUtils.newMVStoreException(DataUtils.java:1004) + at org.h2.mvstore.FileStore.open(FileStore.java:178) + at org.h2.mvstore.FileStore.open(FileStore.java:128) + at org.h2.mvstore.MVStore.(MVStore.java:452) + ... 97 more +2023-08-12 00:40:36 database: flush +org.h2.message.DbException: General error: "org.h2.mvstore.MVStoreException: The file is locked: C:/Users/systo/git/Stirling-PDF/mydatabase.mv.db [2.1.214/7]" [50000-214] + at org.h2.message.DbException.get(DbException.java:212) + at org.h2.message.DbException.convert(DbException.java:395) + at org.h2.mvstore.db.Store.lambda$new$0(Store.java:125) + at org.h2.mvstore.MVStore.handleException(MVStore.java:3318) + at org.h2.mvstore.MVStore.panic(MVStore.java:593) + at org.h2.mvstore.MVStore.(MVStore.java:469) + at org.h2.mvstore.MVStore$Builder.open(MVStore.java:4082) + at org.h2.mvstore.db.Store.(Store.java:136) + at org.h2.engine.Database.(Database.java:324) + at org.h2.engine.Engine.openSession(Engine.java:92) + at org.h2.engine.Engine.openSession(Engine.java:222) + at org.h2.engine.Engine.createSession(Engine.java:201) + at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:338) + at org.h2.jdbc.JdbcConnection.(JdbcConnection.java:122) + at org.h2.Driver.connect(Driver.java:59) + at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138) + at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:359) + at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201) + at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:470) + at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561) + at com.zaxxer.hikari.pool.HikariPool.(HikariPool.java:100) + at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112) + at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) + at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:316) + at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:152) + at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:34) + at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:119) + at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:264) + at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:239) + at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:216) + at org.hibernate.boot.model.relational.Database.(Database.java:45) + at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.getDatabase(InFlightMetadataCollectorImpl.java:230) + at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.(InFlightMetadataCollectorImpl.java:198) + at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:166) + at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1380) + at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1451) + at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:75) + at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:376) + at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) + at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) + at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:352) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1817) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1766) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:598) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520) + at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) + at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) + at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) + at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) + at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1155) + at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) + at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:608) + at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) + at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) + at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:436) + at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) + at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) + at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) + at stirling.software.SPDF.SPdfApplication.main(SPdfApplication.java:53) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:50) +Caused by: org.h2.jdbc.JdbcSQLNonTransientException: General error: "org.h2.mvstore.MVStoreException: The file is locked: C:/Users/systo/git/Stirling-PDF/mydatabase.mv.db [2.1.214/7]" [50000-214] + at org.h2.message.DbException.getJdbcSQLException(DbException.java:554) + at org.h2.message.DbException.getJdbcSQLException(DbException.java:477) + ... 64 more +Caused by: org.h2.mvstore.MVStoreException: The file is locked: C:/Users/systo/git/Stirling-PDF/mydatabase.mv.db [2.1.214/7] + at org.h2.mvstore.DataUtils.newMVStoreException(DataUtils.java:1004) + at org.h2.mvstore.FileStore.open(FileStore.java:178) + at org.h2.mvstore.FileStore.open(FileStore.java:128) + at org.h2.mvstore.MVStore.(MVStore.java:452) + ... 58 more diff --git a/src/main/java/stirling/software/SPDF/SPdfApplication.java b/src/main/java/stirling/software/SPDF/SPdfApplication.java index f9512295..f374f9b1 100644 --- a/src/main/java/stirling/software/SPDF/SPdfApplication.java +++ b/src/main/java/stirling/software/SPDF/SPdfApplication.java @@ -10,11 +10,13 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.core.env.Environment; import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import jakarta.annotation.PostConstruct; import stirling.software.SPDF.utils.GeneralUtils; @SpringBootApplication +@EnableWebSecurity(debug = true) //@EnableScheduling public class SPdfApplication { diff --git a/src/main/java/stirling/software/SPDF/config/AppConfig.java b/src/main/java/stirling/software/SPDF/config/AppConfig.java index 430bcae8..9212bf7e 100644 --- a/src/main/java/stirling/software/SPDF/config/AppConfig.java +++ b/src/main/java/stirling/software/SPDF/config/AppConfig.java @@ -5,6 +5,17 @@ import org.springframework.context.annotation.Configuration; @Configuration public class AppConfig { + + + @Bean(name = "loginEnabled") + public boolean loginEnabled() { + String appName = System.getProperty("login.enabled"); + if (appName == null) + appName = System.getenv("login.enabled"); + + return (appName != null) ? Boolean.valueOf(appName) : false; + } + @Bean(name = "appName") public String appName() { String appName = System.getProperty("APP_HOME_NAME"); diff --git a/src/main/java/stirling/software/SPDF/config/CleanUrlInterceptor.java b/src/main/java/stirling/software/SPDF/config/CleanUrlInterceptor.java index efa084b3..dc2e144b 100644 --- a/src/main/java/stirling/software/SPDF/config/CleanUrlInterceptor.java +++ b/src/main/java/stirling/software/SPDF/config/CleanUrlInterceptor.java @@ -24,8 +24,9 @@ import org.springframework.web.servlet.ModelAndView; public class CleanUrlInterceptor implements HandlerInterceptor { - private static final List ALLOWED_PARAMS = Arrays.asList("lang", "endpoint", "endpoints"); + private static final List ALLOWED_PARAMS = Arrays.asList("lang", "endpoint", "endpoints", "logout", "error"); + @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { @@ -39,9 +40,12 @@ public class CleanUrlInterceptor implements HandlerInterceptor { String[] queryParameters = queryString.split("&"); for (String param : queryParameters) { String[] keyValue = param.split("="); + System.out.print("astirli " + keyValue[0]); if (keyValue.length != 2) { continue; } + System.out.print("astirli2 " + keyValue[0]); + if (ALLOWED_PARAMS.contains(keyValue[0])) { parameters.put(keyValue[0], keyValue[1]); } diff --git a/src/main/java/stirling/software/SPDF/controller/api/UserController.java b/src/main/java/stirling/software/SPDF/controller/api/UserController.java new file mode 100644 index 00000000..0fdfebb4 --- /dev/null +++ b/src/main/java/stirling/software/SPDF/controller/api/UserController.java @@ -0,0 +1,28 @@ +package stirling.software.SPDF.controller.api; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; + +import stirling.software.SPDF.config.security.UserService; + +@Controller +public class UserController { + + @Autowired + private UserService userService; + + @PostMapping("/register") + public String register(@RequestParam String username, @RequestParam String password, Model model) { + if(userService.usernameExists(username)) { + model.addAttribute("error", "Username already exists"); + return "register"; + } + + userService.saveUser(username, password); + return "redirect:/login?registered=true"; + } +} diff --git a/src/main/java/stirling/software/SPDF/controller/web/GeneralWebController.java b/src/main/java/stirling/software/SPDF/controller/web/GeneralWebController.java index 4d6e991a..7da338ba 100644 --- a/src/main/java/stirling/software/SPDF/controller/web/GeneralWebController.java +++ b/src/main/java/stirling/software/SPDF/controller/web/GeneralWebController.java @@ -16,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.io.Resource; import org.springframework.core.io.ResourceLoader; import org.springframework.core.io.support.ResourcePatternUtils; +import org.springframework.security.core.Authentication; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; @@ -24,10 +25,30 @@ import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.v3.oas.annotations.Hidden; import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.servlet.http.HttpServletRequest; @Controller @Tag(name = "General", description = "General APIs") public class GeneralWebController { + + @GetMapping("/login") + public String login(HttpServletRequest request, Model model, Authentication authentication) { + if (authentication != null && authentication.isAuthenticated()) { + return "redirect:/"; + } + + if (request.getParameter("error") != null) { + + model.addAttribute("error", request.getParameter("error")); + } + if (request.getParameter("logout") != null) { + + model.addAttribute("logoutMessage", "You have been logged out."); + } + + return "login"; + } + @GetMapping("/pipeline") @Hidden public String pipelineForm(Model model) { diff --git a/src/main/java/stirling/software/SPDF/model/Authority.java b/src/main/java/stirling/software/SPDF/model/Authority.java new file mode 100644 index 00000000..e87ece3f --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/Authority.java @@ -0,0 +1,52 @@ +package stirling.software.SPDF.model; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; + +@Entity +@Table(name = "authorities") +public class Authority { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "authority") + private String authority; + + @ManyToOne + @JoinColumn(name = "username") + private User user; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getAuthority() { + return authority; + } + + public void setAuthority(String authority) { + this.authority = authority; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + +} diff --git a/src/main/java/stirling/software/SPDF/model/User.java b/src/main/java/stirling/software/SPDF/model/User.java new file mode 100644 index 00000000..2cea4d73 --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/User.java @@ -0,0 +1,62 @@ +package stirling.software.SPDF.model; + +import java.util.Set; + +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Id; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; + +@Entity +@Table(name = "users") +public class User { + + @Id + @Column(name = "username") + private String username; + + @Column(name = "password") + private String password; + + @Column(name = "enabled") + private boolean enabled; + + @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "user") + private Set authorities; + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public Set getAuthorities() { + return authorities; + } + + public void setAuthorities(Set authorities) { + this.authorities = authorities; + } + +} diff --git a/src/main/java/stirling/software/SPDF/repository/AuthorityRepository.java b/src/main/java/stirling/software/SPDF/repository/AuthorityRepository.java new file mode 100644 index 00000000..62f546b8 --- /dev/null +++ b/src/main/java/stirling/software/SPDF/repository/AuthorityRepository.java @@ -0,0 +1,12 @@ +package stirling.software.SPDF.repository; + +import java.util.Set; + +import org.springframework.data.jpa.repository.JpaRepository; + +import stirling.software.SPDF.model.Authority; + +public interface AuthorityRepository extends JpaRepository { + //Set findByUsername(String username); + Set findByUser_Username(String username); +} diff --git a/src/main/java/stirling/software/SPDF/repository/UserRepository.java b/src/main/java/stirling/software/SPDF/repository/UserRepository.java new file mode 100644 index 00000000..064df341 --- /dev/null +++ b/src/main/java/stirling/software/SPDF/repository/UserRepository.java @@ -0,0 +1,12 @@ +package stirling.software.SPDF.repository; + +import java.util.Optional; + +import org.springframework.data.jpa.repository.JpaRepository; + +import stirling.software.SPDF.model.User; + +public interface UserRepository extends JpaRepository { + Optional findByUsername(String username); +} + diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index c4118342..bf594bfc 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -16,8 +16,11 @@ server.error.include-stacktrace=always server.error.include-exception=true server.error.include-message=always -#logging.level.org.springframework.web=DEBUG +logging.level.org.springframework.web=DEBUG +logging.level.org.springframework=DEBUG +logging.level.org.springframework.security=DEBUG +login.enabled=true server.servlet.session.tracking-modes=cookie server.servlet.context-path=${APP_ROOT_PATH:/} @@ -32,4 +35,12 @@ spring.mvc.async.request-timeout=${ASYNC_CONNECTION_TIMEOUT:300000} spring.resources.static-locations=file:customFiles/static/ #spring.thymeleaf.prefix=file:/customFiles/templates/,classpath:/templates/ -#spring.thymeleaf.cache=false \ No newline at end of file +#spring.thymeleaf.cache=false + + +spring.datasource.url=jdbc:h2:file:./mydatabase;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE +spring.datasource.driver-class-name=org.h2.Driver +spring.datasource.username=sa +spring.datasource.password= +spring.h2.console.enabled=true +spring.jpa.hibernate.ddl-auto=update diff --git a/src/main/resources/messages_en_GB.properties b/src/main/resources/messages_en_GB.properties index 977260a5..182701ce 100644 --- a/src/main/resources/messages_en_GB.properties +++ b/src/main/resources/messages_en_GB.properties @@ -55,6 +55,15 @@ settings.downloadOption.2=Open in new window settings.downloadOption.3=Download file settings.zipThreshold=Zip files when the number of downloaded files exceeds +settings.userSettings=User Settings +settings.changeUsername=New Username +settings.changeUsernameButton=Change Username +settings.password=Password +settings.oldPassword=Old password +settings.newPassword=New Password +settings.changePasswordButton=Change Password +settings.confirmNewPassword=Confirm New Password +settings.signOut=Sign Out ############# # HOME-PAGE # ############# diff --git a/src/main/resources/templates/fragments/navbar.html b/src/main/resources/templates/fragments/navbar.html index ea253dab..4ae83570 100644 --- a/src/main/resources/templates/fragments/navbar.html +++ b/src/main/resources/templates/fragments/navbar.html @@ -338,6 +338,49 @@ + +
+
User Settings
+ +
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+ + +