use of org.gluu.oxtrust.model.scim2.schema.SchemaType in project oxTrust by GluuFederation.
the class GroupCoreLoadingStrategy 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);
// Use serializer to walk the class structure
ObjectMapper mapper = new ObjectMapper();
mapper.disable(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS);
SimpleModule groupCoreLoadingStrategyModule = new SimpleModule("GroupCoreLoadingStrategyModule", new Version(1, 0, 0, ""));
SchemaTypeGroupSerializer serializer = new SchemaTypeGroupSerializer();
serializer.setSchemaType(schemaType);
groupCoreLoadingStrategyModule.addSerializer(Group.class, serializer);
mapper.registerModule(groupCoreLoadingStrategyModule);
mapper.writeValueAsString(createDummyGroup());
return serializer.getSchemaType();
}
use of org.gluu.oxtrust.model.scim2.schema.SchemaType in project oxTrust by GluuFederation.
the class UserCoreLoadingStrategy 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);
// Use serializer to walk the class structure
ObjectMapper mapper = new ObjectMapper();
mapper.disable(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS);
SimpleModule userCoreLoadingStrategyModule = new SimpleModule("UserCoreLoadingStrategyModule", new Version(1, 0, 0, ""));
SchemaTypeUserSerializer serializer = new SchemaTypeUserSerializer();
serializer.setSchemaType(schemaType);
userCoreLoadingStrategyModule.addSerializer(User.class, serializer);
mapper.registerModule(userCoreLoadingStrategyModule);
mapper.writeValueAsString(createDummyUser());
return serializer.getSchemaType();
}
use of org.gluu.oxtrust.model.scim2.schema.SchemaType 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 org.gluu.oxtrust.model.scim2.schema.SchemaType in project oxTrust by GluuFederation.
the class FilterUtil method stripScim2Schema.
public static String stripScim2Schema(String uri) {
for (SchemaType schemaType : SchemaTypeMapping.getSchemaInstances()) {
String schema = schemaType.getId() + ":";
if (uri.startsWith(schema)) {
int index = uri.indexOf(schema) + schema.length();
uri = uri.substring(index);
break;
}
}
return uri;
}
Aggregations