Interface OrganizationProvider

All Superinterfaces:
Provider
All Known Implementing Classes:
InfinispanOrganizationProvider, JpaOrganizationProvider

public interface OrganizationProvider extends Provider
A Provider that manages organization and its data within the scope of a realm.
  • Method Details

    • create

      default OrganizationModel create(String name, String alias)
      Creates a new organization with given name and alias to the realm. The internal ID of the organization will be created automatically.
      Parameters:
      name - the name of the organization.
      alias - the alias of the organization. If not set, defaults to the value set to name. Once set, the alias is immutable.
      Returns:
      Model of the created organization.
      Throws:
      ModelDuplicateException - If there is already an organization with the given name or alias
    • create

      OrganizationModel create(String id, String name, String alias)
      Creates a new organization with given id, name, and alias to the realm
      Parameters:
      id - the id of the organization.
      name - the name of the organization.
      alias - the alias of the organization. If not set, defaults to the value set to name. Once set, the alias is immutable.
      Returns:
      Model of the created organization.
      Throws:
      ModelDuplicateException - If there is already an organization with the given name or alias
    • getById

      Returns a OrganizationModel by its id;
      Parameters:
      id - the id of an organization
      Returns:
      the organization with the given id or null if there is no such an organization.
    • getByDomainName

      OrganizationModel getByDomainName(String domainName)
      Returns a OrganizationModel by its internet domain.
      Parameters:
      domainName - the organization's internet domain (e.g. redhat.com)
      Returns:
      the organization that is linked to the given internet domain
    • getAllStream

      default Stream<OrganizationModel> getAllStream()
      Returns all organizations in the realm.
      Returns:
      a Stream of the realm's organizations.
    • getAllStream

      Stream<OrganizationModel> getAllStream(String search, Boolean exact, Integer first, Integer max)
      Returns all organizations in the realm filtered according to the specified parameters.
      Parameters:
      search - a String representing either an organization name or domain.
      exact - if true, the organizations will be searched using exact match for the search param - i.e. either the organization name or one of its domains must match exactly the search param. If false, the method returns all organizations whose name or (domains) partially match the search param.
      first - the position of the first result to be processed (pagination offset). Ignored if negative or null.
      max - the maximum number of results to be returned. Ignored if negative or null.
      Returns:
      a Stream of the matched organizations. Never returns null.
    • getAllStream

      Stream<OrganizationModel> getAllStream(Map<String,String> attributes, Integer first, Integer max)
      Returns all organizations in the realm filtered according to the specified parameters.
      Parameters:
      attributes - a Map containing the attributes (name/value) that must match organization attributes.
      first - the position of the first result to be processed (pagination offset). Ignored if negative or null.
      max - the maximum number of results to be returned. Ignored if negative or null.
      Returns:
      a Stream of the matched organizations. Never returns null.
    • count

      default long count(String search, Boolean exact)
      Returns the number of organizations in the realm filtered according to the specified parameters.
      Parameters:
      search - a String representing either an organization name or domain.
      exact - if true, the organizations will be searched using exact match for the search param - i.e. either the organization name or one of its domains must match exactly the search param. If false, the method returns all organizations whose name or (domains) partially match the search param.
      Returns:
      the number matched organizations.
    • count

      default long count(Map<String,String> attributes)
      Returns the number of organizations in the realm filtered according to the specified parameters.
      Parameters:
      attributes - a Map containing the attributes (name/value) that must match organization attributes.
      Returns:
      the number matched organizations.
    • remove

      boolean remove(OrganizationModel organization)
      Removes the given organization from the realm together with the data associated with it, e.g. its members etc.
      Parameters:
      organization - Organization to be removed.
      Returns:
      true if the organization was removed, false otherwise
      Throws:
      ModelException - if the organization doesn't exist or doesn't belong to the realm.
    • removeAll

      void removeAll()
      Removes all organizations from the realm.
    • addManagedMember

      boolean addManagedMember(OrganizationModel organization, UserModel user)
      Adds the given UserModel as a managed member of the given OrganizationModel.
      Parameters:
      organization - the organization
      user - the user
      Returns:
      true if the user was added as a member. Otherwise, returns false
      Throws:
      ModelException - if the UserModel is member of different organization
    • addMember

      boolean addMember(OrganizationModel organization, UserModel user)
      Adds the given UserModel as an unmanaged member of the given OrganizationModel.
      Parameters:
      organization - the organization
      user - the user
      Returns:
      true if the user was added as a member. Otherwise, returns false
      Throws:
      ModelException - if the UserModel is member of different organization
    • getMembersStream

      @Deprecated(forRemoval=true, since="26") Stream<UserModel> getMembersStream(OrganizationModel organization, String search, Boolean exact, Integer first, Integer max)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns the members of a given OrganizationModel filtered according to the specified parameters.
      Parameters:
      organization - the organization
      Returns:
      Stream of the members. Never returns null.
    • getMembersStream

      default Stream<UserModel> getMembersStream(OrganizationModel organization, Map<String,String> filters, Boolean exact, Integer first, Integer max)
      Returns the members of a given OrganizationModel filtered according to the specified filters.
      Parameters:
      organization - the organization
      Returns:
      Stream of the members. Never returns null.
    • getMembersCount

      long getMembersCount(OrganizationModel organization)
      Returns number of members in the organization.
      Parameters:
      organization - the organization
      Returns:
      Number of members in the organization.
    • getMemberById

      UserModel getMemberById(OrganizationModel organization, String id)
      Returns the member of the OrganizationModel by its id.
      Parameters:
      organization - the organization
      id - the member id
      Returns:
      the member of the OrganizationModel with the given id
    • getByMember

      Stream<OrganizationModel> getByMember(UserModel member)
      Returns the OrganizationModel that the member belongs to.
      Parameters:
      member - the member of an organization
      Returns:
      the organizations the member belongs to or an empty stream if the user doesn't belong to any.
    • createGroup

      default GroupModel createGroup(OrganizationModel organization, String name, GroupModel toParent)
      Creates a new group within the given OrganizationModel. The internal ID of the group will be created automatically. The created group will be of type GroupModel.Type.ORGANIZATION. If toParent is null, the group will be created as a top-level organization group, as a direct child of the organization's internal group structure. If toParent is provided, the group will be created as a subgroup of the specified parent.
      Parameters:
      organization - the organization to create the group in
      name - the name of the group to create
      toParent - the parent group under which to create the new group. If null, the group is created as a top-level organization group. If provided, must be an organization group (type GroupModel.Type.ORGANIZATION) belonging to the same organization.
      Returns:
      the newly created GroupModel
      Throws:
      ModelException - if organization or name is null
      ModelValidationException - if toParent is not an organization group or does not belong to the specified organization
    • createGroup

      GroupModel createGroup(OrganizationModel organization, String id, String name, GroupModel toParent)
      Creates a new group with the given id within the given OrganizationModel. The created group will be of type GroupModel.Type.ORGANIZATION. If toParent is null, the group will be created as a top-level organization group, as a direct child of the organization's internal group structure. If toParent is provided, the group will be created as a subgroup of the specified parent.
      Parameters:
      organization - the organization to create the group in
      id - the id of the group. If null, an id will be generated automatically.
      name - the name of the group to create
      toParent - the parent group under which to create the new group. If null, the group is created as a top-level organization group. If provided, must be an organization group (type GroupModel.Type.ORGANIZATION) belonging to the same organization.
      Returns:
      the newly created GroupModel
      Throws:
      ModelException - if organization or name is null
      ModelValidationException - if toParent is not an organization group or does not belong to the specified organization
    • getTopLevelGroups

      Stream<GroupModel> getTopLevelGroups(OrganizationModel organization, Integer firstResult, Integer maxResults)
      Returns the top-level groups of the given OrganizationModel.
      Parameters:
      organization - the organization
      firstResult - the position of the first result to be processed (pagination offset). Ignored if negative or null.
      maxResults - the maximum number of results to be returned. Ignored if negative or null.
      Returns:
      Stream of top-level groups in the organization. Never returns null.
    • searchGroupsByName

      Stream<GroupModel> searchGroupsByName(OrganizationModel organization, String search, Boolean exact, Integer firstResult, Integer maxResults)
      Returns groups of the given OrganizationModel filtered by group name.
      Parameters:
      organization - the organization
      search - the string to search for in group names. Case-sensitive.
      exact - if true, the groups will be searched using exact match. If false, partial match is used.
      firstResult - the position of the first result to be processed (pagination offset). Ignored if negative or null.
      maxResults - the maximum number of results to be returned. Ignored if negative or null.
      Returns:
      Stream of groups matching the search criteria. Never returns null.
    • searchGroupsByAttributes

      Stream<GroupModel> searchGroupsByAttributes(OrganizationModel organization, Map<String,String> attributes, Integer firstResult, Integer maxResults)
      Returns groups of the given OrganizationModel filtered by group attributes.
      Parameters:
      organization - the organization
      attributes - a Map containing the attributes (name/value) that must match group attributes.
      firstResult - the position of the first result to be processed (pagination offset). Ignored if negative or null.
      maxResults - the maximum number of results to be returned. Ignored if negative or null.
      Returns:
      Stream of groups matching the attribute criteria. Never returns null.
    • getOrganizationGroupsByMember

      Stream<GroupModel> getOrganizationGroupsByMember(OrganizationModel organization, UserModel member)
      Returns all organization groups that the given member explicitly belongs to within the given organization. Only returns groups of type GroupModel.Type.ORGANIZATION that belong to the specified organization. Membership is explicit - being a member of a child group does not imply membership in parent groups.
      Parameters:
      organization - the organization whose groups to check
      member - the user whose group memberships to retrieve
      Returns:
      Stream of organization groups the member belongs to. Never returns null.
    • addIdentityProvider

      boolean addIdentityProvider(OrganizationModel organization, IdentityProviderModel identityProvider)
      Associate the given IdentityProviderModel with the given OrganizationModel.
      Parameters:
      organization - the organization
      identityProvider - the identityProvider
      Returns:
      true if the identityProvider was associated with the organization. Otherwise, returns false
    • getIdentityProviders

      Stream<IdentityProviderModel> getIdentityProviders(OrganizationModel organization)
      Parameters:
      organization - the organization
      Returns:
      Stream of the identity providers associated with the given organization. Never returns null.
    • removeIdentityProvider

      boolean removeIdentityProvider(OrganizationModel organization, IdentityProviderModel identityProvider)
      Removes the link between the given OrganizationModel and the identity provider associated with it if such a link exists.
      Parameters:
      organization - the organization
      identityProvider - the identity provider
      Returns:
      true if the link was removed, false otherwise
    • isEnabled

      boolean isEnabled()
      Indicates if the current realm supports organization.
      Returns:
      true if organization is supported. Otherwise, returns false
    • isManagedMember

      boolean isManagedMember(OrganizationModel organization, UserModel member)

      Indicates if the given member is managed by the organization.

      A member is managed by the organization whenever the member cannot exist without the organization they belong to so that their lifecycle is bound to the organization lifecycle. For instance, when a member is federated from the identity provider associated with an organization, there is a strong relationship between the member identity and the organization.

      On the other hand, existing realm users whose identities are not intrinsically linked to an organization but are eventually joining an organization are not managed by the organization. They have a lifecycle that does not depend on the organization they are linked to.

      Parameters:
      organization - the organization
      member - the member
      Returns:
      true if the member is managed by the given organization. Otherwise, returns false
    • isMember

      default boolean isMember(OrganizationModel organization, UserModel user)
      Indicates if the given user is a member of the given organization.
      Parameters:
      organization - the organization
      user - the member
      Returns:
      true if the user is a member. Otherwise, false
    • removeMember

      boolean removeMember(OrganizationModel organization, UserModel member)

      Removes a member from the organization.

      This method can either remove the given member entirely from the realm (and the organization) or only remove the link to the organization so that the user still exists but is no longer a member of the organization. The decision to remove the user entirely or only the link depends on whether the user is managed by the organization or not, respectively.

      Parameters:
      organization - the organization
      member - the member
      Returns:
      true if the given member is a member and was successfully removed from the organization. Otherwise, returns false
    • count

      long count()
      Returns number of organizations in the realm.
      Returns:
      long Number of organizations
    • getByAlias

      default OrganizationModel getByAlias(String alias)
      Returns an OrganizationModel with the given alias.
      Parameters:
      alias - the alias
      Returns:
      the organization
    • getInvitationManager

      InvitationManager getInvitationManager()
      Returns a InvitationManager for managing invitations
      Returns:
      the invitation manager