use of org.wso2.carbon.identity.scim2.common.DAO.GroupDAO in project identity-inbound-provisioning-scim2 by wso2-extensions.
the class SCIMGroupResolver method resolveGroupDomainByGroupId.
@Override
public boolean resolveGroupDomainByGroupId(Group group, int tenantId) throws UserStoreException {
if (group == null || StringUtils.isBlank(group.getGroupID())) {
return true;
}
String groupId = group.getGroupID();
if (log.isDebugEnabled()) {
log.debug(String.format("Retrieving group with id:%s from tenant: %s", groupId, tenantId));
}
GroupDAO groupDAO = new GroupDAO();
String groupName;
try {
groupName = groupDAO.getGroupNameById(tenantId, groupId);
} catch (IdentitySCIMException exception) {
throw new UserStoreException(String.format("Error occurred while resolving the domain name for " + "group with id: %s in tenant: %s", groupId, tenantId), exception);
}
if (StringUtils.isBlank(groupName)) {
if (log.isDebugEnabled()) {
log.debug(String.format("No group found in IDN_SCIM_GROUP with group id: %s in tenant: %s", groupId, tenantId));
}
return true;
}
String resolvedDomain = IdentityUtil.extractDomainFromName(groupName);
if (log.isDebugEnabled()) {
log.debug(String.format("Domain: %s resolved for group id: %s in tenant: %s", resolvedDomain, groupId, tenantId));
}
group.setGroupName(groupName);
group.setDisplayName(UserCoreUtil.removeDomainFromName(groupName));
group.setUserStoreDomain(resolvedDomain);
return true;
}
use of org.wso2.carbon.identity.scim2.common.DAO.GroupDAO in project identity-inbound-provisioning-scim2 by wso2-extensions.
the class SCIMGroupHandler method addMandatoryAttributes.
/**
* When adding a group through management console, we need to make it SCIM compatible, if SCIM
* enabled in the UserStoreManager config, by adding the READONLY attributes added by Charon.
*
* @param groupName
*/
public void addMandatoryAttributes(String groupName) throws IdentitySCIMException {
Map<String, String> attributes = new HashMap<>();
String id = UUID.randomUUID().toString();
attributes.put(SCIMConstants.CommonSchemaConstants.ID_URI, id);
String createdDate = AttributeUtil.formatDateTime(Instant.now());
attributes.put(SCIMConstants.CommonSchemaConstants.CREATED_URI, createdDate);
attributes.put(SCIMConstants.CommonSchemaConstants.LAST_MODIFIED_URI, createdDate);
attributes.put(SCIMConstants.CommonSchemaConstants.LOCATION_URI, SCIMCommonUtils.getSCIMGroupURL(id));
GroupDAO groupDAO = new GroupDAO();
groupDAO.addSCIMGroupAttributes(tenantId, groupName, attributes);
}
use of org.wso2.carbon.identity.scim2.common.DAO.GroupDAO in project identity-inbound-provisioning-scim2 by wso2-extensions.
the class SCIMGroupHandler method getGroupWithAttributes.
/**
* Set the attributes retrieved from the Identity table, in the given group object.
*
* @param group
* @return
*/
public Group getGroupWithAttributes(Group group, String groupName) throws IdentitySCIMException, CharonException, BadRequestException {
GroupDAO groupDAO = new GroupDAO();
Map<String, String> attributes = groupDAO.getSCIMGroupAttributes(tenantId, groupName);
if (attributes.isEmpty()) {
if (logger.isDebugEnabled()) {
logger.debug("The group: " + groupName + ", is not a SCIM group. Skipping..");
}
return group;
}
for (Map.Entry<String, String> entry : attributes.entrySet()) {
if (SCIMConstants.CommonSchemaConstants.ID_URI.equals(entry.getKey())) {
group.setId(entry.getValue());
} else if (SCIMConstants.CommonSchemaConstants.CREATED_URI.equals(entry.getKey())) {
group.setCreatedDate(Date.from(AttributeUtil.parseDateTime(entry.getValue())));
} else if (SCIMConstants.CommonSchemaConstants.LAST_MODIFIED_URI.equals(entry.getKey())) {
group.setLastModified(Date.from(AttributeUtil.parseDateTime(entry.getValue())));
} else if (SCIMConstants.CommonSchemaConstants.LOCATION_URI.equals(entry.getKey())) {
group.setLocation(SCIMCommonUtils.getSCIMGroupURL(group.getId()));
}
}
return group;
}
use of org.wso2.carbon.identity.scim2.common.DAO.GroupDAO in project identity-inbound-provisioning-scim2 by wso2-extensions.
the class SCIMGroupHandler method getGroupName.
/**
* Get the group name by Id.
*
* @param id
* @return
*/
public String getGroupName(String id) throws IdentitySCIMException {
GroupDAO groupDAO = new GroupDAO();
String roleName = groupDAO.getGroupNameById(tenantId, id);
if (roleName == null) {
if (logger.isDebugEnabled()) {
logger.debug("Role doesn't exist with id: " + id);
}
return null;
} else {
return roleName;
}
}
Aggregations