use of com.emc.storageos.model.usergroup.UserAttributeParam 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.model.usergroup.UserAttributeParam in project coprhd-controller by CoprHD.
the class StorageOSUserMapper method mapFromAttributes.
/*
* @see org.springframework.ldap.core.AttributesMapper#mapFromAttributes(javax.naming.directory.Attributes)
* creates StorageOSUserDAO from attributes
*/
@Override
public Object mapFromAttributes(Attributes attributes) throws NamingException {
StorageOSUserDAO storageOSUser = new StorageOSUserDAO();
storageOSUser.setUserName(_username);
NamingEnumeration<? extends Attribute> attributesEnumeration = attributes.getAll();
while (attributesEnumeration.hasMoreElements()) {
Attribute attribute = attributesEnumeration.nextElement();
NamingEnumeration<?> attributeValues = attribute.getAll();
if (attribute.getID().equals(_distinguishedNameAttribute)) {
if (null != attribute.get(0)) {
storageOSUser.setDistinguishedName(attribute.get(0).toString());
}
}
List<String> values = new ArrayList<String>();
while (attributeValues.hasMoreElements()) {
values.add(attributeValues.nextElement().toString());
}
_attrKeyValueMap.put(attribute.getID(), values);
// Add the returned attributes from the AD/LDAP to the user.
UserAttributeParam userAttributeParam = new UserAttributeParam(attribute.getID(), new HashSet(values));
String attributeString = userAttributeParam.toString();
storageOSUser.addAttribute(attributeString);
_log.debug("Adding attribute {} to user", attributeString);
}
return storageOSUser;
}
use of com.emc.storageos.model.usergroup.UserAttributeParam in project coprhd-controller by CoprHD.
the class UserGroupMapper method map.
public static final UserGroupRestRep map(UserGroup from) {
if (from == null) {
_log.info("Invalid user group");
return null;
}
UserGroupRestRep to = new UserGroupRestRep();
mapDataObjectFields(from, to);
to.setDomain(from.getDomain());
if (CollectionUtils.isEmpty(from.getAttributes())) {
_log.error("Empty attributes list in user group {}", from.getLabel());
return to;
}
for (String attributeString : from.getAttributes()) {
if (StringUtils.isBlank(attributeString)) {
_log.info("Invalid attribute param string in user group {}", from.getLabel());
continue;
}
UserAttributeParam attribute = UserAttributeParam.fromString(attributeString);
to.getAttributes().add(attribute);
}
return to;
}
use of com.emc.storageos.model.usergroup.UserAttributeParam in project coprhd-controller by CoprHD.
the class UserGroupMapper method map.
public static final UserGroup map(UserGroupCreateParam from) {
if (from == null) {
_log.info("Invalid user group create param");
return null;
}
UserGroup to = new UserGroup();
to.setDomain(from.getDomain());
to.setLabel(from.getLabel());
Map<String, UserAttributeParam> attributeParamMap = new TreeMap<String, UserAttributeParam>(String.CASE_INSENSITIVE_ORDER);
if (!CollectionUtils.isEmpty(from.getAttributes())) {
for (UserAttributeParam attribute : from.getAttributes()) {
UserAttributeParam userAttributeParam = attributeParamMap.get(attribute.getKey());
if (userAttributeParam == null) {
userAttributeParam = new UserAttributeParam(attribute.getKey(), attribute.getValues());
attributeParamMap.put(attribute.getKey(), userAttributeParam);
} else {
userAttributeParam.getValues().addAll(attribute.getValues());
}
}
} else {
_log.error("Empty attributes list in user group create param {}", from.getLabel());
}
if (!CollectionUtils.isEmpty(attributeParamMap)) {
for (UserAttributeParam attribute : attributeParamMap.values()) {
to.getAttributes().add(attribute.toString());
}
} else {
_log.warn("Mapping from UserGroupCreateParam {} to UserGroup did not create any attributes list", from.getLabel());
}
return to;
}
Aggregations