rename anonymus to anonymous

This commit is contained in:
Ludy87 2025-04-17 18:02:02 +02:00
parent fa8df329df
commit 1fb4a40edf
No known key found for this signature in database
GPG Key ID: 92696155E0220F94
8 changed files with 27 additions and 40 deletions

View File

@ -66,7 +66,7 @@ sourceSets {
exclude "stirling/software/SPDF/model/User.java"
exclude "stirling/software/SPDF/repository/**"
} else {
exclude "stirling/software/SPDF/config/anonymus/**"
exclude "stirling/software/SPDF/config/anonymous/**"
}
if (System.getenv("STIRLING_PDF_DESKTOP_UI") == "false") {
@ -534,6 +534,7 @@ dependencies {
annotationProcessor "org.projectlombok:lombok:$lombokVersion"
testRuntimeOnly 'org.mockito:mockito-inline:5.2.0'
implementation("org.springframework.boot:spring-boot-starter-webflux")
}
tasks.withType(JavaCompile).configureEach {

View File

@ -33,10 +33,7 @@ public class EndpointInterceptor implements HandlerInterceptor {
public boolean preHandle(
HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
HttpSession session = request.getSession(false);
if (session == null) {
session = request.getSession(true);
}
HttpSession session = request.getSession(true);
String requestURI = request.getRequestURI();
boolean isApiRequest = requestURI.contains("/api/v1");

View File

@ -1,4 +1,4 @@
package stirling.software.SPDF.config.anonymus.session;
package stirling.software.SPDF.config.anonymous.session;
import java.util.Date;
@ -15,7 +15,7 @@ import stirling.software.SPDF.config.interfaces.SessionsModelInterface;
@ToString(exclude = "session") // exclude session from toString to avoid verbose output or sensitive
// data
@AllArgsConstructor
public class AnonymusSessionInfo implements SessionsModelInterface {
public class AnonymousSessionInfo implements SessionsModelInterface {
private static final String principalName = "anonymousUser";
private HttpSession session;

View File

@ -1,4 +1,4 @@
package stirling.software.SPDF.config.anonymus.session;
package stirling.software.SPDF.config.anonymous.session;
import java.time.Duration;
import java.time.Instant;
@ -22,7 +22,7 @@ import stirling.software.SPDF.config.interfaces.SessionsModelInterface;
@Component
@Slf4j
public class AnonymusSessionListener implements HttpSessionListener, SessionsInterface {
public class AnonymousSessionListener implements HttpSessionListener, SessionsInterface {
@Value("${server.servlet.session.timeout:30m}")
private Duration defaultMaxInactiveInterval;
@ -49,11 +49,11 @@ public class AnonymusSessionListener implements HttpSessionListener, SessionsInt
if (allNonExpiredSessions >= getMaxUserSessions()) {
sessions.put(
session.getId(),
new AnonymusSessionInfo(session, creationTime, creationTime, true));
new AnonymousSessionInfo(session, creationTime, creationTime, true));
} else {
sessions.put(
session.getId(),
new AnonymusSessionInfo(session, creationTime, creationTime, false));
new AnonymousSessionInfo(session, creationTime, creationTime, false));
}
}
@ -63,7 +63,7 @@ public class AnonymusSessionListener implements HttpSessionListener, SessionsInt
if (session == null) {
return;
}
AnonymusSessionInfo sessionsInfo = (AnonymusSessionInfo) sessions.get(session.getId());
AnonymousSessionInfo sessionsInfo = (AnonymousSessionInfo) sessions.get(session.getId());
if (sessionsInfo == null) {
return;
}
@ -84,7 +84,7 @@ public class AnonymusSessionListener implements HttpSessionListener, SessionsInt
// Mark a single session as expired
public void expireSession(String sessionId) {
if (sessions.containsKey(sessionId)) {
AnonymusSessionInfo sessionInfo = (AnonymusSessionInfo) sessions.get(sessionId);
AnonymousSessionInfo sessionInfo = (AnonymousSessionInfo) sessions.get(sessionId);
sessionInfo.setExpired(true);
try {
sessionInfo.getSession().invalidate();
@ -103,7 +103,7 @@ public class AnonymusSessionListener implements HttpSessionListener, SessionsInt
.findFirst()
.ifPresent(
session -> {
AnonymusSessionInfo sessionInfo = (AnonymusSessionInfo) session;
AnonymousSessionInfo sessionInfo = (AnonymousSessionInfo) session;
sessionInfo.setExpired(true);
try {
log.info(
@ -122,7 +122,7 @@ public class AnonymusSessionListener implements HttpSessionListener, SessionsInt
sessions.values()
.forEach(
sessionInfo -> {
AnonymusSessionInfo info = (AnonymusSessionInfo) sessionInfo;
AnonymousSessionInfo info = (AnonymousSessionInfo) sessionInfo;
info.setExpired(true);
HttpSession session = info.getSession();
try {
@ -138,12 +138,12 @@ public class AnonymusSessionListener implements HttpSessionListener, SessionsInt
sessions.values().stream()
.filter(
sessionInfo -> {
AnonymusSessionInfo info = (AnonymusSessionInfo) sessionInfo;
AnonymousSessionInfo info = (AnonymousSessionInfo) sessionInfo;
return info.getPrincipalName().equals(username);
})
.forEach(
sessionInfo -> {
AnonymusSessionInfo info = (AnonymusSessionInfo) sessionInfo;
AnonymousSessionInfo info = (AnonymousSessionInfo) sessionInfo;
info.setExpired(true);
HttpSession session = info.getSession();
try {
@ -157,7 +157,7 @@ public class AnonymusSessionListener implements HttpSessionListener, SessionsInt
@Override
public void updateSessionLastRequest(String sessionId) {
if (sessions.containsKey(sessionId)) {
AnonymusSessionInfo sessionInfo = (AnonymusSessionInfo) sessions.get(sessionId);
AnonymousSessionInfo sessionInfo = (AnonymousSessionInfo) sessions.get(sessionId);
sessionInfo.setLastRequest(new Date());
}
}
@ -183,8 +183,8 @@ public class AnonymusSessionListener implements HttpSessionListener, SessionsInt
@Override
public void registerSession(HttpSession session) {
if (!sessions.containsKey(session.getId())) {
AnonymusSessionInfo sessionInfo =
new AnonymusSessionInfo(session, new Date(), new Date(), false);
AnonymousSessionInfo sessionInfo =
new AnonymousSessionInfo(session, new Date(), new Date(), false);
sessions.put(session.getId(), sessionInfo);
log.debug("Session {} registered", session.getId());
}
@ -192,7 +192,7 @@ public class AnonymusSessionListener implements HttpSessionListener, SessionsInt
@Override
public void removeSession(HttpSession session) {
AnonymusSessionInfo sessionsInfo = (AnonymusSessionInfo) sessions.get(session.getId());
AnonymousSessionInfo sessionsInfo = (AnonymousSessionInfo) sessions.get(session.getId());
if (sessionsInfo != null) {
sessionsInfo.setExpired(true);
}

View File

@ -1,4 +1,4 @@
package stirling.software.SPDF.config.anonymus.session;
package stirling.software.SPDF.config.anonymous.session;
import java.time.Duration;
import java.time.Instant;
@ -14,9 +14,9 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
@Component
public class AnonymusSessionService {
public class AnonymousSessionService {
@Autowired private AnonymusSessionListener sessionRegistry;
@Autowired private AnonymousSessionListener sessionRegistry;
@Value("${server.servlet.session.timeout:30m}")
private Duration defaultMaxInactiveInterval;

View File

@ -1,4 +1,4 @@
package stirling.software.SPDF.config.anonymus.session;
package stirling.software.SPDF.config.anonymous.session;
import java.util.List;
@ -17,21 +17,14 @@ import stirling.software.SPDF.config.interfaces.SessionsModelInterface;
@Controller
@Slf4j
public class AnonymusSessionStatusController {
public class AnonymousSessionStatusController {
@Autowired private AnonymusSessionListener sessionRegistry;
@Autowired private AnonymousSessionListener sessionRegistry;
@GetMapping("/userSession")
public String getUserSessions(HttpServletRequest request, Model model) {
HttpSession session = request.getSession(false);
if (session != null) {
boolean isSessionValid =
sessionRegistry.getAllNonExpiredSessions().stream()
.allMatch(
sessionEntity ->
sessionEntity.getSessionId().equals(session.getId()));
// Get all sessions for the user
List<SessionsModelInterface> sessionList =
sessionRegistry.getAllNonExpiredSessions().stream()

View File

@ -1,4 +1,4 @@
package stirling.software.SPDF.config.anonymus.session;
package stirling.software.SPDF.config.security.session;
import java.util.List;
@ -17,10 +17,7 @@ import jakarta.servlet.http.HttpSession;
import lombok.extern.slf4j.Slf4j;
import stirling.software.SPDF.config.interfaces.SessionsInterface;
import stirling.software.SPDF.config.security.UserUtils;
import stirling.software.SPDF.config.security.session.CustomHttpSessionListener;
import stirling.software.SPDF.config.security.session.SessionPersistentRegistry;
@Controller
@Slf4j
@ -30,7 +27,6 @@ public class SessionStatusController {
private boolean loginEnabled;
@Autowired private SessionPersistentRegistry sessionPersistentRegistry;
@Autowired private SessionsInterface sessionInterface;
@Autowired private CustomHttpSessionListener customHttpSessionListener;

View File

@ -294,7 +294,7 @@ session.refreshPage=Refresh Page
userSession.title=User Sessions
userSession.header=User Sessions
userSession.maxUserSession=If the maximum number of sessions for this user is reached, you can end other logins here to continue on this device.
userSession.lastRequest=last Request
userSession.lastRequest=Last Request
#############
# HOME-PAGE #