OKMAuth
Used for managing security and users. For example, add or remove grants on a node, create or modify users, or get the profiles.
Starting from version 8.1.14, some methods return the DbUser object instead of the old CommonUser, which has been deprecated.
Basics
The class com.openkm.bean.Permission contains permission values ( READ, WRITE, etc. ). You should use it in combination with methods that are changing or getting security grants.
To set READ and WRITE access, you should do:
int permission = Permission.READ + Permission.WRITE;
To check if you have permission access,s you should do:
// permission is a valid integer value
if ((permission | Permission.WRITE) = Permission.WRITE) {
// Has WRITE grants.
}
In almost all methods, you'll see a parameter named "nodeId". The value of this parameter can be a valid node UUID ( folder, document, mail, record ).
Example of nodeId:
- Using UUID -> "b153c4b7-3d1c-4589-bd42-0ed0f34fd338";
Also, in all methods, you'll see a parameter named "token". Because the Cron tasks are executed in the background without authentication, the methods used in this scenario might use the token parameter. From the default application execution context, you must use "null" value, which indicates that the application must use the "user session".
In special cases, you might be "promoted as Administrator" using the "administrator token".
String systemToken = DbSessionManager.getInstance().getSystemToken();
Methods
login
Description:
Method | Return values | Description |
---|---|---|
login() |
void |
Simulates user UI login process. |
When a user logs in from UI, some background process creates main user nodes, like /okm:trash. Unfortunately, if the user has never logged in from UI and login from the API, these nodes are still not created and will raise an error, because it is necessary at the beginning execute the login method. The user must be logged in before executing the method. |
Example:
package com.openkm;
import com.openkm.api.OKMAuth;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMAuth okmAuth = ContextWrapper.getContext().getBean(OKMAuth.class);
okmAuth.login();
} catch (Exception e) {
e.printStackTrace();
}
}
}
login
Description:
Method | Return values | Description |
---|---|---|
login(String user, String pass) |
String |
The login process returns an authentication token. |
Login token by default have an expiration time of 24h. After executing the login method, all the next calls will automatically use the authentication token. Each time the login method is executed, the login token is replaced with a newer. When a user login in to the application for the first time, is called internally calls a method that creates user specific folders, like /okm:trash/userId etc. From API point of view, this method should be only executed first time user accessing from API, for creating specific user folder structure. Otherwise, you can get errors, for example PathNotExistsException /okm:trash/userId when deleting objects, because the folders have not been created. |
Example:
package com.openkm;
import com.openkm.api.OKMAuth;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMAuth okmAuth = ContextWrapper.getContext().getBean(OKMAuth.class);
okmAuth.login("userId","password");
} catch (Exception e) {
e.printStackTrace();
}
}
}
grantUser
Description:
Method | Return values | Description |
---|---|---|
grantUser(String token, String nodeId, String user, int permissions, boolean recursive) |
void |
Add a user grant on a node. |
The parameter recursive only has sense when the nodeId is a folder or record node. When the parameter recursive is true, the change will be applied to the node and its descendants. |
Example:
package com.openkm;
import com.openkm.api.OKMAuth;
import com.openkm.bean.Permission;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMAuth okmAuth = ContextWrapper.getContext().getBean(OKMAuth.class);
// Add sochoa write grants at the node but not descendants
okmAuth.grantUser(null, "b153c4b7-3d1c-4589-bd42-0ed0f34fd338", "sochoa", Permission.ALL_GRANTS, false);
// Add all okmAdmin grants at the node and descendants
okmAuth.grantUser(null, "b153c4b7-3d1c-4589-bd42-0ed0f34fd338", "okmAdmin", Permission.ALL_GRANTS, true);
} catch (Exception e) {
e.printStackTrace();
}
}
}
revokeUser
Description:
Method | Return values | Description |
---|---|---|
revokeUser(String token, String nodeId, String user, int permissions, boolean recursive) |
void |
Remove user grant on a node. |
The parameter recursive only has sense when the nodeId is a folder or a record node. When the parameter recursive is true, the change will be applied to the node and descendants. |
Example:
package com.openkm;
import com.openkm.api.OKMAuth;
import com.openkm.bean.Permission;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMAuth okmAuth = ContextWrapper.getContext().getBean(OKMAuth.class);
// Add sochoa write grants at the node but not descendants
okmAuth.revokeUser(null, "b153c4b7-3d1c-4589-bd42-0ed0f34fd338", "sochoa", Permission.ALL_GRANTS, false);
// Remove all okmAdmin grants at the node and descendants
okmAuth.revokeUser(null, "b153c4b7-3d1c-4589-bd42-0ed0f34fd338", "okmAdmin", Permission.ALL_GRANTS, true);
} catch (Exception e) {
e.printStackTrace();
}
}
}
getGrantedUsers
Description:
Method | Return values | Description |
---|---|---|
getGrantedUsers(String token, String nodeId) |
Map<String, Integer> |
Return the granted users of a node. |
Example:
package com.openkm;
import java.util.Map;
import com.openkm.api.OKMAuth;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMAuth okmAuth = ContextWrapper.getContext().getBean(OKMAuth.class);
Map<String, Integer> grants = okmAuth.getGrantedUsers(null, "b153c4b7-3d1c-4589-bd42-0ed0f34fd338");
for (String role : grants.keySet()) {
System.out.println(role + "->" + grants.get(role));
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
grantRole
Description:
Method | Return values | Description |
---|---|---|
grantRole(String token, String nodeId, String role, int permissions, boolean recursive) |
void |
Add a role grant on a node. |
The parameter recursive only has sense when the nodeId is a folder or a record node. When the parameter recursive is true, the change will be applied to the node and descendants. |
Example:
package com.openkm;
import com.openkm.api.OKMAuth;
import com.openkm.bean.Permission;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMAuth okmAuth = ContextWrapper.getContext().getBean(OKMAuth.class);
// Add ROLE_USER write grants at the node but not descendants
okmAuth.grantRole(null, "b153c4b7-3d1c-4589-bd42-0ed0f34fd338", "ROLE_USER", Permission.ALL_GRANTS, false);
// Add all ROLE_ADMIN grants to the node and descendants
okmAuth.grantRole(null, "b153c4b7-3d1c-4589-bd42-0ed0f34fd338", "ROLE_ADMIN", Permission.ALL_GRANTS, true);
} catch (Exception e) {
e.printStackTrace();
}
}
}
revokeRole
Description:
Method | Return values | Description |
---|---|---|
revokeRole(String token, String nodeId, String role, int permissions, boolean recursive) |
void |
Remove role grant on a node. |
The parameter recursive only has sense when the nodeId is a folder or a record node. When the parameter recursive is true, the change will be applied to the node and its descendants. |
Example:
package com.openkm;
import com.openkm.api.OKMAuth;
import com.openkm.bean.Permission;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMAuth okmAuth = ContextWrapper.getContext().getBean(OKMAuth.class);
// Remove ROLE_USER write grants at the node but not descendants
okmAuth.revokeRole(null, "b153c4b7-3d1c-4589-bd42-0ed0f34fd338", "ROLE_USER", Permission.ALL_GRANTS, false);
// Remove all ROLE_ADMIN grants to the node and descendants
okmAuth.revokeRole(null, "b153c4b7-3d1c-4589-bd42-0ed0f34fd338", "ROLE_ADMIN", Permission.ALL_GRANTS, true);
} catch (Exception e) {
e.printStackTrace();
}
}
}
getGrantedRoles
Description:
Method | Return values | Description |
---|---|---|
getGrantedRoles(String token, String nodeId) |
Map<String, Integer> |
Return the granted roles of a node. |
Example:
package com.openkm;
import java.util.Map;
import com.openkm.api.OKMAuth;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMAuth okmAuth = ContextWrapper.getContext().getBean(OKMAuth.class);
Map<String, Integer> grants = okmAuth.getGrantedRoles(null, "b153c4b7-3d1c-4589-bd42-0ed0f34fd338");
for (String role : grants.keySet()) {
System.out.println(role + "->" + grants.get(role));
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
getUsers
Description:
Method | Return values | Description |
---|---|---|
getUsers(String token) |
List<DbUser> |
Return the list of all the users. |
Example:
package com.openkm;
import com.openkm.api.OKMAuth;
import com.openkm.bean.DbUser;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMAuth okmAuth = ContextWrapper.getContext().getBean(OKMAuth.class);
for (DbUser user : okmAuth.getUsers(null)) {
System.out.println(user.getId());
System.out.println(user.getName());
System.out.println(user.getEmail());
System.out.println(user.getActive());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
getRoles
Description:
Method | Return values | Description |
---|---|---|
getRoles(String token) |
List<String> |
Return the list of all the roles. |
Example:
package com.openkm;
import com.openkm.api.OKMAuth;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMAuth okmAuth = ContextWrapper.getContext().getBean(OKMAuth.class);
for (String role : okmAuth.getRoles(null)) {
System.out.println(role);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
getUsersByRole
Description:
Method | Return values | Description |
---|---|---|
getUsersByRole(String token, String role) |
List<DbUser> |
Return the list of all the users who have been assigned a role. |
Example:
package com.openkm;
import com.openkm.api.OKMAuth;
import com.openkm.bean.DbUser;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMAuth okmAuth = ContextWrapper.getContext().getBean(OKMAuth.class);
for (DbUser user : okmAuth.getUsersByRole(null, "ROLE_ADMIN")) {
System.out.println(user.getId());
System.out.println(user.getName());
System.out.println(user.getEmail());
System.out.println(user.getActive());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
getRolesByUser
Description:
Method | Return values | Description |
---|---|---|
getRolesByUser(String token, String user) |
List<String> |
Return the list of all the roles assigned to a user. |
Example:
package com.openkm;
import com.openkm.api.OKMAuth;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMAuth okmAuth = ContextWrapper.getContext().getBean(OKMAuth.class);
for (String role : okmAuth.getRolesByUser(null, "okmAdmin")) {
System.out.println(role);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
changeSecurity
Description:
Method | Return values | Description |
---|---|---|
public void changeSecurity(String token, String nodeId, Map<String, Integer> grantUsers, Map<String, Integer> revokeUsers, |
void |
Change the security of a node. |
Example:
package com.openkm;
import java.util.HashMap;
import java.util.Map;
import com.openkm.api.OKMAuth;
import com.openkm.bean.Permission;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMAuth okmAuth = ContextWrapper.getContext().getBean(OKMAuth.class);
String nodeId = "b153c4b7-3d1c-4589-bd42-0ed0f34fd338";
Map<String, Integer> grantUsers = new HashMap<>();
Map<String, Integer> revokeUsers = new HashMap<>();
Map<String, Integer> grantRoles = new HashMap<>();
grantRoles.put("ROLE_TEST", Permission.READ | Permission.WRITE);
Map<String, Integer> revokeRoles = new HashMap<>();
okmAuth.changeSecurity(null, nodeId, grantUsers, revokeUsers, grantRoles, revokeRoles, false);
} catch (Exception e) {
e.printStackTrace();
}
}
}
overwriteSecurity
Description:
Method | Return values | Description |
---|---|---|
public void overwriteSecurity(String token, String nodeId, Map<String, Integer> grantUsers, |
void |
Overwrite the security of a node. |
Example:
package com.openkm;
import java.util.HashMap;
import java.util.Map;
import com.openkm.api.OKMAuth;
import com.openkm.bean.Permission;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMAuth okmAuth = ContextWrapper.getContext().getBean(OKMAuth.class);
String nodeId = "b153c4b7-3d1c-4589-bd42-0ed0f34fd338";
Map<String, Integer> grantUsers = new HashMap<>();
Map<String, Integer> grantRoles = new HashMap<>();
grantRoles.put("ROLE_TEST", Permission.READ | Permission.WRITE);
okmAuth.overwriteSecurity(null, nodeId, grantUsers, grantRoles, false);
} catch (Exception e) {
e.printStackTrace();
}
}
}
createUser
Description:
Method | Return values | Description |
---|---|---|
createUser(String token, User user) |
void |
Create a new user. |
Example:
package com.openkm;
import com.openkm.api.OKMAuth;
import com.openkm.bean.User;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMAuth okmAuth = ContextWrapper.getContext().getBean(OKMAuth.class);
User user = new User();
user.setId("test");
user.setPassword("password.2019");
user.setEmail("some@mail.com");
user.setName("User Name");
user.setActive(true);
okmAuth.createUser(null, user);
} catch (Exception e) {
e.printStackTrace();
}
}
}
deleteUser
Description:
Method | Return values | Description |
---|---|---|
deleteUser(String token, String user) |
void |
Delete a user. |
Example:
package com.openkm;
import com.openkm.api.OKMAuth;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMAuth okmAuth = ContextWrapper.getContext().getBean(OKMAuth.class);
okmAuth.deleteUser(null, "test");
} catch (Exception e) {
e.printStackTrace();
}
}
}
updateUser
Description:
Method | Return values | Description |
---|---|---|
updateUser(String token, User user) |
void |
Update a user. |
Example:
package com.openkm;
import com.openkm.api.OKMAuth;
import com.openkm.bean.User;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMAuth okmAuth = ContextWrapper.getContext().getBean(OKMAuth.class);
User user = new User();
user.setId("test");
user.setPassword("newpassword");
user.setEmail("some@mail.com");
user.setName("Test");
user.setActive(false);
okmAuth.updateUser(null, user);
} catch (Exception e) {
e.printStackTrace();
}
}
}
createRole
Description:
Method | Return values | Description |
---|---|---|
createRole(String token, Role role) |
void |
Create a new role. |
Example:
package com.openkm;
import com.openkm.api.OKMAuth;
import com.openkm.bean.Role;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMAuth okmAuth = ContextWrapper.getContext().getBean(OKMAuth.class);
Role role = new Role();
role.setId("ROLE_TEST");
role.setActive(true);
okmAuth.createRole(null, role);
} catch (Exception e) {
e.printStackTrace();
}
}
}
deleteRole
Description:
Method | Return values | Description |
---|---|---|
deleteRole(String token, String role) |
void |
Delete a role. |
Example:
package com.openkm;
import com.openkm.api.OKMAuth;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMAuth okmAuth = ContextWrapper.getContext().getBean(OKMAuth.class);
okmAuth.deleteRole(null, "ROLE_TEST");
} catch (Exception e) {
e.printStackTrace();
}
}
}
updateRole
Description:
Method | Return values | Description |
---|---|---|
updateRole(String token, String role, boolean active) |
void |
Update a role. |
Example:
package com.openkm;
import com.openkm.api.OKMAuth;
public class Test {
public static void main(String[] args) {
try {
OKMAuth.getInstance().updateRole(null, "ROLE_TEST",true);
} catch (Exception e) {
e.printStackTrace();
}
}
}
assignRole
Description:
Method | Return values | Description |
---|---|---|
assignRole(String token, String user, String role) |
void |
Assign a role to a user. |
Example:
package com.openkm;
import com.openkm.api.OKMAuth;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMAuth okmAuth = ContextWrapper.getContext().getBean(OKMAuth.class);
okmAuth.assignRole(null, "test", "ROLE_USER");
} catch (Exception e) {
e.printStackTrace();
}
}
}
removeRole
Description:
Method | Return values | Description |
---|---|---|
removeRole(String token, String user, String role) |
void |
Remove a role from a user. |
Example:
package com.openkm;
import com.openkm.api.OKMAuth;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMAuth okmAuth = ContextWrapper.getContext().getBean(OKMAuth.class);
okmAuth.removeRole(null, "test", "ROLE_USER");
} catch (Exception e) {
e.printStackTrace();
}
}
}
getProfiles
Description:
Method | Return values | Description |
---|---|---|
getProfiles(String token, boolean filterByActive) |
List<Profile> |
Return the list of all profiles. |
The parameter filterByActive, when enabled, the method will return only the active profiles; otherwise will return all available profiles. Each user has assigned one profile that enables more or fewer of the OpenKM UI features. |
Example:
package com.openkm;
import com.openkm.api.OKMAuth;
import com.openkm.db.bean.Profile;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMAuth okmAuth = ContextWrapper.getContext().getBean(OKMAuth.class);
for (Profile profile : okmAuth.getProfiles(null, true)) {
System.out.println(profile);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
getUserProfile
Description:
Method | Return values | Description |
---|---|---|
getUserProfile(String token, String userId) |
Profile |
Return the profile assigned to a user. |
Each user has assigned one profile that enables more or fewer of the OpenKM UI features. |
Example:
package com.openkm;
import com.openkm.api.OKMAuth;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMAuth okmAuth = ContextWrapper.getContext().getBean(OKMAuth.class);
System.out.println(okmAuth.getUserProfile(null, "okmAdmin"));
} catch (Exception e) {
e.printStackTrace();
}
}
}
setUserProfile
Description:
Method | Return values | Description |
---|---|---|
setUserProfile(String token, String userId, long profileId) |
void |
Change the assigned profile to a user. |
Each user has assigned one profile that enables more or less of the OpenKM UI features. |
Example:
package com.openkm;
import com.openkm.api.OKMAuth;
import com.openkm.db.bean.Profile;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMAuth okmAuth = ContextWrapper.getContext().getBean(OKMAuth.class);
// Set the profile named "default" to the user
for (Profile profile : okmAuth.getProfiles(null, true)) {
if (profile.getName().equals("default")) {
okmAuth.setUserProfile(null, "okmAdmin", profile.getId());
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
logout
Description:
Method | Return values | Description |
---|---|---|
logout() |
void |
Execute the logout method on the OpenKM side. |
Example:
package com.openkm;
import com.openkm.api.OKMAuth;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMAuth okmAuth = ContextWrapper.getContext().getBean(OKMAuth.class);
okmAuth.logout(null);
} catch (Exception e) {
e.printStackTrace();
}
}
}
getUser
Description:
Method | Return values | Description |
---|---|---|
getUser(String token, String userId) |
DbUser |
Return user data. |
Example:
package com.openkm;
import com.openkm.api.OKMAuth;
import com.openkm.bean.DbUser;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMAuth okmAuth = ContextWrapper.getContext().getBean(OKMAuth.class);
DbUser commonUser = okmAuth.getUser(null, "okmAdmin");
System.out.print(commonUser);
} catch (Exception e) {
e.printStackTrace();
}
}
}
setUserPermissions
Description:
Method | Return values | Description |
---|---|---|
public void setUserPermissions(String token, String nodeId, String user, int permissions, boolean recursive) |
void |
Update user permissions on a node. |
The parameter recursive only has sense when the uuid is a folder or record node. When the parameter recursive is true, the changes will be applied to the node and descendants. |
Example:
package com.openkm;
import com.openkm.api.OKMAuth;
import com.openkm.bean.Permission;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMAuth okmAuth = ContextWrapper.getContext().getBean(OKMAuth.class);
// Update permissions of sochoa at the node but not descendants
okmAuth.setUserPermissions(null, "3c68b3a1-c65c-4b1e-84b5-9ce2712ca573", "sochoa", Permission.READ + Permission.WRITE, false);
// Update permissions of okmAdmin at the node and descendants
okmAuth.setUserPermissions(null, "3c68b3a1-c65c-4b1e-84b5-9ce2712ca573", "okmAdmin", Permission.ALL_GRANTS, true);
} catch (Exception e) {
e.printStackTrace();
}
}
}
setRolePermissions
Description:
Method | Return values | Description |
---|---|---|
setRolePermissions(String token, String nodeId, String role, int permissions, boolean recursive) |
void |
Update role permissions on a node. |
The parameter recursive only has sense when the uuid is a folder or record node. When the parameter recursive is true, the changes will be applied to the node and descendants. |
Example:
package com.openkm;
import com.openkm.api.OKMAuth;
import com.openkm.bean.Permission;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMAuth okmAuth = ContextWrapper.getContext().getBean(OKMAuth.class);
// Update permissions of ROLE_USER at the node but not descendants
okmAuth.setRolePermissions(null, "3c68b3a1-c65c-4b1e-84b5-9ce2712ca573", "ROLE_USER", Permission.READ + Permission.WRITE, false);
// Update permissions of ROLE_ADMIN at the node and descendants
okmAuth.setRolePermissions(null, "3c68b3a1-c65c-4b1e-84b5-9ce2712ca573", "ROLE_ADMIN", Permission.ALL_GRANTS, true);
} catch (Exception e) {
e.printStackTrace();
}
}
}
getUserTenants
Description:
Method | Return values | Description |
---|---|---|
getUserTenants(String token) |
List<Tenant> |
Return the list of all tenants to which the user has access. |
Example:
package com.openkm;
import java.util.List;
import com.openkm.api.OKMAuth;
import com.openkm.db.bean.Tenant;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMAuth okmAuth = ContextWrapper.getContext().getBean(OKMAuth.class);
List<Tenant> tenants = okmAuth.getUserTenants(null);
for (Tenant tenant : tenants) {
System.out.println(tenant);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
setUserTenant
Description:
Method | Return values | Description |
---|---|---|
setUserTenant(String token, long tenantId) |
void |
Change the assigned tenant to a user. |
A user can have access to several tenants but only have one assigned. |
Example:
package com.openkm;
import com.openkm.api.OKMAuth;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMAuth okmAuth = ContextWrapper.getContext().getBean(OKMAuth.class);
long tenantId = 1;
okmAuth.setUserTenant(null, tenantId);
} catch (Exception e) {
e.printStackTrace();
}
}
}
isPasswordExpired
Description:
Method | Return values | Description |
---|---|---|
isPasswordExpired(String token) |
Boolean |
Check if the user password has expired. |
Example:
package com.openkm;
import com.openkm.api.OKMAuth;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMAuth okmAuth = ContextWrapper.getContext().getBean(OKMAuth.class);
Boolean isExpired = okmAuth.isPasswordExpired(null);
} catch (Exception e) {
e.printStackTrace();
}
}
}
resetPassword
Description:
Method | Return values | Description |
---|---|---|
resetPassword(String userId) |
void |
Sends an email with a link that, if the user presses it, will reset the password. |
Example:
package com.openkm;
import com.openkm.api.OKMAuth;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMAuth okmAuth = ContextWrapper.getContext().getBean(OKMAuth.class);
String userId = "okmAdmin";
okmAuth.resetPassword(userId);
} catch (Exception e) {
e.printStackTrace();
}
}
}