mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-09-08 17:51:20 +02:00
📁 pre-commit
Signed-off-by: stirlingbot[bot] <stirlingbot[bot]@users.noreply.github.com>
This commit is contained in:
parent
8192b1a44f
commit
394ecfb08c
@ -1,9 +1,8 @@
|
|||||||
package stirling.software.SPDF.controller.api.misc;
|
package stirling.software.SPDF.controller.api.misc;
|
||||||
|
|
||||||
import io.github.pixee.security.Filenames;
|
import java.nio.charset.StandardCharsets;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import java.util.Map;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||||
import org.apache.pdfbox.pdmodel.common.PDNameTreeNode;
|
import org.apache.pdfbox.pdmodel.common.PDNameTreeNode;
|
||||||
import org.apache.pdfbox.pdmodel.interactive.action.PDActionJavaScript;
|
import org.apache.pdfbox.pdmodel.interactive.action.PDActionJavaScript;
|
||||||
@ -14,13 +13,17 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import io.github.pixee.security.Filenames;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
import stirling.software.common.model.api.PDFFile;
|
import stirling.software.common.model.api.PDFFile;
|
||||||
import stirling.software.common.service.CustomPDFDocumentFactory;
|
import stirling.software.common.service.CustomPDFDocumentFactory;
|
||||||
import stirling.software.common.util.WebResponseUtils;
|
import stirling.software.common.util.WebResponseUtils;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/v1/misc")
|
@RequestMapping("/api/v1/misc")
|
||||||
@Tag(name = "Misc", description = "Miscellaneous APIs")
|
@Tag(name = "Misc", description = "Miscellaneous APIs")
|
||||||
@ -55,12 +58,14 @@ public class ShowJavascript {
|
|||||||
|
|
||||||
if (jsCodeStr != null && !jsCodeStr.trim().isEmpty()) {
|
if (jsCodeStr != null && !jsCodeStr.trim().isEmpty()) {
|
||||||
script.append("// File: ")
|
script.append("// File: ")
|
||||||
.append(Filenames.toSimpleFileName(inputFile.getOriginalFilename()))
|
.append(
|
||||||
.append(", Script: ")
|
Filenames.toSimpleFileName(
|
||||||
.append(name)
|
inputFile.getOriginalFilename()))
|
||||||
.append("\n")
|
.append(", Script: ")
|
||||||
.append(jsCodeStr)
|
.append(name)
|
||||||
.append("\n");
|
.append("\n")
|
||||||
|
.append(jsCodeStr)
|
||||||
|
.append("\n");
|
||||||
foundScript = true;
|
foundScript = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -68,9 +73,10 @@ public class ShowJavascript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!foundScript) {
|
if (!foundScript) {
|
||||||
script = new StringBuilder("PDF '")
|
script =
|
||||||
.append(Filenames.toSimpleFileName(inputFile.getOriginalFilename()))
|
new StringBuilder("PDF '")
|
||||||
.append("' does not contain Javascript");
|
.append(Filenames.toSimpleFileName(inputFile.getOriginalFilename()))
|
||||||
|
.append("' does not contain Javascript");
|
||||||
}
|
}
|
||||||
|
|
||||||
return WebResponseUtils.bytesToWebResponse(
|
return WebResponseUtils.bytesToWebResponse(
|
||||||
|
@ -75,8 +75,11 @@ public class CustomUserDetailsService implements UserDetailsService {
|
|||||||
*/
|
*/
|
||||||
private AuthenticationType determinePreferredSSOType() {
|
private AuthenticationType determinePreferredSSOType() {
|
||||||
// Check what SSO types are enabled and prefer in order: OAUTH2 > SAML2 > fallback to OAUTH2
|
// Check what SSO types are enabled and prefer in order: OAUTH2 > SAML2 > fallback to OAUTH2
|
||||||
boolean oauth2Enabled = securityProperties.getOauth2() != null && securityProperties.getOauth2().getEnabled();
|
boolean oauth2Enabled =
|
||||||
boolean saml2Enabled = securityProperties.getSaml2() != null && securityProperties.getSaml2().getEnabled();
|
securityProperties.getOauth2() != null
|
||||||
|
&& securityProperties.getOauth2().getEnabled();
|
||||||
|
boolean saml2Enabled =
|
||||||
|
securityProperties.getSaml2() != null && securityProperties.getSaml2().getEnabled();
|
||||||
|
|
||||||
if (oauth2Enabled) {
|
if (oauth2Enabled) {
|
||||||
return AuthenticationType.OAUTH2;
|
return AuthenticationType.OAUTH2;
|
||||||
|
Loading…
Reference in New Issue
Block a user