milanperera 5 years ago
parent 4c78c1bf13
commit a044bbd385

@ -115,6 +115,7 @@ public class UserManagementServiceImpl implements UserManagementService {
private static final Log log = LogFactory.getLog(UserManagementServiceImpl.class); 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_USER = "Internal/devicemgt-user";
private static final String DEFAULT_SUBSCRIBER = "Internal/subscriber";
// Permissions that are given for a normal device user. // Permissions that are given for a normal device user.
private static final Permission[] PERMISSIONS_FOR_DEVICE_USER = { private static final Permission[] PERMISSIONS_FOR_DEVICE_USER = {
@ -159,6 +160,23 @@ public class UserManagementServiceImpl implements UserManagementService {
String[] userInfoRoles = userInfo.getRoles(); String[] userInfoRoles = userInfo.getRoles();
tmpRoles.add(DEFAULT_DEVICE_USER); tmpRoles.add(DEFAULT_DEVICE_USER);
if (userInfoRoles != null) { if (userInfoRoles != null) {
//check if subscriber role is coming in the payload
boolean subscriberFound = false;
for (String r : userInfoRoles) {
if (DEFAULT_SUBSCRIBER.equals(r)) {
subscriberFound = true;
break;
}
}
if (!subscriberFound) {
// Add Internal/subscriber role to new users
if (userStoreManager.isExistingRole(DEFAULT_SUBSCRIBER)) {
tmpRoles.add(DEFAULT_SUBSCRIBER);
} else {
log.warn("User: " + userInfo.getUsername() + " will not be able to enroll devices as '" +
DEFAULT_SUBSCRIBER + "' is missing in the system");
}
}
tmpRoles.addAll(Arrays.asList(userInfoRoles)); tmpRoles.addAll(Arrays.asList(userInfoRoles));
} }
String[] roles = new String[tmpRoles.size()]; String[] roles = new String[tmpRoles.size()];

Loading…
Cancel
Save