mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Adding DEFAULT_DEVICE_USER on adding user
This commit is contained in:
parent
5ce413012e
commit
8e6855a203
@ -77,6 +77,9 @@ public class UserManagementServiceImpl implements UserManagementService {
|
||||
private static final String API_BASE_PATH = "/users";
|
||||
private static final Log log = LogFactory.getLog(UserManagementServiceImpl.class);
|
||||
|
||||
private static final String DEFAULT_DEVICE_USER = "Internal/devicemgt-user";
|
||||
private static final String DEFAULT_DEVICE_ADMIN = "Internal/devicemgt-admin";
|
||||
|
||||
@POST
|
||||
@Override
|
||||
public Response addUser(UserInfo userInfo) {
|
||||
@ -100,8 +103,14 @@ public class UserManagementServiceImpl implements UserManagementService {
|
||||
this.buildDefaultUserClaims(userInfo.getFirstname(), userInfo.getLastname(),
|
||||
userInfo.getEmailAddress());
|
||||
// calling addUser method of carbon user api
|
||||
List<String> tmpRoles = new ArrayList<>();
|
||||
tmpRoles.add(DEFAULT_DEVICE_USER);
|
||||
tmpRoles.addAll(Arrays.asList(userInfo.getRoles()));
|
||||
String[] roles = new String[tmpRoles.size()];
|
||||
tmpRoles.toArray(roles);
|
||||
|
||||
userStoreManager.addUser(userInfo.getUsername(), initialUserPassword,
|
||||
userInfo.getRoles(), defaultUserClaims, null);
|
||||
roles, defaultUserClaims, null);
|
||||
// Outputting debug message upon successful addition of user
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("User '" + userInfo.getUsername() + "' has successfully been added.");
|
||||
@ -211,7 +220,9 @@ public class UserManagementServiceImpl implements UserManagementService {
|
||||
log.debug("User credential of username: " + username + " has been changed");
|
||||
}
|
||||
List<String> currentRoles = this.getFilteredRoles(userStoreManager, username);
|
||||
List<String> newRoles = Arrays.asList(userInfo.getRoles());
|
||||
List<String> newRoles = new ArrayList<>();
|
||||
newRoles.add(DEFAULT_DEVICE_USER);
|
||||
newRoles.addAll(Arrays.asList(userInfo.getRoles()));
|
||||
|
||||
List<String> rolesToAdd = new ArrayList<>(newRoles);
|
||||
List<String> rolesToDelete = new ArrayList<>();
|
||||
|
||||
@ -91,11 +91,4 @@ public final class DeviceManagementConstants {
|
||||
public static final String DB_TYPE_POSTGRESQL = "PostgreSQL";
|
||||
}
|
||||
|
||||
public static final class Users {
|
||||
private Users() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
public static final String DEFAULT_DEVICE_USER = "Internal/devicemgt-user";
|
||||
public static final String DEFAULT_DEVICE_ADMIN = "Internal/devicemgt-admin";
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user