use of io.jans.scim.model.scim2.Meta in project oxTrust by GluuFederation.
the class FidoDeviceCoreLoadingStrategy 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("FidoDeviceCoreLoadingStrategyModule", new Version(1, 0, 0, ""));
SchemaTypeFidoDeviceSerializer serializer = new SchemaTypeFidoDeviceSerializer();
serializer.setSchemaType(schemaType);
userCoreLoadingStrategyModule.addSerializer(FidoDevice.class, serializer);
mapper.registerModule(userCoreLoadingStrategyModule);
mapper.writeValueAsString(createDummyFidoDevice());
return serializer.getSchemaType();
}
use of io.jans.scim.model.scim2.Meta in project oxTrust by GluuFederation.
the class FidoDeviceWebService method transferAttributesToFidoResource.
private void transferAttributesToFidoResource(GluuCustomFidoDevice fidoDevice, FidoDeviceResource res, String url, String userId) {
res.setId(fidoDevice.getId());
Meta meta = new Meta();
meta.setResourceType(ScimResourceUtil.getType(res.getClass()));
meta.setCreated(DateUtil.generalizedToISOStringDate(fidoDevice.getCreationDate()));
meta.setLastModified(fidoDevice.getMetaLastModified());
meta.setLocation(fidoDevice.getMetaLocation());
if (meta.getLocation() == null)
meta.setLocation(url + "/" + fidoDevice.getId());
res.setMeta(meta);
// Set values in order of appearance in FidoDeviceResource class
res.setUserId(userId);
res.setCreationDate(meta.getCreated());
res.setApplication(fidoDevice.getApplication());
res.setCounter(fidoDevice.getCounter());
res.setDeviceData(fidoDevice.getDeviceData());
res.setDeviceHashCode(fidoDevice.getDeviceHashCode());
res.setDeviceKeyHandle(fidoDevice.getDeviceKeyHandle());
res.setDeviceRegistrationConf(fidoDevice.getDeviceRegistrationConf());
res.setLastAccessTime(DateUtil.generalizedToISOStringDate(fidoDevice.getLastAccessTime()));
res.setStatus(fidoDevice.getStatus());
res.setDisplayName(fidoDevice.getDisplayName());
res.setDescription(fidoDevice.getDescription());
res.setNickname(fidoDevice.getNickname());
}
use of io.jans.scim.model.scim2.Meta in project oxTrust by GluuFederation.
the class ResourceTypeWS method fillResourceType.
private void fillResourceType(ResourceType rt, Schema schemaAnnot, String endpointUrl, String location, List<SchemaExtensionHolder> schemaExtensions) {
rt.setId(schemaAnnot.name());
rt.setName(schemaAnnot.name());
rt.setDescription(schemaAnnot.description());
rt.setEndpoint(endpointUrl.substring(appConfiguration.getBaseEndpoint().length()));
rt.setSchema(schemaAnnot.id());
rt.setSchemaExtensions(schemaExtensions);
Meta rtMeta = new Meta();
rtMeta.setLocation(location);
rtMeta.setResourceType("ResourceType");
rt.setMeta(rtMeta);
}
use of io.jans.scim.model.scim2.Meta in project oxTrust by GluuFederation.
the class SchemaWebService method getSchemaInstance.
private SchemaResource getSchemaInstance(Class<? extends BaseScimResource> clazz, String urn) throws Exception {
if (ScimResourceUtil.getDefaultSchemaUrn(clazz).equals(urn))
// Process core attributes
return getSchemaInstance(clazz);
else {
// process extension attributes
SchemaResource resource = null;
Class<? extends BaseScimResource> schemaCls = SchemaResource.class;
// Find the appropriate extension
List<Extension> extensions = extService.getResourceExtensions(clazz);
for (Extension extension : extensions) {
if (extension.getUrn().equals(urn)) {
Meta meta = new Meta();
meta.setResourceType(ScimResourceUtil.getType(schemaCls));
meta.setLocation(endpointUrl + "/" + urn);
resource = new SchemaResource();
resource.setId(urn);
resource.setName(extension.getName());
resource.setDescription(extension.getDescription());
resource.setMeta(meta);
List<SchemaAttribute> attribs = new ArrayList<SchemaAttribute>();
for (ExtensionField field : extension.getFields().values()) {
SchemaAttribute schAttr = new SchemaAttribute();
schAttr.setName(field.getName());
schAttr.setMultiValued(field.isMultiValued());
schAttr.setDescription(field.getDescription());
schAttr.setRequired(false);
schAttr.setCanonicalValues(null);
schAttr.setCaseExact(false);
schAttr.setMutability(AttributeDefinition.Mutability.READ_WRITE.getName());
schAttr.setReturned(AttributeDefinition.Returned.DEFAULT.getName());
schAttr.setUniqueness(AttributeDefinition.Uniqueness.NONE.getName());
schAttr.setReferenceTypes(null);
AttributeDefinition.Type type = field.getAttributeDefinitionType();
schAttr.setType(type == null ? null : type.getName());
schAttr.setSubAttributes(null);
attribs.add(schAttr);
}
resource.setAttributes(attribs);
break;
}
}
return resource;
}
}
use of io.jans.scim.model.scim2.Meta in project oxTrust by GluuFederation.
the class SchemaWebService method getSchemaInstance.
private SchemaResource getSchemaInstance(Class<? extends BaseScimResource> clazz) throws Exception {
SchemaResource resource;
Class<? extends BaseScimResource> schemaCls = SchemaResource.class;
Schema annotation = ScimResourceUtil.getSchemaAnnotation(clazz);
if (!clazz.equals(schemaCls) && annotation != null) {
Meta meta = new Meta();
meta.setResourceType(ScimResourceUtil.getType(schemaCls));
meta.setLocation(endpointUrl + "/" + annotation.id());
resource = new SchemaResource();
resource.setId(annotation.id());
resource.setName(annotation.name());
resource.setDescription(annotation.description());
resource.setMeta(meta);
List<SchemaAttribute> attribs = new ArrayList<SchemaAttribute>();
// paths are, happily alphabetically sorted :)
for (String path : IntrospectUtil.allAttrs.get(clazz)) {
SchemaAttribute schAttr = new SchemaAttribute();
Field f = IntrospectUtil.findFieldFromPath(clazz, path);
Attribute attrAnnot = f.getAnnotation(Attribute.class);
if (attrAnnot != null) {
JsonProperty jsonAnnot = f.getAnnotation(JsonProperty.class);
schAttr.setName(jsonAnnot == null ? f.getName() : jsonAnnot.value());
schAttr.setType(attrAnnot.type().getName());
schAttr.setMultiValued(!attrAnnot.multiValueClass().equals(NullType.class) || IntrospectUtil.isCollection(f.getType()));
schAttr.setDescription(attrAnnot.description());
schAttr.setRequired(attrAnnot.isRequired());
schAttr.setCanonicalValues(attrAnnot.canonicalValues().length == 0 ? null : Arrays.asList(attrAnnot.canonicalValues()));
schAttr.setCaseExact(attrAnnot.isCaseExact());
schAttr.setMutability(attrAnnot.mutability().getName());
schAttr.setReturned(attrAnnot.returned().getName());
schAttr.setUniqueness(attrAnnot.uniqueness().getName());
schAttr.setReferenceTypes(attrAnnot.referenceTypes().length == 0 ? null : Arrays.asList(attrAnnot.referenceTypes()));
if (attrAnnot.type().equals(AttributeDefinition.Type.COMPLEX))
schAttr.setSubAttributes(new ArrayList<SchemaAttribute>());
// root list
List<SchemaAttribute> list = attribs;
String[] parts = path.split("\\.");
for (int i = 0; i < parts.length - 1; i++) {
// skip last part (real attribute name)
int j = list.indexOf(new SchemaAttribute(parts[i]));
list = list.get(j).getSubAttributes();
}
list.add(schAttr);
}
}
resource.setAttributes(attribs);
} else
resource = null;
return resource;
}
Aggregations