use of io.jans.scim.model.scim2.Meta in project oxTrust by GluuFederation.
the class UserExtensionLoadingStrategy method load.
@Override
public SchemaType load(AppConfiguration appConfiguration, SchemaType schemaType) throws Exception {
log.info(" load() ");
Meta meta = new Meta();
meta.setLocation(appConfiguration.getBaseEndpoint() + "/scim/v2/Schemas/" + schemaType.getId());
meta.setResourceType("Schema");
schemaType.setMeta(meta);
// List<GluuAttribute> scimCustomAttributes = attributeService.getSCIMRelatedAttributesImpl(attributeService.getCustomAttributes());
List<GluuAttribute> scimCustomAttributes = attributeService.getSCIMRelatedAttributes();
List<AttributeHolder> attributeHolders = new ArrayList<AttributeHolder>();
for (GluuAttribute scimCustomAttribute : scimCustomAttributes) {
AttributeHolder attributeHolder = new AttributeHolder();
attributeHolder.setName(scimCustomAttribute.getName());
if (scimCustomAttribute.getDataType() != null) {
String typeStr = "";
GluuAttributeDataType attributeDataType = scimCustomAttribute.getDataType();
if (attributeDataType.equals(GluuAttributeDataType.STRING)) {
typeStr = "string";
} else if (attributeDataType.equals(GluuAttributeDataType.PHOTO)) {
typeStr = "reference";
attributeHolder.getReferenceTypes().add("external");
} else if (attributeDataType.equals(GluuAttributeDataType.DATE)) {
typeStr = "dateTime";
} else if (attributeDataType.equals(GluuAttributeDataType.NUMERIC)) {
typeStr = "decimal";
} else {
log.info(" NO MATCH: scimCustomAttribute.getDataType().getDisplayName() = " + scimCustomAttribute.getDataType().getDisplayName());
typeStr = "string";
}
attributeHolder.setType(typeStr);
}
attributeHolder.setDescription(scimCustomAttribute.getDescription());
attributeHolder.setRequired(scimCustomAttribute.isRequred());
if (scimCustomAttribute.getOxMultivaluedAttribute() != null) {
Boolean multiValued = Boolean.parseBoolean(scimCustomAttribute.getOxMultivaluedAttribute().getValue());
attributeHolder.setMultiValued(multiValued);
}
attributeHolders.add(attributeHolder);
}
UserExtensionSchema userExtensionSchema = (UserExtensionSchema) schemaType;
userExtensionSchema.setAttributeHolders(attributeHolders);
return userExtensionSchema;
}
use of io.jans.scim.model.scim2.Meta in project oxTrust by GluuFederation.
the class ResourceTypeWS method getResourceTypeGroup.
@Path("Group")
@GET
@Produces(Constants.MEDIA_TYPE_SCIM_JSON + "; charset=utf-8")
@HeaderParam("Accept")
@DefaultValue(Constants.MEDIA_TYPE_SCIM_JSON)
public Response getResourceTypeGroup(@HeaderParam("Authorization") String authorization) throws Exception {
ResourceType groupResourceType = new ResourceType();
groupResourceType.setDescription(Constants.GROUP_CORE_SCHEMA_DESCRIPTION);
groupResourceType.setEndpoint("/v2/Groups");
groupResourceType.setName(Constants.GROUP_CORE_SCHEMA_NAME);
groupResourceType.setId(Constants.GROUP_CORE_SCHEMA_NAME);
groupResourceType.setSchema(Constants.GROUP_CORE_SCHEMA_ID);
Meta groupMeta = new Meta();
groupMeta.setLocation(appConfiguration.getBaseEndpoint() + "/scim/v2/ResourceTypes/Group");
groupMeta.setResourceType("ResourceType");
groupResourceType.setMeta(groupMeta);
// ResourceType[] resourceTypes = new ResourceType[]{groupResourceType};
URI location = new URI(appConfiguration.getBaseEndpoint() + "/scim/v2/ResourceTypes/Group");
// return Response.ok(resourceTypes).location(location).build();
return Response.ok(groupResourceType).location(location).build();
}
use of io.jans.scim.model.scim2.Meta in project oxTrust by GluuFederation.
the class ResourceTypeWS method getResourceTypeFidoDevice.
@Path("FidoDevice")
@GET
@Produces(Constants.MEDIA_TYPE_SCIM_JSON + "; charset=utf-8")
@HeaderParam("Accept")
@DefaultValue(Constants.MEDIA_TYPE_SCIM_JSON)
public Response getResourceTypeFidoDevice(@HeaderParam("Authorization") String authorization) throws Exception {
ResourceType fidoDeviceResourceType = new ResourceType();
fidoDeviceResourceType.setDescription(Constants.FIDO_DEVICES_CORE_SCHEMA_DESCRIPTION);
fidoDeviceResourceType.setEndpoint("/v2/FidoDevices");
fidoDeviceResourceType.setName(Constants.FIDO_DEVICES_CORE_SCHEMA_NAME);
fidoDeviceResourceType.setId(Constants.FIDO_DEVICES_CORE_SCHEMA_NAME);
fidoDeviceResourceType.setSchema(Constants.FIDO_DEVICES_CORE_SCHEMA_ID);
Meta fidoDeviceMeta = new Meta();
fidoDeviceMeta.setLocation(appConfiguration.getBaseEndpoint() + "/scim/v2/ResourceTypes/FidoDevice");
fidoDeviceMeta.setResourceType("ResourceType");
fidoDeviceResourceType.setMeta(fidoDeviceMeta);
URI location = new URI(appConfiguration.getBaseEndpoint() + "/scim/v2/ResourceTypes/FidoDevice");
return Response.ok(fidoDeviceResourceType).location(location).build();
}
use of io.jans.scim.model.scim2.Meta in project oxTrust by GluuFederation.
the class Scim2UserService method transferAttributesToUserResource.
public void transferAttributesToUserResource(GluuCustomPerson person, UserResource res, String url) {
log.debug("transferAttributesToUserResource");
res.setId(person.getInum());
res.setExternalId(person.getAttribute("oxTrustExternalId"));
Meta meta = new Meta();
meta.setResourceType(ScimResourceUtil.getType(res.getClass()));
meta.setCreated(person.getAttribute("oxTrustMetaCreated"));
if (meta.getCreated() == null) {
Date tmpDate = person.getCreationDate();
meta.setCreated(tmpDate == null ? null : ISODateTimeFormat.dateTime().withZoneUTC().print(tmpDate.getTime()));
}
meta.setLastModified(person.getAttribute("oxTrustMetaLastModified"));
if (meta.getLastModified() == null) {
Date tmpDate = person.getUpdatedAt();
meta.setLastModified(tmpDate == null ? null : ISODateTimeFormat.dateTime().withZoneUTC().print(tmpDate.getTime()));
}
meta.setLocation(person.getAttribute("oxTrustMetaLocation"));
if (meta.getLocation() == null)
meta.setLocation(url + "/" + person.getInum());
res.setMeta(meta);
// Set values in order of appearance in UserResource class
res.setUserName(person.getUid());
Name name = new Name();
name.setGivenName(person.getGivenName());
name.setFamilyName(person.getSurname());
name.setMiddleName(person.getAttribute("middleName"));
name.setHonorificPrefix(person.getAttribute("oxTrusthonorificPrefix"));
name.setHonorificSuffix(person.getAttribute("oxTrusthonorificSuffix"));
String formatted = person.getAttribute("oxTrustNameFormatted");
if (// recomputes the formatted name if absent in LDAP
formatted == null)
name.computeFormattedName();
else
name.setFormatted(formatted);
res.setName(name);
res.setDisplayName(person.getDisplayName());
res.setNickName(person.getAttribute("nickname"));
res.setProfileUrl(person.getAttribute("oxTrustProfileURL"));
res.setTitle(person.getAttribute("oxTrustTitle"));
res.setUserType(person.getAttribute("oxTrustUserType"));
res.setPreferredLanguage(person.getPreferredLanguage());
res.setLocale(person.getAttribute("locale"));
res.setTimezone(person.getTimezone());
res.setActive(Boolean.valueOf(person.getAttribute("oxTrustActive")) || GluuBoolean.getByValue(person.getAttribute("gluuStatus")).isBooleanValue());
res.setPassword(person.getUserPassword());
res.setEmails(getAttributeListValue(person, Email.class, "oxTrustEmail"));
res.setPhoneNumbers(getAttributeListValue(person, PhoneNumber.class, "oxTrustPhoneValue"));
res.setIms(getAttributeListValue(person, InstantMessagingAddress.class, "oxTrustImsValue"));
res.setPhotos(getAttributeListValue(person, Photo.class, "oxTrustPhotos"));
res.setAddresses(getAttributeListValue(person, Address.class, "oxTrustAddresses"));
List<String> listOfGroups = person.getMemberOf();
if (listOfGroups != null && listOfGroups.size() > 0) {
List<Group> groupList = new ArrayList<Group>();
for (String groupDN : listOfGroups) {
try {
GluuGroup gluuGroup = groupService.getGroupByDn(groupDN);
Group group = new Group();
group.setValue(gluuGroup.getInum());
String reference = groupWS.getEndpointUrl() + "/" + gluuGroup.getInum();
group.setRef(reference);
group.setDisplay(gluuGroup.getDisplayName());
// Only support direct membership: see section 4.1.2 of RFC 7644
group.setType(Group.Type.DIRECT);
groupList.add(group);
} catch (Exception e) {
log.warn("transferAttributesToUserResource. Group with dn {} could not be added to User Resource. {}", groupDN, person.getUid());
log.error(e.getMessage(), e);
}
}
if (groupList.size() > 0)
res.setGroups(groupList);
}
res.setEntitlements(getAttributeListValue(person, Entitlement.class, "oxTrustEntitlements"));
res.setRoles(getAttributeListValue(person, Role.class, "oxTrustRole"));
res.setX509Certificates(getAttributeListValue(person, X509Certificate.class, "oxTrustx509Certificate"));
res.setPairwiseIdentitifers(person.getOxPPID());
transferExtendedAttributesToResource(person, res);
}
use of io.jans.scim.model.scim2.Meta in project oxTrust by GluuFederation.
the class BaseScimWebService method assignMetaInformation.
protected void assignMetaInformation(BaseScimResource resource) {
// Generate some meta information (this replaces the info client passed in the request)
long now = new Date().getTime();
String val = ISODateTimeFormat.dateTime().withZoneUTC().print(now);
Meta meta = new Meta();
meta.setResourceType(ScimResourceUtil.getType(resource.getClass()));
meta.setCreated(val);
meta.setLastModified(val);
// For version attritute: Service provider support for this attribute is optional and subject to the service provider's support for versioning
// For location attribute: this will be set after current user creation in LDAP
resource.setMeta(meta);
}
Aggregations