use of org.gluu.oxtrust.model.scim2.schema.core.fido.FidoDeviceCoreSchema in project oxTrust by GluuFederation.
the class SchemaTypeFidoDeviceSerializer method serialize.
@Override
public void serialize(FidoDevice fidoDevice, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
log.info(" serialize() ");
try {
ObjectMapper mapper = new ObjectMapper();
mapper.disable(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS);
JsonNode rootNode = mapper.convertValue(fidoDevice, JsonNode.class);
Iterator<Map.Entry<String, JsonNode>> iterator = rootNode.getFields();
while (iterator.hasNext()) {
Map.Entry<String, JsonNode> rootNodeEntry = iterator.next();
if (!rootNodeEntry.getKey().equalsIgnoreCase("meta") && !rootNodeEntry.getKey().equalsIgnoreCase("externalId")) {
AttributeHolder attributeHolder = new AttributeHolder();
attributeHolder.setName(rootNodeEntry.getKey());
if (rootNodeEntry.getValue().isBoolean()) {
attributeHolder.setType("boolean");
} else {
attributeHolder.setType("string");
}
if (rootNodeEntry.getKey().equalsIgnoreCase("userId")) {
attributeHolder.setDescription("User ID that owns the device. Using this in a query filter is not supported.");
} else if (rootNodeEntry.getKey().equalsIgnoreCase("schemas")) {
attributeHolder.setDescription("schemas list");
} else {
attributeHolder.setDescription(rootNodeEntry.getKey());
}
if (rootNodeEntry.getKey().equalsIgnoreCase("id") || rootNodeEntry.getKey().equalsIgnoreCase("schemas") || rootNodeEntry.getKey().equalsIgnoreCase("userId")) {
attributeHolder.setUniqueness("server");
attributeHolder.setReturned("always");
attributeHolder.setCaseExact(Boolean.TRUE);
}
if (rootNodeEntry.getKey().equalsIgnoreCase("displayName")) {
attributeHolder.setReturned("always");
}
if (!rootNodeEntry.getKey().equalsIgnoreCase("displayName") && !rootNodeEntry.getKey().equalsIgnoreCase("description")) {
attributeHolder.setMutability("readOnly");
}
attributeHolders.add(attributeHolder);
}
}
FidoDeviceCoreSchema fidoDeviceCoreSchema = (FidoDeviceCoreSchema) schemaType;
fidoDeviceCoreSchema.setAttributeHolders(attributeHolders);
schemaType = fidoDeviceCoreSchema;
} catch (Exception e) {
e.printStackTrace();
throw new IOException("Unexpected processing error; please check the FidoDevice class structure.");
}
}
Aggregations