From 146a0fb8b0e90f9196e569152f649baf60d6cc8f Mon Sep 17 00:00:00 2001
From: Joaquín Reñé <jrene@curisit.net>
Date: Tue, 07 Oct 2025 14:52:57 +0000
Subject: [PATCH] #4410 - Comments on classes

---
 securis/src/main/java/net/curisit/securis/services/helpers/UserHelper.java |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/securis/src/main/java/net/curisit/securis/services/helpers/UserHelper.java b/securis/src/main/java/net/curisit/securis/services/helpers/UserHelper.java
index 4c561dc..b9bff32 100644
--- a/securis/src/main/java/net/curisit/securis/services/helpers/UserHelper.java
+++ b/securis/src/main/java/net/curisit/securis/services/helpers/UserHelper.java
@@ -1,3 +1,6 @@
+/*
+ * Copyright @ 2013 CurisTEC, S.A.S. All Rights Reserved.
+ */
 package net.curisit.securis.services.helpers;
 
 import jakarta.enterprise.context.ApplicationScoped;
@@ -8,14 +11,45 @@
 import net.curisit.securis.security.BasicSecurityContext;
 import net.curisit.securis.services.exception.SeCurisServiceException;
 
+/**
+ * UserHelper
+ * <p>
+ * Small helper to resolve the current user (from security context) or by username.
+ * Throws a typed {@link SeCurisServiceException} if the user cannot be found.
+ *
+ * Thread-safety: ApplicationScoped, stateless.
+ * 
+ * @author JRA
+ * Last reviewed by JRA on Oct 5, 2025.
+ */
 @ApplicationScoped
 public class UserHelper {
 
+    /**
+     * getUser
+     * <p>
+     * Resolve the current authenticated user from {@link BasicSecurityContext}.
+     *
+     * @param bsc Security context containing a principal.
+     * @param em  EntityManager to fetch the user.
+     * @return Managed {@link User}.
+     * @throws SeCurisServiceException if the principal is null or not found in DB.
+     */
     public User getUser(BasicSecurityContext bsc, EntityManager em) throws SeCurisServiceException {
         String username = bsc.getUserPrincipal().getName();
         return getUser(username, em);
     }
 
+    /**
+     * getUser
+     * <p>
+     * Resolve a user by username.
+     *
+     * @param username Username to look up (nullable allowed; returns null).
+     * @param em       EntityManager to fetch the user.
+     * @return Managed {@link User} or null if username is null.
+     * @throws SeCurisServiceException if a non-null username does not exist.
+     */
     public User getUser(String username, EntityManager em) throws SeCurisServiceException {
         User user = null;
         if (username != null) {

--
Gitblit v1.3.2