use of org.gluu.oxtrust.model.scim2.extensions.Extension in project oxTrust by GluuFederation.
the class CopyUtils2 method copy.
/**
* Copy data from GluuCustomPerson object to ScimPerson object "Reda"
*
* @param source
* @param destination
* @return
* @throws Exception
*/
public User copy(GluuCustomPerson source, User destination) throws Exception {
if (source == null) {
return null;
}
if (destination == null) {
log.trace(" creating a new GluuCustomPerson instant ");
destination = new User();
}
log.trace(" setting ID ");
if (source.getInum() != null) {
destination.setId(source.getInum());
}
log.trace(" setting userName ");
if (source.getUid() != null) {
destination.setUserName(source.getUid());
}
log.trace(" setting ExternalID ");
if (source.getAttribute("oxTrustExternalId") != null) {
destination.setExternalId(source.getAttribute("oxTrustExternalId"));
}
log.trace(" setting givenname ");
if (source.getGivenName() != null) {
org.gluu.oxtrust.model.scim2.Name name = new org.gluu.oxtrust.model.scim2.Name();
name.setGivenName(source.getGivenName());
if (source.getSurname() != null)
name.setFamilyName(source.getSurname());
if (source.getAttribute("middleName") != null)
name.setMiddleName(source.getAttribute("middleName"));
/*
if (source.getAttribute("oxTrustMiddleName") != null)
name.setMiddleName(source.getAttribute("oxTrustMiddleName"));
*/
if (source.getAttribute("oxTrusthonorificPrefix") != null)
name.setHonorificPrefix(source.getAttribute("oxTrusthonorificPrefix"));
if (source.getAttribute("oxTrusthonorificSuffix") != null)
name.setHonorificSuffix(source.getAttribute("oxTrusthonorificSuffix"));
name.setFormatted(name.getFormatted());
destination.setName(name);
}
log.trace(" getting displayname ");
if (source.getDisplayName() != null) {
destination.setDisplayName(source.getDisplayName());
}
log.trace(" getting nickname ");
/*
if (source.getAttribute("oxTrustNickName") != null) {
destination.setNickName(source.getAttribute("oxTrustNickName"));
}
*/
if (source.getAttribute("nickname") != null) {
destination.setNickName(source.getAttribute("nickname"));
}
log.trace(" getting profileURL ");
if (source.getAttribute("oxTrustProfileURL") != null) {
destination.setProfileUrl(source.getAttribute("oxTrustProfileURL"));
}
log.trace(" getting emails ");
// source = Utils.syncEmailReverse(source, true);
if (source.getAttributeArray("oxTrustEmail") != null) {
/*
String[] emailArray = source.getAttributeArray("oxTrustEmail");
List<Email> emails = new ArrayList<Email>();
for (String emailStr : emailArray) {
Email email = mapper.readValue(emailStr, Email.class);
emails.add(email);
}
// List<Email> listOfEmails = mapper.readValue(source.getAttribute("oxTrustEmail"), new TypeReference<List<Email>>(){});
// destination.setEmails(listOfEmails);
*/
List<Email> emails = getAttributeListValue(source, Email.class, "oxTrustEmail");
destination.setEmails(emails);
}
log.trace(" getting addresses ");
// getting addresses
if (source.getAttribute("oxTrustAddresses") != null) {
List<Address> addresses = getAttributeListValue(source, Address.class, "oxTrustAddresses");
destination.setAddresses(addresses);
}
log.trace(" setting phoneNumber ");
// getting user's PhoneNumber
if (source.getAttribute("oxTrustPhoneValue") != null) {
List<PhoneNumber> phoneNumbers = getAttributeListValue(source, PhoneNumber.class, "oxTrustPhoneValue");
destination.setPhoneNumbers(phoneNumbers);
}
if ((source.getOxPPID()) != null) {
destination.setPairwiseIdentitifers(source.getOxPPID());
}
log.trace(" getting ims ");
// getting ims
if (source.getAttribute("oxTrustImsValue") != null) {
List<Im> ims = getAttributeListValue(source, Im.class, "oxTrustImsValue");
destination.setIms(ims);
}
log.trace(" setting photos ");
// getting photos
if (source.getAttribute("oxTrustPhotos") != null) {
List<Photo> photos = getAttributeListValue(source, Photo.class, "oxTrustPhotos");
destination.setPhotos(photos);
}
log.trace(" setting userType ");
if (source.getAttribute("oxTrustUserType") != null) {
destination.setUserType(source.getAttribute("oxTrustUserType"));
}
log.trace(" setting title ");
if (source.getAttribute("oxTrustTitle") != null) {
destination.setTitle(source.getAttribute("oxTrustTitle"));
}
log.trace(" setting Locale ");
/*
if (source.getAttribute("oxTrustLocale") != null) {
destination.setLocale(source.getAttribute("oxTrustLocale"));
}
*/
if (source.getAttribute("locale") != null) {
destination.setLocale(source.getAttribute("locale"));
}
log.trace(" setting preferredLanguage ");
if (source.getPreferredLanguage() != null) {
destination.setPreferredLanguage(source.getPreferredLanguage());
}
log.trace(" setting timeZone ");
if (source.getTimezone() != null) {
destination.setTimezone(source.getTimezone());
}
log.trace(" setting active ");
if (source.getAttribute("oxTrustActive") != null) {
destination.setActive(Boolean.parseBoolean(source.getAttribute("oxTrustActive")));
}
log.trace(" setting password ");
destination.setPassword("Hidden for Privacy Reasons");
// getting user groups
log.trace(" setting groups ");
if (source.getMemberOf() != null) {
List<String> listOfGroups = source.getMemberOf();
List<GroupRef> groupRefList = new ArrayList<GroupRef>();
for (String groupDN : listOfGroups) {
GluuGroup gluuGroup = groupService.getGroupByDn(groupDN);
GroupRef groupRef = new GroupRef();
groupRef.setDisplay(gluuGroup.getDisplayName());
groupRef.setValue(gluuGroup.getInum());
String reference = appConfiguration.getBaseEndpoint() + "/scim/v2/Groups/" + gluuGroup.getInum();
groupRef.setReference(reference);
groupRefList.add(groupRef);
}
destination.setGroups(groupRefList);
}
// getting roles
if (source.getAttribute("oxTrustRole") != null) {
List<Role> roles = getAttributeListValue(source, Role.class, "oxTrustRole");
destination.setRoles(roles);
}
log.trace(" getting entitlements ");
// getting entitlements
if (source.getAttribute("oxTrustEntitlements") != null) {
List<Entitlement> entitlements = getAttributeListValue(source, Entitlement.class, "oxTrustEntitlements");
destination.setEntitlements(entitlements);
}
// getting x509Certificates
log.trace(" setting certs ");
if (source.getAttribute("oxTrustx509Certificate") != null) {
List<X509Certificate> x509Certificates = getAttributeListValue(source, X509Certificate.class, "oxTrustx509Certificate");
destination.setX509Certificates(x509Certificates);
}
log.trace(" setting extensions ");
// List<GluuAttribute> scimCustomAttributes = attributeService.getSCIMRelatedAttributesImpl(attributeService.getCustomAttributes());
List<GluuAttribute> scimCustomAttributes = attributeService.getSCIMRelatedAttributes();
if (scimCustomAttributes != null && !scimCustomAttributes.isEmpty()) {
Map<String, Extension> extensionMap = new HashMap<String, Extension>();
Extension.Builder extensionBuilder = new Extension.Builder(Constants.USER_EXT_SCHEMA_ID);
boolean hasExtension = false;
outer: for (GluuCustomAttribute customAttribute : source.getCustomAttributes()) {
for (GluuAttribute scimCustomAttribute : scimCustomAttributes) {
if (customAttribute.getName().equals(scimCustomAttribute.getName())) {
hasExtension = true;
GluuAttributeDataType scimCustomAttributeDataType = scimCustomAttribute.getDataType();
if ((scimCustomAttribute.getOxMultivaluedAttribute() != null) && scimCustomAttribute.getOxMultivaluedAttribute().equals(OxMultivalued.TRUE)) {
extensionBuilder.setFieldAsList(customAttribute.getName(), Arrays.asList(customAttribute.getValues()));
} else {
if (scimCustomAttributeDataType.equals(GluuAttributeDataType.STRING) || scimCustomAttributeDataType.equals(GluuAttributeDataType.PHOTO)) {
String value = ExtensionFieldType.STRING.fromString(customAttribute.getValue());
extensionBuilder.setField(customAttribute.getName(), value);
} else if (scimCustomAttributeDataType.equals(GluuAttributeDataType.DATE)) {
Date value = ExtensionFieldType.DATE_TIME.fromString(customAttribute.getValue());
extensionBuilder.setField(customAttribute.getName(), value);
} else if (scimCustomAttributeDataType.equals(GluuAttributeDataType.NUMERIC)) {
BigDecimal value = ExtensionFieldType.DECIMAL.fromString(customAttribute.getValue());
extensionBuilder.setField(customAttribute.getName(), value);
}
}
continue outer;
}
}
}
if (hasExtension) {
extensionMap.put(Constants.USER_EXT_SCHEMA_ID, extensionBuilder.build());
destination.getSchemas().add(Constants.USER_EXT_SCHEMA_ID);
destination.setExtensions(extensionMap);
}
}
log.trace(" getting meta ");
Meta meta = (destination.getMeta() != null) ? destination.getMeta() : new Meta();
if (source.getAttribute("oxTrustMetaVersion") != null) {
meta.setVersion(source.getAttribute("oxTrustMetaVersion"));
}
String location = source.getAttribute("oxTrustMetaLocation");
if (location != null && !location.isEmpty()) {
if (!location.startsWith("https://") && !location.startsWith("http://")) {
location = appConfiguration.getBaseEndpoint() + location;
}
} else {
location = appConfiguration.getBaseEndpoint() + "/scim/v2/Users/" + source.getInum();
}
meta.setLocation(location);
if (source.getAttribute("oxTrustMetaCreated") != null && !source.getAttribute("oxTrustMetaCreated").isEmpty()) {
try {
DateTime dateTimeUtc = new DateTime(source.getAttribute("oxTrustMetaCreated"), DateTimeZone.UTC);
meta.setCreated(dateTimeUtc.toDate());
} catch (Exception e) {
log.error(" Date parse exception (NEW format), continuing...", e);
// For backward compatibility
try {
meta.setCreated(new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy").parse(source.getAttribute("oxTrustMetaCreated")));
} catch (Exception ex) {
log.error(" Date parse exception (OLD format)", ex);
}
}
}
if (source.getAttribute("oxTrustMetaLastModified") != null && !source.getAttribute("oxTrustMetaLastModified").isEmpty()) {
try {
DateTime dateTimeUtc = new DateTime(source.getAttribute("oxTrustMetaLastModified"), DateTimeZone.UTC);
meta.setLastModified(dateTimeUtc.toDate());
} catch (Exception e) {
log.error(" Date parse exception (NEW format), continuing...", e);
// For backward compatibility
try {
meta.setLastModified(new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy").parse(source.getAttribute("oxTrustMetaLastModified")));
} catch (Exception ex) {
log.error(" Date parse exception (OLD format)", ex);
}
}
}
destination.setMeta(meta);
return destination;
}
use of org.gluu.oxtrust.model.scim2.extensions.Extension in project oxTrust by GluuFederation.
the class PatchUtil method addPatch.
public GluuCustomPerson addPatch(User source, GluuCustomPerson destination) throws Exception {
if (source == null) {
return null;
}
if (destination == null) {
log.trace(" creating a new GluuCustomPerson instant ");
destination = new GluuCustomPerson();
}
log.trace(" setting schemas ");
destination.setSchemas(source.getSchemas());
personService.addCustomObjectClass(destination);
// getting emails
log.trace(" setting emails ");
if (source.getEmails() != null && source.getEmails().size() > 0) {
List<Email> emails = copyUtils2.getAttributeListValue(destination, Email.class, "oxTrustEmail");
if (emails == null) {
emails = new ArrayList<Email>();
}
emails.addAll(source.getEmails());
copyUtils2.setAttributeListValue(destination, emails, "oxTrustEmail");
}
// getting addresses
log.trace(" setting addresses ");
if (source.getAddresses() != null && source.getAddresses().size() > 0) {
List<Address> addresses = copyUtils2.getAttributeListValue(destination, Address.class, "oxTrustAddresses");
if (addresses == null) {
addresses = new ArrayList<Address>();
}
addresses.addAll(source.getAddresses());
copyUtils2.setAttributeListValue(destination, addresses, "oxTrustAddresses");
}
// getting phone numbers;
log.trace(" setting phoneNumbers ");
if (source.getPhoneNumbers() != null && source.getPhoneNumbers().size() > 0) {
List<PhoneNumber> phoneNumbers = copyUtils2.getAttributeListValue(destination, PhoneNumber.class, "oxTrustPhoneValue");
if (phoneNumbers == null) {
phoneNumbers = new ArrayList<PhoneNumber>();
}
phoneNumbers.addAll(source.getPhoneNumbers());
copyUtils2.setAttributeListValue(destination, phoneNumbers, "oxTrustPhoneValue");
}
// getting ims
log.trace(" setting ims ");
if (source.getIms() != null && source.getIms().size() > 0) {
List<Im> ims = copyUtils2.getAttributeListValue(destination, Im.class, "oxTrustImsValue");
if (ims == null) {
ims = new ArrayList<Im>();
}
ims.addAll(source.getIms());
copyUtils2.setAttributeListValue(destination, ims, "oxTrustImsValue");
}
// getting Photos
log.trace(" setting photos ");
if (source.getPhotos() != null && source.getPhotos().size() > 0) {
List<Photo> photos = copyUtils2.getAttributeListValue(destination, Photo.class, "oxTrustPhotos");
if (photos == null) {
photos = new ArrayList<Photo>();
}
photos.addAll(source.getPhotos());
copyUtils2.setAttributeListValue(destination, photos, "oxTrustPhotos");
}
// getting user groups
log.trace(" setting groups ");
if (source.getGroups() != null && source.getGroups().size() > 0) {
List<String> groupsList = destination.getMemberOf();
List<GroupRef> listGroups = source.getGroups();
for (GroupRef group : listGroups) {
String groupToAdd = groupService.getDnForGroup(group.getValue());
if (groupToAdd != null || !groupToAdd.trim().equalsIgnoreCase("")) {
groupsList.add(groupToAdd);
}
}
destination.setMemberOf(groupsList);
}
// getting roles
log.trace(" setting roles ");
if (source.getRoles() != null && source.getRoles().size() > 0) {
List<Role> roles = copyUtils2.getAttributeListValue(destination, Role.class, "oxTrustRole");
if (roles == null) {
roles = new ArrayList<Role>();
}
roles.addAll(source.getRoles());
copyUtils2.setAttributeListValue(destination, roles, "oxTrustRole");
}
// getting entitlements
log.trace(" setting entitlements ");
if (source.getEntitlements() != null && source.getEntitlements().size() > 0) {
List<Entitlement> entitlements = copyUtils2.getAttributeListValue(destination, Entitlement.class, "oxTrustEntitlements");
if (entitlements == null) {
entitlements = new ArrayList<Entitlement>();
}
entitlements.addAll(source.getEntitlements());
copyUtils2.setAttributeListValue(destination, entitlements, "oxTrustEntitlements");
}
// getting x509Certificates
log.trace(" setting certs ");
if (source.getX509Certificates() != null && source.getX509Certificates().size() > 0) {
List<X509Certificate> X509Certificates = copyUtils2.getAttributeListValue(destination, X509Certificate.class, "oxTrustx509Certificate");
if (X509Certificates == null) {
X509Certificates = new ArrayList<X509Certificate>();
}
X509Certificates.addAll(source.getX509Certificates());
copyUtils2.setAttributeListValue(destination, X509Certificates, "oxTrustx509Certificate");
}
log.trace(" setting extensions ");
if (source.getExtensions() != null && (source.getExtensions().size() > 0)) {
Map<String, Extension> destMap = destination.fetchExtensions();
if (destMap == null) {
destMap = new HashMap<String, Extension>();
}
destMap.putAll(source.getExtensions());
destination.setExtensions(destMap);
}
if (source.isActive() != null) {
copyUtils2.setGluuStatus(source, destination);
}
return destination;
}
use of org.gluu.oxtrust.model.scim2.extensions.Extension in project oxTrust by GluuFederation.
the class UserExtensionsTest method testCreatePersonFromUserObject.
@Test(dependsOnMethods = "testCreatePersonFromJsonString")
@Parameters
public void testCreatePersonFromUserObject() throws Exception {
System.out.println(" testCreatePersonFromUserObject() ");
// Create custom attributes
// String, not
GluuAttribute scimCustomFirst = null;
// multi-valued
if (attributeService.getAttributeByName("scimCustomFirst") == null) {
scimCustomFirst = createCustomAttribute(attributeService, schemaService, appConfiguration, "scimCustomFirst", "Custom First", "First custom attribute", GluuAttributeDataType.STRING, OxMultivalued.FALSE);
}
// Date, multi-valued
GluuAttribute scimCustomSecond = null;
if (attributeService.getAttributeByName("scimCustomSecond") == null) {
scimCustomSecond = createCustomAttribute(attributeService, schemaService, appConfiguration, "scimCustomSecond", "Custom Second", "Second custom attribute", GluuAttributeDataType.DATE, OxMultivalued.TRUE);
}
// Numeric, not
GluuAttribute scimCustomThird = null;
// multi-valued
if (attributeService.getAttributeByName("scimCustomThird") == null) {
scimCustomThird = createCustomAttribute(attributeService, schemaService, appConfiguration, "scimCustomThird", "Custom Third", "Third custom attribute", GluuAttributeDataType.NUMERIC, OxMultivalued.FALSE);
}
ObjectMapper mapper = new ObjectMapper();
mapper.disable(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES);
User user = createUserObject();
// Create Person
GluuCustomPerson gluuPerson = copyUtils2.copy(user, null, false);
assertNotNull(gluuPerson, "gluuPerson is null!");
System.out.println(">>>>>>>>>> gluuPerson.getUid() = " + gluuPerson.getUid());
String inum = personService.generateInumForNewPerson();
String dn = personService.getDnForPerson(inum);
String iname = personService.generateInameForNewPerson(user.getUserName());
gluuPerson.setDn(dn);
gluuPerson.setInum(inum);
gluuPerson.setIname(iname);
gluuPerson.setCommonName(gluuPerson.getGivenName() + " " + gluuPerson.getSurname());
personService.addPerson(gluuPerson);
// Retrieve Person
GluuCustomPerson retrievedPerson = personService.getPersonByUid(gluuPerson.getUid());
assertNotNull(retrievedPerson, "Failed to find person.");
User newPerson = copyUtils2.copy(retrievedPerson, null);
Extension extension = newPerson.getExtension(Constants.USER_EXT_SCHEMA_ID);
assertNotNull(extension, "(Persistence) Custom extension not persisted.");
Extension.Field customFirstField = extension.getFields().get("scimCustomFirst");
assertNotNull(customFirstField, "(Persistence) \"scimCustomFirst\" field not persisted.");
assertEquals(customFirstField.getValue(), "customFirstValue");
System.out.println("##### (Persistence) customFirstField.getValue() = " + customFirstField.getValue());
Extension.Field customSecondField = extension.getFields().get("scimCustomSecond");
assertNotNull(customSecondField, "(Persistence) \"scimCustomSecond\" field not persisted.");
List<Date> dateList = Arrays.asList(mapper.readValue(customSecondField.getValue(), Date[].class));
assertEquals(dateList.size(), 2);
System.out.println("##### (Persistence) dateList.get(0) = " + dateList.get(0));
System.out.println("##### (Persistence) dateList.get(1) = " + dateList.get(1));
Extension.Field customThirdField = extension.getFields().get("scimCustomThird");
assertNotNull(customThirdField, "(Persistence) \"scimCustomThird\" field not persisted.");
assertEquals(new BigDecimal(customThirdField.getValue()), new BigDecimal(3000));
System.out.println("##### (Persistence) customThirdField.getValue() = " + customThirdField.getValue());
// Remove Person
memberService.removePerson(retrievedPerson);
// Remove custom attributes
// schemaService.removeAttributeTypeFromObjectClass(scimCustomFirst.getOrigin(),
// scimCustomFirst.getName());
// schemaService.removeStringAttribute(scimCustomFirst.getName());
// attributeService.removeAttribute(scimCustomFirst);
// schemaService.removeAttributeTypeFromObjectClass(scimCustomSecond.getOrigin(),
// scimCustomSecond.getName());
// schemaService.removeStringAttribute(scimCustomSecond.getName());
// attributeService.removeAttribute(scimCustomSecond);
// schemaService.removeAttributeTypeFromObjectClass(scimCustomThird.getOrigin(),
// scimCustomThird.getName());
// schemaService.removeStringAttribute(scimCustomThird.getName());
// attributeService.removeAttribute(scimCustomThird);
}
use of org.gluu.oxtrust.model.scim2.extensions.Extension in project oxTrust by GluuFederation.
the class UserDeserializer method deserialize.
@Override
public User deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
log.info(" deserialize() ");
try {
JsonNode rootNode = jsonParser.readValueAsTree();
ObjectMapper mapper = new ObjectMapper();
mapper.disable(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES);
User user = mapper.readValue(rootNode.toString(), User.class);
if (user.getSchemas() == null) {
throw new IllegalArgumentException("Required field \"schemas\" is null or missing.");
} else if (!user.getSchemas().contains(Constants.USER_CORE_SCHEMA_ID)) {
throw new IllegalArgumentException("User Core schema is required.");
} else if (user.getSchemas().contains(Constants.USER_EXT_SCHEMA_ID)) {
JsonNode userExtensionNode = rootNode.get(Constants.USER_EXT_SCHEMA_ID);
if (userExtensionNode != null) {
ExtensionDeserializer deserializer = new ExtensionDeserializer();
deserializer.setId(Constants.USER_EXT_SCHEMA_ID);
SimpleModule deserializerModule = new SimpleModule("ExtensionDeserializerModule", new Version(1, 0, 0, ""));
deserializerModule.addDeserializer(Extension.class, deserializer);
mapper.registerModule(deserializerModule);
Extension extension = mapper.readValue(userExtensionNode.toString(), Extension.class);
user.addExtension(extension);
} else {
throw new IllegalArgumentException("User Extension schema is indicated, but value body is absent.");
}
}
return user;
} catch (Exception e) {
e.printStackTrace();
throw new IOException(INTERNAL_SERVER_ERROR_MESSAGE);
}
}
use of org.gluu.oxtrust.model.scim2.extensions.Extension in project oxTrust by GluuFederation.
the class UserSerializer method serializeUserExtension.
protected void serializeUserExtension(Map.Entry<String, JsonNode> rootNodeEntry, ObjectMapper mapper, User user, JsonGenerator jsonGenerator) throws Exception {
Extension extension = user.getExtension(rootNodeEntry.getKey());
Map<String, Object> list = new HashMap<String, Object>();
boolean enclosingWritten = false;
for (Map.Entry<String, Extension.Field> extEntry : extension.getFields().entrySet()) {
if (attributes != null && attributes.size() > 0) {
for (String attribute : attributes) {
attribute = FilterUtil.stripScim2Schema(attribute);
if (extEntry.getKey().equalsIgnoreCase(attribute)) {
if (!enclosingWritten) {
jsonGenerator.writeFieldName(rootNodeEntry.getKey());
enclosingWritten = true;
}
break;
}
}
} else {
if (!enclosingWritten) {
jsonGenerator.writeFieldName(rootNodeEntry.getKey());
enclosingWritten = true;
}
}
if (enclosingWritten) {
GluuAttribute gluuAttribute = attributeService.getAttributeByName(extEntry.getKey());
GluuAttributeDataType attributeDataType = gluuAttribute.getDataType();
if ((gluuAttribute.getOxMultivaluedAttribute() != null) && gluuAttribute.getOxMultivaluedAttribute().equals(OxMultivalued.TRUE)) {
if (attributeDataType.equals(GluuAttributeDataType.STRING) || attributeDataType.equals(GluuAttributeDataType.PHOTO)) {
List<String> stringList = Arrays.asList(mapper.readValue(extEntry.getValue().getValue(), String[].class));
list.put(extEntry.getKey(), stringList);
} else if (attributeDataType.equals(GluuAttributeDataType.DATE)) {
List<Date> dateList = Arrays.asList(mapper.readValue(extEntry.getValue().getValue(), Date[].class));
List<String> stringList = new ArrayList<String>();
DateTimeFormatter dateTimeFormatter = ISODateTimeFormat.dateTime().withZoneUTC();
for (Date date : dateList) {
String dateString = dateTimeFormatter.print(date.getTime());
stringList.add(dateString);
}
list.put(extEntry.getKey(), stringList);
} else if (attributeDataType.equals(GluuAttributeDataType.NUMERIC)) {
List<BigDecimal> numberList = Arrays.asList(mapper.readValue(extEntry.getValue().getValue(), BigDecimal[].class));
list.put(extEntry.getKey(), numberList);
}
} else {
list.put(extEntry.getKey(), extEntry.getValue().getValue());
}
}
}
if (enclosingWritten) {
jsonGenerator.writeObject(list);
}
}
Aggregations