-
Notifications
You must be signed in to change notification settings - Fork 72
/
OrganizationModel.java
94 lines (56 loc) · 2.22 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
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();
Long getMembersCount();
Stream<UserModel> getMembersStream();
Stream<UserModel> searchForMembersStream(String search, Integer firstResult, Integer maxResults);
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 {}
}