PrincipalUtils
Utility methods for retrieving information from the security context. For example, get the actual userId from the security context session or get the actual tenant of the logged-in user.
Methods
Section titled “Methods”getUser
Section titled “getUser”Description:
| Method | Return values | Description |
|---|---|---|
| getUser() | String | Get the userId of the logged-in user. |
Example:
package com.openkm;
import com.openkm.principal.PrincipalUtils;
public class Test {
public static void main(String[] args) { try { System.out.println(PrincipalUtils.getUser()); } catch (Exception e) { e.printStackTrace(); } }}getTenantId
Section titled “getTenantId”Description:
| Method | Return values | Description |
|---|---|---|
| getTenantId() | long | Get the tenantId of the logged-in user. |
Example:
package com.openkm;
import com.openkm.principal.PrincipalUtils;
public class Test {
public static void main(String[] args) { try { long tenantId = PrincipalUtils.getTenantId(); System.out.println(tenantId); } catch (Exception e) { e.printStackTrace(); } }}