From 98f0820040ad4e0f37ffb51eb857e3de285e4f15 Mon Sep 17 00:00:00 2001 From: d042399 Date: Mon, 2 May 2022 19:35:51 -0700 Subject: [PATCH 1/8] SAP user extension definition initial --- .../SAPUserExtensionAttributes.java | 180 ++++++++++++++++++ 1 file changed, 180 insertions(+) create mode 100644 scimono-server/src/main/java/com/sap/scimono/entity/definition/SAPUserExtensionAttributes.java diff --git a/scimono-server/src/main/java/com/sap/scimono/entity/definition/SAPUserExtensionAttributes.java b/scimono-server/src/main/java/com/sap/scimono/entity/definition/SAPUserExtensionAttributes.java new file mode 100644 index 00000000..aaba9a7a --- /dev/null +++ b/scimono-server/src/main/java/com/sap/scimono/entity/definition/SAPUserExtensionAttributes.java @@ -0,0 +1,180 @@ +package com.sap.scimono.entity.definition; + +import com.sap.scimono.entity.EnterpriseExtension; + +import static com.sap.scimono.entity.definition.SAPUserExtensionAttributes.Constants.*; + + +public enum SAPUserExtensionAttributes implements ScimAttribute { + + LOGINTIME(LOGINTIME_FIELD, null), + SOURCESYSTEM(SOURCESYSTEM_FIELD, null), + SOURCESYSTEMID(SOURCESYSTEMID_FIELD, null), + APPLICATIONID(APPLICATIONID_FIELD, null), + EMAILTEMPLATESETID(EMAILTEMPLATESETID_FIELD, null), + SENDMAIL(SENDMAIL_FIELD, null), + TARGETURL(TARGETURL_FIELD, null), + MAILVERIFIED(MAILVERIFIED_FIELD, null), + USERID(USERID_FIELD, null), + SAPUSERNAME(SAPUSERNAME_FIELD, null), + TOTPENABLED(TOTPENABLED_FIELD, null), + WEBAUTHENABLED(WEBAUTHENABLED_FIELD, null), + MFAENABLED(MFAENABLED_FIELD, null), + VALIDFROM(VALIDFROM_FIELD, null), + VALIDTO(VALIDTO_FIELD, null), + + CONTACTPREFERENCES(CONTACTPREFERENCES_FIELD, null), + CONTACTPREFERENCES_DESCRIPTION(CONTACTPREFERENCES_DESCRIPTION_FIELD, CONTACTPREFERENCES), + CONTACTPREFERENCES_EMAIL(CONTACTPREFERENCES_EMAIL_FIELD, CONTACTPREFERENCES), + CONTACTPREFERENCES_TELEPHONE(CONTACTPREFERENCES_TELEPHONE_FIELD, CONTACTPREFERENCES), + + SOCIALIDENTITIES(SOCIALIDENTITIES_FIELD, null), + SOCIALIDENTITIES_SOCIALPROVIDER(SOCIALIDENTITIES_SOCIALPROVIDER_FIELD, SOCIALIDENTITIES), + SOCIALIDENTITIES_DATEOFLINKING(SOCIALIDENTITIES_DATEOFLINKING_FIELD, SOCIALIDENTITIES), + + PASSWORDDETAILS(PASSWORDDETAILS_FIELD, null), + PASSWORDDETAILS_LOGINTIME(PASSWORDDETAILS_LOGINTIME_FIELD, PASSWORDDETAILS), + PASSWORDDETAILS_FAILEDLOGINATTEMPTS(PASSWORDDETAILS_FAILEDLOGINATTEMPTS_FIELD, PASSWORDDETAILS), + PASSWORDDETAILS_SETTIME(PASSWORDDETAILS_SETTIME_FIELD, PASSWORDDETAILS), + PASSWORDDETAILS_STATUS(PASSWORDDETAILS_STATUS_FIELD, PASSWORDDETAILS), + PASSWORDDETAILS_POLICY(PASSWORDDETAILS_POLICY_FIELD, PASSWORDDETAILS), + + EMAILS(EMAILS_FIELD, null), + EMAILS_TYPE(EMAILS_TYPE_FIELD, EMAILS), + EMAILS_VALUE(EMAILS_VALUE_FIELD, EMAILS), + EMAILS_DISPLAY(EMAILS_DISPLAY_FIELD, EMAILS), + EMAILS_PRIMARY(EMAILS_PRIMARY_FIELD, EMAILS), + EMAILS_VERIFIED(EMAILS_VERIFIED_FIELD, EMAILS), + EMAILS_VERIFIEDTIME(EMAILS_VERIFIEDTIME_FIELD, EMAILS), + + PHONENUMBERS(PHONENUMBERS_FIELD, null), + PHONENUMBERS_TYPE(PHONENUMBERS_TYPE_FIELD, PHONENUMBERS), + PHONENUMBERS_VALUE(PHONENUMBERS_VALUE_FIELD, PHONENUMBERS), + PHONENUMBERS_DISPLAY(PHONENUMBERS_DISPLAY_FIELD, PHONENUMBERS), + PHONENUMBERS_PRIMARY(PHONENUMBERS_PRIMARY_FIELD, PHONENUMBERS); + + + private final ScimAttribute scimAttribute; + + private static final ScimAttributesFactory SAP_EXTENSION_ATTRIBUTES_FACTORY + = new ScimAttributesFactory<>(SAPUserExtensionAttributes::values); + + SAPUserExtensionAttributes(String attributeName, SAPUserExtensionAttributes parent) { + scimAttribute = new ScimAttributeImpl<>(attributeName, EnterpriseExtension.ENTERPRISE_URN, parent, SAPUserExtensionAttributes::values); + } + + @Override + public boolean isTopLevelAttribute() { + return scimAttribute.isTopLevelAttribute(); + } + + @Override + public String scimName() { + return scimAttribute.scimName(); + } + + @Override + public String fullAttributePath() { + return scimAttribute.fullAttributePath(); + } + + @Override + public String relativePath() { + return scimAttribute.relativePath(); + } + + @Override + public SAPUserExtensionAttributes subAttributeFrom(String childAttributeName) { + return scimAttribute.subAttributeFrom(childAttributeName); + } + + @Override + public SAPUserExtensionAttributes getParent() { + return null; + } + + @Override + public String getSchemaId() { + return null; + } + + public interface Constants { + //($date-time) + String LOGINTIME_FIELD = "loginTime"; + String SOURCESYSTEM_FIELD = "sourceSystem"; + String SOURCESYSTEMID_FIELD = "sourceSystemId"; + // Specifies the id of the application from which the email template set is going to be chosen. + String APPLICATIONID_FIELD = "applicationId"; + + // Specifies the id of the email template set which is going to be used to create an activation mail message. + String EMAILTEMPLATESETID_FIELD = "emailTemplateSetId"; + + // Specifies if an activation mail should be sent. + String SENDMAIL_FIELD = "sendMail"; + + // Specifies an application link to which an user will be redirected after account activation. + String TARGETURL_FIELD = "targetUrl"; + + // Specifies if the primary e-mail is verified. + String MAILVERIFIED_FIELD = "mailVerified"; + + String USERUUID_FIELD = "userUuid"; + String USERID_FIELD = "userId"; + String SAPUSERNAME_FIELD = "sapUserName"; + // Specifies if time-based one-time password authentication is enabled. + String TOTPENABLED_FIELD = "totpEnabled"; + + // Specifies if web authentication is enabled. + String WEBAUTHENABLED_FIELD = "webAuthEnabled"; + + // Specifies if multi-factor authentication is enabled. + String MFAENABLED_FIELD = "mfaEnabled"; + + // Specifies the time and date from which the user is valid. + String VALIDFROM_FIELD = "validFrom"; + + // Specifies the time and date to which the user is valid. + String VALIDTO_FIELD = "validTo"; + + + // Specifies the contact preferences of the user. The allowed values for each preference is "yes", "no" or "unknown". + String CONTACTPREFERENCES_FIELD = "contactPreferences"; + String CONTACTPREFERENCES_DESCRIPTION_FIELD = "description"; + + String CONTACTPREFERENCES_EMAIL_FIELD = "email"; + String CONTACTPREFERENCES_TELEPHONE_FIELD = "telephone"; + + + String SOCIALIDENTITIES_FIELD = "socialIdentities"; + String SOCIALIDENTITIES_SOCIALID_FIELD = "socialId"; + String SOCIALIDENTITIES_SOCIALPROVIDER_FIELD = "socialProvider"; + // ($date-time) + String SOCIALIDENTITIES_DATEOFLINKING_FIELD = "dateOfLinking"; + + + // ($date-time) + String PASSWORDDETAILS_FIELD = "passwordDetails"; + String PASSWORDDETAILS_LOGINTIME_FIELD = "loginTime"; + String PASSWORDDETAILS_FAILEDLOGINATTEMPTS_FIELD = "failedLoginAttempts"; + // ($date-time) + String PASSWORDDETAILS_SETTIME_FIELD = "setTime"; + String PASSWORDDETAILS_STATUS_FIELD = "status"; + String PASSWORDDETAILS_POLICY_FIELD = "policy"; + + // Values should be equal to the values of the emails attribute in the user core schema when creating or updating user. + String EMAILS_FIELD = "emails"; + String EMAILS_TYPE_FIELD = "type"; + String EMAILS_VALUE_FIELD = "value"; + String EMAILS_DISPLAY_FIELD = "display"; + String EMAILS_PRIMARY_FIELD = "primary"; + String EMAILS_VERIFIED_FIELD = "verified"; + String EMAILS_VERIFIEDTIME_FIELD = "verifiedTime"; + + String PHONENUMBERS_FIELD = "phoneNumbers"; + // Enum: [ work, mobile, other ] + String PHONENUMBERS_TYPE_FIELD = "type"; + String PHONENUMBERS_VALUE_FIELD = "value"; + String PHONENUMBERS_DISPLAY_FIELD = "display"; + String PHONENUMBERS_PRIMARY_FIELD = "primary"; + } +} From 6f6dbe4a34d610a82da3b9d6f5451999c4e9ab5a Mon Sep 17 00:00:00 2001 From: d042399 Date: Mon, 2 May 2022 19:43:55 -0700 Subject: [PATCH 2/8] SAP user extension definition uuid and social ID added --- .../scimono/entity/definition/SAPUserExtensionAttributes.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scimono-server/src/main/java/com/sap/scimono/entity/definition/SAPUserExtensionAttributes.java b/scimono-server/src/main/java/com/sap/scimono/entity/definition/SAPUserExtensionAttributes.java index aaba9a7a..d20e7ac6 100644 --- a/scimono-server/src/main/java/com/sap/scimono/entity/definition/SAPUserExtensionAttributes.java +++ b/scimono-server/src/main/java/com/sap/scimono/entity/definition/SAPUserExtensionAttributes.java @@ -16,6 +16,7 @@ public enum SAPUserExtensionAttributes implements ScimAttribute Date: Tue, 17 May 2022 12:43:03 -0700 Subject: [PATCH 3/8] SAP user extension definitions --- .../scimono/entity/ContactPreferences.java | 121 ++++++ .../sap/scimono/entity/SAPUserExtension.java | 349 ++++++++++++++++++ .../SAPUserExtensionAttributes.java | 53 +-- .../sap/scimono/exception/SCIMException.java | 5 + 4 files changed, 504 insertions(+), 24 deletions(-) create mode 100644 scimono-server/src/main/java/com/sap/scimono/entity/ContactPreferences.java create mode 100644 scimono-server/src/main/java/com/sap/scimono/entity/SAPUserExtension.java diff --git a/scimono-server/src/main/java/com/sap/scimono/entity/ContactPreferences.java b/scimono-server/src/main/java/com/sap/scimono/entity/ContactPreferences.java new file mode 100644 index 00000000..02a276e9 --- /dev/null +++ b/scimono-server/src/main/java/com/sap/scimono/entity/ContactPreferences.java @@ -0,0 +1,121 @@ +package com.sap.scimono.entity; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.sap.scimono.entity.definition.SAPUserExtensionAttributes; +import com.sap.scimono.helper.Strings; + +import java.io.Serializable; +import java.util.Map; +import java.util.Objects; + +import static com.sap.scimono.entity.definition.ResourceConstants.MultivaluedAttributeConstants.*; +import static java.util.Objects.hash; + + +/** + * Java class for ContactPreferences complex type + */ +@JsonInclude(JsonInclude.Include.NON_EMPTY) +public final class ContactPreferences implements Serializable { + + private static final long serialVersionUID = -1606197800095918850L; + + + @JsonProperty(CONTACT_PREFERENCES_EMAIL) + private final String contact_preferences_email; + @JsonProperty(CONTACT_PREFERENCES_TELEPHONE) + private final String contact_preferences_telephone; + + @JsonCreator + public ContactPreferences(@JsonProperty(CONTACT_PREFERENCES_EMAIL) final String email, @JsonProperty(CONTACT_PREFERENCES_TELEPHONE) final String telephone) { + this.contact_preferences_email = email; + this.contact_preferences_telephone = telephone; + } + + private ContactPreferences(final Builder builder) { + contact_preferences_email = builder.contact_preferences_email; + contact_preferences_telephone = builder.contact_preferences_telephone; + } + + public String getEmail() { + return contact_preferences_email; + } + + public String getTelephone() { + return contact_preferences_telephone; + } + + @JsonIgnore + public boolean isEmpty() { + return Strings.isNullOrEmpty(contact_preferences_email + contact_preferences_telephone); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + hash(contact_preferences_email); + result = prime * result + hash(contact_preferences_telephone); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!(obj instanceof com.sap.scimono.entity.ContactPreferences)) { + return false; + } + ContactPreferences other = (ContactPreferences) obj; + if (!Objects.equals(contact_preferences_email, other.contact_preferences_email)) { + return false; + } + return (!Objects.equals(contact_preferences_telephone, other.contact_preferences_telephone)); + } + + public static class Builder { + private String contact_preferences_email; + private String contact_preferences_telephone; + + public Builder() { + // Default constructor used to instantiate new ContactPreferences objects + } + + public Builder(ContactPreferences contactPreferences) { + // Default constructor used to instantiate new contactPreferences objects + this.contact_preferences_email = contactPreferences.contact_preferences_email; + this.contact_preferences_telephone = contactPreferences.contact_preferences_telephone; + } + + public Builder(final Map contactPreferencesValues) { + if (contactPreferencesValues != null) { + contact_preferences_email = contactPreferencesValues.get(SAPUserExtensionAttributes.CONTACT_PREFERENCES_EMAIL.scimName()); + contact_preferences_telephone = contactPreferencesValues.get(SAPUserExtensionAttributes.CONTACT_PREFERENCES_TELEPHONE.scimName()); + } + } + + public ContactPreferences.Builder setEmail(final String email) { + this.contact_preferences_email = email; + return this; + } + + public ContactPreferences.Builder setTelephone(final String telephone) { + this.contact_preferences_telephone = telephone; + return this; + } + + public ContactPreferences build() { + return new ContactPreferences(this); + } + } +} + + + diff --git a/scimono-server/src/main/java/com/sap/scimono/entity/SAPUserExtension.java b/scimono-server/src/main/java/com/sap/scimono/entity/SAPUserExtension.java new file mode 100644 index 00000000..6f3a37b5 --- /dev/null +++ b/scimono-server/src/main/java/com/sap/scimono/entity/SAPUserExtension.java @@ -0,0 +1,349 @@ +package com.sap.scimono.entity; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.sap.scimono.entity.base.Extension; + +import java.util.Map; + +import static com.sap.scimono.entity.definition.SAPUserExtensionAttributes.*; + +/** + * Java class for SAP Core User Schema extension. See SAP API Business Hub. + */ +@JsonAutoDetect(getterVisibility = JsonAutoDetect.Visibility.NONE) +public final class SAPUserExtension extends Extension { + public static final String SAP_USER_EXTENSION_URN = "urn:ietf:params:scim:schemas:extension:sap:2.0:User"; + + private static final long serialVersionUID = 1606838139038034633L; + + private SAPUserExtension(final Builder builder) { + super(builder); + } + + public String getLoginTime() { + return getAttributeValueAsString(LOGINTIME.scimName()); + } + + public Integer getSourceSystem() { + return getAttributeValueAsInteger(SOURCESYSTEM.scimName()); + } + + public String getSourceSystemId() { + return getAttributeValueAsString(SOURCESYSTEMID.scimName()); + } + + public String getApplicationId() { + return getAttributeValueAsString(APPLICATIONID.scimName()); + } + + public String getEmailTemplateSetId() { + return getAttributeValueAsString(EMAILTEMPLATESETID.scimName()); + } + + public Boolean getSendMail() { + return getAttributeValueAsBoolean(SENDMAIL.scimName()); + } + + public String getTargetUrl() { + return getAttributeValueAsString(TARGETURL.scimName()); + } + + public Boolean getMailVerified() { + return getAttributeValueAsBoolean(MAILVERIFIED.scimName()); + } + + public String getUserUuid() { + return getAttributeValueAsString(USERUUID.scimName()); + } + + public String getUserId() { + return getAttributeValueAsString(USERID.scimName()); + } + + public String getSapUserName() { + return getAttributeValueAsString(SAPUSERNAME.scimName()); + } + + public Boolean getTotpEnabled() { + return getAttributeValueAsBoolean(TOTPENABLED.scimName()); + } + + public Boolean getWebAuthEnabled() { + return getAttributeValueAsBoolean(WEBAUTHENABLED.scimName()); + } + + public Boolean getMfaEnabled() { + return getAttributeValueAsBoolean(MFAENABLED.scimName()); + } + + public String getValidFrom() { + return getAttributeValueAsString(VALIDFROM.scimName()); + } + + public String getValidTo() { + return getAttributeValueAsString(VALIDTO.scimName()); + } + + public ContactPreferences getContactPreferences(){ + return (ContactPreferences) getAttribute((CONTACT_PREFERENCES.scimName())); + } + + + public static final class Builder extends Extension.Builder { + + public Builder() { + super(SAP_USER_EXTENSION_URN); + } + + public Builder(SAPUserExtension sapExtension) { + super(SAP_USER_EXTENSION_URN); + setLoginTime(sapExtension.getLoginTime()); + setSourceSystem(sapExtension.getSourceSystem()); + setSourceSystemId(sapExtension.getSourceSystemId()); + setApplicationId(sapExtension.getApplicationId()); + setEmailTemplateSetId(sapExtension.getEmailTemplateSetId()); + setSendMail(sapExtension.getSendMail()); + setTargetUrl(sapExtension.getTargetUrl()); + setMailVerified(sapExtension.getMailVerified()); + setUserUuid(sapExtension.getUserUuid()); + setUserId(sapExtension.getUserId()); + setSapUserName(sapExtension.getSapUserName()); + setTotpEnabled(sapExtension.getTotpEnabled()); + setWebAuthEnabled(sapExtension.getWebAuthEnabled()); + setMfaEnabled(sapExtension.getMfaEnabled()); + setValidFrom(sapExtension.getValidFrom()); + setValidTo(sapExtension.getValidTo()); + + ContactPreferences contactPreferences = sapExtension.getContactPreferences(); + if (contactPreferences != null){ + setContactPreferences(new ContactPreferences.Builder(contactPreferences).build()); + } + /*//todo multivalue + Manager enterpriseExtensionManager = sapExtension.getManager(); + if (enterpriseExtensionManager != null) { + setManager(new Manager.Builder(enterpriseExtensionManager).build()); + }*/ + } + + public Builder(final Map values) { + this(); + setLoginTime((String) values.get(LOGINTIME.scimName())); + setSourceSystem((Integer) values.get(SOURCESYSTEM.scimName())); + setSourceSystemId((String) values.get(SOURCESYSTEMID.scimName())); + setApplicationId((String) values.get(APPLICATIONID.scimName())); + setEmailTemplateSetId((String) values.get(EMAILTEMPLATESETID.scimName())); + setSendMail((Boolean) values.get(SENDMAIL.scimName())); + setTargetUrl((String) values.get(TARGETURL.scimName())); + setMailVerified((Boolean) values.get(MAILVERIFIED.scimName())); + setUserUuid((String) values.get(USERUUID.scimName())); + setUserId((String) values.get(USERID.scimName())); + setSapUserName((String) values.get(SAPUSERNAME.scimName())); + setTotpEnabled((Boolean) values.get(TOTPENABLED.scimName())); + setWebAuthEnabled((Boolean) values.get(WEBAUTHENABLED.scimName())); + setMfaEnabled((Boolean) values.get(MFAENABLED.scimName())); + setValidFrom((String) values.get(VALIDFROM.scimName())); + setValidTo((String) values.get(VALIDTO.scimName())); + + /*todo multi value + * objects: + * contactPreferences + * socialIdentities + * passwordDetails + * + * ContactPreferences: + type: object + properties: + email: + type: string + telephone: + type: string + description: Specifies the contact preferences of the user. The allowed values for each preference is "yes", "no" or "unknown". + SocialIdentities: + type: object + properties: + socialId: + type: string + socialProvider: + type: string + dateOfLinking: + type: string + format: date-time + PasswordDetails: + type: object + properties: + loginTime: + type: string + format: date-time + failedLoginAttempts: + type: integer + setTime: + type: string + format: date-time + status: + type: string + policy: + type: string + * + * + * + * arrays + * emails + * phoneNumbers + * + * emails + * ExtendedMultivalue: + type: object + properties: + type: + type: string + value: + type: string + display: + type: string + primary: + type: boolean + verified: + type: boolean + verifiedTime: + type: string + format: date-time + + * + * PhoneNumber: + type: object + required: + - type + - value + properties: + type: + type: string + enum: + - work + - mobile + - other + value: + type: string + display: + type: string + primary: + type: boolean + * + * + * + * + * + * + * + * + * */ + /*setManager(new Manager.Builder((Map) values.get(MANAGER.scimName())).build());*/ + } + + // todo multi value attributes / arrays + /*public Builder setManager(final Manager manager) { + if (manager != null && !manager.isEmpty()) { + setAttribute(MANAGER.scimName(), manager); + } else { + setAttribute(MANAGER.scimName(), null); + } + + return this; + } +*/ + + public Builder setLoginTime(final String loginTime) { + setAttribute(LOGINTIME.scimName(), loginTime); + return this; + } + + public Builder setSourceSystem(final Integer sourceSystem) { + setAttribute(SOURCESYSTEM.scimName(), sourceSystem); + return this; + } + + public Builder setSourceSystemId(final String sourceSystemId) { + setAttribute(SOURCESYSTEMID.scimName(), sourceSystemId); + return this; + } + + public Builder setApplicationId(final String applicationId) { + setAttribute(APPLICATIONID.scimName(), applicationId); + return this; + } + + public Builder setEmailTemplateSetId(final String emailTemplateSetId) { + setAttribute(EMAILTEMPLATESETID.scimName(), emailTemplateSetId); + return this; + } + + public Builder setSendMail(final Boolean sendMail) { + setAttribute(SENDMAIL.scimName(), sendMail); + return this; + } + + public Builder setTargetUrl(final String targetUrl) { + setAttribute(TARGETURL.scimName(), targetUrl); + return this; + } + + public Builder setMailVerified(final Boolean mailVerified) { + setAttribute(MAILVERIFIED.scimName(), mailVerified); + return this; + } + + public Builder setUserUuid(final String userUuid) { + setAttribute(USERUUID.scimName(), userUuid); + return this; + } + + public Builder setUserId(final String userId) { + setAttribute(USERID.scimName(), userId); + return this; + } + + public Builder setSapUserName(final String sapUserName) { + setAttribute(SAPUSERNAME.scimName(), sapUserName); + return this; + } + + public Builder setTotpEnabled(final Boolean totpEnabled) { + setAttribute(TOTPENABLED.scimName(), totpEnabled); + return this; + } + + public Builder setWebAuthEnabled(final Boolean webAuthEnabled) { + setAttribute(WEBAUTHENABLED.scimName(), webAuthEnabled); + return this; + } + + public Builder setMfaEnabled(final Boolean mfaEnabled) { + setAttribute(MFAENABLED.scimName(), mfaEnabled); + return this; + } + + public Builder setValidFrom(final String validFrom) { + setAttribute(VALIDFROM.scimName(), validFrom); + return this; + } + + public Builder setValidTo(final String validTo) { + setAttribute(VALIDTO.scimName(), validTo); + return this; + } + + public SAPUserExtension.Builder setContactPreferences(final ContactPreferences contactPreferences) { + if (contactPreferences != null && !contactPreferences.isEmpty()) { + setAttribute(CONTACT_PREFERENCES.scimName(), contactPreferences); + } else { + setAttribute(CONTACT_PREFERENCES.scimName(), null); + } + return this; + } + + @Override + public SAPUserExtension build() { + return new SAPUserExtension(this); + } + } + +} diff --git a/scimono-server/src/main/java/com/sap/scimono/entity/definition/SAPUserExtensionAttributes.java b/scimono-server/src/main/java/com/sap/scimono/entity/definition/SAPUserExtensionAttributes.java index d20e7ac6..5702c6f8 100644 --- a/scimono-server/src/main/java/com/sap/scimono/entity/definition/SAPUserExtensionAttributes.java +++ b/scimono-server/src/main/java/com/sap/scimono/entity/definition/SAPUserExtensionAttributes.java @@ -1,6 +1,6 @@ package com.sap.scimono.entity.definition; -import com.sap.scimono.entity.EnterpriseExtension; +import com.sap.scimono.entity.SAPUserExtension; import static com.sap.scimono.entity.definition.SAPUserExtensionAttributes.Constants.*; @@ -24,21 +24,22 @@ public enum SAPUserExtensionAttributes implements ScimAttribute scimAttribute; @@ -61,7 +62,7 @@ public enum SAPUserExtensionAttributes implements ScimAttribute(SAPUserExtensionAttributes::values); SAPUserExtensionAttributes(String attributeName, SAPUserExtensionAttributes parent) { - scimAttribute = new ScimAttributeImpl<>(attributeName, EnterpriseExtension.ENTERPRISE_URN, parent, SAPUserExtensionAttributes::values); + scimAttribute = new ScimAttributeImpl<>(attributeName, SAPUserExtension.SAP_USER_EXTENSION_URN, parent, SAPUserExtensionAttributes::values); } @Override @@ -91,12 +92,16 @@ public SAPUserExtensionAttributes subAttributeFrom(String childAttributeName) { @Override public SAPUserExtensionAttributes getParent() { - return null; + return scimAttribute.getParent(); } @Override public String getSchemaId() { - return null; + return scimAttribute.getSchemaId(); + } + + public static SAPUserExtensionAttributes from(String attributeName) { + return SAP_EXTENSION_ATTRIBUTES_FACTORY.from(attributeName); } public interface Constants { diff --git a/scimono-server/src/main/java/com/sap/scimono/exception/SCIMException.java b/scimono-server/src/main/java/com/sap/scimono/exception/SCIMException.java index 34d9ddb1..f1fea7b9 100644 --- a/scimono-server/src/main/java/com/sap/scimono/exception/SCIMException.java +++ b/scimono-server/src/main/java/com/sap/scimono/exception/SCIMException.java @@ -67,6 +67,11 @@ public enum Type { public String toJson() { return jsonRepresentation; } + + @Override + public String toString() { + return jsonRepresentation; + } } } From 107f216815a6a50d923195e06c96ec90bc7412f7 Mon Sep 17 00:00:00 2001 From: d042399 Date: Tue, 17 May 2022 12:49:17 -0700 Subject: [PATCH 4/8] SAP user extension definitions --- .../sap/scimono/entity/base/Extension.java | 31 ++++++++++++++++--- .../entity/definition/ResourceConstants.java | 2 ++ 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/scimono-server/src/main/java/com/sap/scimono/entity/base/Extension.java b/scimono-server/src/main/java/com/sap/scimono/entity/base/Extension.java index f15c554f..528fdbbe 100644 --- a/scimono-server/src/main/java/com/sap/scimono/entity/base/Extension.java +++ b/scimono-server/src/main/java/com/sap/scimono/entity/base/Extension.java @@ -17,17 +17,17 @@ package com.sap.scimono.entity.base; -import static java.util.Objects.hash; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; import java.io.Serializable; import java.util.HashMap; import java.util.Map; import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; +import static java.util.Objects.hash; /** * This class represents a schema extension. @@ -73,6 +73,27 @@ public String getAttributeValueAsString(final String attrName) { return String.valueOf(attributeValue); } + public Boolean getAttributeValueAsBoolean(String attrName) { + Object attributeValue = attributes.get(attrName); + + if (!(attributeValue instanceof Boolean)) { + return null; + } + + return (Boolean) attributeValue; + } + + public Integer getAttributeValueAsInteger(String attrName) { + Object attributeValue = attributes.get(attrName); + + if (!(attributeValue instanceof Integer)) { + return null; + } + + return (Integer) attributeValue; + } + + @JsonAnyGetter public Map getAttributes() { return new HashMap<>(attributes); diff --git a/scimono-server/src/main/java/com/sap/scimono/entity/definition/ResourceConstants.java b/scimono-server/src/main/java/com/sap/scimono/entity/definition/ResourceConstants.java index df19a751..c9b79fdb 100644 --- a/scimono-server/src/main/java/com/sap/scimono/entity/definition/ResourceConstants.java +++ b/scimono-server/src/main/java/com/sap/scimono/entity/definition/ResourceConstants.java @@ -21,5 +21,7 @@ interface MultivaluedAttributeConstants { String DISPLAY_FIELD = "display"; String PRIMARY_FIELD = "primary"; String REF_FIELD = "$ref"; + String CONTACT_PREFERENCES_EMAIL = "email"; + String CONTACT_PREFERENCES_TELEPHONE = "telephone"; } } From bab46b4577fafb6630aaa75336069ecc34b77dc5 Mon Sep 17 00:00:00 2001 From: d042399 Date: Tue, 17 May 2022 15:38:35 -0700 Subject: [PATCH 5/8] sap model SocialIdentities --- .../java/com/sap/scimono/entity/SAPUserExtension.java | 10 +--------- .../java/com/sap/scimono/entity/base/Extension.java | 1 + .../scimono/entity/definition/ResourceConstants.java | 3 +++ 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/scimono-server/src/main/java/com/sap/scimono/entity/SAPUserExtension.java b/scimono-server/src/main/java/com/sap/scimono/entity/SAPUserExtension.java index 6f3a37b5..45bdedfd 100644 --- a/scimono-server/src/main/java/com/sap/scimono/entity/SAPUserExtension.java +++ b/scimono-server/src/main/java/com/sap/scimono/entity/SAPUserExtension.java @@ -146,18 +146,10 @@ public Builder(final Map values) { /*todo multi value * objects: - * contactPreferences * socialIdentities * passwordDetails * - * ContactPreferences: - type: object - properties: - email: - type: string - telephone: - type: string - description: Specifies the contact preferences of the user. The allowed values for each preference is "yes", "no" or "unknown". + SocialIdentities: type: object properties: diff --git a/scimono-server/src/main/java/com/sap/scimono/entity/base/Extension.java b/scimono-server/src/main/java/com/sap/scimono/entity/base/Extension.java index 528fdbbe..0dc228c8 100644 --- a/scimono-server/src/main/java/com/sap/scimono/entity/base/Extension.java +++ b/scimono-server/src/main/java/com/sap/scimono/entity/base/Extension.java @@ -29,6 +29,7 @@ import static java.util.Objects.hash; + /** * This class represents a schema extension. *

diff --git a/scimono-server/src/main/java/com/sap/scimono/entity/definition/ResourceConstants.java b/scimono-server/src/main/java/com/sap/scimono/entity/definition/ResourceConstants.java index c9b79fdb..71fcddaf 100644 --- a/scimono-server/src/main/java/com/sap/scimono/entity/definition/ResourceConstants.java +++ b/scimono-server/src/main/java/com/sap/scimono/entity/definition/ResourceConstants.java @@ -23,5 +23,8 @@ interface MultivaluedAttributeConstants { String REF_FIELD = "$ref"; String CONTACT_PREFERENCES_EMAIL = "email"; String CONTACT_PREFERENCES_TELEPHONE = "telephone"; + String SOCIALIDENTITIES_SOCIALID = "socialId"; + String SOCIALIDENTITIES_SOCIALPROVIDER = "socialProvider"; + String SOCIALIDENTITIES_DATEOFLINKING = "dateOfLinking"; } } From f7427526b8ddefe38315f01ee36fb055b827eebd Mon Sep 17 00:00:00 2001 From: d042399 Date: Tue, 17 May 2022 16:01:59 -0700 Subject: [PATCH 6/8] sap model PasswordDetails --- .../sap/scimono/entity/PasswordDetails.java | 169 ++++++++++++++++++ .../sap/scimono/entity/SAPUserExtension.java | 56 +----- .../entity/definition/ResourceConstants.java | 5 + 3 files changed, 180 insertions(+), 50 deletions(-) create mode 100644 scimono-server/src/main/java/com/sap/scimono/entity/PasswordDetails.java diff --git a/scimono-server/src/main/java/com/sap/scimono/entity/PasswordDetails.java b/scimono-server/src/main/java/com/sap/scimono/entity/PasswordDetails.java new file mode 100644 index 00000000..0bae9844 --- /dev/null +++ b/scimono-server/src/main/java/com/sap/scimono/entity/PasswordDetails.java @@ -0,0 +1,169 @@ +package com.sap.scimono.entity; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.sap.scimono.entity.definition.SAPUserExtensionAttributes; +import com.sap.scimono.helper.Strings; + +import java.io.Serializable; +import java.util.Map; +import java.util.Objects; + +import static com.sap.scimono.entity.definition.ResourceConstants.MultivaluedAttributeConstants.*; +import static java.util.Objects.hash; + + +/** + * Java class for PasswordDetails complex type + */ +@JsonInclude(JsonInclude.Include.NON_EMPTY) +public final class PasswordDetails implements Serializable { + + private static final long serialVersionUID = -1606771200095918850L; + + + @JsonProperty(PASSWORDDETAILS_LOGINTIME) + private final String loginTime; + @JsonProperty(PASSWORDDETAILS_FAILEDLOGINATTEMPTS) + private final int failedLoginAttempts; + @JsonProperty(PASSWORDDETAILS_SETTIME) + private final String setTime; + @JsonProperty(PASSWORDDETAILS_STATUS) + private final String status; + @JsonProperty(PASSWORDDETAILS_POLICY) + private final String policy; + + private PasswordDetails(final PasswordDetails.Builder builder) { + loginTime = builder.loginTime; + failedLoginAttempts = builder.failedLoginAttempts; + setTime = builder.setTime; + status = builder.status; + policy = builder.policy; + + } + + + @JsonCreator + public PasswordDetails(String id, int failedLoginAttempts, String setTime, String status, String policy) { + this.loginTime = id; + this.failedLoginAttempts = failedLoginAttempts; + this.setTime = setTime; + this.status = status; + this.policy = policy; + } + + private PasswordDetails(final Builder builder, String loginTime, int failedLoginAttempts, String setTime, String status, String policy) { + this.loginTime = loginTime; + this.failedLoginAttempts = failedLoginAttempts; + this.setTime = setTime; + this.status = status; + this.policy = policy; + } + + + @JsonIgnore + public boolean isEmpty() { + return Strings.isNullOrEmpty(loginTime + failedLoginAttempts + setTime); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + hash(loginTime); + result = prime * result + hash(failedLoginAttempts); + result = prime * result + hash(setTime); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!(obj instanceof PasswordDetails)) { + return false; + } + PasswordDetails other = (PasswordDetails) obj; + if (!Objects.equals(loginTime, other.loginTime)) { + return false; + } + if (!Objects.equals(failedLoginAttempts, other.failedLoginAttempts)) { + return false; + } + if (!Objects.equals(setTime, other.setTime)) { + return false; + } + if (!Objects.equals(status, other.status)) { + return false; + } + return (!Objects.equals(policy, other.policy)); + } + + public static class Builder { + private String loginTime; + private int failedLoginAttempts; + private String setTime; + private String status; + private String policy; + + public PasswordDetails.Builder setLoginTime(String loginTime) { + this.loginTime = loginTime; + return this; + } + + public PasswordDetails.Builder setFailedLoginAttempts(int failedLoginAttempts) { + this.failedLoginAttempts = failedLoginAttempts; + return this; + } + + public PasswordDetails.Builder setSetTime(String setTime) { + this.setTime = setTime; + return this; + } + + public PasswordDetails.Builder setStatus(String status) { + this.status = status; + return this; + } + + public void setPolicy(String policy) { + this.policy = policy; + } + + public Builder() { + // Default constructor used to instantiate new ContactPreferences objects + } + + public Builder(PasswordDetails passwordDetails) { + // Default constructor used to instantiate new contactPreferences objects + this.loginTime = passwordDetails.loginTime; + this.failedLoginAttempts = passwordDetails.failedLoginAttempts; + this.setTime = passwordDetails.setTime; + this.status = passwordDetails.status; + this.policy = passwordDetails.policy; + } + + public Builder(final Map passwordDetails) { + if (passwordDetails != null) { + loginTime = passwordDetails.get(SAPUserExtensionAttributes.PASSWORD_DETAILS_LOGINTIME.scimName()); + failedLoginAttempts = Integer.parseInt(passwordDetails.get(SAPUserExtensionAttributes.PASSWORD_DETAILS_FAILEDLOGINATTEMPTS.scimName())); + setTime = passwordDetails.get(SAPUserExtensionAttributes.PASSWORD_DETAILS_SETTIME.scimName()); + status = passwordDetails.get(SAPUserExtensionAttributes.PASSWORD_DETAILS_STATUS.scimName()); + policy = passwordDetails.get(SAPUserExtensionAttributes.PASSWORD_DETAILS_POLICY.scimName()); + + } + } + public PasswordDetails build() { + return new PasswordDetails(this); + } + } +} + + + diff --git a/scimono-server/src/main/java/com/sap/scimono/entity/SAPUserExtension.java b/scimono-server/src/main/java/com/sap/scimono/entity/SAPUserExtension.java index 45bdedfd..bf7b8f9b 100644 --- a/scimono-server/src/main/java/com/sap/scimono/entity/SAPUserExtension.java +++ b/scimono-server/src/main/java/com/sap/scimono/entity/SAPUserExtension.java @@ -143,62 +143,18 @@ public Builder(final Map values) { setMfaEnabled((Boolean) values.get(MFAENABLED.scimName())); setValidFrom((String) values.get(VALIDFROM.scimName())); setValidTo((String) values.get(VALIDTO.scimName())); - - /*todo multi value - * objects: - * socialIdentities - * passwordDetails - * - - SocialIdentities: - type: object - properties: - socialId: - type: string - socialProvider: - type: string - dateOfLinking: - type: string - format: date-time +/* PasswordDetails: type: object properties: - loginTime: - type: string - format: date-time - failedLoginAttempts: - type: integer - setTime: - type: string - format: date-time - status: - type: string - policy: - type: string - * + loginTime + failedLoginAttempts + setTime + status + policy * * - * arrays - * emails - * phoneNumbers * - * emails - * ExtendedMultivalue: - type: object - properties: - type: - type: string - value: - type: string - display: - type: string - primary: - type: boolean - verified: - type: boolean - verifiedTime: - type: string - format: date-time * * PhoneNumber: diff --git a/scimono-server/src/main/java/com/sap/scimono/entity/definition/ResourceConstants.java b/scimono-server/src/main/java/com/sap/scimono/entity/definition/ResourceConstants.java index 71fcddaf..b3c1db92 100644 --- a/scimono-server/src/main/java/com/sap/scimono/entity/definition/ResourceConstants.java +++ b/scimono-server/src/main/java/com/sap/scimono/entity/definition/ResourceConstants.java @@ -26,5 +26,10 @@ interface MultivaluedAttributeConstants { String SOCIALIDENTITIES_SOCIALID = "socialId"; String SOCIALIDENTITIES_SOCIALPROVIDER = "socialProvider"; String SOCIALIDENTITIES_DATEOFLINKING = "dateOfLinking"; + String PASSWORDDETAILS_LOGINTIME = "loginTime"; + String PASSWORDDETAILS_FAILEDLOGINATTEMPTS = "failedLoginAttempts"; + String PASSWORDDETAILS_SETTIME = "setTime"; + String PASSWORDDETAILS_STATUS = "status"; + String PASSWORDDETAILS_POLICY = "policy"; } } From 854bb7276b8d44b589caf7206934fe40f5d1b758 Mon Sep 17 00:00:00 2001 From: d042399 Date: Tue, 17 May 2022 16:02:36 -0700 Subject: [PATCH 7/8] sap model SocialIdentities --- .../sap/scimono/entity/SocialIdentities.java | 131 ++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 scimono-server/src/main/java/com/sap/scimono/entity/SocialIdentities.java diff --git a/scimono-server/src/main/java/com/sap/scimono/entity/SocialIdentities.java b/scimono-server/src/main/java/com/sap/scimono/entity/SocialIdentities.java new file mode 100644 index 00000000..d0195846 --- /dev/null +++ b/scimono-server/src/main/java/com/sap/scimono/entity/SocialIdentities.java @@ -0,0 +1,131 @@ +package com.sap.scimono.entity; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.sap.scimono.entity.definition.SAPUserExtensionAttributes; +import com.sap.scimono.helper.Strings; + +import java.io.Serializable; +import java.util.Map; +import java.util.Objects; + +import static com.sap.scimono.entity.definition.ResourceConstants.MultivaluedAttributeConstants.*; +import static java.util.Objects.hash; + + +/** + * Java class for SocialIdentities complex type + */ +@JsonInclude(JsonInclude.Include.NON_EMPTY) +public final class SocialIdentities implements Serializable { + + private static final long serialVersionUID = -1606777800095918850L; + + + @JsonProperty(PASSWORDDETAILS_LOGINTIME) + private final String id; + @JsonProperty(PASSWORDDETAILS_FAILEDLOGINATTEMPTS) + private final String dateoflinking; + @JsonProperty(PASSWORDDETAILS_SETTIME) + private final String socialProvider; + + + @JsonCreator + public SocialIdentities(String id, String dateoflinking, String socialProvider) { + this.id = id; + this.dateoflinking = dateoflinking; + this.socialProvider = socialProvider; + } + + private SocialIdentities(final Builder builder, String id, String dateOflinking, String socialProvider) { + this.id = id; + this.dateoflinking = dateOflinking; + this.socialProvider = socialProvider; + } + + + @JsonIgnore + public boolean isEmpty() { + return Strings.isNullOrEmpty(id + dateoflinking + socialProvider); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + hash(id); + result = prime * result + hash(dateoflinking); + result = prime * result + hash(socialProvider); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!(obj instanceof SocialIdentities)) { + return false; + } + SocialIdentities other = (SocialIdentities) obj; + if (!Objects.equals(id, other.id)) { + return false; + } + if (!Objects.equals(dateoflinking, other.dateoflinking)) { + return false; + } + return (!Objects.equals(socialProvider, other.socialProvider)); + } + + public static class Builder { + private String id; + private String socialProvider; + private String dateofLinking; + + public SocialIdentities.Builder setId(String id) { + this.id = id; + return this; + } + + public SocialIdentities.Builder setSocialProvider(String socialProvider) { + this.socialProvider = socialProvider; + return this; + } + + public SocialIdentities.Builder setDateofLinking(String dateofLinking) { + this.dateofLinking = dateofLinking; + return this; + } + + public Builder() { + // Default constructor used to instantiate new ContactPreferences objects + } + + public Builder(SocialIdentities contactPreferences) { + // Default constructor used to instantiate new contactPreferences objects + this.dateofLinking = contactPreferences.dateoflinking; + this.id = contactPreferences.id; + this.socialProvider = contactPreferences.socialProvider; + } + + public Builder(final Map contactPreferencesValues) { + if (contactPreferencesValues != null) { + id = contactPreferencesValues.get(SAPUserExtensionAttributes.SOCIAL_IDENTITIES_SOCIAL_ID.scimName()); + socialProvider = contactPreferencesValues.get(SAPUserExtensionAttributes.SOCIAL_IDENTITIES_SOCIAL_PROVIDER.scimName()); + dateofLinking = contactPreferencesValues.get(SAPUserExtensionAttributes.SOCIAL_IDENTITIES_DATE_OF_LINKING.scimName()); + } + } + + public SocialIdentities build() { + return new SocialIdentities(this, id, dateofLinking, socialProvider); + } + } +} + + + From ed9bcaeee318c554d9200c9b02834f247cb7281b Mon Sep 17 00:00:00 2001 From: d042399 Date: Tue, 17 May 2022 16:12:16 -0700 Subject: [PATCH 8/8] sap user extension builder --- .../sap/scimono/entity/SAPUserExtension.java | 95 ++++++++----------- 1 file changed, 37 insertions(+), 58 deletions(-) diff --git a/scimono-server/src/main/java/com/sap/scimono/entity/SAPUserExtension.java b/scimono-server/src/main/java/com/sap/scimono/entity/SAPUserExtension.java index bf7b8f9b..7618da3c 100644 --- a/scimono-server/src/main/java/com/sap/scimono/entity/SAPUserExtension.java +++ b/scimono-server/src/main/java/com/sap/scimono/entity/SAPUserExtension.java @@ -88,6 +88,14 @@ public ContactPreferences getContactPreferences(){ return (ContactPreferences) getAttribute((CONTACT_PREFERENCES.scimName())); } + public PasswordDetails getPasswordDetails(){ + return (PasswordDetails) getAttribute((PASSWORD_DETAILS.scimName())); + } + + public SocialIdentities getSocialIdentities(){ + return (SocialIdentities) getAttribute((SOCIAL_IDENTITIES.scimName())); + } + public static final class Builder extends Extension.Builder { @@ -118,11 +126,15 @@ public Builder(SAPUserExtension sapExtension) { if (contactPreferences != null){ setContactPreferences(new ContactPreferences.Builder(contactPreferences).build()); } - /*//todo multivalue - Manager enterpriseExtensionManager = sapExtension.getManager(); - if (enterpriseExtensionManager != null) { - setManager(new Manager.Builder(enterpriseExtensionManager).build()); - }*/ + PasswordDetails passwordDetails = sapExtension.getPasswordDetails(); + if (passwordDetails != null){ + setPasswordDetails(new PasswordDetails.Builder(passwordDetails).build()); + } + SocialIdentities socialIdentities = sapExtension.getSocialIdentities(); + if (socialIdentities != null){ + setSocialIdentities(new SocialIdentities.Builder(socialIdentities).build()); + } + } public Builder(final Map values) { @@ -143,61 +155,8 @@ public Builder(final Map values) { setMfaEnabled((Boolean) values.get(MFAENABLED.scimName())); setValidFrom((String) values.get(VALIDFROM.scimName())); setValidTo((String) values.get(VALIDTO.scimName())); -/* - PasswordDetails: - type: object - properties: - loginTime - failedLoginAttempts - setTime - status - policy - * - * - * - - * - * PhoneNumber: - type: object - required: - - type - - value - properties: - type: - type: string - enum: - - work - - mobile - - other - value: - type: string - display: - type: string - primary: - type: boolean - * - * - * - * - * - * - * - * - * */ - /*setManager(new Manager.Builder((Map) values.get(MANAGER.scimName())).build());*/ - } - - // todo multi value attributes / arrays - /*public Builder setManager(final Manager manager) { - if (manager != null && !manager.isEmpty()) { - setAttribute(MANAGER.scimName(), manager); - } else { - setAttribute(MANAGER.scimName(), null); - } - return this; } -*/ public Builder setLoginTime(final String loginTime) { setAttribute(LOGINTIME.scimName(), loginTime); @@ -288,6 +247,26 @@ public SAPUserExtension.Builder setContactPreferences(final ContactPreferences c return this; } + public SAPUserExtension.Builder setPasswordDetails(final PasswordDetails passwordDetails) { + if (passwordDetails != null && !passwordDetails.isEmpty()) { + setAttribute(PASSWORD_DETAILS.scimName(), passwordDetails); + } else { + setAttribute(PASSWORD_DETAILS.scimName(), null); + } + return this; + } + + public SAPUserExtension.Builder setSocialIdentities(final SocialIdentities socialIdentities) { + if (socialIdentities != null && !socialIdentities.isEmpty()) { + setAttribute(SOCIAL_IDENTITIES.scimName(), socialIdentities); + } else { + setAttribute(SOCIAL_IDENTITIES.scimName(), null); + } + return this; + } + + + @Override public SAPUserExtension build() { return new SAPUserExtension(this);