From a6642ccd7cbdba1176330efade20f3acbe3229e2 Mon Sep 17 00:00:00 2001 From: shekhar16 Date: Tue, 19 Jun 2018 23:31:18 +0530 Subject: [PATCH] #815 : corrections --- .../oxtrust/action/UpdatePersonAction.java | 27 ++++++++++--------- .../gluu/oxtrust/model/GluuCustomPerson.java | 9 ++++--- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/server/src/main/java/org/gluu/oxtrust/action/UpdatePersonAction.java b/server/src/main/java/org/gluu/oxtrust/action/UpdatePersonAction.java index c59b4e581..f6ccc311e 100644 --- a/server/src/main/java/org/gluu/oxtrust/action/UpdatePersonAction.java +++ b/server/src/main/java/org/gluu/oxtrust/action/UpdatePersonAction.java @@ -232,7 +232,7 @@ public String update() { try { this.gluuStatus = this.person.getStatus(); List oxexternal = this.person.getOxExternalUid(); - String oxOTPDevices = this.person.getOxOTPDevices(); + OTPDevice oxOTPDevices = this.person.getOxOTPDevices(); externalAuthCustomAttributes = new ArrayList(); String oxMobileDevices = this.person.getOxMobileDevices(); if(oxexternal != null && oxexternal.size()>0){ @@ -269,10 +269,10 @@ public String update() { } } - if (oxOTPDevices != null && !oxOTPDevices.trim().equals("")) { + /*if (oxOTPDevices != null && !oxOTPDevices.trim().equals("")) { ObjectMapper mapper = new ObjectMapper(); - OTPDevice oTPDevice = mapper.readValue(oxOTPDevices, OTPDevice.class); - ArrayList devices = oTPDevice.getDevices(); + OTPDevice oTPDevice = mapper.readValue(oxOTPDevices, OTPDevice.class);*/ + ArrayList devices = oxOTPDevices.getDevices(); if (devices != null && devices.size() > 0) { for (Device device : devices) { @@ -285,7 +285,7 @@ public String update() { deviceDataMap.add(gluuDeviceDataBean); } } - } + //} if (oxMobileDevices != null && !oxMobileDevices.trim().equals("")) { ObjectMapper mapper = new ObjectMapper(); @@ -610,26 +610,27 @@ public void removeDevice(GluuDeviceDataBean deleteDeviceData){ } } - String oxOTPDevices = this.person.getOxOTPDevices(); - if (oxOTPDevices != null && !oxOTPDevices.trim().equals("")) { + OTPDevice oxOTPDevices = this.person.getOxOTPDevices(); + /*if (oxOTPDevices != null && !oxOTPDevices.trim().equals("")) { ObjectMapper mapper = new ObjectMapper(); - OTPDevice oTPDevice = mapper.readValue(oxOTPDevices, OTPDevice.class); - ArrayList devices = oTPDevice.getDevices(); + OTPDevice oTPDevice = mapper.readValue(oxOTPDevices, OTPDevice.class);*/ + ArrayList devices = oxOTPDevices.getDevices(); if (devices != null && devices.size() > 0) { for (Device device : devices) { if(deleteDeviceData.getId().equals(device.getId())){ deviceDataMap.remove(deleteDeviceData); devices.remove(device); - Map> map= new HashMap>(); + /*Map> map= new HashMap>(); map.put("devices", devices); - String jsonInString = mapper.writeValueAsString(map); - this.person.setOxOTPDevices(jsonInString); + String jsonInString = mapper.writeValueAsString(map);*/ + oxOTPDevices.setDevices(devices); + this.person.setOxOTPDevices(oxOTPDevices); return; } } } - } + //} String oxMobileDevices = this.person.getOxMobileDevices(); if (oxMobileDevices != null && !oxMobileDevices.trim().equals("")) { diff --git a/server/src/main/java/org/gluu/oxtrust/model/GluuCustomPerson.java b/server/src/main/java/org/gluu/oxtrust/model/GluuCustomPerson.java index 166a5e724..23582c89a 100644 --- a/server/src/main/java/org/gluu/oxtrust/model/GluuCustomPerson.java +++ b/server/src/main/java/org/gluu/oxtrust/model/GluuCustomPerson.java @@ -22,6 +22,7 @@ import org.codehaus.jackson.map.ObjectMapper; import org.gluu.site.ldap.persistence.annotation.LdapAttribute; import org.gluu.site.ldap.persistence.annotation.LdapEntry; +import org.gluu.site.ldap.persistence.annotation.LdapJsonObject; import org.gluu.site.ldap.persistence.annotation.LdapObjectClass; import org.xdi.ldap.model.GluuBoolean; import org.xdi.ldap.model.GluuStatus; @@ -58,11 +59,13 @@ public class GluuCustomPerson extends User @LdapAttribute(name = "oxPPID") private List oxPPID; + // @LdapJsonObject @LdapAttribute(name = "oxExternalUid") private List oxExternalUid; + @LdapJsonObject @LdapAttribute(name = "oxOTPDevices") - private String oxOTPDevices; + private OTPDevice oxOTPDevices; @LdapAttribute(name = "oxMobileDevices") private String oxMobileDevices; @@ -75,11 +78,11 @@ public void setOxMobileDevices(String oxMobileDevices) { this.oxMobileDevices = oxMobileDevices; } - public String getOxOTPDevices() { + public OTPDevice getOxOTPDevices() { return oxOTPDevices; } - public void setOxOTPDevices(String oxOTPDevices) { + public void setOxOTPDevices(OTPDevice oxOTPDevices) { this.oxOTPDevices = oxOTPDevices; }