renamed module: enterprise > proprietary

This commit is contained in:
Dario Ghunney Ware 2025-05-09 16:48:48 +01:00
parent cab21eb590
commit 4aa02a9271
106 changed files with 332 additions and 358 deletions

View File

@ -84,7 +84,7 @@ jobs:
core.setOutput('repository', repository);
core.setOutput('ref', pr.head.ref);
- name: Check for security/login flag
id: check-security-flag
env:
@ -156,9 +156,9 @@ jobs:
- name: Run Gradle Command
run: |
if [ "${{ needs.check-comment.outputs.enable_security }}" == "true" ]; then
export DOCKER_ENABLE_SECURITY=true
export ADDITIONAL_FEATURES=true
else
export DOCKER_ENABLE_SECURITY=false
export ADDITIONAL_FEATURES=false
fi
./gradlew clean build
env:
@ -223,7 +223,7 @@ jobs:
- /stirling/PR-${{ needs.check-comment.outputs.pr_number }}/config:/configs:rw
- /stirling/PR-${{ needs.check-comment.outputs.pr_number }}/logs:/logs:rw
environment:
DOCKER_ENABLE_SECURITY: "${DOCKER_SECURITY}"
ADDITIONAL_FEATURES: "${DOCKER_SECURITY}"
SECURITY_ENABLELOGIN: "${LOGIN_SECURITY}"
SYSTEM_DEFAULTLOCALE: en-GB
UI_APPNAME: "Stirling-PDF PR#${{ needs.check-comment.outputs.pr_number }}"
@ -250,7 +250,7 @@ jobs:
docker-compose pull
docker-compose up -d
ENDSSH
# Set output for use in PR comment
echo "security_status=${SECURITY_STATUS}" >> $GITHUB_ENV

View File

@ -40,12 +40,12 @@ jobs:
- name: Build with Gradle and no spring security
run: ./gradlew clean build
env:
DOCKER_ENABLE_SECURITY: false
ADDITIONAL_FEATURES: false
- name: Build with Gradle and with spring security
run: ./gradlew clean build
env:
DOCKER_ENABLE_SECURITY: true
ADDITIONAL_FEATURES: true
- name: Upload Test Reports
if: always()

View File

@ -75,7 +75,7 @@ jobs:
- name: Generate jar (With Security=${{ matrix.enable_security }})
run: ./gradlew clean createExe
env:
DOCKER_ENABLE_SECURITY: ${{ matrix.enable_security }}
ADDITIONAL_FEATURES: ${{ matrix.enable_security }}
STIRLING_PDF_DESKTOP_UI: false
- name: Rename binaries
@ -171,7 +171,7 @@ jobs:
- name: Build Installer
run: ./gradlew build jpackage -x test --info
env:
DOCKER_ENABLE_SECURITY: false
ADDITIONAL_FEATURES: false
STIRLING_PDF_DESKTOP_UI: true
BROWSER_OPEN: true

View File

@ -37,7 +37,7 @@ jobs:
- name: Run Gradle Command
run: ./gradlew clean build
env:
DOCKER_ENABLE_SECURITY: false
ADDITIONAL_FEATURES: false
STIRLING_PDF_DESKTOP_UI: false
- name: Install cosign

View File

@ -42,7 +42,7 @@ jobs:
- name: Generate jar (With Security=${{ matrix.enable_security }})
run: ./gradlew clean createExe
env:
DOCKER_ENABLE_SECURITY: ${{ matrix.enable_security }}
ADDITIONAL_FEATURES: ${{ matrix.enable_security }}
STIRLING_PDF_DESKTOP_UI: false
- name: Get version number

View File

@ -33,7 +33,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
DOCKER_ENABLE_SECURITY: true
ADDITIONAL_FEATURES: true
STIRLING_PDF_DESKTOP_UI: true
run: |
./gradlew clean build sonar \

View File

@ -28,7 +28,7 @@ jobs:
- name: Build with Gradle
run: ./gradlew clean build
env:
DOCKER_ENABLE_SECURITY: false
ADDITIONAL_FEATURES: false
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
@ -76,7 +76,7 @@ jobs:
- /stirling/test-${{ github.sha }}/config:/configs:rw
- /stirling/test-${{ github.sha }}/logs:/logs:rw
environment:
DOCKER_ENABLE_SECURITY: "false"
ADDITIONAL_FEATURES: "false"
SECURITY_ENABLELOGIN: "false"
SYSTEM_DEFAULTLOCALE: en-GB
UI_APPNAME: "Stirling-PDF Test"

View File

@ -55,7 +55,7 @@ Stirling-PDF uses Lombok to reduce boilerplate code. Some IDEs, like Eclipse, do
Visit the [Lombok website](https://projectlombok.org/setup/) for installation instructions specific to your IDE.
5. Add environment variable
For local testing, you should generally be testing the full 'Security' version of Stirling-PDF. To do this, you must add the environment flag DOCKER_ENABLE_SECURITY=true to your system and/or IDE build/run step.
For local testing, you should generally be testing the full 'Security' version of Stirling-PDF. To do this, you must add the environment flag ADDITIONAL_FEATURES=true to your system and/or IDE build/run step.
## 4. Project Structure
@ -141,7 +141,7 @@ services:
- /stirling/latest/config:/configs:rw
- /stirling/latest/logs:/logs:rw
environment:
DOCKER_ENABLE_SECURITY: "true"
ADDITIONAL_FEATURES: "true"
SECURITY_ENABLELOGIN: "true"
PUID: 1002
PGID: 1002
@ -170,7 +170,7 @@ Stirling-PDF uses different Docker images for various configurations. The build
1. Set the security environment variable:
```bash
export DOCKER_ENABLE_SECURITY=false # or true for security-enabled builds
export ADDITIONAL_FEATURES=false # or true for security-enabled builds
```
2. Build the project with Gradle:
@ -196,7 +196,7 @@ Stirling-PDF uses different Docker images for various configurations. The build
For the fat version (with security enabled):
```bash
export DOCKER_ENABLE_SECURITY=true
export ADDITIONAL_FEATURES=true
docker build --no-cache --pull --build-arg VERSION_TAG=alpha -t stirlingtools/stirling-pdf:latest-fat -f ./Dockerfile.fat .
```

View File

@ -23,7 +23,7 @@ LABEL org.opencontainers.image.version="${VERSION_TAG}"
LABEL org.opencontainers.image.keywords="PDF, manipulation, merge, split, convert, OCR, watermark"
# Set Environment Variables
ENV DOCKER_ENABLE_SECURITY=false \
ENV ADDITIONAL_FEATURES=false \
VERSION_TAG=$VERSION_TAG \
JAVA_BASE_OPTS="-XX:+UnlockExperimentalVMOptions -XX:MaxRAMPercentage=75 -XX:InitiatingHeapOccupancyPercent=20 -XX:+G1PeriodicGCInvokesConcurrent -XX:G1PeriodicGCInterval=10000 -XX:+UseStringDeduplication -XX:G1PeriodicGCSystemLoadThreshold=70" \
JAVA_CUSTOM_OPTS="" \

View File

@ -13,8 +13,8 @@ WORKDIR /app
# Copy the entire project to the working directory
COPY . .
# Build the application with DOCKER_ENABLE_SECURITY=false
RUN DOCKER_ENABLE_SECURITY=true \
# Build the application with ADDITIONAL_FEATURES=false
RUN ADDITIONAL_FEATURES=true \
STIRLING_PDF_DESKTOP_UI=false \
./gradlew clean build -x spotlessApply -x spotlessCheck -x test -x sonarqube
@ -30,7 +30,7 @@ COPY --from=build /app/build/libs/*.jar app.jar
ARG VERSION_TAG
# Set Environment Variables
ENV DOCKER_ENABLE_SECURITY=false \
ENV ADDITIONAL_FEATURES=false \
VERSION_TAG=$VERSION_TAG \
JAVA_BASE_OPTS="-XX:+UnlockExperimentalVMOptions -XX:MaxRAMPercentage=75 -XX:InitiatingHeapOccupancyPercent=20 -XX:+G1PeriodicGCInvokesConcurrent -XX:G1PeriodicGCInterval=10000 -XX:+UseStringDeduplication -XX:G1PeriodicGCSystemLoadThreshold=70" \
JAVA_CUSTOM_OPTS="" \

View File

@ -4,7 +4,7 @@ FROM alpine:3.21.3@sha256:a8560b36e8b8210634f77d9f7f9efd7ffa463e380b75e2e74aff45
ARG VERSION_TAG
# Set Environment Variables
ENV DOCKER_ENABLE_SECURITY=false \
ENV ADDITIONAL_FEATURES=false \
HOME=/home/stirlingpdfuser \
VERSION_TAG=$VERSION_TAG \
JAVA_BASE_OPTS="-XX:+UnlockExperimentalVMOptions -XX:MaxRAMPercentage=75 -XX:InitiatingHeapOccupancyPercent=20 -XX:+G1PeriodicGCInvokesConcurrent -XX:G1PeriodicGCInterval=10000 -XX:+UseStringDeduplication -XX:G1PeriodicGCSystemLoadThreshold=70" \

View File

@ -50,7 +50,7 @@ licenseReport {
sourceSets {
main {
java {
if (System.getenv("DOCKER_ENABLE_SECURITY") == "false") {
if (System.getenv("ADDITIONAL_FEATURES") == "false") {
exclude "stirling/software/SPDF/config/interfaces/DatabaseInterface.java"
exclude "stirling/software/SPDF/config/security/**"
exclude "stirling/software/SPDF/controller/api/DatabaseController.java"
@ -70,15 +70,15 @@ sourceSets {
exclude "stirling/software/SPDF/model/User.java"
exclude "stirling/software/SPDF/repository/**"
exclude 'stirling/software/enterprise/security/controller/**'
exclude 'stirling/software/enterprise/security/model/ApiKeyAuthenticationToken.java'
exclude 'stirling/software/enterprise/security/model/AttemptCounter.java'
exclude 'stirling/software/enterprise/security/model/Authority.java'
exclude 'stirling/software/enterprise/security/model/BackupNotFoundException.java'
exclude 'stirling/software/enterprise/security/model/PersistentLogin.java'
exclude 'stirling/software/enterprise/security/model/SessionEntity.java'
exclude 'stirling/software/enterprise/security/model/User.java'
exclude 'stirling/software/enterprise/security/database/repository/**'
exclude 'stirling/software/proprietary/security/controller/**'
exclude 'stirling/software/proprietary/security/model/ApiKeyAuthenticationToken.java'
exclude 'stirling/software/proprietary/security/model/AttemptCounter.java'
exclude 'stirling/software/proprietary/security/model/Authority.java'
exclude 'stirling/software/proprietary/security/model/BackupNotFoundException.java'
exclude 'stirling/software/proprietary/security/model/PersistentLogin.java'
exclude 'stirling/software/proprietary/security/model/SessionEntity.java'
exclude 'stirling/software/proprietary/security/model/User.java'
exclude 'stirling/software/proprietary/security/database/repository/**'
}
if (System.getenv("STIRLING_PDF_DESKTOP_UI") == "false") {
@ -438,8 +438,8 @@ dependencies {
exclude group: 'org.bouncycastle', module: 'bcmail-jdk15on'
}
if (System.getenv("DOCKER_ENABLE_SECURITY") == "true") {
implementation project(':enterprise')
if (System.getenv("ADDITIONAL_FEATURES") == "true") {
implementation project(':proprietary')
}
if (System.getenv("STIRLING_PDF_DESKTOP_UI") != "false") {
@ -505,13 +505,12 @@ dependencies {
implementation "org.bouncycastle:bcprov-jdk18on:$bouncycastleVersion"
implementation "org.bouncycastle:bcpkix-jdk18on:$bouncycastleVersion"
implementation "org.springframework.boot:spring-boot-starter-actuator:$springBootVersion"
implementation "io.micrometer:micrometer-core:1.14.7"
implementation group: "com.google.zxing", name: "core", version: "3.5.3"
// https://mvnrepository.com/artifact/org.commonmark/commonmark
implementation "org.commonmark:commonmark:0.24.0"
implementation "org.commonmark:commonmark-ext-gfm-tables:0.24.0"
implementation 'io.micrometer:micrometer-core:1.14.7'
implementation 'com.google.zxing:core:3.5.3'
implementation 'org.commonmark:commonmark:0.24.0' // https://mvnrepository.com/artifact/org.commonmark/commonmark
implementation 'org.commonmark:commonmark-ext-gfm-tables:0.24.0'
developmentOnly("org.springframework.boot:spring-boot-devtools:$springBootVersion")
developmentOnly "org.springframework.boot:spring-boot-devtools:$springBootVersion"
compileOnly "org.projectlombok:lombok:$lombokVersion"
annotationProcessor "org.projectlombok:lombok:$lombokVersion"

View File

@ -6,10 +6,6 @@ plugins {
group = 'stirling.software'
version = '0.45.6'
ext {
lombokVersion = "1.18.38"
}
java {
sourceCompatibility = JavaVersion.VERSION_17
}
@ -48,10 +44,9 @@ dependencies {
testImplementation platform('org.junit:junit-bom:5.10.0')
testImplementation "org.springframework.boot:spring-boot-starter-test"
testRuntimeOnly 'org.springframework.boot:spring-boot-starter-data-jpa'
testRuntimeOnly 'com.h2database:h2:2.3.232'
testRuntimeOnly 'org.postgresql:postgresql:42.7.5'
testImplementation 'org.junit.jupiter:junit-jupiter'
testRuntimeOnly 'org.springframework.boot:spring-boot-starter-data-jpa'
testRuntimeOnly 'org.mockito:mockito-inline:5.2.0'
}
test {

View File

@ -1,7 +1,5 @@
package stirling.software.common.configuration;
import io.github.pixee.security.SystemCommand;
import jakarta.annotation.PostConstruct;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
@ -10,8 +8,9 @@ import java.util.List;
import java.util.Locale;
import java.util.Properties;
import java.util.function.Predicate;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@ -24,9 +23,6 @@ import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.thymeleaf.spring6.SpringTemplateEngine;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import stirling.software.common.model.ApplicationProperties;
@Lazy
@ -154,7 +150,7 @@ public class AppConfig {
}
@Bean(name = "missingActiveSecurity")
@ConditionalOnMissingClass("stirling.software.enterprise.security.SecurityConfiguration")
@ConditionalOnMissingClass("stirling.software.proprietary.security.SecurityConfiguration")
public boolean missingActiveSecurity() {
return true;
}

View File

@ -30,7 +30,7 @@ import lombok.extern.slf4j.Slf4j;
import stirling.software.common.configuration.InstallationPathConfig;
@Slf4j
public class GeneralUtils {
public class GeneralUtil {
public static File convertMultipartFileToFile(MultipartFile multipartFile) throws IOException {
File tempFile = Files.createTempFile("temp", null).toFile();

View File

@ -84,7 +84,7 @@ public class PdfUtils {
public static boolean hasImages(PDDocument document, String pagesToCheck) throws IOException {
String[] pageOrderArr = pagesToCheck.split(",");
List<Integer> pageList =
GeneralUtils.parsePageList(pageOrderArr, document.getNumberOfPages());
GeneralUtil.parsePageList(pageOrderArr, document.getNumberOfPages());
for (int pageNumber : pageList) {
PDPage page = document.getPage(pageNumber);
@ -100,7 +100,7 @@ public class PdfUtils {
throws IOException {
String[] pageOrderArr = pageNumbersToCheck.split(",");
List<Integer> pageList =
GeneralUtils.parsePageList(pageOrderArr, document.getNumberOfPages());
GeneralUtil.parsePageList(pageOrderArr, document.getNumberOfPages());
for (int pageNumber : pageList) {
PDPage page = document.getPage(pageNumber);

View File

@ -6,152 +6,152 @@ import java.util.List;
import org.junit.jupiter.api.Test;
public class GeneralUtilsTest {
public class GeneralUtilTest {
@Test
void testParsePageListWithAll() {
List<Integer> result = GeneralUtils.parsePageList(new String[] {"all"}, 5, false);
List<Integer> result = GeneralUtil.parsePageList(new String[] {"all"}, 5, false);
assertEquals(List.of(0, 1, 2, 3, 4), result, "'All' keyword should return all pages.");
}
@Test
void testParsePageListWithAllOneBased() {
List<Integer> result = GeneralUtils.parsePageList(new String[] {"all"}, 5, true);
List<Integer> result = GeneralUtil.parsePageList(new String[] {"all"}, 5, true);
assertEquals(List.of(1, 2, 3, 4, 5), result, "'All' keyword should return all pages.");
}
@Test
void nFunc() {
List<Integer> result = GeneralUtils.parsePageList(new String[] {"n"}, 5, true);
List<Integer> result = GeneralUtil.parsePageList(new String[] {"n"}, 5, true);
assertEquals(List.of(1, 2, 3, 4, 5), result, "'n' keyword should return all pages.");
}
@Test
void nFuncAdvanced() {
List<Integer> result = GeneralUtils.parsePageList(new String[] {"4n"}, 9, true);
List<Integer> result = GeneralUtil.parsePageList(new String[] {"4n"}, 9, true);
// skip 0 as not valid
assertEquals(List.of(4, 8), result, "'All' keyword should return all pages.");
}
@Test
void nFuncAdvancedZero() {
List<Integer> result = GeneralUtils.parsePageList(new String[] {"4n"}, 9, false);
List<Integer> result = GeneralUtil.parsePageList(new String[] {"4n"}, 9, false);
// skip 0 as not valid
assertEquals(List.of(3, 7), result, "'All' keyword should return all pages.");
}
@Test
void nFuncAdvanced2() {
List<Integer> result = GeneralUtils.parsePageList(new String[] {"4n-1"}, 9, true);
List<Integer> result = GeneralUtil.parsePageList(new String[] {"4n-1"}, 9, true);
// skip -1 as not valid
assertEquals(List.of(3, 7), result, "4n-1 should do (0-1), (4-1), (8-1)");
}
@Test
void nFuncAdvanced3() {
List<Integer> result = GeneralUtils.parsePageList(new String[] {"4n+1"}, 9, true);
List<Integer> result = GeneralUtil.parsePageList(new String[] {"4n+1"}, 9, true);
assertEquals(List.of(5, 9), result, "'All' keyword should return all pages.");
}
@Test
void nFunc_spaces() {
List<Integer> result = GeneralUtils.parsePageList(new String[] {"n + 1"}, 9, true);
List<Integer> result = GeneralUtil.parsePageList(new String[] {"n + 1"}, 9, true);
assertEquals(List.of(2, 3, 4, 5, 6, 7, 8, 9), result);
}
@Test
void nFunc_consecutive_Ns_nnn() {
List<Integer> result = GeneralUtils.parsePageList(new String[] {"nnn"}, 9, true);
List<Integer> result = GeneralUtil.parsePageList(new String[] {"nnn"}, 9, true);
assertEquals(List.of(1, 8), result);
}
@Test
void nFunc_consecutive_Ns_nn() {
List<Integer> result = GeneralUtils.parsePageList(new String[] {"nn"}, 9, true);
List<Integer> result = GeneralUtil.parsePageList(new String[] {"nn"}, 9, true);
assertEquals(List.of(1, 4, 9), result);
}
@Test
void nFunc_opening_closing_round_brackets() {
List<Integer> result = GeneralUtils.parsePageList(new String[] {"(n-1)(n-2)"}, 9, true);
List<Integer> result = GeneralUtil.parsePageList(new String[] {"(n-1)(n-2)"}, 9, true);
assertEquals(List.of(2, 6), result);
}
@Test
void nFunc_opening_round_brackets() {
List<Integer> result = GeneralUtils.parsePageList(new String[] {"2(n-1)"}, 9, true);
List<Integer> result = GeneralUtil.parsePageList(new String[] {"2(n-1)"}, 9, true);
assertEquals(List.of(2, 4, 6, 8), result);
}
@Test
void nFunc_opening_round_brackets_n() {
List<Integer> result = GeneralUtils.parsePageList(new String[] {"n(n-1)"}, 9, true);
List<Integer> result = GeneralUtil.parsePageList(new String[] {"n(n-1)"}, 9, true);
assertEquals(List.of(2, 6), result);
}
@Test
void nFunc_closing_round_brackets() {
List<Integer> result = GeneralUtils.parsePageList(new String[] {"(n-1)2"}, 9, true);
List<Integer> result = GeneralUtil.parsePageList(new String[] {"(n-1)2"}, 9, true);
assertEquals(List.of(2, 4, 6, 8), result);
}
@Test
void nFunc_closing_round_brackets_n() {
List<Integer> result = GeneralUtils.parsePageList(new String[] {"(n-1)n"}, 9, true);
List<Integer> result = GeneralUtil.parsePageList(new String[] {"(n-1)n"}, 9, true);
assertEquals(List.of(2, 6), result);
}
@Test
void nFunc_function_surrounded_with_brackets() {
List<Integer> result = GeneralUtils.parsePageList(new String[] {"(n-1)"}, 9, true);
List<Integer> result = GeneralUtil.parsePageList(new String[] {"(n-1)"}, 9, true);
assertEquals(List.of(1, 2, 3, 4, 5, 6, 7, 8), result);
}
@Test
void nFuncAdvanced4() {
List<Integer> result = GeneralUtils.parsePageList(new String[] {"3+2n"}, 9, true);
List<Integer> result = GeneralUtil.parsePageList(new String[] {"3+2n"}, 9, true);
assertEquals(List.of(5, 7, 9), result, "'All' keyword should return all pages.");
}
@Test
void nFuncAdvancedZerobased() {
List<Integer> result = GeneralUtils.parsePageList(new String[] {"4n"}, 9, false);
List<Integer> result = GeneralUtil.parsePageList(new String[] {"4n"}, 9, false);
assertEquals(List.of(3, 7), result, "'All' keyword should return all pages.");
}
@Test
void nFuncAdvanced2Zerobased() {
List<Integer> result = GeneralUtils.parsePageList(new String[] {"4n-1"}, 9, false);
List<Integer> result = GeneralUtil.parsePageList(new String[] {"4n-1"}, 9, false);
assertEquals(List.of(2, 6), result, "'All' keyword should return all pages.");
}
@Test
void testParsePageListWithRangeOneBasedOutput() {
List<Integer> result = GeneralUtils.parsePageList(new String[] {"1-3"}, 5, true);
List<Integer> result = GeneralUtil.parsePageList(new String[] {"1-3"}, 5, true);
assertEquals(List.of(1, 2, 3), result, "Range should be parsed correctly.");
}
@Test
void testParsePageListWithRangeZeroBaseOutput() {
List<Integer> result = GeneralUtils.parsePageList(new String[] {"1-3"}, 5, false);
List<Integer> result = GeneralUtil.parsePageList(new String[] {"1-3"}, 5, false);
assertEquals(List.of(0, 1, 2), result, "Range should be parsed correctly.");
}
@Test
void testParsePageListWithRangeOneBasedOutputFull() {
List<Integer> result = GeneralUtils.parsePageList(new String[] {"1,3,7-8"}, 8, true);
List<Integer> result = GeneralUtil.parsePageList(new String[] {"1,3,7-8"}, 8, true);
assertEquals(List.of(1, 3, 7, 8), result, "Range should be parsed correctly.");
}
@Test
void testParsePageListWithRangeOneBasedOutputFullOutOfRange() {
List<Integer> result = GeneralUtils.parsePageList(new String[] {"1,3,7-8"}, 5, true);
List<Integer> result = GeneralUtil.parsePageList(new String[] {"1,3,7-8"}, 5, true);
assertEquals(List.of(1, 3), result, "Range should be parsed correctly.");
}
@Test
void testParsePageListWithRangeZeroBaseOutputFull() {
List<Integer> result = GeneralUtils.parsePageList(new String[] {"1,3,7-8"}, 8, false);
List<Integer> result = GeneralUtil.parsePageList(new String[] {"1,3,7-8"}, 8, false);
assertEquals(List.of(0, 2, 6, 7), result, "Range should be parsed correctly.");
}
}

View File

@ -1,6 +0,0 @@
package stirling.software.enterprise.security.model;
public enum AuthenticationType {
WEB,
SSO
}

View File

@ -20,7 +20,7 @@ services:
- ./stirling/latest/logs:/logs:rw
- ../testing/allEndpointsRemovedSettings.yml:/configs/settings.yml:rw
environment:
DOCKER_ENABLE_SECURITY: "true"
ADDITIONAL_FEATURES: "true"
SECURITY_ENABLELOGIN: "false"
PUID: 1002
PGID: 1002

View File

@ -20,7 +20,7 @@ services:
- ./stirling/latest/config:/configs:rw
- ./stirling/latest/logs:/logs:rw
environment:
DOCKER_ENABLE_SECURITY: "true"
ADDITIONAL_FEATURES: "true"
SECURITY_ENABLELOGIN: "false"
PUID: 1002
PGID: 1002

View File

@ -18,7 +18,7 @@ services:
- ./stirling/latest/config:/configs:rw
- ./stirling/latest/logs:/logs:rw
environment:
DOCKER_ENABLE_SECURITY: "true"
ADDITIONAL_FEATURES: "true"
SECURITY_ENABLELOGIN: "false"
PUID: 1002
PGID: 1002

View File

@ -18,7 +18,7 @@ services:
- /stirling/latest/config:/configs:rw
- /stirling/latest/logs:/logs:rw
environment:
DOCKER_ENABLE_SECURITY: "true"
ADDITIONAL_FEATURES: "true"
SECURITY_ENABLELOGIN: "true"
SECURITY_OAUTH2_ENABLED: "true"
SECURITY_OAUTH2_AUTOCREATEUSER: "true" # This is set to true to allow auto-creation of non-existing users in Stirling-PDF

View File

@ -18,7 +18,7 @@ services:
- ./stirling/latest/config:/configs:rw
- ./stirling/latest/logs:/logs:rw
environment:
DOCKER_ENABLE_SECURITY: "true"
ADDITIONAL_FEATURES: "true"
SECURITY_ENABLELOGIN: "true"
PUID: 1002
PGID: 1002

View File

@ -18,7 +18,7 @@ services:
- /stirling/latest/config:/configs:rw
- /stirling/latest/logs:/logs:rw
environment:
DOCKER_ENABLE_SECURITY: "true"
ADDITIONAL_FEATURES: "true"
SECURITY_ENABLELOGIN: "true"
SYSTEM_DEFAULTLOCALE: en-US
UI_APPNAME: Stirling-PDF-Lite

View File

@ -17,7 +17,7 @@ services:
- /stirling/latest/config:/configs:rw
- /stirling/latest/logs:/logs:rw
environment:
DOCKER_ENABLE_SECURITY: "false"
ADDITIONAL_FEATURES: "false"
SECURITY_ENABLELOGIN: "false"
SYSTEM_DEFAULTLOCALE: en-US
UI_APPNAME: Stirling-PDF-Ultra-lite

View File

@ -18,7 +18,7 @@ services:
- /stirling/latest/config:/configs:rw
- /stirling/latest/logs:/logs:rw
environment:
DOCKER_ENABLE_SECURITY: "false"
ADDITIONAL_FEATURES: "false"
SECURITY_ENABLELOGIN: "false"
LANGS: "en_GB,en_US,ar_AR,de_DE,fr_FR,es_ES,zh_CN,zh_TW,ca_CA,it_IT,sv_SE,pl_PL,ro_RO,ko_KR,pt_BR,ru_RU,el_GR,hi_IN,hu_HU,tr_TR,id_ID"
SYSTEM_DEFAULTLOCALE: en-US

View File

@ -18,7 +18,7 @@ services:
- /stirling/latest/config:/configs:rw
- /stirling/latest/logs:/logs:rw
environment:
DOCKER_ENABLE_SECURITY: "true"
ADDITIONAL_FEATURES: "true"
SECURITY_ENABLELOGIN: "true"
PUID: 1002
PGID: 1002

View File

@ -13,18 +13,13 @@ repositories {
}
java {
// 17 is lowest but we support and recommend 21
sourceCompatibility = JavaVersion.VERSION_17
}
ext {
lombokVersion = "1.18.38"
}
sourceSets {
main {
java {
if (System.getenv("DOCKER_ENABLE_SECURITY") == "false") {
if (System.getenv("ADDITIONAL_FEATURES") == "false") {
exclude 'stirling/software/enterprise/security/UserAuthenticationFilter.java'
exclude 'stirling/software/enterprise/security/UserBasedRateLimitingFilter.java'
exclude 'stirling/software/enterprise/security/CustomAuthenticationSuccessHandler.java'
@ -53,7 +48,7 @@ sourceSets {
test {
java {
if (System.getenv("DOCKER_ENABLE_SECURITY") == "false") {
if (System.getenv("ADDITIONAL_FEATURES") == "false") {
exclude 'stirling/software/enterprise/security/**'
}
}
@ -80,33 +75,29 @@ dependencies {
implementation 'org.springframework:spring-webmvc:6.2.6'
implementation 'com.posthog.java:posthog:1.2.0'
// https://mvnrepository.com/artifact/com.bucket4j/bucket4j_jdk17
implementation 'com.bucket4j:bucket4j_jdk17-core:8.14.0'
implementation 'com.bucket4j:bucket4j_jdk17-core:8.14.0' // https://mvnrepository.com/artifact/com.bucket4j/bucket4j_jdk17
implementation 'io.github.pixee:java-security-toolkit:1.2.1'
implementation 'org.bouncycastle:bcprov-jdk18on:1.80'
if (System.getenv('DOCKER_ENABLE_SECURITY') != 'false') {
implementation 'io.micrometer:micrometer-registry-prometheus'
if (System.getenv('ADDITIONAL_FEATURES') != 'false') {
implementation "org.springframework:spring-jdbc:6.2.6"
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5:3.1.3.RELEASE'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation "org.springframework.security:spring-security-core:$springSecuritySamlVersion"
implementation "org.springframework.security:spring-security-saml2-service-provider:$springSecuritySamlVersion"
implementation "org.springframework.session:spring-session-core:3.4.3"
implementation "org.springframework:spring-jdbc:6.2.6"
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5:3.1.3.RELEASE'
implementation 'io.micrometer:micrometer-registry-prometheus'
implementation 'com.unboundid.product.scim2:scim2-sdk-client:2.3.5'
// Don't upgrade h2database
runtimeOnly "com.h2database:h2:2.3.232"
runtimeOnly "com.h2database:h2:2.3.232" // Don't upgrade h2database
runtimeOnly "org.postgresql:postgresql:42.7.5"
constraints {
implementation "org.opensaml:opensaml-core:$openSamlVersion"
implementation "org.opensaml:opensaml-saml-api:$openSamlVersion"
implementation "org.opensaml:opensaml-saml-impl:$openSamlVersion"
}
implementation "org.springframework.security:spring-security-saml2-service-provider:$springSecuritySamlVersion"
// implementation 'org.springframework.security:spring-security-core:$springSecuritySamlVersion'
implementation 'com.coveo:saml-client:5.0.0'
}
@ -117,7 +108,7 @@ dependencies {
testImplementation platform('org.junit:junit-bom:5.10.0')
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
// testRuntimeOnly 'org.mockito:mockito-inline:5.2.0'
testRuntimeOnly 'org.mockito:mockito-inline:5.2.0'
}
test {

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security;
package stirling.software.proprietary.security;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
@ -13,9 +13,9 @@ import org.springframework.security.authentication.LockedException;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler;
import stirling.software.enterprise.security.model.User;
import stirling.software.enterprise.security.service.LoginAttemptService;
import stirling.software.enterprise.security.service.UserService;
import stirling.software.proprietary.security.model.User;
import stirling.software.proprietary.security.service.LoginAttemptService;
import stirling.software.proprietary.security.service.UserService;
@Slf4j
public class CustomAuthenticationFailureHandler extends SimpleUrlAuthenticationFailureHandler {

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security;
package stirling.software.proprietary.security;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
@ -10,8 +10,8 @@ import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
import org.springframework.security.web.savedrequest.SavedRequest;
import stirling.software.common.util.RequestUriUtil;
import stirling.software.enterprise.security.service.LoginAttemptService;
import stirling.software.enterprise.security.service.UserService;
import stirling.software.proprietary.security.service.LoginAttemptService;
import stirling.software.proprietary.security.service.UserService;
@Slf4j
public class CustomAuthenticationSuccessHandler

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security;
package stirling.software.proprietary.security;
import com.coveo.saml.SamlClient;
import com.coveo.saml.SamlException;
@ -23,8 +23,8 @@ import stirling.software.common.model.ApplicationProperties.Security.OAUTH2;
import stirling.software.common.model.ApplicationProperties.Security.SAML2;
import stirling.software.common.model.provider.KeycloakProvider;
import stirling.software.common.util.UrlUtils;
import stirling.software.enterprise.security.saml2.CertificateUtils;
import stirling.software.enterprise.security.saml2.CustomSaml2AuthenticatedPrincipal;
import stirling.software.proprietary.security.saml2.CertificateUtils;
import stirling.software.proprietary.security.saml2.CustomSaml2AuthenticatedPrincipal;
@Slf4j
@RequiredArgsConstructor

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security;
package stirling.software.proprietary.security;
import jakarta.annotation.PostConstruct;
import java.sql.SQLException;
@ -9,8 +9,8 @@ import org.springframework.stereotype.Component;
import stirling.software.common.model.ApplicationProperties;
import stirling.software.common.model.exception.UnsupportedProviderException;
import stirling.software.common.model.enumeration.Role;
import stirling.software.enterprise.security.service.DatabaseServiceInterface;
import stirling.software.enterprise.security.service.UserService;
import stirling.software.proprietary.security.service.DatabaseServiceInterface;
import stirling.software.proprietary.security.service.UserService;
@Slf4j
@Component

View File

@ -1,9 +1,9 @@
package stirling.software.enterprise.security;
package stirling.software.proprietary.security;
import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import stirling.software.enterprise.security.filter.IPRateLimitingFilter;
import stirling.software.proprietary.security.filter.IPRateLimitingFilter;
@Component
@RequiredArgsConstructor

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.configuration;
package stirling.software.proprietary.security.configuration;
import javax.sql.DataSource;
import lombok.Getter;
@ -17,8 +17,8 @@ import stirling.software.common.model.exception.UnsupportedProviderException;
@Slf4j
@Getter
@Configuration
@EnableJpaRepositories(basePackages = "stirling.software.enterprise.security.database.repository")
@EntityScan({"stirling.software.enterprise.security.model"})
@EnableJpaRepositories(basePackages = "stirling.software.proprietary.security.database.repository")
@EntityScan({"stirling.software.proprietary.security.model"})
public class DatabaseConfig {
public final String DATASOURCE_DEFAULT_URL;

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.configuration;
package stirling.software.proprietary.security.configuration;
import java.util.Optional;
import lombok.extern.slf4j.Slf4j;
@ -29,25 +29,24 @@ import org.springframework.security.web.savedrequest.NullRequestCache;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
import stirling.software.common.configuration.AppConfig;
import stirling.software.common.model.ApplicationProperties;
import stirling.software.enterprise.security.CustomAuthenticationFailureHandler;
import stirling.software.enterprise.security.CustomAuthenticationSuccessHandler;
import stirling.software.enterprise.security.CustomLogoutSuccessHandler;
import stirling.software.enterprise.security.filter.FirstLoginFilter;
import stirling.software.enterprise.security.filter.IPRateLimitingFilter;
import stirling.software.enterprise.security.filter.UserAuthenticationFilter;
import stirling.software.enterprise.security.database.repository.JPATokenRepositoryImpl;
import stirling.software.enterprise.security.database.repository.PersistentLoginRepository;
import stirling.software.enterprise.security.model.User;
import stirling.software.enterprise.security.oauth2.CustomOAuth2AuthenticationFailureHandler;
import stirling.software.enterprise.security.oauth2.CustomOAuth2AuthenticationSuccessHandler;
import stirling.software.enterprise.security.saml2.CustomSaml2AuthenticationFailureHandler;
import stirling.software.enterprise.security.saml2.CustomSaml2AuthenticationSuccessHandler;
import stirling.software.enterprise.security.saml2.CustomSaml2ResponseAuthenticationConverter;
import stirling.software.enterprise.security.service.CustomOAuth2UserService;
import stirling.software.enterprise.security.service.CustomUserDetailsService;
import stirling.software.enterprise.security.service.LoginAttemptService;
import stirling.software.enterprise.security.service.UserService;
import stirling.software.enterprise.security.session.SessionPersistentRegistry;
import stirling.software.proprietary.security.CustomAuthenticationFailureHandler;
import stirling.software.proprietary.security.CustomAuthenticationSuccessHandler;
import stirling.software.proprietary.security.database.repository.JPATokenRepositoryImpl;
import stirling.software.proprietary.security.database.repository.PersistentLoginRepository;
import stirling.software.proprietary.security.filter.FirstLoginFilter;
import stirling.software.proprietary.security.filter.IPRateLimitingFilter;
import stirling.software.proprietary.security.filter.UserAuthenticationFilter;
import stirling.software.proprietary.security.model.User;
import stirling.software.proprietary.security.oauth2.CustomOAuth2AuthenticationFailureHandler;
import stirling.software.proprietary.security.oauth2.CustomOAuth2AuthenticationSuccessHandler;
import stirling.software.proprietary.security.saml2.CustomSaml2AuthenticationFailureHandler;
import stirling.software.proprietary.security.saml2.CustomSaml2AuthenticationSuccessHandler;
import stirling.software.proprietary.security.saml2.CustomSaml2ResponseAuthenticationConverter;
import stirling.software.proprietary.security.service.CustomOAuth2UserService;
import stirling.software.proprietary.security.service.CustomUserDetailsService;
import stirling.software.proprietary.security.service.LoginAttemptService;
import stirling.software.proprietary.security.service.UserService;
import stirling.software.proprietary.security.session.SessionPersistentRegistry;
@Configuration
@EnableWebSecurity
@ -169,7 +168,7 @@ public class SecurityConfiguration {
logout ->
logout.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.logoutSuccessHandler(
new CustomLogoutSuccessHandler(applicationProperties, appConfig))
new stirling.software.proprietary.security.CustomLogoutSuccessHandler(applicationProperties, appConfig))
.clearAuthentication(true)
.invalidateHttpSession(true)
.deleteCookies("JSESSIONID", "remember-me"));

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.controller.api;
package stirling.software.proprietary.security.controller.api;
import java.io.IOException;
import java.io.InputStream;
@ -26,8 +26,8 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import stirling.software.enterprise.security.database.H2SQLCondition;
import stirling.software.enterprise.security.service.DatabaseService;
import stirling.software.proprietary.security.database.H2SQLCondition;
import stirling.software.proprietary.security.service.DatabaseService;
@Slf4j
@Controller

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.controller.api;
package stirling.software.proprietary.security.controller.api;
import java.io.IOException;
import java.security.Principal;
@ -30,15 +30,15 @@ import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import stirling.software.enterprise.security.model.AuthenticationType;
import stirling.software.proprietary.security.model.AuthenticationType;
import stirling.software.common.model.enumeration.Role;
import stirling.software.enterprise.security.model.User;
import stirling.software.proprietary.security.model.User;
import stirling.software.common.model.ApplicationProperties;
import stirling.software.common.model.exception.UnsupportedProviderException;
import stirling.software.enterprise.security.model.api.user.UsernameAndPass;
import stirling.software.enterprise.security.saml2.CustomSaml2AuthenticatedPrincipal;
import stirling.software.enterprise.security.service.UserService;
import stirling.software.enterprise.security.session.SessionPersistentRegistry;
import stirling.software.proprietary.security.model.api.user.UsernameAndPass;
import stirling.software.proprietary.security.saml2.CustomSaml2AuthenticatedPrincipal;
import stirling.software.proprietary.security.service.UserService;
import stirling.software.proprietary.security.session.SessionPersistentRegistry;
@Controller
@Tag(name = "User", description = "User APIs")

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.controller.web;
package stirling.software.proprietary.security.controller.web;
import static stirling.software.common.util.ProviderUtil.validateProvider;
@ -29,11 +29,7 @@ import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import stirling.software.enterprise.security.model.Authority;
import stirling.software.common.model.enumeration.Role;
import stirling.software.enterprise.security.model.SessionEntity;
import stirling.software.enterprise.security.model.User;
import stirling.software.enterprise.security.database.repository.UserRepository;
import stirling.software.common.model.ApplicationProperties;
import stirling.software.common.model.ApplicationProperties.Security;
import stirling.software.common.model.ApplicationProperties.Security.OAUTH2;
@ -42,8 +38,12 @@ import stirling.software.common.model.ApplicationProperties.Security.SAML2;
import stirling.software.common.model.provider.GitHubProvider;
import stirling.software.common.model.provider.GoogleProvider;
import stirling.software.common.model.provider.KeycloakProvider;
import stirling.software.enterprise.security.saml2.CustomSaml2AuthenticatedPrincipal;
import stirling.software.enterprise.security.session.SessionPersistentRegistry;
import stirling.software.proprietary.security.database.repository.UserRepository;
import stirling.software.proprietary.security.model.Authority;
import stirling.software.proprietary.security.model.SessionEntity;
import stirling.software.proprietary.security.model.User;
import stirling.software.proprietary.security.saml2.CustomSaml2AuthenticatedPrincipal;
import stirling.software.proprietary.security.session.SessionPersistentRegistry;
@Controller
@Slf4j

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.controller.web;
package stirling.software.proprietary.security.controller.web;
import java.util.List;
@ -15,7 +15,7 @@ import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import stirling.software.common.model.FileInfo;
import stirling.software.enterprise.security.service.DatabaseService;
import stirling.software.proprietary.security.service.DatabaseService;
@Controller
@Tag(name = "Database Management", description = "Database management and security APIs")

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.database;
package stirling.software.proprietary.security.database;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.database;
package stirling.software.proprietary.security.database;
import java.sql.SQLException;
import lombok.RequiredArgsConstructor;
@ -6,7 +6,7 @@ import org.springframework.context.annotation.Conditional;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import stirling.software.common.model.exception.UnsupportedProviderException;
import stirling.software.enterprise.security.service.DatabaseServiceInterface;
import stirling.software.proprietary.security.service.DatabaseServiceInterface;
@Component
@Conditional(H2SQLCondition.class)

View File

@ -1,11 +1,10 @@
package stirling.software.enterprise.security.database.repository;
package stirling.software.proprietary.security.database.repository;
import java.util.Set;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import stirling.software.enterprise.security.model.Authority;
import stirling.software.proprietary.security.model.Authority;
@Repository
public interface AuthorityRepository extends JpaRepository<Authority, Long> {

View File

@ -1,12 +1,11 @@
package stirling.software.enterprise.security.database.repository;
package stirling.software.proprietary.security.database.repository;
import java.util.Date;
import org.springframework.security.web.authentication.rememberme.PersistentRememberMeToken;
import org.springframework.security.web.authentication.rememberme.PersistentTokenRepository;
import org.springframework.transaction.annotation.Transactional;
import stirling.software.enterprise.security.model.PersistentLogin;
import stirling.software.proprietary.security.model.PersistentLogin;
public class JPATokenRepositoryImpl implements PersistentTokenRepository {

View File

@ -1,9 +1,8 @@
package stirling.software.enterprise.security.database.repository;
package stirling.software.proprietary.security.database.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import stirling.software.enterprise.security.model.PersistentLogin;
import stirling.software.proprietary.security.model.PersistentLogin;
@Repository
public interface PersistentLoginRepository extends JpaRepository<PersistentLogin, String> {

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.database.repository;
package stirling.software.proprietary.security.database.repository;
import jakarta.transaction.Transactional;
import java.util.Date;
@ -8,7 +8,7 @@ import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import stirling.software.enterprise.security.model.SessionEntity;
import stirling.software.proprietary.security.model.SessionEntity;
@Repository
public interface SessionRepository extends JpaRepository<SessionEntity, String> {

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.database.repository;
package stirling.software.proprietary.security.database.repository;
import java.util.List;
import java.util.Optional;
@ -7,8 +7,7 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import stirling.software.enterprise.security.model.User;
import stirling.software.proprietary.security.model.User;
@Repository
public interface UserRepository extends JpaRepository<User, Long> {

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.filter;
package stirling.software.proprietary.security.filter;
import java.io.IOException;

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.filter;
package stirling.software.proprietary.security.filter;
import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
@ -16,8 +16,8 @@ import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter;
import stirling.software.common.util.RequestUriUtil;
import stirling.software.enterprise.security.model.User;
import stirling.software.enterprise.security.service.UserService;
import stirling.software.proprietary.security.model.User;
import stirling.software.proprietary.security.service.UserService;
@Slf4j
@Component

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.filter;
package stirling.software.proprietary.security.filter;
import jakarta.servlet.Filter;
import jakarta.servlet.FilterChain;

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.filter;
package stirling.software.proprietary.security.filter;
import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
@ -23,11 +23,11 @@ import org.springframework.web.filter.OncePerRequestFilter;
import stirling.software.common.model.ApplicationProperties;
import stirling.software.common.model.ApplicationProperties.Security.OAUTH2;
import stirling.software.common.model.ApplicationProperties.Security.SAML2;
import stirling.software.enterprise.security.model.ApiKeyAuthenticationToken;
import stirling.software.enterprise.security.model.User;
import stirling.software.enterprise.security.saml2.CustomSaml2AuthenticatedPrincipal;
import stirling.software.enterprise.security.service.UserService;
import stirling.software.enterprise.security.session.SessionPersistentRegistry;
import stirling.software.proprietary.security.model.ApiKeyAuthenticationToken;
import stirling.software.proprietary.security.model.User;
import stirling.software.proprietary.security.saml2.CustomSaml2AuthenticatedPrincipal;
import stirling.software.proprietary.security.service.UserService;
import stirling.software.proprietary.security.session.SessionPersistentRegistry;
@Slf4j
@Component

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.filter;
package stirling.software.proprietary.security.filter;
import io.github.bucket4j.Bandwidth;
import io.github.bucket4j.Bucket;

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.model;
package stirling.software.proprietary.security.model;
import java.util.Collection;

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.model;
package stirling.software.proprietary.security.model;
public class AttemptCounter {
private int attemptCount;

View File

@ -0,0 +1,6 @@
package stirling.software.proprietary.security.model;
public enum AuthenticationType {
WEB,
SSO
}

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.model;
package stirling.software.proprietary.security.model;
import java.io.Serializable;

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.model;
package stirling.software.proprietary.security.model;
import java.util.Date;

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.model;
package stirling.software.proprietary.security.model;
import java.io.Serializable;
import java.util.Date;

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.model;
package stirling.software.proprietary.security.model;
import java.io.Serializable;
import java.util.HashMap;

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.model.api.user;
package stirling.software.proprietary.security.model.api.user;
import io.swagger.v3.oas.annotations.media.Schema;

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.model.api.user;
package stirling.software.proprietary.security.model.api.user;
import io.swagger.v3.oas.annotations.media.Schema;

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.model.api.user;
package stirling.software.proprietary.security.model.api.user;
import io.swagger.v3.oas.annotations.media.Schema;

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.model.api.user;
package stirling.software.proprietary.security.model.api.user;
import io.swagger.v3.oas.annotations.media.Schema;

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.oauth2;
package stirling.software.proprietary.security.oauth2;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.oauth2;
package stirling.software.proprietary.security.oauth2;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
@ -17,9 +17,9 @@ import stirling.software.common.model.ApplicationProperties;
import stirling.software.common.model.ApplicationProperties.Security.OAUTH2;
import stirling.software.common.model.exception.UnsupportedProviderException;
import stirling.software.common.util.RequestUriUtil;
import stirling.software.enterprise.security.model.AuthenticationType;
import stirling.software.enterprise.security.service.LoginAttemptService;
import stirling.software.enterprise.security.service.UserService;
import stirling.software.proprietary.security.model.AuthenticationType;
import stirling.software.proprietary.security.service.LoginAttemptService;
import stirling.software.proprietary.security.service.UserService;
@RequiredArgsConstructor
public class CustomOAuth2AuthenticationSuccessHandler

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.oauth2;
package stirling.software.proprietary.security.oauth2;
import java.util.ArrayList;
import java.util.HashSet;
@ -28,8 +28,8 @@ import stirling.software.common.model.provider.GitHubProvider;
import stirling.software.common.model.provider.GoogleProvider;
import stirling.software.common.model.provider.KeycloakProvider;
import stirling.software.common.model.provider.Provider;
import stirling.software.enterprise.security.model.User;
import stirling.software.enterprise.security.service.UserService;
import stirling.software.proprietary.security.model.User;
import stirling.software.proprietary.security.service.UserService;
import static org.springframework.security.oauth2.core.AuthorizationGrantType.AUTHORIZATION_CODE;
import static stirling.software.common.util.ProviderUtil.validateProvider;
import static stirling.software.common.util.ValidationUtil.isStringEmpty;

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.saml2;
package stirling.software.proprietary.security.saml2;
import java.io.ByteArrayInputStream;
import java.io.InputStreamReader;

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.saml2;
package stirling.software.proprietary.security.saml2;
import java.io.Serializable;
import java.util.List;

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.saml2;
package stirling.software.proprietary.security.saml2;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.saml2;
package stirling.software.proprietary.security.saml2;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
@ -16,9 +16,9 @@ import stirling.software.common.model.ApplicationProperties;
import stirling.software.common.model.ApplicationProperties.Security.SAML2;
import stirling.software.common.model.exception.UnsupportedProviderException;
import stirling.software.common.util.RequestUriUtil;
import stirling.software.enterprise.security.model.AuthenticationType;
import stirling.software.enterprise.security.service.LoginAttemptService;
import stirling.software.enterprise.security.service.UserService;
import stirling.software.proprietary.security.model.AuthenticationType;
import stirling.software.proprietary.security.service.LoginAttemptService;
import stirling.software.proprietary.security.service.UserService;
@AllArgsConstructor
@Slf4j

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.saml2;
package stirling.software.proprietary.security.saml2;
import java.util.ArrayList;
import java.util.HashMap;
@ -17,8 +17,8 @@ import org.springframework.core.convert.converter.Converter;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.saml2.provider.service.authentication.OpenSaml4AuthenticationProvider.ResponseToken;
import org.springframework.security.saml2.provider.service.authentication.Saml2Authentication;
import stirling.software.enterprise.security.model.User;
import stirling.software.enterprise.security.service.UserService;
import stirling.software.proprietary.security.model.User;
import stirling.software.proprietary.security.service.UserService;
@Slf4j
@ConditionalOnProperty(name = "security.saml2.enabled", havingValue = "true")

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.saml2;
package stirling.software.proprietary.security.saml2;
import jakarta.servlet.http.HttpServletRequest;
import java.security.cert.X509Certificate;

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.service;
package stirling.software.proprietary.security.service;
import java.util.Optional;
import lombok.RequiredArgsConstructor;
@ -7,8 +7,8 @@ import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
import stirling.software.common.configuration.interfaces.ShowAdminInterface;
import stirling.software.common.model.ApplicationProperties;
import stirling.software.enterprise.security.database.repository.UserRepository;
import stirling.software.enterprise.security.model.User;
import stirling.software.proprietary.security.database.repository.UserRepository;
import stirling.software.proprietary.security.model.User;
@Service
@RequiredArgsConstructor

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.service;
package stirling.software.proprietary.security.service;
import java.util.Optional;
import lombok.extern.slf4j.Slf4j;
@ -13,7 +13,7 @@ import org.springframework.security.oauth2.core.oidc.user.OidcUser;
import stirling.software.common.model.ApplicationProperties;
import stirling.software.common.model.ApplicationProperties.Security.OAUTH2;
import stirling.software.common.model.enumeration.UsernameAttribute;
import stirling.software.enterprise.security.model.User;
import stirling.software.proprietary.security.model.User;
@Slf4j
public class CustomOAuth2UserService implements OAuth2UserService<OidcUserRequest, OidcUser> {

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.service;
package stirling.software.proprietary.security.service;
import java.util.Collection;
import java.util.Set;
@ -10,9 +10,9 @@ import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
import stirling.software.enterprise.security.database.repository.UserRepository;
import stirling.software.enterprise.security.model.Authority;
import stirling.software.enterprise.security.model.User;
import stirling.software.proprietary.security.database.repository.UserRepository;
import stirling.software.proprietary.security.model.Authority;
import stirling.software.proprietary.security.model.User;
@Service
@RequiredArgsConstructor

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.service;
package stirling.software.proprietary.security.service;
import java.io.IOException;
import java.nio.file.DirectoryStream;

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.service;
package stirling.software.proprietary.security.service;
import java.sql.SQLException;
import java.util.List;

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.service;
package stirling.software.proprietary.security.service;
import jakarta.annotation.PostConstruct;
import java.util.concurrent.ConcurrentHashMap;
@ -7,7 +7,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import stirling.software.common.model.ApplicationProperties;
import stirling.software.enterprise.security.model.AttemptCounter;
import stirling.software.proprietary.security.model.AttemptCounter;
@Service
@Slf4j

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.service;
package stirling.software.proprietary.security.service;
import java.io.IOException;
import java.sql.SQLException;
@ -28,14 +28,14 @@ import org.springframework.transaction.annotation.Transactional;
import stirling.software.common.model.ApplicationProperties;
import stirling.software.common.model.exception.UnsupportedProviderException;
import stirling.software.common.service.UserServiceInterface;
import stirling.software.enterprise.security.database.repository.AuthorityRepository;
import stirling.software.enterprise.security.database.repository.UserRepository;
import stirling.software.enterprise.security.model.AuthenticationType;
import stirling.software.enterprise.security.model.Authority;
import stirling.software.common.model.enumeration.Role;
import stirling.software.enterprise.security.model.User;
import stirling.software.enterprise.security.saml2.CustomSaml2AuthenticatedPrincipal;
import stirling.software.enterprise.security.session.SessionPersistentRegistry;
import stirling.software.proprietary.security.database.repository.AuthorityRepository;
import stirling.software.proprietary.security.database.repository.UserRepository;
import stirling.software.proprietary.security.model.AuthenticationType;
import stirling.software.proprietary.security.model.Authority;
import stirling.software.proprietary.security.model.User;
import stirling.software.proprietary.security.saml2.CustomSaml2AuthenticatedPrincipal;
import stirling.software.proprietary.security.session.SessionPersistentRegistry;
@Service
@Slf4j
@ -302,7 +302,6 @@ public class UserService implements UserServiceInterface {
public void changeUsername(User user, String newUsername)
throws IllegalArgumentException,
IOException,
SQLException,
UnsupportedProviderException {
if (!isUsernameValid(newUsername)) {
@ -414,7 +413,7 @@ public class UserService implements UserServiceInterface {
if (principal instanceof UserDetails detailsUser) {
return detailsUser.getUsername();
} else if (principal instanceof stirling.software.enterprise.security.model.User domainUser) {
} else if (principal instanceof User domainUser) {
return domainUser.getUsername();
} else if (principal instanceof OAuth2User oAuth2User) {
return oAuth2User.getAttribute(oAuth2.getUseAsUsername());

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.session;
package stirling.software.proprietary.security.session;
import jakarta.servlet.http.HttpSessionEvent;
import jakarta.servlet.http.HttpSessionListener;

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.session;
package stirling.software.proprietary.security.session;
import jakarta.transaction.Transactional;
import java.time.Duration;
@ -15,9 +15,9 @@ import org.springframework.security.core.session.SessionRegistry;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.oauth2.core.user.OAuth2User;
import org.springframework.stereotype.Component;
import stirling.software.enterprise.security.database.repository.SessionRepository;
import stirling.software.enterprise.security.model.SessionEntity;
import stirling.software.enterprise.security.saml2.CustomSaml2AuthenticatedPrincipal;
import stirling.software.proprietary.security.database.repository.SessionRepository;
import stirling.software.proprietary.security.model.SessionEntity;
import stirling.software.proprietary.security.saml2.CustomSaml2AuthenticatedPrincipal;
@Component
@RequiredArgsConstructor

View File

@ -1,9 +1,9 @@
package stirling.software.enterprise.security.session;
package stirling.software.proprietary.security.session;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.core.session.SessionRegistryImpl;
import stirling.software.enterprise.security.database.repository.SessionRepository;
import stirling.software.proprietary.security.database.repository.SessionRepository;
@Configuration
public class SessionRegistryConfig {

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.session;
package stirling.software.proprietary.security.session;
import java.time.Instant;
import java.time.temporal.ChronoUnit;

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security;
package stirling.software.proprietary.security;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

View File

@ -1,4 +1,4 @@
package stirling.software.enterprise.security.configuration;
package stirling.software.proprietary.security.configuration;
import javax.sql.DataSource;
import org.junit.jupiter.api.BeforeEach;

View File

@ -1,6 +1,6 @@
echo "Running Stirling PDF with DOCKER_ENABLE_SECURITY=${DOCKER_ENABLE_SECURITY} and VERSION_TAG=${VERSION_TAG}"
# Check for DOCKER_ENABLE_SECURITY and download the appropriate JAR if required
if [ "$DOCKER_ENABLE_SECURITY" = "true" ] && [ "$VERSION_TAG" != "alpha" ]; then
echo "Running Stirling PDF with ADDITIONAL_FEATURES=${ADDITIONAL_FEATURES} and VERSION_TAG=${VERSION_TAG}"
# Check for ADDITIONAL_FEATURES and download the appropriate JAR if required
if [ "$ADDITIONAL_FEATURES" = "true" ] && [ "$VERSION_TAG" != "alpha" ]; then
if [ ! -f app-security.jar ]; then
echo "Trying to download from: https://files.stirlingpdf.com/v$VERSION_TAG/Stirling-PDF-with-login.jar"
curl -L -o app-security.jar https://files.stirlingpdf.com/v$VERSION_TAG/Stirling-PDF-with-login.jar

View File

@ -4,8 +4,8 @@ plugins {
}
rootProject.name = 'Stirling-PDF'
include 'common', 'enterprise'
include 'common'
//if (System.getenv('DOCKER_ENABLE_SECURITY') == 'true') {
// include 'enterprise'
//}
if (System.getenv('ADDITIONAL_FEATURES') == 'true') {
include 'proprietary'
}

View File

@ -20,7 +20,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import stirling.software.common.model.ApplicationProperties;
import stirling.software.common.util.GeneralUtils;
import stirling.software.common.util.GeneralUtil;
@Service
@Slf4j
@ -586,6 +586,6 @@ public class KeygenLicenseVerifier {
}
private String generateMachineFingerprint() {
return GeneralUtils.generateMachineFingerprint();
return GeneralUtil.generateMachineFingerprint();
}
}

View File

@ -12,7 +12,7 @@ import lombok.extern.slf4j.Slf4j;
import stirling.software.SPDF.EE.configuration.KeygenLicenseVerifier.License;
import stirling.software.common.model.ApplicationProperties;
import stirling.software.common.util.GeneralUtils;
import stirling.software.common.util.GeneralUtil;
@Slf4j
@Component
@ -88,7 +88,7 @@ public class LicenseKeyChecker {
public void updateLicenseKey(String newKey) throws IOException {
applicationProperties.getPremium().setKey(newKey);
GeneralUtils.saveKeyToSettings("EnterpriseEdition.key", newKey);
GeneralUtil.saveKeyToSettings("EnterpriseEdition.key", newKey);
checkLicense();
}

View File

@ -38,8 +38,8 @@ import stirling.software.common.util.UrlUtils;
scanBasePackages = {
"stirling.software.SPDF",
"stirling.software.common",
"stirling.software.enterprise",
"stirling.software.enterprise.configuration"
"stirling.software.proprietary",
"stirling.software.proprietary.configuration"
},
exclude = {
DataSourceAutoConfiguration.class,

View File

@ -18,7 +18,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import stirling.software.common.model.ApplicationProperties;
import stirling.software.common.util.GeneralUtils;
import stirling.software.common.util.GeneralUtil;
@Component
@Slf4j
@ -39,31 +39,31 @@ public class InitialSetup {
public void initUUIDKey() throws IOException {
String uuid = applicationProperties.getAutomaticallyGenerated().getUUID();
if (!GeneralUtils.isValidUUID(uuid)) {
if (!GeneralUtil.isValidUUID(uuid)) {
// Generating a random UUID as the secret key
uuid = UUID.randomUUID().toString();
GeneralUtils.saveKeyToSettings("AutomaticallyGenerated.UUID", uuid);
GeneralUtil.saveKeyToSettings("AutomaticallyGenerated.UUID", uuid);
applicationProperties.getAutomaticallyGenerated().setUUID(uuid);
}
}
public void initSecretKey() throws IOException {
String secretKey = applicationProperties.getAutomaticallyGenerated().getKey();
if (!GeneralUtils.isValidUUID(secretKey)) {
if (!GeneralUtil.isValidUUID(secretKey)) {
// Generating a random UUID as the secret key
secretKey = UUID.randomUUID().toString();
GeneralUtils.saveKeyToSettings("AutomaticallyGenerated.key", secretKey);
GeneralUtil.saveKeyToSettings("AutomaticallyGenerated.key", secretKey);
applicationProperties.getAutomaticallyGenerated().setKey(secretKey);
}
}
public void initEnableCSRFSecurity() throws IOException {
if (GeneralUtils.isVersionHigher(
if (GeneralUtil.isVersionHigher(
"0.36.0", applicationProperties.getAutomaticallyGenerated().getAppVersion())) {
Boolean csrf = applicationProperties.getSecurity().getCsrfDisabled();
if (!csrf) {
GeneralUtils.saveKeyToSettings("security.csrfDisabled", false);
GeneralUtils.saveKeyToSettings("system.enableAnalytics", true);
GeneralUtil.saveKeyToSettings("security.csrfDisabled", false);
GeneralUtil.saveKeyToSettings("system.enableAnalytics", true);
applicationProperties.getSecurity().setCsrfDisabled(false);
}
}
@ -74,14 +74,14 @@ public class InitialSetup {
String termsUrl = applicationProperties.getLegal().getTermsAndConditions();
if (StringUtils.isEmpty(termsUrl)) {
String defaultTermsUrl = "https://www.stirlingpdf.com/terms";
GeneralUtils.saveKeyToSettings("legal.termsAndConditions", defaultTermsUrl);
GeneralUtil.saveKeyToSettings("legal.termsAndConditions", defaultTermsUrl);
applicationProperties.getLegal().setTermsAndConditions(defaultTermsUrl);
}
// Initialize Privacy Policy
String privacyUrl = applicationProperties.getLegal().getPrivacyPolicy();
if (StringUtils.isEmpty(privacyUrl)) {
String defaultPrivacyUrl = "https://www.stirlingpdf.com/privacy-policy";
GeneralUtils.saveKeyToSettings("legal.privacyPolicy", defaultPrivacyUrl);
GeneralUtil.saveKeyToSettings("legal.privacyPolicy", defaultPrivacyUrl);
applicationProperties.getLegal().setPrivacyPolicy(defaultPrivacyUrl);
}
}
@ -95,7 +95,7 @@ public class InitialSetup {
appVersion = props.getProperty("version");
} catch (Exception e) {
}
GeneralUtils.saveKeyToSettings("AutomaticallyGenerated.appVersion", appVersion);
GeneralUtil.saveKeyToSettings("AutomaticallyGenerated.appVersion", appVersion);
applicationProperties.getAutomaticallyGenerated().setAppVersion(appVersion);
}
}

View File

@ -33,7 +33,7 @@ import lombok.extern.slf4j.Slf4j;
import stirling.software.SPDF.model.api.general.MergePdfsRequest;
import stirling.software.common.service.CustomPDFDocumentFactory;
import stirling.software.common.util.GeneralUtils;
import stirling.software.common.util.GeneralUtil;
import stirling.software.common.util.WebResponseUtils;
@RestController
@ -137,7 +137,7 @@ public class MergeController {
for (MultipartFile multipartFile : files) {
totalSize += multipartFile.getSize();
File tempFile =
GeneralUtils.convertMultipartFileToFile(
GeneralUtil.convertMultipartFileToFile(
multipartFile); // Convert MultipartFile to File
filesToDelete.add(tempFile); // Add temp file to the list for later deletion
mergerUtility.addSource(tempFile); // Add source file to the merger utility

View File

@ -28,7 +28,7 @@ import lombok.RequiredArgsConstructor;
import stirling.software.SPDF.model.api.general.OverlayPdfsRequest;
import stirling.software.common.service.CustomPDFDocumentFactory;
import stirling.software.common.util.GeneralUtils;
import stirling.software.common.util.GeneralUtil;
import stirling.software.common.util.WebResponseUtils;
@RestController
@ -56,7 +56,7 @@ public class PdfOverlayController {
try {
for (int i = 0; i < overlayFiles.length; i++) {
overlayPdfFiles[i] = GeneralUtils.multipartToFile(overlayFiles[i]);
overlayPdfFiles[i] = GeneralUtil.multipartToFile(overlayFiles[i]);
}
String mode = request.getOverlayMode(); // "SequentialOverlay", "InterleavedOverlay",

View File

@ -25,7 +25,7 @@ import stirling.software.SPDF.model.SortTypes;
import stirling.software.SPDF.model.api.PDFWithPageNums;
import stirling.software.SPDF.model.api.general.RearrangePagesRequest;
import stirling.software.common.service.CustomPDFDocumentFactory;
import stirling.software.common.util.GeneralUtils;
import stirling.software.common.util.GeneralUtil;
import stirling.software.common.util.WebResponseUtils;
@RestController
@ -56,7 +56,7 @@ public class RearrangePagesPDFController {
String[] pageOrderArr = pagesToDelete.split(",");
List<Integer> pagesToRemove =
GeneralUtils.parsePageList(pageOrderArr, document.getNumberOfPages(), false);
GeneralUtil.parsePageList(pageOrderArr, document.getNumberOfPages(), false);
Collections.sort(pagesToRemove);
@ -262,7 +262,7 @@ public class RearrangePagesPDFController {
&& !"custom".equals(sortType.toLowerCase())) {
newPageOrder = processSortTypes(sortType, totalPages, pageOrder);
} else {
newPageOrder = GeneralUtils.parsePageList(pageOrderArr, totalPages, false);
newPageOrder = GeneralUtil.parsePageList(pageOrderArr, totalPages, false);
}
log.info("newPageOrder = " + newPageOrder);
log.info("totalPages = " + totalPages);

View File

@ -19,7 +19,7 @@ import lombok.RequiredArgsConstructor;
import stirling.software.SPDF.config.EndpointConfiguration;
import stirling.software.common.configuration.InstallationPathConfig;
import stirling.software.common.model.ApplicationProperties;
import stirling.software.common.util.GeneralUtils;
import stirling.software.common.util.GeneralUtil;
@Controller
@Tag(name = "Settings", description = "Settings APIs")
@ -40,7 +40,7 @@ public class SettingsController {
"Setting has already been set, To adjust please edit "
+ InstallationPathConfig.getSettingsPath());
}
GeneralUtils.saveKeyToSettings("system.enableAnalytics", enabled);
GeneralUtil.saveKeyToSettings("system.enableAnalytics", enabled);
applicationProperties.getSystem().setEnableAnalytics(enabled);
return ResponseEntity.ok("Updated");
}

View File

@ -26,7 +26,7 @@ import lombok.extern.slf4j.Slf4j;
import stirling.software.SPDF.model.api.general.SplitPdfBySizeOrCountRequest;
import stirling.software.common.service.CustomPDFDocumentFactory;
import stirling.software.common.util.GeneralUtils;
import stirling.software.common.util.GeneralUtil;
import stirling.software.common.util.WebResponseUtils;
@RestController
@ -81,7 +81,7 @@ public class SplitPdfBySizeController {
if (type == 0) {
log.debug("Processing split by size");
long maxBytes = GeneralUtils.convertSizeToBytes(value);
long maxBytes = GeneralUtil.convertSizeToBytes(value);
log.debug("Max bytes per document: {}", maxBytes);
handleSplitBySize(sourceDocument, maxBytes, zipOut, filename);
} else if (type == 1) {

View File

@ -34,7 +34,7 @@ import stirling.software.SPDF.model.api.converters.ConvertToImageRequest;
import stirling.software.SPDF.model.api.converters.ConvertToPdfRequest;
import stirling.software.common.service.CustomPDFDocumentFactory;
import stirling.software.common.util.CheckProgramInstall;
import stirling.software.common.util.GeneralUtils;
import stirling.software.common.util.GeneralUtil;
import stirling.software.common.util.PdfUtils;
import stirling.software.common.util.ProcessExecutor;
import stirling.software.common.util.ProcessExecutor.ProcessExecutorResult;
@ -251,7 +251,7 @@ public class ConvertImgPDFController {
// Load the input PDF
PDDocument document = pdfDocumentFactory.load(pdfFile);
int totalPages = document.getNumberOfPages();
List<Integer> newPageOrder = GeneralUtils.parsePageList(pageOrderArr, totalPages, false);
List<Integer> newPageOrder = GeneralUtil.parsePageList(pageOrderArr, totalPages, false);
// Create a new list to hold the pages in the new order
List<PDPage> newPages = new ArrayList<>();

View File

@ -23,7 +23,7 @@ import stirling.software.SPDF.model.api.converters.UrlToPdfRequest;
import stirling.software.common.configuration.RuntimePathConfig;
import stirling.software.common.model.ApplicationProperties;
import stirling.software.common.service.CustomPDFDocumentFactory;
import stirling.software.common.util.GeneralUtils;
import stirling.software.common.util.GeneralUtil;
import stirling.software.common.util.ProcessExecutor;
import stirling.software.common.util.ProcessExecutor.ProcessExecutorResult;
import stirling.software.common.util.WebResponseUtils;
@ -53,12 +53,12 @@ public class ConvertWebsiteToPDF {
throw new IllegalArgumentException("This endpoint has been disabled by the admin.");
}
// Validate the URL format
if (!URL.matches("^https?://.*") || !GeneralUtils.isValidURL(URL)) {
if (!URL.matches("^https?://.*") || !GeneralUtil.isValidURL(URL)) {
throw new IllegalArgumentException("Invalid URL format provided.");
}
// validate the URL is reachable
if (!GeneralUtils.isURLReachable(URL)) {
if (!GeneralUtil.isURLReachable(URL)) {
throw new IllegalArgumentException("URL is not reachable, please provide a valid URL.");
}

View File

@ -52,7 +52,7 @@ import lombok.extern.slf4j.Slf4j;
import stirling.software.SPDF.config.EndpointConfiguration;
import stirling.software.SPDF.model.api.misc.OptimizePdfRequest;
import stirling.software.common.service.CustomPDFDocumentFactory;
import stirling.software.common.util.GeneralUtils;
import stirling.software.common.util.GeneralUtil;
import stirling.software.common.util.ProcessExecutor;
import stirling.software.common.util.ProcessExecutor.ProcessExecutorResult;
import stirling.software.common.util.WebResponseUtils;
@ -111,7 +111,7 @@ public class CompressController {
scaleFactor,
jpegQuality,
convertToGrayscale,
GeneralUtils.formatBytes(originalFileSize));
GeneralUtil.formatBytes(originalFileSize));
try (PDDocument doc = pdfDocumentFactory.load(pdfFile)) {
// Find all unique images in the document
@ -145,8 +145,8 @@ public class CompressController {
double overallReduction = 100.0 - ((compressedFileSize * 100.0) / originalFileSize);
log.info(
"Overall PDF compression: {} → {} (reduced by {}%)",
GeneralUtils.formatBytes(originalFileSize),
GeneralUtils.formatBytes(compressedFileSize),
GeneralUtil.formatBytes(originalFileSize),
GeneralUtil.formatBytes(compressedFileSize),
String.format("%.1f", overallReduction));
return newCompressedPDF;
}
@ -316,8 +316,8 @@ public class CompressController {
log.info(
"Image hash {}: Compressed from {} to {} (reduced by {}%)",
imageHash,
GeneralUtils.formatBytes(originalSize),
GeneralUtils.formatBytes(compressedSize),
GeneralUtil.formatBytes(originalSize),
GeneralUtil.formatBytes(compressedSize),
String.format("%.1f", reductionPercentage));
} else {
log.info("Image hash {}: Not suitable for compression, skipping", imageHash);
@ -456,8 +456,8 @@ public class CompressController {
stats.nestedImages);
log.info(
"Total original image size: {}, compressed: {} (reduced by {}%)",
GeneralUtils.formatBytes(stats.totalOriginalBytes),
GeneralUtils.formatBytes(stats.totalCompressedBytes),
GeneralUtil.formatBytes(stats.totalOriginalBytes),
GeneralUtil.formatBytes(stats.totalCompressedBytes),
String.format("%.1f", overallImageReduction));
}
@ -673,7 +673,7 @@ public class CompressController {
Long expectedOutputSize = 0L;
boolean autoMode = false;
if (expectedOutputSizeString != null && expectedOutputSizeString.length() > 1) {
expectedOutputSize = GeneralUtils.convertSizeToBytes(expectedOutputSizeString);
expectedOutputSize = GeneralUtil.convertSizeToBytes(expectedOutputSizeString);
autoMode = true;
}
@ -794,7 +794,7 @@ public class CompressController {
throws IOException {
long preQpdfSize = Files.size(currentFile);
log.info("Pre-QPDF file size: {}", GeneralUtils.formatBytes(preQpdfSize));
log.info("Pre-QPDF file size: {}", GeneralUtil.formatBytes(preQpdfSize));
// Map optimization levels to QPDF compression levels
int qpdfCompressionLevel;
@ -839,7 +839,7 @@ public class CompressController {
double qpdfReduction = 100.0 - ((postQpdfSize * 100.0) / preQpdfSize);
log.info(
"Post-QPDF file size: {} (reduced by {}%)",
GeneralUtils.formatBytes(postQpdfSize), String.format("%.1f", qpdfReduction));
GeneralUtil.formatBytes(postQpdfSize), String.format("%.1f", qpdfReduction));
} catch (Exception e) {
if (returnCode != null && returnCode.getRc() != 3) {

Some files were not shown because too many files have changed in this diff Show More