use of org.gluu.oxtrust.model.scim.ScimPersonPhones in project oxTrust by GluuFederation.
the class CopyUtils method patch.
public GluuCustomPerson patch(ScimPersonPatch source, GluuCustomPerson destination, boolean isUpdate) throws Exception {
if (source == null || !isValidData(source, isUpdate)) {
return null;
}
if (destination == null) {
log.trace(" creating a new Scimperson instant ");
destination = new GluuCustomPerson();
}
log.trace(" setting userName ");
log.trace(" source.getUserName() :" + source.getUserName() + "h");
log.trace(" userName length : " + source.getUserName().length());
if (source.getUserName() != null && source.getUserName().length() > 0) {
destination.setUid(source.getUserName());
}
log.trace(" setting givenname ");
if (source.getName().getGivenName() != null && source.getName().getGivenName().length() > 0) {
destination.setGivenName(source.getName().getGivenName());
}
log.trace(" setting famillyname ");
if (source.getName().getFamilyName() != null && source.getName().getGivenName().length() > 0) {
destination.setSurname(source.getName().getFamilyName());
}
log.trace(" setting middlename ");
if (source.getName().getMiddleName() != null && source.getName().getMiddleName().length() > 0) {
destination.setAttribute(OX_TRUST_MIDDLE_NAME, source.getName().getMiddleName());
}
log.trace(" setting honor");
if (source.getName().getHonorificPrefix() != null && source.getName().getHonorificPrefix().length() > 0) {
destination.setAttribute(OX_TRUSTHONORIFIC_PREFIX, source.getName().getHonorificPrefix());
}
if (source.getName().getHonorificSuffix() != null && source.getName().getHonorificSuffix().length() > 0) {
destination.setAttribute(OX_TRUSTHONORIFIC_SUFFIX, source.getName().getHonorificSuffix());
}
log.trace(" setting displayname ");
if (source.getDisplayName() != null && source.getDisplayName().length() > 0) {
destination.setDisplayName(source.getDisplayName());
}
log.trace(" setting externalID ");
if (source.getExternalId() != null && source.getExternalId().length() > 0) {
destination.setAttribute(OX_TRUST_EXTERNAL_ID, source.getExternalId());
}
log.trace(" setting nickname ");
if (source.getNickName() != null && source.getNickName().length() > 0) {
destination.setAttribute(OX_TRUST_NICK_NAME, source.getNickName());
}
log.trace(" setting profileURL ");
if (source.getProfileUrl() != null && source.getProfileUrl().length() > 0) {
destination.setAttribute(OX_TRUST_PROFILE_URL, source.getProfileUrl());
}
// getting emails
log.trace(" setting emails ");
if (source.getEmails() != null && source.getEmails().size() > 0) {
List<ScimPersonEmailsPatch> emails = source.getEmails();
String[] emailsList = new String[source.getEmails().size()];
String[] emailsTypes = new String[source.getEmails().size()];
String[] emailsPrimary = new String[source.getEmails().size()];
int emailsSize = 0;
if (destination.getAttributes(OX_TRUST_EMAIL) != null && destination.getAttributes(OX_TRUST_EMAIL).length > 0) {
emailsList = destination.getAttributes(OX_TRUST_EMAIL);
emailsTypes = destination.getAttributes(OX_TRUST_EMAIL_TYPE);
emailsPrimary = destination.getAttributes(OX_TRUST_EMAIL_PRIMARY);
// emailsSize =
// destination.getAttributes("oxTrustEmail").length;
}
boolean emailIsFound = false;
while (emailIsFound != true) {
if (emails.get(0).getPrimary() == "true") {
for (String oneEmail : emailsList) {
if (oneEmail == emails.get(0).getValue()) {
if (emails.get(0).getPrimary() != null && emails.get(0).getPrimary().length() > 0) {
emailsPrimary[emailsSize] = emails.get(0).getPrimary();
}
emailIsFound = true;
}
emailsSize++;
}
emailsSize = 0;
for (String onePrimary : emailsPrimary) {
if (onePrimary == emails.get(0).getPrimary()) {
if (emails.get(0).getPrimary() != null && emails.get(0).getPrimary().length() > 0) {
emailsPrimary[emailsSize] = "false";
}
}
emailsSize++;
}
if (emails.get(0).getValue() != null && emails.get(0).getValue().length() > 0) {
emailsList[emailsSize] = emails.get(0).getValue();
}
if (emails.get(0).getType() != null && emails.get(0).getType().length() > 0) {
emailsTypes[emailsSize] = emails.get(0).getType();
}
if (emails.get(0).getPrimary() != null && emails.get(0).getPrimary().length() > 0) {
emailsPrimary[emailsSize] = emails.get(0).getPrimary();
}
emailIsFound = true;
}
if (emails.get(0).getPrimary() == "false") {
emailsSize = emailsList.length;
if (emails.get(0).getValue() != null && emails.get(0).getValue().length() > 0) {
emailsList[emailsSize] = emails.get(0).getValue();
}
if (emails.get(0).getType() != null && emails.get(0).getType().length() > 0) {
emailsTypes[emailsSize] = emails.get(0).getType();
}
if (emails.get(0).getPrimary() != null && emails.get(0).getPrimary().length() > 0) {
emailsPrimary[emailsSize] = emails.get(0).getPrimary();
}
emailIsFound = true;
}
}
destination.setAttribute(OX_TRUST_EMAIL, emailsList);
destination.setAttribute(OX_TRUST_EMAIL_TYPE, emailsTypes);
destination.setAttribute(OX_TRUST_EMAIL_PRIMARY, emailsPrimary);
}
// getting addresses
log.trace(" settting addresses ");
if (source.getAddresses() != null && source.getAddresses().size() == 2) {
List<ScimPersonAddressesPatch> addresses = source.getAddresses();
String[] street = new String[source.getAddresses().size()];
String[] formatted = new String[source.getAddresses().size()];
String[] locality = new String[source.getAddresses().size()];
String[] region = new String[source.getAddresses().size()];
String[] postalCode = new String[source.getAddresses().size()];
String[] country = new String[source.getAddresses().size()];
String[] addressType = new String[source.getAddresses().size()];
String[] addressPrimary = new String[source.getAddresses().size()];
int addressSize = 0;
if (destination.getAttributes(OX_TRUST_STREET) != null && destination.getAttributes(OX_TRUST_STREET).length > 0) {
street = destination.getAttributes(OX_TRUST_STREET);
formatted = destination.getAttributes(OX_TRUST_ADDRESS_FORMATTED);
locality = destination.getAttributes(OX_TRUST_LOCALITY);
region = destination.getAttributes(OX_TRUST_REGION);
postalCode = destination.getAttributes(OX_TRUST_POSTAL_CODE);
country = destination.getAttributes(OX_TRUST_COUNTRY);
addressType = destination.getAttributes(OX_TRUST_ADDRESS_TYPE);
addressPrimary = destination.getAttributes(OX_TRUST_ADDRESS_PRIMARY);
// addressSize =
// destination.getAttributes("oxTrustStreet").length;
}
for (String oneStreet : street) {
if (oneStreet == addresses.get(0).getStreetAddress()) {
if (addresses.get(1).getStreetAddress() != null && addresses.get(1).getStreetAddress().length() > 0) {
street[addressSize] = addresses.get(1).getStreetAddress();
}
if (addresses.get(1).getFormatted() != null && addresses.get(1).getFormatted().length() > 0) {
formatted[addressSize] = addresses.get(1).getFormatted();
}
if (addresses.get(1).getLocality() != null && addresses.get(1).getLocality().length() > 0) {
locality[addressSize] = addresses.get(1).getLocality();
}
if (addresses.get(1).getRegion() != null && addresses.get(1).getRegion().length() > 0) {
region[addressSize] = addresses.get(1).getRegion();
}
if (addresses.get(1).getPostalCode() != null && addresses.get(1).getPostalCode().length() > 0) {
postalCode[addressSize] = addresses.get(1).getPostalCode();
}
if (addresses.get(1).getCountry() != null && addresses.get(1).getCountry().length() > 0) {
country[addressSize] = addresses.get(1).getCountry();
}
if (addresses.get(1).getType() != null && addresses.get(1).getType().length() > 0) {
addressType[addressSize] = addresses.get(1).getType();
}
if (addresses.get(1).getPrimary() != null && addresses.get(1).getPrimary().length() > 0) {
addressPrimary[addressSize] = addresses.get(1).getPrimary();
}
}
addressSize++;
}
destination.setAttribute(OX_TRUST_STREET, street);
destination.setAttribute(OX_TRUST_LOCALITY, locality);
destination.setAttribute(OX_TRUST_REGION, region);
destination.setAttribute(OX_TRUST_POSTAL_CODE, postalCode);
destination.setAttribute(OX_TRUST_COUNTRY, country);
destination.setAttribute(OX_TRUST_ADDRESS_FORMATTED, formatted);
destination.setAttribute(OX_TRUST_ADDRESS_PRIMARY, addressPrimary);
destination.setAttribute(OX_TRUST_ADDRESS_TYPE, addressType);
}
// getting phone numbers;
log.trace(" setting phoneNumbers ");
if (source.getPhoneNumbers() != null && source.getPhoneNumbers().size() > 0) {
List<ScimPersonPhonesPatch> phones = source.getPhoneNumbers();
String[] phoneNumber = new String[source.getPhoneNumbers().size()];
String[] phoneType = new String[source.getPhoneNumbers().size()];
int phoneSize = 0;
if (destination.getAttributes(OX_TRUST_PHONE_VALUE) != null && destination.getAttributes(OX_TRUST_PHONE_VALUE).length > 0) {
phoneNumber = destination.getAttributes(OX_TRUST_PHONE_VALUE);
phoneType = destination.getAttributes(OX_TRUST_PHONE_TYPE);
// phoneSize =
// destination.getAttributes("oxTrustPhoneValue").length;
}
for (ScimPersonPhones phone : phones) {
if (phone.getValue() != null && phone.getValue().length() > 0) {
phoneNumber[phoneSize] = phone.getValue();
}
if (phone.getType() != null && phone.getType().length() > 0) {
phoneType[phoneSize] = phone.getType();
}
phoneSize++;
}
destination.setAttribute(OX_TRUST_PHONE_VALUE, phoneNumber);
destination.setAttribute(OX_TRUST_PHONE_TYPE, phoneType);
}
// getting ims
log.trace(" setting ims ");
if (source.getIms() != null && source.getIms().size() > 0) {
List<ScimPersonImsPatch> ims = source.getIms();
String[] imValue = new String[source.getIms().size()];
String[] imType = new String[source.getIms().size()];
int imSize = 0;
if (destination.getAttributes(OX_TRUST_IMS_VALUE) != null && destination.getAttributes(OX_TRUST_IMS_VALUE).length > 0) {
imValue = destination.getAttributes(OX_TRUST_IMS_VALUE);
imType = destination.getAttributes("oxTrustImsType");
imSize = destination.getAttributes(OX_TRUST_IMS_VALUE).length;
}
for (ScimPersonIms im : ims) {
if (im.getValue() != null && im.getValue().length() > 0) {
imValue[imSize] = im.getValue();
}
if (im.getType() != null && im.getType().length() > 0) {
imType[imSize] = im.getType();
}
imSize++;
}
destination.setAttribute(OX_TRUST_IMS_VALUE, imValue);
destination.setAttribute("oxTrustImsType", imType);
}
// getting Photos
log.trace(" setting photos ");
if (source.getPhotos() != null && source.getPhotos().size() > 0) {
List<ScimPersonPhotosPatch> photos = source.getPhotos();
String[] photoType = new String[source.getPhotos().size()];
String[] photoValue = new String[source.getPhotos().size()];
int photoSize = 0;
if (destination.getAttributes(OX_TRUST_PHOTOS) != null && destination.getAttributes(OX_TRUST_PHOTOS).length > 0) {
photoType = destination.getAttributes(OX_TRUST_PHOTOS_TYPE);
photoValue = destination.getAttributes(OX_TRUST_PHOTOS);
photoSize = destination.getAttributes(OX_TRUST_PHOTOS_TYPE).length;
}
for (ScimPersonPhotos photo : photos) {
if (photo.getType() != null && photo.getType().length() > 0) {
photoType[photoSize] = photo.getType();
}
if (photo.getValue() != null && photo.getValue().length() > 0) {
photoValue[photoSize] = photo.getValue();
}
photoSize++;
}
destination.setAttribute(OX_TRUST_PHOTOS_TYPE, photoType);
destination.setAttribute(OX_TRUST_PHOTOS, photoValue);
}
if (source.getUserType() != null && source.getUserType().length() > 0) {
destination.setAttribute(OX_TRUST_USER_TYPE, source.getUserType());
}
if (source.getTitle() != null && source.getTitle().length() > 0) {
destination.setAttribute(OX_TRUST_TITLE, source.getTitle());
}
if (source.getPreferredLanguage() != null && source.getPreferredLanguage().length() > 0) {
destination.setPreferredLanguage(source.getPreferredLanguage());
}
if (source.getLocale() != null && source.getLocale().length() > 0) {
destination.setAttribute(OX_TRUST_LOCALE, source.getLocale());
}
if (source.getTimezone() != null && source.getTimezone().length() > 0) {
destination.setTimezone(source.getTimezone());
}
if (source.getActive() != null && source.getActive().length() > 0) {
destination.setAttribute(OX_TRUST_ACTIVE, source.getActive());
}
if (source.getPassword() != null && source.getPassword().length() > 0) {
destination.setUserPassword(source.getPassword());
}
// getting user groups
log.trace(" setting groups ");
if (source.getGroups() != null && source.getGroups().size() > 0) {
List<ScimPersonGroupsPatch> listGroups = source.getGroups();
List<String> members = new ArrayList<String>();
for (ScimPersonGroups group : listGroups) {
members.add(groupService.getDnForGroup(group.getValue()));
}
destination.setMemberOf(members);
}
// getting roles
log.trace(" setting roles ");
if (source.getRoles() != null && source.getRoles().size() > 0) {
List<ScimRolesPatch> roles = source.getRoles();
String[] scimRole = new String[source.getRoles().size()];
int rolesSize = 0;
if (destination.getAttributes(OX_TRUST_ROLE) != null && destination.getAttributes(OX_TRUST_ROLE).length > 0) {
scimRole = destination.getAttributes(OX_TRUST_ROLE);
rolesSize = destination.getAttributes(OX_TRUST_ROLE).length;
}
for (ScimRoles role : roles) {
if (role.getValue() != null && role.getValue().length() > 0) {
scimRole[rolesSize] = role.getValue();
}
rolesSize++;
}
destination.setAttribute(OX_TRUST_ROLE, scimRole);
}
// getting entitlements
log.trace(" setting entitlements ");
if (source.getEntitlements() != null && source.getEntitlements().size() > 0) {
List<ScimEntitlementsPatch> ents = source.getEntitlements();
String[] listEnts = new String[source.getEntitlements().size()];
int entsSize = 0;
if (destination.getAttributes(OX_TRUST_ENTITLEMENTS) != null && destination.getAttributes(OX_TRUST_ENTITLEMENTS).length > 0) {
listEnts = destination.getAttributes(OX_TRUST_ENTITLEMENTS);
entsSize = destination.getAttributes(OX_TRUST_ENTITLEMENTS).length;
}
for (ScimEntitlements ent : ents) {
if (ent.getValue() != null && ent.getValue().length() > 0) {
listEnts[entsSize] = ent.getValue();
}
entsSize++;
}
destination.setAttribute(OX_TRUST_ENTITLEMENTS, listEnts);
}
// getting x509Certificates
log.trace(" setting certs ");
if (source.getX509Certificates() != null && source.getX509Certificates().size() > 0) {
List<Scimx509CertificatesPatch> certs = source.getX509Certificates();
String[] listCerts = new String[source.getX509Certificates().size()];
int certsSize = 0;
if (destination.getAttributes(OX_TRUSTX509_CERTIFICATE) != null && destination.getAttributes(OX_TRUSTX509_CERTIFICATE).length > 0) {
listCerts = destination.getAttributes(OX_TRUSTX509_CERTIFICATE);
certsSize = destination.getAttributes(OX_TRUSTX509_CERTIFICATE).length;
}
for (Scimx509Certificates cert : certs) {
if (cert.getValue() != null && cert.getValue().length() > 0) {
listCerts[certsSize] = cert.getValue();
}
certsSize++;
}
destination.setAttribute(OX_TRUSTX509_CERTIFICATE, listCerts);
}
// getting meta
log.trace(" setting meta ");
if (source.getMeta().getCreated() != null && source.getMeta().getCreated().length() > 0) {
destination.setAttribute(OX_TRUST_META_CREATED, source.getMeta().getCreated());
}
if (source.getMeta().getLastModified() != null && source.getMeta().getLastModified().length() > 0) {
destination.setAttribute(OX_TRUST_META_LAST_MODIFIED, source.getMeta().getLastModified());
}
if (source.getMeta().getVersion() != null && source.getMeta().getVersion().length() > 0) {
destination.setAttribute(OX_TRUST_META_VERSION, source.getMeta().getVersion());
}
if (source.getMeta().getLocation() != null && source.getMeta().getLocation().length() > 0) {
destination.setAttribute(OX_TRUST_META_LOCATION, source.getMeta().getLocation());
}
setGluuStatus(source, destination);
return destination;
}
use of org.gluu.oxtrust.model.scim.ScimPersonPhones in project oxTrust by GluuFederation.
the class CopyUtilsTestCreate method testCopyScim1CreateException.
@Test
public void testCopyScim1CreateException() throws Exception {
GluuCustomPerson destination = null;
ScimPerson source = new ScimPerson();
source.setActive("true");
ScimPersonAddresses address = new ScimPersonAddresses();
address.setCountry("country");
address.setFormatted("formatted");
address.setLocality("locality");
address.setPostalCode("postalCode");
address.setPrimary("address_primary");
address.setRegion("region");
address.setStreetAddress("streetAddress");
address.setType("address_type");
List<ScimPersonAddresses> addresses = new ArrayList<ScimPersonAddresses>();
addresses.add(address);
source.setAddresses(addresses);
List<ScimCustomAttributes> customAttributes = new ArrayList<ScimCustomAttributes>();
ScimCustomAttributes customattribute = new ScimCustomAttributes();
customattribute.setName("custom_name");
List<String> values = new ArrayList<String>();
String value = "value";
values.add(value);
customattribute.setValues(values);
customAttributes.add(customattribute);
source.setCustomAttributes(customAttributes);
source.setDisplayName("displayName");
ScimPersonEmails email = new ScimPersonEmails();
email.setPrimary("email_primary");
email.setType("email_type");
email.setValue("email_value");
List<ScimPersonEmails> emails = new ArrayList<ScimPersonEmails>();
emails.add(email);
source.setEmails(emails);
ScimEntitlements entitlement = new ScimEntitlements();
entitlement.setValue("entitlement_value");
List<ScimEntitlements> entitlements = new ArrayList<ScimEntitlements>();
entitlements.add(entitlement);
source.setEntitlements(entitlements);
source.setExternalId("externalId");
ScimPersonGroups group = new ScimPersonGroups();
group.setDisplay("group_display");
group.setValue("group_value");
List<ScimPersonGroups> groups = new ArrayList<ScimPersonGroups>();
groups.add(group);
source.setGroups(groups);
source.setId("id");
ScimPersonIms personims = new ScimPersonIms();
personims.setType("ims_type");
personims.setValue("ims_value");
List<ScimPersonIms> ims = new ArrayList<ScimPersonIms>();
ims.add(personims);
source.setIms(ims);
source.setLocale("locale");
PersonMeta meta = new PersonMeta();
meta.setCreated("created");
meta.setLastModified("lastModified");
meta.setLocation("location");
meta.setVersion("version");
source.setMeta(meta);
ScimName name = new ScimName();
name.setFamilyName("familyName");
name.setGivenName("givenName");
name.setHonorificPrefix("honorificPrefix");
name.setHonorificSuffix("honorificSuffix");
name.setMiddleName("middleName");
source.setName(name);
source.setNickName("nickName");
source.setPassword("password");
ScimPersonPhones phonenumber = new ScimPersonPhones();
phonenumber.setType("phone_type");
phonenumber.setValue("phone_value");
List<ScimPersonPhones> phoneNumbers = new ArrayList<ScimPersonPhones>();
phoneNumbers.add(phonenumber);
source.setPhoneNumbers(phoneNumbers);
ScimPersonPhotos photo = new ScimPersonPhotos();
photo.setType("photo_type");
photo.setValue("photo_value");
List<ScimPersonPhotos> photos = new ArrayList<ScimPersonPhotos>();
photos.add(photo);
source.setPhotos(photos);
source.setPreferredLanguage("preferredLanguage");
source.setProfileUrl("profileUrl");
ScimRoles role = new ScimRoles();
role.setValue("role_value");
List<ScimRoles> roles = new ArrayList<ScimRoles>();
roles.add(role);
source.setRoles(roles);
List<String> schemas = new ArrayList<String>();
schemas.add("shema");
source.setSchemas(schemas);
source.setTimezone("timezone");
source.setTitle("title");
source.setUserName("exception");
source.setUserType("userType");
Scimx509Certificates cert = new Scimx509Certificates();
cert.setValue("cert_value");
List<Scimx509Certificates> x509Certificates = new ArrayList<Scimx509Certificates>();
x509Certificates.add(cert);
source.setX509Certificates(x509Certificates);
GluuCustomPerson copy = copyUtils.copy(source, destination, false);
assertNull(copy);
}
use of org.gluu.oxtrust.model.scim.ScimPersonPhones in project oxTrust by GluuFederation.
the class CopyUtilsTestCreate method testCopyScim1FilledCreate.
@Test
public void testCopyScim1FilledCreate() throws Exception {
GluuCustomPerson destination = new GluuCustomPerson();
ScimPerson source = new ScimPerson();
source.setActive("true");
ScimPersonAddresses address = new ScimPersonAddresses();
address.setCountry("country");
address.setFormatted("formatted");
address.setLocality("locality");
address.setPostalCode("postalCode");
address.setPrimary("address_primary");
address.setRegion("region");
address.setStreetAddress("streetAddress");
address.setType("address_type");
List<ScimPersonAddresses> addresses = new ArrayList<ScimPersonAddresses>();
addresses.add(address);
source.setAddresses(addresses);
List<ScimCustomAttributes> customAttributes = new ArrayList<ScimCustomAttributes>();
ScimCustomAttributes customattribute = new ScimCustomAttributes();
customattribute.setName("custom_name");
List<String> values = new ArrayList<String>();
String value = "value";
values.add(value);
customattribute.setValues(values);
customAttributes.add(customattribute);
source.setCustomAttributes(customAttributes);
source.setDisplayName("displayName");
ScimPersonEmails email = new ScimPersonEmails();
email.setPrimary("email_primary");
email.setType("email_type");
email.setValue("email_value");
List<ScimPersonEmails> emails = new ArrayList<ScimPersonEmails>();
emails.add(email);
source.setEmails(emails);
ScimEntitlements entitlement = new ScimEntitlements();
entitlement.setValue("entitlement_value");
List<ScimEntitlements> entitlements = new ArrayList<ScimEntitlements>();
entitlements.add(entitlement);
source.setEntitlements(entitlements);
source.setExternalId("externalId");
ScimPersonGroups group = new ScimPersonGroups();
group.setDisplay("group_display");
group.setValue("group_value");
List<ScimPersonGroups> groups = new ArrayList<ScimPersonGroups>();
groups.add(group);
source.setGroups(groups);
source.setId("id");
ScimPersonIms personims = new ScimPersonIms();
personims.setType("ims_type");
personims.setValue("ims_value");
List<ScimPersonIms> ims = new ArrayList<ScimPersonIms>();
ims.add(personims);
source.setIms(ims);
source.setLocale("locale");
PersonMeta meta = new PersonMeta();
meta.setCreated("created");
meta.setLastModified("lastModified");
meta.setLocation("location");
meta.setVersion("version");
source.setMeta(meta);
ScimName name = new ScimName();
name.setFamilyName("familyName");
name.setGivenName("givenName");
name.setHonorificPrefix("honorificPrefix");
name.setHonorificSuffix("honorificSuffix");
name.setMiddleName("middleName");
source.setName(name);
source.setNickName("nickName");
source.setPassword("password");
ScimPersonPhones phonenumber = new ScimPersonPhones();
phonenumber.setType("phone_type");
phonenumber.setValue("phone_value");
List<ScimPersonPhones> phoneNumbers = new ArrayList<ScimPersonPhones>();
phoneNumbers.add(phonenumber);
source.setPhoneNumbers(phoneNumbers);
ScimPersonPhotos photo = new ScimPersonPhotos();
photo.setType("photo_type");
photo.setValue("photo_value");
List<ScimPersonPhotos> photos = new ArrayList<ScimPersonPhotos>();
photos.add(photo);
source.setPhotos(photos);
source.setPreferredLanguage("preferredLanguage");
source.setProfileUrl("profileUrl");
ScimRoles role = new ScimRoles();
role.setValue("role_value");
List<ScimRoles> roles = new ArrayList<ScimRoles>();
roles.add(role);
source.setRoles(roles);
List<String> schemas = new ArrayList<String>();
schemas.add("shema");
source.setSchemas(schemas);
source.setTimezone("timezone");
source.setTitle("title");
source.setUserName("userName");
source.setUserType("userType");
Scimx509Certificates cert = new Scimx509Certificates();
cert.setValue("cert_value");
List<Scimx509Certificates> x509Certificates = new ArrayList<Scimx509Certificates>();
x509Certificates.add(cert);
source.setX509Certificates(x509Certificates);
GluuCustomPerson copy = copyUtils.copy(source, destination, false);
assertNotNull(copy);
assertEquals(copy.getUid(), "userName");
assertEquals(copy.getGivenName(), "givenName");
assertEquals(copy.getSurname(), "familyName");
assertEquals(copy.getDisplayName(), "displayName");
assertEquals(copy.getPreferredLanguage(), "preferredLanguage");
assertEquals(copy.getTimezone(), "timezone");
assertEquals(copy.getUserPassword(), "password");
assertNotNull(copy.getMemberOf());
assertEquals(copy.getMemberOf().size(), 1);
assertEquals(copy.getMemberOf().get(0), "Mocked DN");
assertEquals(copy.getAttribute(GLUU_STATUS), "true");
assertNull(copy.getAttribute(OX_TRUST_PHOTOS_TYPE));
assertNull(copy.getAttribute(OX_TRUST_PHONE_TYPE));
assertNull(copy.getAttribute(OX_TRUST_ADDRESS_PRIMARY));
assertNull(copy.getAttribute(OX_TRUST_ADDRESS_TYPE));
assertNull(copy.getAttribute(OX_TRUST_COUNTRY));
assertNull(copy.getAttribute(OX_TRUST_POSTAL_CODE));
assertNull(copy.getAttribute(OX_TRUST_REGION));
assertNull(copy.getAttribute(OX_TRUST_LOCALITY));
assertNull(copy.getAttribute(OX_TRUST_ADDRESS_FORMATTED));
assertNull(copy.getAttribute(OX_TRUST_STREET));
assertNull(copy.getAttribute(OX_TRUST_EMAIL_PRIMARY));
assertNull(copy.getAttribute(OX_TRUST_EMAIL_TYPE));
assertEquals(copy.getAttribute(OX_TRUST_META_LOCATION), "location");
assertEquals(copy.getAttribute(OX_TRUST_META_VERSION), "version");
assertEquals(copy.getAttribute(OX_TRUST_META_LAST_MODIFIED), "lastModified");
assertEquals(copy.getAttribute(OX_TRUST_META_CREATED), "created");
assertEquals(copy.getAttribute(OX_TRUSTX509_CERTIFICATE), "[{\"value\":\"cert_value\"}]");
assertEquals(copy.getAttribute(OX_TRUST_ENTITLEMENTS), "[{\"value\":\"entitlement_value\"}]");
assertEquals(copy.getAttribute(OX_TRUST_ROLE), "[{\"value\":\"role_value\"}]");
assertEquals(copy.getAttribute(OX_TRUST_ACTIVE), "true");
assertEquals(copy.getAttribute(OX_TRUST_LOCALE), "locale");
assertEquals(copy.getAttribute(OX_TRUST_TITLE), "title");
assertEquals(copy.getAttribute(OX_TRUST_USER_TYPE), "userType");
assertEquals(copy.getAttribute(OX_TRUST_PHOTOS), "[{\"value\":\"photo_value\",\"type\":\"photo_type\"}]");
assertEquals(copy.getAttribute(OX_TRUST_IMS_VALUE), "[{\"value\":\"ims_value\",\"type\":\"ims_type\"}]");
assertEquals(copy.getAttribute(OX_TRUST_PHONE_VALUE), "[{\"value\":\"phone_value\",\"type\":\"phone_type\"}]");
assertEquals(copy.getAttribute(OX_TRUST_ADDRESSES), "[{\"type\":\"address_type\",\"streetAddress\":\"streetAddress\",\"locality\":\"locality\",\"region\":\"region\",\"postalCode\":\"postalCode\",\"country\":\"country\",\"formatted\":\"formatted\",\"primary\":\"address_primary\"}]");
assertEquals(copy.getAttribute(OX_TRUST_EMAIL), "[{\"value\":\"email_value\",\"type\":\"email_type\",\"primary\":\"email_primary\"}]");
assertEquals(copy.getAttribute(OX_TRUST_PROFILE_URL), "profileUrl");
assertEquals(copy.getAttribute(OX_TRUST_NICK_NAME), "nickName");
assertEquals(copy.getAttribute(OX_TRUST_EXTERNAL_ID), "externalId");
assertEquals(copy.getAttribute(OX_TRUSTHONORIFIC_SUFFIX), "honorificSuffix");
assertEquals(copy.getAttribute(OX_TRUSTHONORIFIC_PREFIX), "honorificPrefix");
assertEquals(copy.getAttribute(OX_TRUST_MIDDLE_NAME), "middleName");
assertNull(copy.getAssociatedClient());
assertNull(copy.getBaseDn());
assertNull(copy.getCommonName());
List<GluuCustomAttribute> customAttributes2 = copy.getCustomAttributes();
assertNotNull(customAttributes2);
assertEquals(customAttributes2.size(), 32);
assertEquals(copy.getDisplayName(), "displayName");
assertNull(copy.getDn());
assertEquals(copy.getGivenName(), "givenName");
assertNull(copy.getGluuAllowPublication());
GluuCustomAttribute gluuCustomAttribute = copy.getGluuCustomAttribute("custom_name");
assertNotNull(gluuCustomAttribute);
assertEquals(gluuCustomAttribute.getName(), "custom_name");
assertEquals(gluuCustomAttribute.getValue(), "value");
assertNull(gluuCustomAttribute.getDate());
assertEquals(gluuCustomAttribute.getDisplayValue(), "value");
assertNull(gluuCustomAttribute.getMetadata());
assertEquals(gluuCustomAttribute.getValues()[0], "value");
assertNull(copy.getGluuOptOuts());
assertNull(copy.getIname());
assertNull(copy.getMail());
assertEquals(copy.getMemberOf().get(0), "Mocked DN");
assertNull(copy.getNetworkPoken());
assertNull(copy.getCreationDate());
assertEquals(copy.getPreferredLanguage(), "preferredLanguage");
assertNull(copy.getSLAManager());
assertNull(copy.getSourceServerName());
assertNull(copy.getStatus());
assertEquals(copy.getSurname(), "familyName");
assertEquals(copy.getTimezone(), "timezone");
assertEquals(copy.getUid(), "userName");
assertEquals(copy.getUserPassword(), "password");
}
use of org.gluu.oxtrust.model.scim.ScimPersonPhones in project oxTrust by GluuFederation.
the class CopyUtilsTestCreate method testCopyScim1FilledCreateExisting.
@Test
public void testCopyScim1FilledCreateExisting() throws Exception {
GluuCustomPerson destination = new GluuCustomPerson();
destination.setAllowPublication(true);
List<String> associatedClientDNs = new ArrayList<String>();
associatedClientDNs.add("a");
associatedClientDNs.add("b");
associatedClientDNs.add("c");
destination.setAssociatedClient(associatedClientDNs);
destination.setBaseDn("dn");
destination.setAttribute(OX_TRUST_NICK_NAME, "original nickname");
destination.setAttribute(OX_TRUST_PROFILE_URL, "original url");
destination.setCommonName("CN");
destination.setGivenName("original givenname");
destination.setPreferredLanguage("Nederlands");
destination.setAttribute(OX_TRUST_ENTITLEMENTS, "[{\"value\":\"original entitlement_value\"}]");
ScimPerson source = new ScimPerson();
source.setActive("true");
ScimPersonAddresses address = new ScimPersonAddresses();
address.setCountry("country");
address.setFormatted("formatted");
address.setLocality("locality");
address.setPostalCode("postalCode");
address.setPrimary("address_primary");
address.setRegion("region");
address.setStreetAddress("streetAddress");
address.setType("address_type");
List<ScimPersonAddresses> addresses = new ArrayList<ScimPersonAddresses>();
addresses.add(address);
source.setAddresses(addresses);
List<ScimCustomAttributes> customAttributes = new ArrayList<ScimCustomAttributes>();
ScimCustomAttributes customattribute = new ScimCustomAttributes();
customattribute.setName("custom_name");
List<String> values = new ArrayList<String>();
String value = "value";
values.add(value);
customattribute.setValues(values);
customAttributes.add(customattribute);
ScimCustomAttributes customattribute2 = new ScimCustomAttributes();
customattribute2.setName("custom_name2");
List<String> values2 = new ArrayList<String>();
String value2 = "value";
values2.add(value2);
customattribute2.setValues(values2);
customAttributes.add(customattribute2);
source.setCustomAttributes(customAttributes);
source.setDisplayName("displayName");
ScimPersonEmails email = new ScimPersonEmails();
email.setPrimary("email_primary");
email.setType("email_type");
email.setValue("email_value");
List<ScimPersonEmails> emails = new ArrayList<ScimPersonEmails>();
emails.add(email);
source.setEmails(emails);
ScimEntitlements entitlement = new ScimEntitlements();
entitlement.setValue("entitlement_value");
List<ScimEntitlements> entitlements = new ArrayList<ScimEntitlements>();
entitlements.add(entitlement);
source.setEntitlements(entitlements);
source.setExternalId("externalId");
ScimPersonGroups group = new ScimPersonGroups();
group.setDisplay("group_display");
group.setValue("group_value");
List<ScimPersonGroups> groups = new ArrayList<ScimPersonGroups>();
groups.add(group);
source.setGroups(groups);
source.setId("id");
ScimPersonIms personims = new ScimPersonIms();
personims.setType("ims_type");
personims.setValue("ims_value");
List<ScimPersonIms> ims = new ArrayList<ScimPersonIms>();
ims.add(personims);
source.setIms(ims);
source.setLocale("locale");
PersonMeta meta = new PersonMeta();
meta.setCreated("created");
meta.setLastModified("lastModified");
meta.setLocation("location");
meta.setVersion("version");
source.setMeta(meta);
ScimName name = new ScimName();
name.setFamilyName("familyName");
name.setGivenName("givenName");
name.setHonorificPrefix("honorificPrefix");
name.setHonorificSuffix("honorificSuffix");
name.setMiddleName("middleName");
source.setName(name);
source.setNickName("nickName");
source.setPassword("password");
ScimPersonPhones phonenumber = new ScimPersonPhones();
phonenumber.setType("phone_type");
phonenumber.setValue("phone_value");
List<ScimPersonPhones> phoneNumbers = new ArrayList<ScimPersonPhones>();
phoneNumbers.add(phonenumber);
source.setPhoneNumbers(phoneNumbers);
ScimPersonPhotos photo = new ScimPersonPhotos();
photo.setType("photo_type");
photo.setValue("photo_value");
List<ScimPersonPhotos> photos = new ArrayList<ScimPersonPhotos>();
photos.add(photo);
source.setPhotos(photos);
source.setPreferredLanguage("preferredLanguage");
source.setProfileUrl(null);
ScimRoles role = new ScimRoles();
role.setValue("role_value");
List<ScimRoles> roles = new ArrayList<ScimRoles>();
roles.add(role);
source.setRoles(roles);
List<String> schemas = new ArrayList<String>();
schemas.add("shema");
source.setSchemas(schemas);
source.setTimezone("timezone");
source.setTitle("title");
source.setUserName("existing");
source.setUserType("userType");
Scimx509Certificates cert = new Scimx509Certificates();
cert.setValue("cert_value");
List<Scimx509Certificates> x509Certificates = new ArrayList<Scimx509Certificates>();
x509Certificates.add(cert);
source.setX509Certificates(x509Certificates);
GluuCustomPerson copy = copyUtils.copy(source, destination, false);
assertNull(copy);
}
use of org.gluu.oxtrust.model.scim.ScimPersonPhones in project oxTrust by GluuFederation.
the class CopyUtilsTestCreate method testCopyScim1CreateNullDestination.
@Test
public void testCopyScim1CreateNullDestination() throws Exception {
GluuCustomPerson destination = null;
ScimPerson source = new ScimPerson();
source.setActive("true");
ScimPersonAddresses address = new ScimPersonAddresses();
address.setCountry("country");
address.setFormatted("formatted");
address.setLocality("locality");
address.setPostalCode("postalCode");
address.setPrimary("address_primary");
address.setRegion("region");
address.setStreetAddress("streetAddress");
address.setType("address_type");
List<ScimPersonAddresses> addresses = new ArrayList<ScimPersonAddresses>();
addresses.add(address);
source.setAddresses(addresses);
List<ScimCustomAttributes> customAttributes = new ArrayList<ScimCustomAttributes>();
ScimCustomAttributes customattribute = new ScimCustomAttributes();
customattribute.setName("custom_name");
List<String> values = new ArrayList<String>();
String value = "value";
values.add(value);
customattribute.setValues(values);
customAttributes.add(customattribute);
source.setCustomAttributes(customAttributes);
source.setDisplayName("displayName");
ScimPersonEmails email = new ScimPersonEmails();
email.setPrimary("email_primary");
email.setType("email_type");
email.setValue("email_value");
List<ScimPersonEmails> emails = new ArrayList<ScimPersonEmails>();
emails.add(email);
source.setEmails(emails);
ScimEntitlements entitlement = new ScimEntitlements();
entitlement.setValue("entitlement_value");
List<ScimEntitlements> entitlements = new ArrayList<ScimEntitlements>();
entitlements.add(entitlement);
source.setEntitlements(entitlements);
source.setExternalId("externalId");
ScimPersonGroups group = new ScimPersonGroups();
group.setDisplay("group_display");
group.setValue("group_value");
List<ScimPersonGroups> groups = new ArrayList<ScimPersonGroups>();
groups.add(group);
source.setGroups(groups);
source.setId("id");
ScimPersonIms personims = new ScimPersonIms();
personims.setType("ims_type");
personims.setValue("ims_value");
List<ScimPersonIms> ims = new ArrayList<ScimPersonIms>();
ims.add(personims);
source.setIms(ims);
source.setLocale("locale");
PersonMeta meta = new PersonMeta();
meta.setCreated("created");
meta.setLastModified("lastModified");
meta.setLocation("location");
meta.setVersion("version");
source.setMeta(meta);
ScimName name = new ScimName();
name.setFamilyName("familyName");
name.setGivenName("givenName");
name.setHonorificPrefix("honorificPrefix");
name.setHonorificSuffix("honorificSuffix");
name.setMiddleName("middleName");
source.setName(name);
source.setNickName("nickName");
source.setPassword("password");
ScimPersonPhones phonenumber = new ScimPersonPhones();
phonenumber.setType("phone_type");
phonenumber.setValue("phone_value");
List<ScimPersonPhones> phoneNumbers = new ArrayList<ScimPersonPhones>();
phoneNumbers.add(phonenumber);
source.setPhoneNumbers(phoneNumbers);
ScimPersonPhotos photo = new ScimPersonPhotos();
photo.setType("photo_type");
photo.setValue("photo_value");
List<ScimPersonPhotos> photos = new ArrayList<ScimPersonPhotos>();
photos.add(photo);
source.setPhotos(photos);
source.setPreferredLanguage("preferredLanguage");
source.setProfileUrl("profileUrl");
ScimRoles role = new ScimRoles();
role.setValue("role_value");
List<ScimRoles> roles = new ArrayList<ScimRoles>();
roles.add(role);
source.setRoles(roles);
List<String> schemas = new ArrayList<String>();
schemas.add("shema");
source.setSchemas(schemas);
source.setTimezone("timezone");
source.setTitle("title");
source.setUserName("userName");
source.setUserType("userType");
Scimx509Certificates cert = new Scimx509Certificates();
cert.setValue("cert_value");
List<Scimx509Certificates> x509Certificates = new ArrayList<Scimx509Certificates>();
x509Certificates.add(cert);
source.setX509Certificates(x509Certificates);
GluuCustomPerson copy = copyUtils.copy(source, destination, false);
assertNotNull(copy);
}
Aggregations