use of com.emc.storageos.db.client.model.UserGroup in project coprhd-controller by CoprHD.
the class StorageOSLdapPersonAttributeDao method getReturningAttributesFromUserGroups.
/**
* Get the list of returning attributes AD or LDAP servers
* based on the configured user group.
*
* @param permissionsHelper to find and match the db objects.
* @param domain to find all the configured user group for the domain.
* @param attrs out param, to be updated with the list of attributes
* to be returned from the AD or LDAP servers.
*/
private void getReturningAttributesFromUserGroups(BasePermissionsHelper permissionsHelper, String domain, List<String> attrs) {
if (StringUtils.isBlank(domain)) {
_log.info("Invalid domain {} to search user group", domain);
return;
}
List<UserGroup> userGroupList = permissionsHelper.getAllUserGroupForDomain(domain);
if (CollectionUtils.isEmpty(userGroupList)) {
_log.debug("User group not found for the domain {}", domain);
return;
}
for (UserGroup userGroup : userGroupList) {
if (userGroup == null || CollectionUtils.isEmpty(userGroup.getAttributes())) {
continue;
}
for (String userAttributesString : userGroup.getAttributes()) {
if (StringUtils.isBlank(userAttributesString)) {
_log.info("Invalid user attributes param string {}", userAttributesString);
continue;
}
UserAttributeParam userAttributeParam = UserAttributeParam.fromString(userAttributesString);
if (userAttributeParam == null) {
_log.info("Conversion from user attributes param string {} to attributes param object failed.", userAttributesString);
continue;
}
_log.debug("Adding attribute {} to the returning attributes list", userAttributeParam.getKey());
attrs.add(userAttributeParam.getKey());
}
}
}
use of com.emc.storageos.db.client.model.UserGroup in project coprhd-controller by CoprHD.
the class StorageOSLdapPersonAttributeDao method addUserGroupsToUserGroupList.
/**
* Add the user group to the storageos user's
* group list if the storageos user's attributes and values matches
* with the user group configs.
*
* @param permissionsHelper to find and match the db objects.
* @param domain to find all the userMappings for the domain.
* @param storageOSUser to be updated with the list of user
* group to the storageos user's group list.
*/
private void addUserGroupsToUserGroupList(BasePermissionsHelper permissionsHelper, String domain, StorageOSUserDAO storageOSUser) {
if (StringUtils.isBlank(domain)) {
_log.error("Invalid domain {} to search user group", domain);
return;
}
List<UserGroup> userGroupList = permissionsHelper.getAllUserGroupForDomain(domain);
if (CollectionUtils.isEmpty(userGroupList)) {
_log.debug("Cannot find user mappings for the domain {}", domain);
return;
}
for (UserGroup userGroup : userGroupList) {
if (userGroup != null) {
if (permissionsHelper.matchUserAttributesToUserGroup(storageOSUser, userGroup)) {
_log.debug("Adding user group {} to the user", userGroup.getLabel());
storageOSUser.addGroup(userGroup.getLabel());
}
} else {
_log.info("Invalid user group returned while searching db with domain {}", domain);
}
}
}
use of com.emc.storageos.db.client.model.UserGroup in project coprhd-controller by CoprHD.
the class ApiTestUserGroup method buildUserGroupFromCreateParam.
UserGroup buildUserGroupFromCreateParam(UserGroupCreateParam createParam, boolean removingDuplicate) {
Assert.assertNotNull(createParam);
Assert.assertFalse(CollectionUtils.isEmpty(createParam.getAttributes()));
UserGroup userGroup = new UserGroup();
userGroup.setLabel(createParam.getLabel());
userGroup.setDomain(createParam.getDomain());
for (UserAttributeParam attributeParam : createParam.getAttributes()) {
userGroup.getAttributes().add(attributeParam.toString());
}
if (!removingDuplicate) {
return removeDuplicateAttributes(userGroup);
} else {
return userGroup;
}
}
use of com.emc.storageos.db.client.model.UserGroup in project coprhd-controller by CoprHD.
the class ApiTestUserGroup method testUserGroupEditByAddingAttributes.
@Test
public void testUserGroupEditByAddingAttributes() {
final String testName = "testUserGroupEditByAddingAttributes - ";
createDefaultAuthnProvider(testName + DEFAULT_AUTH_PROVIDER_CREATION);
UserGroupCreateParam createParam = getDefaultUserGroupCreateParam();
ClientResponse clientUserGroupCreateResp = rSys.path(getTestApi()).post(ClientResponse.class, createParam);
UserGroupRestRep userGroupCreateResp = validateUserGroupCreateSuccess(createParam, clientUserGroupCreateResp);
UserGroup createdUserGroup = buildUserGroupFromRestRep(userGroupCreateResp);
UserGroupUpdateParam updateParam = getUserGroupUpdateParamFromRestRep(userGroupCreateResp);
// Add one additional attribute to the user group.
UserAttributeParam attributeParam = new UserAttributeParam();
attributeParam.setKey("newKey");
attributeParam.getValues().add("newValue1");
attributeParam.getValues().add("newValue1");
attributeParam.getValues().add("newValue2");
updateParam.getAddAttributes().add(attributeParam);
// Clear both add and remove attributes.
updateParam.getRemoveAttributes().clear();
// Change the domain.
updateParam.setDomain(getSecondDomain());
String testEditAPI = getTestEditApi(userGroupCreateResp.getId());
ClientResponse clientUserGroupEditResp = rSys.path(testEditAPI).put(ClientResponse.class, updateParam);
validateUserGroupEditSuccess(createdUserGroup, updateParam, clientUserGroupEditResp);
}
use of com.emc.storageos.db.client.model.UserGroup in project coprhd-controller by CoprHD.
the class ApiTestUserGroup method validateUserGroupCreateSuccess.
private UserGroupRestRep validateUserGroupCreateSuccess(UserGroupCreateParam expected, ClientResponse actual) {
Assert.assertEquals(HttpStatus.SC_OK, actual.getStatus());
UserGroupRestRep resp = actual.getEntity(UserGroupRestRep.class);
Assert.assertNotNull(resp);
validateUserGroupCommon(expected, resp);
UserGroup expectedUserGroup = buildUserGroupFromCreateParam(expected, false);
UserGroup actualUserGroup = buildUserGroupFromRestRep(resp);
Assert.assertTrue(isSame(expectedUserGroup, actualUserGroup));
// Add the created userGroup to cleanup list, so that at the end of this test
// the object will be destroyed.
final String deleteObjectURL = this.getTestEditApi(resp.getId());
CleanupResource userGroupToCleanup = new CleanupResource("delete", deleteObjectURL, rSys, null);
registerResourceForCleanup(userGroupToCleanup);
return resp;
}
Aggregations