-
Notifications
You must be signed in to change notification settings - Fork 77
/
Copy pathOrganizationModel.java
108 lines (67 loc) · 2.66 KB
/
OrganizationModel.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package io.phasetwo.service.model;
import com.google.common.collect.MoreCollectors;
import java.util.Set;
import java.util.stream.Stream;
import org.keycloak.models.IdentityProviderModel;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.RealmModel;
import org.keycloak.models.UserModel;
import org.keycloak.provider.ProviderEvent;
public interface OrganizationModel extends WithAttributes {
String getId();
String getName();
void setName(String name);
String getDisplayName();
void setDisplayName(String displayName);
Set<String> getDomains();
void setDomains(Set<String> domain);
DomainModel getDomain(String name);
String getUrl();
void setUrl(String url);
RealmModel getRealm();
UserModel getCreatedBy();
default Long getMembersCount() {
return getMembersCount(false);
}
default Stream<UserModel> getMembersStream() {
return getMembersStream(false);
}
default Stream<UserModel> searchForMembersStream(
String search, Integer firstResult, Integer maxResults) {
return searchForMembersStream(search, firstResult, maxResults, false);
}
Long getMembersCount(boolean excludeAdminAccounts);
Stream<UserModel> getMembersStream(boolean excludeAdminAccounts);
Stream<UserModel> searchForMembersStream(
String search, Integer firstResult, Integer maxResults, boolean excludeAdminAccounts);
boolean hasMembership(UserModel user);
void grantMembership(UserModel user);
void revokeMembership(UserModel user);
Long getInvitationsCount();
Stream<InvitationModel> getInvitationsStream();
default Stream<InvitationModel> getInvitationsByEmail(String email) {
return getInvitationsStream().filter(i -> i.getEmail().equals(email));
}
InvitationModel getInvitation(String id);
void revokeInvitation(String id);
void revokeInvitations(String email);
InvitationModel addInvitation(String email, UserModel inviter);
Stream<OrganizationRoleModel> getRolesStream();
Stream<OrganizationRoleModel> getRolesByUserStream(UserModel user);
default OrganizationRoleModel getRoleByName(String name) {
return getRolesStream()
.filter(r -> name.equals(r.getName()))
.collect(MoreCollectors.toOptional())
.orElse(null);
}
void removeRole(String name);
OrganizationRoleModel addRole(String name);
Stream<IdentityProviderModel> getIdentityProvidersStream();
interface OrganizationEvent extends ProviderEvent {
OrganizationModel getOrganization();
KeycloakSession getKeycloakSession();
RealmModel getRealm();
}
interface OrganizationCreationEvent extends OrganizationEvent {}
interface OrganizationRemovedEvent extends OrganizationEvent {}
}