Class ResourceAttributes<R extends ResourceAttributes<R>>

Object
se.curity.identityserver.sdk.attribute.Attributes
se.curity.identityserver.sdk.attribute.scim.v2.ResourceAttributes<R>
All Implemented Interfaces:
Iterable<Attribute>, AttributeContainer<Attributes>, SerializableAsMap
Direct Known Subclasses:
AccountAttributes, DeviceAttributes, DynamicallyRegisteredClientAttributes

public abstract class ResourceAttributes<R extends ResourceAttributes<R>> extends Attributes
Base class for the SCIM types

A resource can be a user, device, group and such.

  • Field Details

  • Constructor Details

    • ResourceAttributes

      protected ResourceAttributes(Attributes attributes, String schema)
      Must perform no validation whatsoever! This is used to create resources that may not contain anything. If the mandatory attributes are missing (ID for example) the caller might be able to handle that appropriately.
      Parameters:
      attributes - attributes
      schema - schema of this resource
  • Method Details

    • wrap

      public static ResourceAttributes<?> wrap(Iterable<Attribute> attributes, String schema)
    • fromMap

      public static ResourceAttributes<?> fromMap(Map<String,?> map)
    • from

      protected abstract R from(Attributes attributes)
      Create a new instance of R from the provided Attributes.
      Parameters:
      attributes - source attributes.
      Returns:
      attributes wrapped into an instance of R.
    • getId

      public String getId()
      A unique identifier for a SCIM resource as defined by the service provider.

      This is a mandatory value.

      Returns:
      the id
    • getExternalId

      @Nullable public @Nullable String getExternalId()
      A String that is an identifier for the resource as defined by the provisioning client.
      Returns:
      the external ID, or null if not set
    • getMeta

      @Nullable public @Nullable Meta getMeta()
      An attribute containing resource metadata.
      Returns:
      the meta data of the resource, or null if not set
    • getSchemas

      public List<String> getSchemas()
      The namespaces used in this resource.

      This is a mandatory value

      Returns:
      list of schemas
    • with

      public R with(Attribute attribute)
      Description copied from interface: AttributeContainer
      Add the given attribute if not present, or replace the attribute if it already exists. Note that two attributes with the same name and different authorities are considered distinct.
      Specified by:
      with in interface AttributeContainer<R extends ResourceAttributes<R>>
      Overrides:
      with in class Attributes
      Parameters:
      attribute - attribute to add or to override
      Returns:
      a copy of this which contains the given Attribute
    • with

      public R with(Iterable<Attribute> attributes)
      Description copied from interface: AttributeContainer
      Add the given attributes if not present, or replace the attribute if it already exists. Note that two attributes with the same name and different authorities are considered distinct.
      Specified by:
      with in interface AttributeContainer<R extends ResourceAttributes<R>>
      Overrides:
      with in class Attributes
      Parameters:
      attributes - attribute to add or to override
      Returns:
      a copy of this which contains the given Attributes
    • append

      public R append(Iterable<Attribute> attributes)
      Description copied from interface: AttributeContainer
      Appends the given attribute to a copy of this, returning the result.
      Specified by:
      append in interface AttributeContainer<R extends ResourceAttributes<R>>
      Overrides:
      append in class Attributes
      Parameters:
      attributes - to append
      Returns:
      copy of this with the provided attribute appended to it
    • withSchemas

      public R withSchemas(String... schemas)
      Update the resource with schemas.
      Parameters:
      schemas - to add
      Returns:
      copy of the resource with the added schemas
    • addSchema

      public R addSchema(String schema)
      Add the given schema to the List of schemas if necessary.

      If the given schema was already in the List, an unmodified instance is returned.

      Parameters:
      schema - to add
      Returns:
      copy of the resource with the added schemas, or the unmodified instance if the schema already existed
    • withMeta

      public R withMeta(Meta meta)
      Update the resource with meta data.
      Parameters:
      meta - to add
      Returns:
      copy of the resource with the added meta
    • withId

      public R withId(String id)
      Update the resource with id.
      Parameters:
      id - to add
      Returns:
      copy of the resource with the added id
    • withExternalId

      public R withExternalId(String externalId)
      Update the resource with external id.
      Parameters:
      externalId - to add
      Returns:
      copy of the resource with the added external id
    • removeAttribute

      public R removeAttribute(String name)
      Remove the top-level attribute with the given name.
      Parameters:
      name - of the attributes to exclude.
      Returns:
      this Attributes without the excluded top-level attribute
      Throws:
      IllegalArgumentException - if a mandatory attribute is removed, because that would cause the resource to become invalid.
    • filter

      public ResourceAttributes<?> filter(ResourceQuery.AttributesEnumeration attributesEnumeration)
      Filter the attributes of this ResourceAttributes.

      Because the attributes enumeration may remove mandatory attributes from type <R>, the returned instance is a more generic ResourceAttributes<?>. Notice that this means the enumeration must NOT filter out attributes which are mandatory in ResourceAttributes<?>.

      Parameters:
      attributesEnumeration - to use for filtering attributes.
      Returns:
      these attributes filtered using the given predicate.
    • getBooleanValue

      @Nullable protected static @Nullable Boolean getBooleanValue(@Nullable Attribute attribute)
    • getStringValue

      @Nullable protected static @Nullable String getStringValue(@Nullable Attribute attribute)
    • getStringValue

      @Nullable protected static @Nullable String getStringValue(@Nullable Attribute attribute, NullableFunction<String,String> validator)
      Gets the validated string value of an attribute
      Parameters:
      attribute - the source attribute
      validator - the validator function, which returns an optional error string
      Returns:
      the validated string value of the attribute
    • getListOfUniqueStringsValue

      @Nullable protected static @Nullable List<String> getListOfUniqueStringsValue(@Nullable Attribute attribute)
    • logFailedAttributeValidation

      protected static void logFailedAttributeValidation(String path, AttributeValue attributeValue, String expectedType)
    • logFailedAttributeValidation

      protected static void logFailedAttributeValidation(String path, String value, String validationError)