Search in sources :

Example 1 with GluuDeviceDataBean

use of org.gluu.oxtrust.model.fido.GluuDeviceDataBean in project oxTrust by GluuFederation.

the class UpdatePersonAction method update.

/**
 * Initializes attributes for updating person
 *
 * @return String describing success of the operation
 * @throws Exception
 */
public String update() {
    if (this.person != null) {
        return OxTrustConstants.RESULT_SUCCESS;
    }
    this.update = true;
    try {
        this.person = personService.getPersonByInum(inum);
    } catch (BaseMappingException ex) {
        log.error("Failed to find person {}", inum, ex);
        facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to find person");
        conversationService.endConversation();
        return OxTrustConstants.RESULT_FAILURE;
    }
    initAttributes(false);
    try {
        this.gluuStatus = this.person.getStatus();
        List<String> oxexternal = this.person.getOxExternalUid();
        externalAuthCustomAttributes = new ArrayList<String>();
        if (oxexternal != null && oxexternal.size() > 0) {
            for (String oxexternalStr : oxexternal) {
                String[] args = oxexternalStr.split(":");
                externalAuthCustomAttributes.add(args[0]);
            }
        }
        List<GluuCustomFidoDevice> gluuCustomFidoDevices = fidoDeviceService.searchFidoDevices(this.person.getInum(), null);
        deviceDataMap = new ArrayList<GluuDeviceDataBean>();
        if (gluuCustomFidoDevices != null) {
            for (GluuCustomFidoDevice gluuCustomFidoDevice : gluuCustomFidoDevices) {
                GluuDeviceDataBean gluuDeviceDataBean = new GluuDeviceDataBean();
                gluuDeviceDataBean.setCreationDate(ldapEntryManager.decodeGeneralizedTime(gluuCustomFidoDevice.getCreationDate()).toGMTString());
                gluuDeviceDataBean.setId(gluuCustomFidoDevice.getId());
                String devicedata = gluuCustomFidoDevice.getDeviceData();
                String modality = "";
                String nickName = "";
                if (devicedata != null) {
                    DeviceData deviceData = getDeviceata(devicedata);
                    // nickName = deviceData.getName();
                    nickName = gluuCustomFidoDevice.getNickname();
                    modality = "Super-Gluu Device";
                } else {
                    // nickName = "U2F";
                    nickName = gluuCustomFidoDevice.getNickname();
                    modality = "U2F device";
                }
                gluuDeviceDataBean.setNickName(nickName);
                gluuDeviceDataBean.setModality(modality);
                deviceDataMap.add(gluuDeviceDataBean);
            }
        }
        if (oxexternal != null && oxexternal.size() > 0) {
            for (String oxexternalStr : oxexternal) {
                String[] args = oxexternalStr.split(":");
                GluuDeviceDataBean gluuDeviceDataBean = new GluuDeviceDataBean();
                gluuDeviceDataBean.setNickName(args[0]);
                gluuDeviceDataBean.setModality(args[0]);
                gluuDeviceDataBean.setId(oxexternalStr);
                deviceDataMap.add(gluuDeviceDataBean);
            }
        }
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    userPasswordAction.setPerson(this.person);
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : BaseMappingException(org.gluu.persist.exception.mapping.BaseMappingException) GluuDeviceDataBean(org.gluu.oxtrust.model.fido.GluuDeviceDataBean) GluuCustomFidoDevice(org.gluu.oxtrust.model.fido.GluuCustomFidoDevice) DeviceData(org.xdi.oxauth.model.fido.u2f.protocol.DeviceData) BaseMappingException(org.gluu.persist.exception.mapping.BaseMappingException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) IOException(java.io.IOException) JsonParseException(org.codehaus.jackson.JsonParseException)

Aggregations

IOException (java.io.IOException)1 JsonParseException (org.codehaus.jackson.JsonParseException)1 JsonMappingException (org.codehaus.jackson.map.JsonMappingException)1 GluuCustomFidoDevice (org.gluu.oxtrust.model.fido.GluuCustomFidoDevice)1 GluuDeviceDataBean (org.gluu.oxtrust.model.fido.GluuDeviceDataBean)1 BaseMappingException (org.gluu.persist.exception.mapping.BaseMappingException)1 DeviceData (org.xdi.oxauth.model.fido.u2f.protocol.DeviceData)1