Search in sources :

Example 51 with GluuAttribute

use of org.xdi.model.GluuAttribute in project oxTrust by GluuFederation.

the class CopyUtils method copy.

/**
	 * Copy data from GluuCustomPerson object to ScimPerson object "Reda"
	 * 
	 * @param source
	 * @param destination
	 * @return
	 * @throws Exception
	 */
public ScimPerson copy(GluuCustomPerson source, ScimPerson destination) throws Exception {
    if (source == null) {
        return null;
    }
    if (destination == null) {
        log.trace(" creating a new GluuCustomPerson instant ");
        destination = new ScimPerson();
    }
    destination.getSchemas().add(Constants.SCIM1_CORE_SCHEMA_ID);
    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(OX_TRUST_EXTERNAL_ID) != null) {
        destination.setExternalId(source.getAttribute(OX_TRUST_EXTERNAL_ID));
    }
    log.trace(" setting givenname ");
    if (source.getGivenName() != null) {
        destination.getName().setGivenName(source.getGivenName());
    }
    log.trace(" getting family name ");
    if (source.getSurname() != null) {
        destination.getName().setFamilyName(source.getSurname());
    }
    log.trace(" getting middlename ");
    if (source.getAttribute(OX_TRUST_MIDDLE_NAME) != null) {
        destination.getName().setMiddleName(source.getAttribute(OX_TRUST_MIDDLE_NAME));
    }
    ;
    log.trace(" getting honorificPrefix ");
    if (source.getAttribute(OX_TRUSTHONORIFIC_PREFIX) != null) {
        destination.getName().setHonorificPrefix(source.getAttribute(OX_TRUSTHONORIFIC_PREFIX));
    }
    ;
    log.trace(" getting honorificSuffix ");
    if (source.getAttribute(OX_TRUSTHONORIFIC_SUFFIX) != null) {
        destination.getName().setHonorificSuffix(source.getAttribute(OX_TRUSTHONORIFIC_SUFFIX));
    }
    ;
    log.trace(" getting displayname ");
    if (source.getDisplayName() != null) {
        destination.setDisplayName(source.getDisplayName());
    }
    log.trace(" getting nickname ");
    if (source.getAttribute(OX_TRUST_NICK_NAME) != null) {
        destination.setNickName(source.getAttribute(OX_TRUST_NICK_NAME));
    }
    log.trace(" getting profileURL ");
    if (source.getAttribute(OX_TRUST_PROFILE_URL) != null) {
        destination.setProfileUrl(source.getAttribute(OX_TRUST_PROFILE_URL));
    }
    log.trace(" getting emails ");
    // if (source.getAttribute(OX_TRUST_EMAIL) != null) {
    if (source.getAttributeArray(OX_TRUST_EMAIL) != null) {
        // List<ScimPersonEmails> listOfEmails = mapper.readValue(source.getAttribute(OX_TRUST_EMAIL), new TypeReference<List<ScimPersonEmails>>(){});
        /*
			 * List<ScimPersonEmails> emails = new
			 * ArrayList<ScimPersonEmails>(); String[] listEmails =
			 * source.getAttributes("oxTrustEmail"); String[] listEmailTyps =
			 * source.getAttributes("oxTrustEmailType"); String[]
			 * listEmailPrimary = source.getAttributes("oxTrustEmailPrimary");
			 * for(int i = 0 ; i<listEmails.length ; i++ ){ ScimPersonEmails
			 * oneEmail = new ScimPersonEmails();
			 * oneEmail.setValue(listEmails[i]);
			 * oneEmail.setType(listEmailTyps[i]);
			 * oneEmail.setPrimary(listEmailPrimary[i]); emails.add(oneEmail); }
			 */
        // destination.setEmails(listOfEmails);
        /*
			String[] emailArray = source.getAttributeArray(OX_TRUST_EMAIL);
			List<ScimPersonEmails> emails = new ArrayList<ScimPersonEmails>();

			for (String emailStr : emailArray) {
				ScimPersonEmails email = mapper.readValue(emailStr, ScimPersonEmails.class);
				emails.add(email);
			}
			*/
        List<ScimPersonEmails> emails = getAttributeListValue(source, ScimPersonEmails.class, OX_TRUST_EMAIL);
        destination.setEmails(emails);
    }
    log.trace(" getting addresses ");
    // getting addresses
    if (source.getAttribute(OX_TRUST_ADDRESSES) != null) {
        // List<ScimPersonAddresses> listOfAddresses = mapper.readValue(source.getAttribute(OX_TRUST_ADDRESSES), new TypeReference<List<ScimPersonAddresses>>(){});
        /*
			 * List<ScimPersonAddresses> addresses = new
			 * ArrayList<ScimPersonAddresses>(); String[] listStreets =
			 * source.getAttributes("oxTrustStreet"); String[] listAddressTypes
			 * = source.getAttributes("oxTrustAddressType"); String[]
			 * listLocalities = source.getAttributes("oxTrustLocality");
			 * String[] listRegions = source.getAttributes("oxTrustRegion");
			 * String[] listPostalCodes =
			 * source.getAttributes("oxTrustPostalCode"); String[] listCountries
			 * = source.getAttributes("oxTrustCountry"); String[]
			 * listAddressFormatted =
			 * source.getAttributes("oxTrustAddressFormatted"); String[]
			 * listAddressPrimary =
			 * source.getAttributes("oxTrustAddressPrimary");
			 * if(listStreets.length > 0){ for(int i = 0 ; i <
			 * listStreets.length ; i++ ){ ScimPersonAddresses address = new
			 * ScimPersonAddresses();
			 * 
			 * if(!listAddressFormatted[i].equalsIgnoreCase("empty")){address.
			 * setFormatted
			 * (listAddressFormatted[i]);}else{address.setFormatted("");}
			 * if(!listStreets
			 * [i].equalsIgnoreCase("empty")){address.setStreetAddress
			 * (listStreets[i]);}else{address.setStreetAddress("");}
			 * if(!listAddressTypes
			 * [i].equalsIgnoreCase("empty")){address.setType
			 * (listAddressTypes[i]);}else{address.setType("");}
			 * if(!listLocalities
			 * [i].equalsIgnoreCase("empty")){address.setLocality
			 * (listLocalities[i]);}else{address.setLocality("");}
			 * if(!listRegions
			 * [i].equalsIgnoreCase("empty")){address.setRegion(listRegions
			 * [i]);}else{address.setRegion("");}
			 * if(!listPostalCodes[i].equalsIgnoreCase
			 * ("empty")){address.setPostalCode
			 * (listPostalCodes[i]);}else{address.setPostalCode("");}
			 * if(!listCountries
			 * [i].equalsIgnoreCase("empty")){address.setCountry
			 * (listCountries[i]);}else{address.setCountry("");}
			 * if(!listAddressPrimary
			 * [i].equalsIgnoreCase("empty")){address.setPrimary
			 * (listAddressPrimary[i]);}else{address.setPrimary("");}
			 * addresses.add(address);
			 * 
			 * } }
			 */
        // destination.setAddresses(listOfAddresses);
        List<ScimPersonAddresses> addresses = getAttributeListValue(source, ScimPersonAddresses.class, OX_TRUST_ADDRESSES);
        destination.setAddresses(addresses);
    }
    log.trace(" setting phoneNumber ");
    // getting user's PhoneNumber
    if (source.getAttribute(OX_TRUST_PHONE_VALUE) != null) {
        // List<ScimPersonPhones> listOfPhones = mapper.readValue(source.getAttribute(OX_TRUST_PHONE_VALUE), new TypeReference<List<ScimPersonPhones>>(){});
        /*
			 * List<ScimPersonPhones> phones = new
			 * ArrayList<ScimPersonPhones>(); String[] listNumbers =
			 * source.getAttributes("oxTrustPhoneValue"); String[]
			 * listPhoneTypes = source.getAttributes("oxTrustPhoneType");
			 * if(listNumbers.length > 0){ for(int i = 0 ; i <
			 * listNumbers.length ; i++){ ScimPersonPhones phone = new
			 * ScimPersonPhones();
			 * if(!listNumbers[i].equalsIgnoreCase("empty")){
			 * phone.setValue(listNumbers[i]);}else{phone.setValue("");}
			 * if(!listPhoneTypes
			 * [i].equalsIgnoreCase("empty")){phone.setType(listPhoneTypes
			 * [i]);}else{phone.setType("");} phones.add(phone);
			 * 
			 * } }
			 */
        // destination.setPhoneNumbers(listOfPhones);
        List<ScimPersonPhones> phoneNumbers = getAttributeListValue(source, ScimPersonPhones.class, OX_TRUST_PHONE_VALUE);
        destination.setPhoneNumbers(phoneNumbers);
    }
    log.trace(" getting ims ");
    // getting ims
    if (source.getAttribute(OX_TRUST_IMS_VALUE) != null) {
        // List<ScimPersonIms> listOfIms = mapper.readValue(source.getAttribute(OX_TRUST_IMS_VALUE), new TypeReference<List<ScimPersonIms>>(){});
        /*
			 * List<ScimPersonIms> ims = new ArrayList<ScimPersonIms>();
			 * String[] imValues = source.getAttributes("oxTrustImsValue");
			 * String[] imTypes = source.getAttributes("oxTrustImsType");
			 * if(imValues.length > 0){ for(int i = 0 ; i < imValues.length ;
			 * i++){ ScimPersonIms im = new ScimPersonIms(); if(imValues[i] !=
			 * null){im.setValue(imValues[i]);im.setType(imTypes[i]);}
			 * ims.add(im); } }
			 */
        // destination.setIms(listOfIms);
        List<ScimPersonIms> ims = getAttributeListValue(source, ScimPersonIms.class, OX_TRUST_IMS_VALUE);
        destination.setIms(ims);
    }
    log.trace(" setting photos ");
    // getting photos
    if (source.getAttribute(OX_TRUST_PHOTOS) != null) {
        // List<ScimPersonPhotos> listOfPhotos = mapper.readValue(source.getAttribute(OX_TRUST_PHOTOS), new TypeReference<List<ScimPersonPhotos>>(){});
        /*
			 * List<ScimPersonPhotos> photos = new
			 * ArrayList<ScimPersonPhotos>(); String[] photoList =
			 * source.getAttributes("oxTrustPhotos"); String[] photoTypes =
			 * source.getAttributes("oxTrustPhotosType");
			 * 
			 * if(photoList.length > 0){ for(int i = 0 ; i < photoList.length ;
			 * i++){
			 * 
			 * ScimPersonPhotos photo = new ScimPersonPhotos(); if(photoList[i]
			 * !=
			 * null){photo.setValue(photoList[i]);photo.setType(photoTypes[i]);}
			 * photos.add(photo); } }
			 */
        // destination.setPhotos(listOfPhotos);
        List<ScimPersonPhotos> photos = getAttributeListValue(source, ScimPersonPhotos.class, OX_TRUST_PHOTOS);
        destination.setPhotos(photos);
    }
    log.trace(" setting userType ");
    if (source.getAttribute(OX_TRUST_USER_TYPE) != null) {
        destination.setUserType(source.getAttribute(OX_TRUST_USER_TYPE));
    }
    log.trace(" setting title ");
    if (source.getAttribute(OX_TRUST_TITLE) != null) {
        destination.setTitle(source.getAttribute(OX_TRUST_TITLE));
    }
    log.trace(" setting Locale ");
    if (source.getAttribute(OX_TRUST_LOCALE) != null) {
        destination.setLocale(source.getAttribute(OX_TRUST_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(OX_TRUST_ACTIVE) != null) {
        destination.setActive(source.getAttribute(OX_TRUST_ACTIVE));
    }
    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<ScimPersonGroups> groupsList = new ArrayList<ScimPersonGroups>();
        for (String groupDN : listOfGroups) {
            ScimPersonGroups group = new ScimPersonGroups();
            GluuGroup gluuGroup = groupService.getGroupByDn(groupDN);
            group.setValue(gluuGroup.getInum());
            group.setDisplay(gluuGroup.getDisplayName());
            groupsList.add(group);
        }
        destination.setGroups(groupsList);
    }
    // getting roles
    if (source.getAttribute(OX_TRUST_ROLE) != null) {
        // List<ScimRoles> listOfRoles = mapper.readValue(source.getAttribute(OX_TRUST_ROLE), new TypeReference<List<ScimRoles>>(){});
        /*
			 * List<ScimRoles> roles = new ArrayList<ScimRoles>(); String[]
			 * listRoles = source.getAttributes("oxTrustRole");
			 * if(listRoles.length > 0){ for(int i = 0 ; i < listRoles.length
			 * ;i++){ ScimRoles role = new ScimRoles(); if(listRoles[i] !=
			 * null){role.setValue(listRoles[i]);} roles.add(role); } }
			 */
        // destination.setRoles(listOfRoles);
        List<ScimRoles> roles = getAttributeListValue(source, ScimRoles.class, OX_TRUST_ROLE);
        destination.setRoles(roles);
    }
    log.trace(" getting entitlements ");
    // getting entitlements
    if (source.getAttribute(OX_TRUST_ENTITLEMENTS) != null) {
        // List<ScimEntitlements> listOfEnts = mapper.readValue(source.getAttribute(OX_TRUST_ENTITLEMENTS), new TypeReference<List<ScimEntitlements>>(){});
        /*
			 * List<ScimEntitlements> entitlements = new
			 * ArrayList<ScimEntitlements>(); String[] listEntitlements =
			 * source.getAttributes("oxTrustEntitlements");
			 * if(listEntitlements.length > 0){ for(int i = 0 ; i <
			 * listEntitlements.length ; i++ ){ ScimEntitlements ent = new
			 * ScimEntitlements(); if(listEntitlements[i] !=
			 * null){ent.setValue(listEntitlements[i]);} entitlements.add(ent);
			 * } }
			 */
        // destination.setEntitlements(listOfEnts);
        List<ScimEntitlements> entitlements = getAttributeListValue(source, ScimEntitlements.class, OX_TRUST_ENTITLEMENTS);
        destination.setEntitlements(entitlements);
    }
    // getting x509Certificates
    log.trace(" setting certs ");
    if (source.getAttribute(OX_TRUSTX509_CERTIFICATE) != null) {
        // List<Scimx509Certificates> listOfCerts = mapper.readValue(source.getAttribute(OX_TRUSTX509_CERTIFICATE), new TypeReference<List<Scimx509Certificates>>(){});
        /*
			 * List<Scimx509Certificates> certificates = new
			 * ArrayList<Scimx509Certificates>(); String[] listCertif =
			 * source.getAttributes("oxTrustx509Certificate");
			 * if(listCertif.length > 0){ for(int i = 0 ; i < listCertif.length
			 * ; i++){ Scimx509Certificates cert = new Scimx509Certificates();
			 * if(listCertif[i] != null){cert.setValue(listCertif[i]);}
			 * certificates.add(cert);
			 * 
			 * } }
			 */
        // destination.setX509Certificates(listOfCerts);
        List<Scimx509Certificates> x509Certificates = getAttributeListValue(source, Scimx509Certificates.class, OX_TRUSTX509_CERTIFICATE);
        destination.setX509Certificates(x509Certificates);
    }
    log.trace(" setting meta ");
    // getting meta data
    if (source.getAttribute(OX_TRUST_META_CREATED) != null) {
        destination.getMeta().setCreated(source.getAttribute(OX_TRUST_META_CREATED));
    }
    if (source.getAttribute(OX_TRUST_META_LAST_MODIFIED) != null) {
        destination.getMeta().setLastModified(source.getAttribute(OX_TRUST_META_LAST_MODIFIED));
    }
    if (source.getAttribute(OX_TRUST_META_VERSION) != null) {
        destination.getMeta().setVersion(source.getAttribute(OX_TRUST_META_VERSION));
    }
    // if (source.getAttribute(OX_TRUST_META_LOCATION) != null) {
    // destination.getMeta().setLocation(source.getAttribute(OX_TRUST_META_LOCATION));
    String location = source.getAttribute(OX_TRUST_META_LOCATION);
    if (location != null && !location.isEmpty()) {
        if (!location.startsWith("https://") && !location.startsWith("http://")) {
            location = appConfiguration.getBaseEndpoint() + location;
        }
    } else {
        location = appConfiguration.getBaseEndpoint() + "/scim/v1/Users/" + source.getInum();
    }
    destination.getMeta().setLocation(location);
    // }
    log.trace(" getting custom Attributes ");
    // getting custom Attributes
    List<GluuAttribute> listOfAttr = attributeService.getSCIMRelatedAttributes();
    if (listOfAttr != null && listOfAttr.size() > 0) {
        List<ScimCustomAttributes> listOfCustomAttr = new ArrayList<ScimCustomAttributes>();
        for (GluuAttribute attr : listOfAttr) {
            boolean isEmpty = attr.getOxMultivaluedAttribute() == null;
            if (!isEmpty && attr.getOxMultivaluedAttribute().getValue().equalsIgnoreCase("true")) {
                boolean isAttrEmpty = source.getAttributes(attr.getName()) == null;
                if (!isAttrEmpty) {
                    String[] arrayValues = source.getAttributes(attr.getName());
                    List<String> values = new ArrayList<String>(Arrays.asList(arrayValues));
                    ScimCustomAttributes scimAttr = new ScimCustomAttributes();
                    scimAttr.setName(attr.getName());
                    scimAttr.setValues(values);
                    listOfCustomAttr.add(scimAttr);
                }
            } else {
                boolean isAttrEmpty = source.getAttributes(attr.getName()) == null;
                if (!isAttrEmpty) {
                    List<String> values = new ArrayList<String>();
                    values.add(source.getAttribute(attr.getName()));
                    ScimCustomAttributes scimAttr = new ScimCustomAttributes();
                    scimAttr.setName(attr.getName());
                    scimAttr.setValues(values);
                    listOfCustomAttr.add(scimAttr);
                }
            }
        }
        if (listOfCustomAttr.size() > 0) {
            destination.setCustomAttributes(listOfCustomAttr);
        }
    }
    log.trace(" returning destination ");
    return destination;
}
Also used : ScimEntitlements(org.gluu.oxtrust.model.scim.ScimEntitlements) ArrayList(java.util.ArrayList) ScimPersonIms(org.gluu.oxtrust.model.scim.ScimPersonIms) ScimPersonEmails(org.gluu.oxtrust.model.scim.ScimPersonEmails) Scimx509Certificates(org.gluu.oxtrust.model.scim.Scimx509Certificates) ScimRoles(org.gluu.oxtrust.model.scim.ScimRoles) ScimPersonAddresses(org.gluu.oxtrust.model.scim.ScimPersonAddresses) GluuGroup(org.gluu.oxtrust.model.GluuGroup) GluuAttribute(org.xdi.model.GluuAttribute) ScimPersonPhotos(org.gluu.oxtrust.model.scim.ScimPersonPhotos) ScimPersonGroups(org.gluu.oxtrust.model.scim.ScimPersonGroups) ScimPersonPhones(org.gluu.oxtrust.model.scim.ScimPersonPhones) ScimPerson(org.gluu.oxtrust.model.scim.ScimPerson) ScimCustomAttributes(org.gluu.oxtrust.model.scim.ScimCustomAttributes)

Example 52 with GluuAttribute

use of org.xdi.model.GluuAttribute in project oxTrust by GluuFederation.

the class CopyUtils2 method copy.

/**
	 * Copy data from GluuCustomPerson object to Person object
	 * 
	 * @param source
	 * @param destination
	 * @return
	 * @throws Exception
	 */
public Person copy(GluuCustomPerson source, Person destination, List<GluuAttribute> attributes) {
    if (source == null) {
        return null;
    }
    if (destination == null) {
        destination = new Person();
    }
    destination.setInum(source.getInum());
    destination.setIname(source.getIname());
    destination.setUserId(source.getUid());
    destination.setFirstName(source.getGivenName());
    destination.setDisplayName(source.getDisplayName());
    destination.setLastName(source.getSurname());
    destination.setEmail(source.getMail());
    destination.setPassword(source.getUserPassword());
    destination.setCommonName(source.getGivenName() + " " + source.getDisplayName());
    List<PersonAttribute> personAttrList = new ArrayList<PersonAttribute>();
    for (GluuAttribute attribute : attributes) {
        PersonAttribute personAttr = new PersonAttribute(attribute.getName(), source.getAttribute(attribute.getName()), attribute.getDisplayName());
        personAttrList.add(personAttr);
    }
    destination.setPersonAttrList(personAttrList);
    return destination;
}
Also used : ArrayList(java.util.ArrayList) Person(org.gluu.oxtrust.model.Person) GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson) ScimPerson(org.gluu.oxtrust.model.scim.ScimPerson) PersonAttribute(org.gluu.oxtrust.model.PersonAttribute) GluuAttribute(org.xdi.model.GluuAttribute)

Example 53 with GluuAttribute

use of org.xdi.model.GluuAttribute in project oxTrust by GluuFederation.

the class UserExtensionLoadingStrategy 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);
    // List<GluuAttribute> scimCustomAttributes = attributeService.getSCIMRelatedAttributesImpl(attributeService.getCustomAttributes());
    List<GluuAttribute> scimCustomAttributes = attributeService.getSCIMRelatedAttributes();
    List<AttributeHolder> attributeHolders = new ArrayList<AttributeHolder>();
    for (GluuAttribute scimCustomAttribute : scimCustomAttributes) {
        AttributeHolder attributeHolder = new AttributeHolder();
        attributeHolder.setName(scimCustomAttribute.getName());
        if (scimCustomAttribute.getDataType() != null) {
            String typeStr = "";
            GluuAttributeDataType attributeDataType = scimCustomAttribute.getDataType();
            if (attributeDataType.equals(GluuAttributeDataType.STRING)) {
                typeStr = "string";
            } else if (attributeDataType.equals(GluuAttributeDataType.PHOTO)) {
                typeStr = "reference";
                attributeHolder.getReferenceTypes().add("external");
            } else if (attributeDataType.equals(GluuAttributeDataType.DATE)) {
                typeStr = "dateTime";
            } else if (attributeDataType.equals(GluuAttributeDataType.NUMERIC)) {
                typeStr = "decimal";
            } else {
                log.info(" NO MATCH: scimCustomAttribute.getDataType().getDisplayName() = " + scimCustomAttribute.getDataType().getDisplayName());
                typeStr = "string";
            }
            attributeHolder.setType(typeStr);
        }
        attributeHolder.setDescription(scimCustomAttribute.getDescription());
        attributeHolder.setRequired(scimCustomAttribute.isRequred());
        if (scimCustomAttribute.getOxMultivaluedAttribute() != null) {
            Boolean multiValued = Boolean.parseBoolean(scimCustomAttribute.getOxMultivaluedAttribute().getValue());
            attributeHolder.setMultiValued(multiValued);
        }
        attributeHolders.add(attributeHolder);
    }
    UserExtensionSchema userExtensionSchema = (UserExtensionSchema) schemaType;
    userExtensionSchema.setAttributeHolders(attributeHolders);
    return userExtensionSchema;
}
Also used : Meta(org.gluu.oxtrust.model.scim2.Meta) AttributeHolder(org.gluu.oxtrust.model.scim2.schema.AttributeHolder) ArrayList(java.util.ArrayList) UserExtensionSchema(org.gluu.oxtrust.model.scim2.schema.extension.UserExtensionSchema) GluuAttributeDataType(org.xdi.model.GluuAttributeDataType) GluuAttribute(org.xdi.model.GluuAttribute)

Example 54 with GluuAttribute

use of org.xdi.model.GluuAttribute in project oxAuth by GluuFederation.

the class AttributeService method getAttributeByDn.

/**
     * returns GluuAttribute by Dn
     *
     * @return GluuAttribute
     */
public GluuAttribute getAttributeByDn(String dn) {
    GluuAttribute gluuAttribute = (GluuAttribute) cacheService.get(CACHE_ATTRIBUTE, dn);
    if (gluuAttribute == null) {
        gluuAttribute = ldapEntryManager.find(GluuAttribute.class, dn);
        cacheService.put(CACHE_ATTRIBUTE, dn, gluuAttribute);
    } else {
        log.trace("Get attribute from cache by Dn '{}'", dn);
    }
    return gluuAttribute;
}
Also used : GluuAttribute(org.xdi.model.GluuAttribute)

Example 55 with GluuAttribute

use of org.xdi.model.GluuAttribute in project oxTrust by GluuFederation.

the class TrustRelationshipInventoryAction method setCustomAttributes.

private void setCustomAttributes(List<GluuSAMLTrustRelationship> trustRelationships) {
    List<GluuAttribute> attributes = attributeService.getAllPersonAttributes(GluuUserRole.ADMIN);
    HashMap<String, GluuAttribute> attributesByDNs = attributeService.getAttributeMapByDNs(attributes);
    for (GluuSAMLTrustRelationship trustRelationship : trustRelationships) {
        trustRelationship.setReleasedCustomAttributes(attributeService.getCustomAttributesByAttributeDNs(trustRelationship.getReleasedAttributes(), attributesByDNs));
    }
}
Also used : GluuSAMLTrustRelationship(org.gluu.oxtrust.model.GluuSAMLTrustRelationship) GluuAttribute(org.xdi.model.GluuAttribute)

Aggregations

GluuAttribute (org.xdi.model.GluuAttribute)64 ArrayList (java.util.ArrayList)24 GluuCustomAttribute (org.gluu.oxtrust.model.GluuCustomAttribute)15 JSONObject (org.codehaus.jettison.json.JSONObject)9 JSONArray (org.codehaus.jettison.json.JSONArray)8 GluuAttributeDataType (org.xdi.model.GluuAttributeDataType)6 IOException (java.io.IOException)5 BigDecimal (java.math.BigDecimal)5 Date (java.util.Date)5 HashMap (java.util.HashMap)5 GluuCustomPerson (org.gluu.oxtrust.model.GluuCustomPerson)5 Extension (org.gluu.oxtrust.model.scim2.Extension)5 JwtSubClaimObject (org.xdi.oxauth.model.jwt.JwtSubClaimObject)5 Filter (com.unboundid.ldap.sdk.Filter)4 List (java.util.List)4 GluuSAMLTrustRelationship (org.gluu.oxtrust.model.GluuSAMLTrustRelationship)4 Claim (org.xdi.oxauth.model.authorize.Claim)4 Scope (org.xdi.oxauth.model.common.Scope)4 PairwiseIdentifier (org.xdi.oxauth.model.ldap.PairwiseIdentifier)4 DynamicScopeExternalContext (org.xdi.oxauth.service.external.context.DynamicScopeExternalContext)4