Class AccountAttributes

All Implemented Interfaces:
Iterable<Attribute>, AttributeContainer<Attributes>, SerializableAsMap

public class AccountAttributes extends ResourceAttributes<AccountAttributes>
A SCIM 2.0 representation of a user account. Note that the keyword here is representation. For mutating properties of an account (such as changing the password) and persisting the changes, always first check to see if a method for doing that already exists in either the AccountManager or the CredentialManager interfaces, and if so those methods must be used.

Example creation of a user

 AccountAttributes user = AccountAttributes.of("User")
     .withPhoneNumbers(PhoneNumber.of("+46771793336", true))
     .withGroups(Group.of("admins"))
     .withEmails(
         Email.of("barbara@jensen.com"),
         Email.of("babs@scim.com").withType("work")
     ).withName(Name.of("Barbara Jensen"))
     .withNickName("Babs");
 

This serializes into:

 {
   "emails": [
     {
       "value": "barbara@jensen.com"
     },
     {
       "type": "work",
       "value": "babs@scim.com"
     }
   ],
   "groups": [
     {
       "value": "admins"
     }
   ],
   "id": "73a6119e-6edb-49bb-a490-d858de770c6e",
   "meta": {
     "created": "2016-05-18T11:19:10.205+02:00[Europe/Stockholm]",
     "lastModified": "2016-05-18T11:19:10.218+02:00[Europe/Stockholm]",
     "resourceType": "User"
   },
   "name": {
     "formatted": "Barbara Jensen"
   },
   "nickName": "Babs",
   "phoneNumbers": [
     {
       "primary": true,
       "value": "+46771793336"
     }
   ],
   "schemas": [
     "urn:ietf:params:scim:schemas:core:2.0:User"
   ],
   "userName": "User"
 }
 
  • Field Details

  • Constructor Details

    • AccountAttributes

      protected AccountAttributes(Attributes attributes)
  • Method Details

    • fromMap

      public static AccountAttributes fromMap(Map<String,?> map)
    • of

      public static AccountAttributes of(String userName, String password, String primaryEmail)
      Create an account with all the mandatory fields.
      Parameters:
      userName - user name
      password - password
      primaryEmail - primary email
      Returns:
      account
    • emailFrom

      @Nullable public static @Nullable String emailFrom(@Nullable AccountAttributes account)
    • getUserName

      public String getUserName()
      A unique identifier of the user.

      This is a mandatory value

      Returns:
      the userName
    • getName

      @Nullable public @Nullable Name getName()
      The name components of the user.
      Returns:
      Name, null if not set
    • getDisplayName

      @Nullable public @Nullable String getDisplayName()
      A displayName for the user. Should be the full name of the user, if available.
      Returns:
      the displayName, or null if not set.
    • getNickName

      @Nullable public @Nullable String getNickName()
      A nickName for the user, a casual way to address the user in real life. I.e. Bob for Robert.
      Returns:
      the nickName, or null if not set.
    • getTitle

      @Nullable public @Nullable String getTitle()
      The user's title, such as "Vice President".
      Returns:
      the title, or null if not found.
    • getPreferredLanguage

      @Nullable public @Nullable String getPreferredLanguage()
      Indicates the user’s preferred written or spoken languages The format of the value is the same as the Accept-Language HTTP header.
      Returns:
      the preferredLanguage, or null if not found.
    • getUserType

      @Nullable public @Nullable String getUserType()
      Used to identify the relationship between the organization and the user. Typical values used might be "Contractor", "Employee", "Intern", "Temp", "External", and "Unknown", but any value may be used.
      Returns:
      the userType, or null if not found.
    • getProfileUrl

      @Nullable public @Nullable String getProfileUrl()
      A url to the users online profile.
      Returns:
      the profileUrl, or null if not found.
    • getLocale

      @Nullable public @Nullable String getLocale()
      The users locale.
      Returns:
      the locale, or null if not found.
    • getTimeZone

      @Nullable public @Nullable String getTimeZone()
      The users time zone.

      Example: "America/Los_Angeles"

      Returns:
      the timeZone, or null if not found.
    • isActive

      public boolean isActive()
      A flag indicating if the user should be seen as active or not.
      Returns:
      true if the value is found, and set to true. False otherwise.
    • getPassword

      @Nullable public @Nullable String getPassword()
      The users password.
      Returns:
      the password, or null if not found
    • getEmails

      public ComplexAttribute<Email> getEmails()
      The email addresses associated with the user.
      Returns:
      list of emails, empty if not found.
    • addEmail

      public AccountAttributes addEmail(Email email)
      Add an email to the user.
      Parameters:
      email - to add
      Returns:
      copy of the user with the email added
    • removeEmail

      public AccountAttributes removeEmail(Email email)
      Remove an email from the user account.
      Parameters:
      email - to remove
      Returns:
      copy of the user with the email removed
    • getEntitlements

      public ComplexAttribute<Entitlement> getEntitlements()
      The entitlements the user has.
      Returns:
      list of entitlements, empty if not found.
    • addEntitlement

      public AccountAttributes addEntitlement(Entitlement entitlement)
      Add an entitlement to the user.
      Parameters:
      entitlement - to add
      Returns:
      copy of the user with the entitlement added
    • removeEntitlement

      public AccountAttributes removeEntitlement(Entitlement entitlement)
      Remove an entitlement from the user account.
      Parameters:
      entitlement - to remove
      Returns:
      copy of the user with the entitlement removed
    • getIms

      The instant messaging handles associated with the user.
      Returns:
      list of IMs, empty if not found.
    • addIms

      public AccountAttributes addIms(InstantMessaging im)
      Add instant messaging handle to the user.

      Example: @twobotechnologies

      Parameters:
      im - instant messaging handle to add
      Returns:
      copy of the user with the handle added
    • removeIms

      public AccountAttributes removeIms(InstantMessaging im)
      Remove instant handle messaging handle.
      Parameters:
      im - instant messaging handle to remove
      Returns:
      copy of the user with the handle removed
    • getPhotos

      public ComplexAttribute<Photo> getPhotos()
      A list of url's to photo resources.
      Returns:
      list of photos, empty if not found
    • addPhoto

      public AccountAttributes addPhoto(Photo photo)
      Add photo to the user.
      Parameters:
      photo - photo to add
      Returns:
      copy of the user with the photo added
    • removePhoto

      public AccountAttributes removePhoto(Photo photo)
      Remove photo from the user.
      Parameters:
      photo - photo to remove
      Returns:
      copy of the user with the photo removed
    • getPhoneNumbers

      public ComplexAttribute<PhoneNumber> getPhoneNumbers()
      Phone numbers associated with the user.
      Returns:
      list of phoneNumbers, empty if not found
    • addPhoneNumber

      public AccountAttributes addPhoneNumber(PhoneNumber phoneNumber)
      Add a phoneNumber to the user.
      Parameters:
      phoneNumber - phoneNumber to add
      Returns:
      copy of the user with the phoneNumber added
    • removePhoneNumber

      public AccountAttributes removePhoneNumber(PhoneNumber phoneNumber)
      Remove a phoneNumber from the user.
      Parameters:
      phoneNumber - phoneNumber to remove
      Returns:
      copy of the user with the phoneNumber removed
    • getGroups

      public ComplexAttribute<Group> getGroups()
      A list of groups to which the user belongs, either through direct membership, through nested groups, or dynamically calculated.
      Returns:
      list of groups, empty if not found
    • addGroup

      public AccountAttributes addGroup(Group group)
      Add a group to the user.
      Parameters:
      group - group to add
      Returns:
      copy of the user with the group added
    • removeGroup

      public AccountAttributes removeGroup(Group group)
      Remove a group from the user.
      Parameters:
      group - group to add
      Returns:
      copy of the user with the group remove
    • getRoles

      public ComplexAttribute<Role> getRoles()
      A list of roles for the user that collectively represent who the user is, e.g., "Student", "Faculty".
      Returns:
      list of roles, empty if not found
    • addRole

      public AccountAttributes addRole(Role role)
      Add a role to the user.
      Parameters:
      role - to be added
      Returns:
      copy of the user with the role added
    • removeRole

      public AccountAttributes removeRole(Role role)
      Remove a role from the user.
      Parameters:
      role - to be removed
      Returns:
      copy of the user with the role removed
    • getAddresses

      public ComplexAttribute<Address> getAddresses()
      List of physical mailing addresses for the user.
      Returns:
      list of addresses, empty if not found
    • addAddress

      public AccountAttributes addAddress(Address address)
      Add a address to the user.
      Parameters:
      address - to be added
      Returns:
      copy of the user with the address added
    • removeAddress

      public AccountAttributes removeAddress(Address address)
      Remove a address from the user.
      Parameters:
      address - to be removed
      Returns:
      copy of the user with the address removed
    • getX509certificates

      public ComplexAttribute<X509Certificates> getX509certificates()
      A list of certificates associated with the User. DER and Base64 encoded.
      Returns:
      list of base64 encoded certificates, empty if not found
    • addX509Certificates

      public AccountAttributes addX509Certificates(X509Certificates x509Certificates)
      Add a certificate to the user.
      Parameters:
      x509Certificates - to be added, DER and Base64 encoded
      Returns:
      copy of the user with the certificate added
    • removeX509Certificates

      public AccountAttributes removeX509Certificates(X509Certificates x509Certificates)
      Remove certificate from the user.
      Parameters:
      x509Certificates - to be removed
      Returns:
      copy of the user, with the certificate removed
    • getDevices

      public ComplexAttribute<Device> getDevices()
      Get the devices associated with the user.
      Returns:
      list of devices, empty if not found
    • addDevice

      public AccountAttributes addDevice(Device device)
      Add a device to the user.
      Parameters:
      device - to be added
      Returns:
      copy of the user with the device added
    • replaceDevice

      public AccountAttributes replaceDevice(Device device)
    • removeDevice

      public AccountAttributes removeDevice(Device device)
      Remove device from the user.
      Parameters:
      device - to be removed
      Returns:
      copy of the user, with the device removed
    • getLinkedAccounts

      public ComplexAttribute<LinkedAccount> getLinkedAccounts()
      Get the accounts linked to this user.
      Returns:
      list of accounts, empty if not found
    • addLinkedAccount

      public AccountAttributes addLinkedAccount(LinkedAccount linkedAccount)
      Add a LinkedAccount to the user. NOTE that for adding new linked accounts and persisting them on the account the AccountManager.link(AccountAttributes, AccountDomain, SubjectAttributes, boolean) method MUST be used.
      Parameters:
      linkedAccount - to be added
      Returns:
      copy of the user with the linkedAccount added
    • removeLinkedAccounts

      public AccountAttributes removeLinkedAccounts(LinkedAccount linkedAccount)
      Remove LinkedAccountfrom the user. NOTE that for removing linked accounts and persisting the changes on the account the AccountManager.deleteLink(AccountAttributes, AccountDomain, SubjectAttributes) or AccountManager.deleteLinks(AccountAttributes) method MUST be used.
      Parameters:
      linkedAccount - to be removed
      Returns:
      copy of the user, with the linkedAccount removed
    • with

      public AccountAttributes with(Attribute attribute)
      Add an arbitrary attribute to the user. can contain anything an Attribute can contain. The attribute will be accessible through the Attributes.get(String) method.

      This can be used to add extensions to the user account.

       AccountAttributes user = AccountAttributes.of("User");
       user = user.with(Attribute.of("foo", "bar"));
       assert "bar".equals(user.get("foo").getValue());
       
      Specified by:
      with in interface AttributeContainer<Attributes>
      Overrides:
      with in class ResourceAttributes<AccountAttributes>
      Parameters:
      attribute - attribute to add or to override
      Returns:
      copy of the user with the attribute set.
    • of

      public static AccountAttributes of(Attribute... attributes)
      Create an object with attributes.
      Parameters:
      attributes - to add to the user object
      Returns:
      AccountAttributes with the attributes
    • of

      public static AccountAttributes of(Iterable<Attribute> attributes)
    • from

      protected AccountAttributes from(Attributes attributes)
      Convert the given Attributes to an AccountAttributes.
      Specified by:
      from in class ResourceAttributes<AccountAttributes>
      Parameters:
      attributes - representing the new AccountAttributes
      Returns:
      AccountAttributes with the attributes
    • of

      public static AccountAttributes of(String id, String userName)
      Create a user object with userName.
      Parameters:
      id - id of the account
      userName - for the account
      Returns:
      AccountAttributes with the userName set
    • withAddresses

      public AccountAttributes withAddresses(Address... addresses)
      Update object with addresses.
      Parameters:
      addresses - to add to the user
      Returns:
      copy of the AccountAttributes, with the added addresses
    • withEmails

      public AccountAttributes withEmails(Email... emails)
      Update the object with emails.
      Parameters:
      emails - to add to the user
      Returns:
      copy of the AccountAttributes, with the added emails
    • withEntitlements

      public AccountAttributes withEntitlements(Entitlement... entitlements)
      Update the object with entitlements.
      Parameters:
      entitlements - to add to the user
      Returns:
      copy of the AccountAttributes, with the added entitlements
    • withGroups

      public AccountAttributes withGroups(Group... groups)
      Update the object with groups.
      Parameters:
      groups - to add to the user
      Returns:
      copy of the AccountAttributes, with the added groups
    • withIms

      public AccountAttributes withIms(InstantMessaging... ims)
      Update the object with im handles.
      Parameters:
      ims - to add to the user
      Returns:
      copy of the AccountAttributes, with the added im handles
    • withPhoneNumbers

      public AccountAttributes withPhoneNumbers(PhoneNumber... phoneNumbers)
      Update the object with phoneNumbers.
      Parameters:
      phoneNumbers - to add to the user
      Returns:
      copy of the AccountAttributes, with the added phoneNumbers
    • withPhotos

      public AccountAttributes withPhotos(Photo... photos)
      Update the object with photos.
      Parameters:
      photos - to add to the user
      Returns:
      copy of the AccountAttributes, with the added photos
    • withRoles

      public AccountAttributes withRoles(Role... roles)
      Update the object with roles.
      Parameters:
      roles - to add to the user
      Returns:
      copy of the AccountAttributes, with the added roles
    • withX509Certificates

      public AccountAttributes withX509Certificates(X509Certificates certificates)
      Update the object with certificates.
      Parameters:
      certificates - to add to the user
      Returns:
      copy of the AccountAttributes, with the added certificates
    • withName

      public AccountAttributes withName(Name name)
      Update the user with the name components.
      Parameters:
      name - to add or override
      Returns:
      copy of the AccountAttributes, with the new name
    • withDisplayName

      public AccountAttributes withDisplayName(String displayName)
      Update the object with displayName.
      Parameters:
      displayName - to add or override
      Returns:
      copy of the AccountAttributes, with the new displayName
    • withNickName

      public AccountAttributes withNickName(String nickName)
      Update the object with nickName.
      Parameters:
      nickName - to add or override
      Returns:
      copy of the AccountAttributes, with the new nickName
    • withTitle

      public AccountAttributes withTitle(String title)
      Update the object with title.
      Parameters:
      title - to add or override
      Returns:
      copy of the AccountAttributes, with the new title
    • withUserType

      public AccountAttributes withUserType(String userType)
      Update the object with userType.
      Parameters:
      userType - to add or override
      Returns:
      copy of the AccountAttributes, with the new userType
    • withProfileUrl

      public AccountAttributes withProfileUrl(String profileUrl)
      Update the object with profileUrl.
      Parameters:
      profileUrl - to add or override
      Returns:
      copy of the AccountAttributes, with the new profileUrl
    • withPreferredLanguage

      public AccountAttributes withPreferredLanguage(String preferredLanguage)
      Update the object with preferredLanguage.
      Parameters:
      preferredLanguage - to add or override
      Returns:
      copy of the AccountAttributes, with the new preferredLanguage
    • withLocale

      public AccountAttributes withLocale(String locale)
      Update the object with locale.
      Parameters:
      locale - to add or override
      Returns:
      copy of the AccountAttributes, with the new locale
    • withTimeZone

      public AccountAttributes withTimeZone(String timezone)
      Update the object with timezone.
      Parameters:
      timezone - to add or override
      Returns:
      copy of the AccountAttributes, with the new timezone
    • withPassword

      public AccountAttributes withPassword(String password)
      Update the object with password. NOTE that actually changing the password of an account should always be done through a CredentialManager as setting or updating passwords involve hashing and possibly other requirements.
      Parameters:
      password - to add or override
      Returns:
      copy of the AccountAttributes, with the new password
    • withActive

      public AccountAttributes withActive(boolean active)
      Update the object with the active flag.
      Parameters:
      active - to add or override
      Returns:
      copy of the AccountAttributes, with the new active
    • withDevices

      public AccountAttributes withDevices(Device... devices)
      Update the object with devices.

      Will add the DEVICES to the schemas if it's not already there

      Parameters:
      devices - to add
      Returns:
      copy of AccountAttributes with the added schema and devices
    • withLinkedAccounts

      public AccountAttributes withLinkedAccounts(LinkedAccount... linkedAccounts)
      Update the object with linked accounts. NOTE that for adding new linked accounts and persisting them on the account the AccountManager.link(AccountAttributes, AccountDomain, SubjectAttributes, boolean) method MUST be used.

      Will add the LINKED_ACCOUNTS to the schemas if it's not already there

      Parameters:
      linkedAccounts - to add
      Returns:
      copy of AccountAttributes with the added schema and linkedAccounts