Interface OrganizationProvider
- All Superinterfaces:
Provider
- All Known Implementing Classes:
InfinispanOrganizationProvider,JpaOrganizationProvider
Provider that manages organization and its data within the scope of a realm.-
Method Summary
Modifier and TypeMethodDescriptionbooleanaddIdentityProvider(OrganizationModel organization, IdentityProviderModel identityProvider) Associate the givenIdentityProviderModelwith the givenOrganizationModel.booleanaddManagedMember(OrganizationModel organization, UserModel user) Adds the givenUserModelas a managed member of the givenOrganizationModel.booleanaddMember(OrganizationModel organization, UserModel user) Adds the givenUserModelas an unmanaged member of the givenOrganizationModel.longcount()Returns number of organizations in the realm.default longReturns the number of organizations in the realm filtered according to the specified parameters.default longReturns the number of organizations in the realm filtered according to the specified parameters.default OrganizationModelCreates a new organization with givennameandaliasto the realm.Creates a new organization with givenid,name, andaliasto the realmcreateGroup(OrganizationModel organization, String id, String name, GroupModel toParent) Creates a new group with the givenidwithin the givenOrganizationModel.default GroupModelcreateGroup(OrganizationModel organization, String name, GroupModel toParent) Creates a new group within the givenOrganizationModel.default Stream<OrganizationModel>Returns all organizations in the realm.getAllStream(String search, Boolean exact, Integer first, Integer max) Returns all organizations in the realm filtered according to the specified parameters.Returns all organizations in the realm filtered according to the specified parameters.default OrganizationModelgetByAlias(String alias) Returns anOrganizationModelwith the givenalias.getByDomainName(String domainName) Returns aOrganizationModelby its internet domain.Returns aOrganizationModelby itsid;getByMember(UserModel member) Returns theOrganizationModelthat thememberbelongs to.getIdentityProviders(OrganizationModel organization) Returns aInvitationManagerfor managing invitationsgetMemberById(OrganizationModel organization, String id) Returns the member of theOrganizationModelby itsid.longgetMembersCount(OrganizationModel organization) Returns number of members in the organization.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.getMembersStream(OrganizationModel organization, Map<String, String> filters, Boolean exact, Integer first, Integer max) Returns the members of a givenOrganizationModelfiltered according to the specifiedfilters.getOrganizationGroupsByMember(OrganizationModel organization, UserModel member) Returns all organization groups that the givenmemberexplicitly belongs to within the givenorganization.getTopLevelGroups(OrganizationModel organization, Integer firstResult, Integer maxResults) Returns the top-level groups of the givenOrganizationModel.booleanIndicates if the current realm supports organization.booleanisManagedMember(OrganizationModel organization, UserModel member) Indicates if the givenmemberis managed by the organization.default booleanisMember(OrganizationModel organization, UserModel user) Indicates if the givenuseris a member of the givenorganization.booleanremove(OrganizationModel organization) Removes the given organization from the realm together with the data associated with it, e.g.voidRemoves all organizations from the realm.booleanremoveIdentityProvider(OrganizationModel organization, IdentityProviderModel identityProvider) Removes the link between the givenOrganizationModeland the identity provider associated with it if such a link exists.booleanremoveMember(OrganizationModel organization, UserModel member) Removes a member from the organization.searchGroupsByAttributes(OrganizationModel organization, Map<String, String> attributes, Integer firstResult, Integer maxResults) Returns groups of the givenOrganizationModelfiltered by group attributes.searchGroupsByName(OrganizationModel organization, String search, Boolean exact, Integer firstResult, Integer maxResults) Returns groups of the givenOrganizationModelfiltered by group name.
-
Method Details
-
create
Creates a new organization with givennameandaliasto 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 toname. 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
Creates a new organization with givenid,name, andaliasto 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 toname. 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 aOrganizationModelby itsid;- Parameters:
id- the id of an organization- Returns:
- the organization with the given
idornullif there is no such an organization.
-
getByDomainName
Returns aOrganizationModelby 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
Returns all organizations in the realm.- Returns:
- a
Streamof the realm's organizations.
-
getAllStream
Returns all organizations in the realm filtered according to the specified parameters.- Parameters:
search- aStringrepresenting either an organization name or domain.exact- iftrue, the organizations will be searched using exact match for thesearchparam - i.e. either the organization name or one of its domains must match exactly thesearchparam. If false, the method returns all organizations whose name or (domains) partially match thesearchparam.first- the position of the first result to be processed (pagination offset). Ignored if negative ornull.max- the maximum number of results to be returned. Ignored if negative ornull.- Returns:
- a
Streamof the matched organizations. Never returnsnull.
-
getAllStream
Returns all organizations in the realm filtered according to the specified parameters.- Parameters:
attributes- aMapcontaining the attributes (name/value) that must match organization attributes.first- the position of the first result to be processed (pagination offset). Ignored if negative ornull.max- the maximum number of results to be returned. Ignored if negative ornull.- Returns:
- a
Streamof the matched organizations. Never returnsnull.
-
count
Returns the number of organizations in the realm filtered according to the specified parameters.- Parameters:
search- aStringrepresenting either an organization name or domain.exact- iftrue, the organizations will be searched using exact match for thesearchparam - i.e. either the organization name or one of its domains must match exactly thesearchparam. If false, the method returns all organizations whose name or (domains) partially match thesearchparam.- Returns:
- the number matched organizations.
-
count
Returns the number of organizations in the realm filtered according to the specified parameters.- Parameters:
attributes- aMapcontaining the attributes (name/value) that must match organization attributes.- Returns:
- the number matched organizations.
-
remove
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:
trueif the organization was removed,falseotherwise- 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
Adds the givenUserModelas a managed member of the givenOrganizationModel.- Parameters:
organization- the organizationuser- the user- Returns:
trueif the user was added as a member. Otherwise, returnsfalse- Throws:
ModelException- if theUserModelis member of different organization
-
addMember
Adds the givenUserModelas an unmanaged member of the givenOrganizationModel.- Parameters:
organization- the organizationuser- the user- Returns:
trueif the user was added as a member. Otherwise, returnsfalse- Throws:
ModelException- if theUserModelis 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 givenOrganizationModelfiltered 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 givenOrganizationModelfiltered according to the specifiedfilters.- Parameters:
organization- the organization- Returns:
- Stream of the members. Never returns
null.
-
getMembersCount
Returns number of members in the organization.- Parameters:
organization- the organization- Returns:
- Number of members in the organization.
-
getMemberById
Returns the member of theOrganizationModelby itsid.- Parameters:
organization- the organizationid- the member id- Returns:
- the member of the
OrganizationModelwith the givenid
-
getByMember
Returns theOrganizationModelthat thememberbelongs to.- Parameters:
member- the member of an organization- Returns:
- the organizations the
memberbelongs to or an empty stream if the user doesn't belong to any.
-
createGroup
Creates a new group within the givenOrganizationModel. The internal ID of the group will be created automatically. The created group will be of typeGroupModel.Type.ORGANIZATION. IftoParentisnull, the group will be created as a top-level organization group, as a direct child of the organization's internal group structure. IftoParentis provided, the group will be created as a subgroup of the specified parent.- Parameters:
organization- the organization to create the group inname- the name of the group to createtoParent- the parent group under which to create the new group. Ifnull, the group is created as a top-level organization group. If provided, must be an organization group (typeGroupModel.Type.ORGANIZATION) belonging to the same organization.- Returns:
- the newly created
GroupModel - Throws:
ModelException- iforganizationornameisnullModelValidationException- iftoParentis not an organization group or does not belong to the specified organization
-
createGroup
Creates a new group with the givenidwithin the givenOrganizationModel. The created group will be of typeGroupModel.Type.ORGANIZATION. IftoParentisnull, the group will be created as a top-level organization group, as a direct child of the organization's internal group structure. IftoParentis provided, the group will be created as a subgroup of the specified parent.- Parameters:
organization- the organization to create the group inid- the id of the group. Ifnull, an id will be generated automatically.name- the name of the group to createtoParent- the parent group under which to create the new group. Ifnull, the group is created as a top-level organization group. If provided, must be an organization group (typeGroupModel.Type.ORGANIZATION) belonging to the same organization.- Returns:
- the newly created
GroupModel - Throws:
ModelException- iforganizationornameisnullModelValidationException- iftoParentis 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 givenOrganizationModel.- Parameters:
organization- the organizationfirstResult- the position of the first result to be processed (pagination offset). Ignored if negative ornull.maxResults- the maximum number of results to be returned. Ignored if negative ornull.- 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 givenOrganizationModelfiltered by group name.- Parameters:
organization- the organizationsearch- the string to search for in group names. Case-sensitive.exact- iftrue, the groups will be searched using exact match. Iffalse, partial match is used.firstResult- the position of the first result to be processed (pagination offset). Ignored if negative ornull.maxResults- the maximum number of results to be returned. Ignored if negative ornull.- 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 givenOrganizationModelfiltered by group attributes.- Parameters:
organization- the organizationattributes- aMapcontaining the attributes (name/value) that must match group attributes.firstResult- the position of the first result to be processed (pagination offset). Ignored if negative ornull.maxResults- the maximum number of results to be returned. Ignored if negative ornull.- Returns:
- Stream of groups matching the attribute criteria. Never returns
null.
-
getOrganizationGroupsByMember
Returns all organization groups that the givenmemberexplicitly belongs to within the givenorganization. Only returns groups of typeGroupModel.Type.ORGANIZATIONthat 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 checkmember- the user whose group memberships to retrieve- Returns:
- Stream of organization groups the member belongs to. Never returns
null.
-
addIdentityProvider
Associate the givenIdentityProviderModelwith the givenOrganizationModel.- Parameters:
organization- the organizationidentityProvider- the identityProvider- Returns:
trueif the identityProvider was associated with the organization. Otherwise, returnsfalse
-
getIdentityProviders
- Parameters:
organization- the organization- Returns:
- Stream of the identity providers associated with the given
organization. Never returnsnull.
-
removeIdentityProvider
boolean removeIdentityProvider(OrganizationModel organization, IdentityProviderModel identityProvider) Removes the link between the givenOrganizationModeland the identity provider associated with it if such a link exists.- Parameters:
organization- the organizationidentityProvider- the identity provider- Returns:
trueif the link was removed,falseotherwise
-
isEnabled
boolean isEnabled()Indicates if the current realm supports organization.- Returns:
trueif organization is supported. Otherwise, returnsfalse
-
isManagedMember
Indicates if the given
memberis 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 organizationmember- the member- Returns:
trueif thememberis managed by the givenorganization. Otherwise, returnsfalse
-
isMember
Indicates if the givenuseris a member of the givenorganization.- Parameters:
organization- the organizationuser- the member- Returns:
trueif the user is a member. Otherwise,false
-
removeMember
Removes a member from the organization.
This method can either remove the given
memberentirely from the realm (and the organization) or only remove the link to theorganizationso 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 organizationmember- the member- Returns:
trueif the givenmemberis a member and was successfully removed from the organization. Otherwise, returnsfalse
-
count
long count()Returns number of organizations in the realm.- Returns:
- long Number of organizations
-
getByAlias
Returns anOrganizationModelwith the givenalias.- Parameters:
alias- the alias- Returns:
- the organization
-
getInvitationManager
InvitationManager getInvitationManager()Returns aInvitationManagerfor managing invitations- Returns:
- the invitation manager
-
getMembersStream(OrganizationModel, Map, Boolean, Integer, Integer)instead.