keycloak-oidc-service
静的公開メンバ関数 | 全メンバ一覧
org.keycloak.models.utils.ModelToRepresentation クラス
org.keycloak.models.utils.ModelToRepresentation 連携図
Collaboration graph

静的公開メンバ関数

static void buildGroupPath (StringBuilder sb, GroupModel group)
 
static String buildGroupPath (GroupModel group)
 
static GroupRepresentation toRepresentation (GroupModel group, boolean full)
 
static List< GroupRepresentation > searchForGroupByName (RealmModel realm, String search, Integer first, Integer max)
 
static List< GroupRepresentation > toGroupHierarchy (RealmModel realm, boolean full, Integer first, Integer max)
 
static List< GroupRepresentation > toGroupHierarchy (RealmModel realm, boolean full)
 
static GroupRepresentation toGroupHierarchy (GroupModel group, boolean full)
 
static UserRepresentation toRepresentation (KeycloakSession session, RealmModel realm, UserModel user)
 
static UserRepresentation toBriefRepresentation (UserModel user)
 
static EventRepresentation toRepresentation (Event event)
 
static AdminEventRepresentation toRepresentation (AdminEvent adminEvent)
 
static AuthDetailsRepresentation toRepresentation (AuthDetails authDetails)
 
static RoleRepresentation toRepresentation (RoleModel role)
 
static RealmRepresentation toRepresentation (RealmModel realm, boolean internal)
 
static void exportGroups (RealmModel realm, RealmRepresentation rep)
 
static void exportAuthenticationFlows (RealmModel realm, RealmRepresentation rep)
 
static void exportRequiredActions (RealmModel realm, RealmRepresentation rep)
 
static RealmEventsConfigRepresentation toEventsConfigReprensetation (RealmModel realm)
 
static CredentialRepresentation toRepresentation (UserCredentialModel cred)
 
static FederatedIdentityRepresentation toRepresentation (FederatedIdentityModel socialLink)
 
static UserSessionRepresentation toRepresentation (UserSessionModel session)
 
static ClientScopeRepresentation toRepresentation (ClientScopeModel clientScopeModel)
 
static ClientRepresentation toRepresentation (ClientModel clientModel, KeycloakSession session)
 
static IdentityProviderRepresentation toRepresentation (RealmModel realm, IdentityProviderModel identityProviderModel)
 
static ProtocolMapperRepresentation toRepresentation (ProtocolMapperModel model)
 
static IdentityProviderMapperRepresentation toRepresentation (IdentityProviderMapperModel model)
 
static UserConsentRepresentation toRepresentation (UserConsentModel model)
 
static AuthenticationFlowRepresentation toRepresentation (RealmModel realm, AuthenticationFlowModel model)
 
static AuthenticationExecutionExportRepresentation toRepresentation (RealmModel realm, AuthenticationExecutionModel model)
 
static AuthenticatorConfigRepresentation toRepresentation (AuthenticatorConfigModel model)
 
static RequiredActionProviderRepresentation toRepresentation (RequiredActionProviderModel model)
 
static List< ConfigPropertyRepresentation > toRepresentation (List< ProviderConfigProperty > configProperties)
 
static ConfigPropertyRepresentation toRepresentation (ProviderConfigProperty prop)
 
static ComponentRepresentation toRepresentation (KeycloakSession session, ComponentModel component, boolean internal)
 
static ComponentRepresentation toRepresentationWithoutConfig (ComponentModel component)
 
static ScopeRepresentation toRepresentation (Scope model)
 
static ResourceServerRepresentation toRepresentation (ResourceServer model, ClientModel client)
 
static< R extends AbstractPolicyRepresentation > R toRepresentation (Policy policy, AuthorizationProvider authorization)
 
static< R extends AbstractPolicyRepresentation > R toRepresentation (Policy policy, AuthorizationProvider authorization, boolean genericRepresentation, boolean export)
 
static ResourceRepresentation toRepresentation (Resource model, ResourceServer resourceServer, AuthorizationProvider authorization)
 
static ResourceRepresentation toRepresentation (Resource model, ResourceServer resourceServer, AuthorizationProvider authorization, Boolean deep)
 
static PermissionTicketRepresentation toRepresentation (PermissionTicket ticket, AuthorizationProvider authorization)
 
static PermissionTicketRepresentation toRepresentation (PermissionTicket ticket, AuthorizationProvider authorization, boolean returnNames)
 

詳解

著者
Bill Burke
バージョン
Revision
1

関数詳解

◆ buildGroupPath() [1/2]

static void org.keycloak.models.utils.ModelToRepresentation.buildGroupPath ( StringBuilder  sb,
GroupModel  group 
)
inlinestatic
53  {
54  if (group.getParent() != null) {
55  buildGroupPath(sb, group.getParent());
56  }
57  sb.append('/').append(group.getName());
58  }
static void buildGroupPath(StringBuilder sb, GroupModel group)
Definition: ModelToRepresentation.java:53

◆ buildGroupPath() [2/2]

static String org.keycloak.models.utils.ModelToRepresentation.buildGroupPath ( GroupModel  group)
inlinestatic
60  {
61  StringBuilder sb = new StringBuilder();
62  buildGroupPath(sb, group);
63  return sb.toString();
64  }
static void buildGroupPath(StringBuilder sb, GroupModel group)
Definition: ModelToRepresentation.java:53

◆ exportAuthenticationFlows()

static void org.keycloak.models.utils.ModelToRepresentation.exportAuthenticationFlows ( RealmModel  realm,
RealmRepresentation  rep 
)
inlinestatic
375  {
376  rep.setAuthenticationFlows(new LinkedList<AuthenticationFlowRepresentation>());
377  rep.setAuthenticatorConfig(new LinkedList<AuthenticatorConfigRepresentation>());
378 
379  List<AuthenticationFlowModel> authenticationFlows = new ArrayList<>(realm.getAuthenticationFlows());
380  //ensure consistent ordering of authenticationFlows.
381  Collections.sort(authenticationFlows, new Comparator<AuthenticationFlowModel>() {
382  @Override
383  public int compare(AuthenticationFlowModel left, AuthenticationFlowModel right) {
384  String l = left.getAlias() != null ? left.getAlias() : "\0";
385  String r = right.getAlias() != null ? right.getAlias() : "\0";
386  return l.compareTo(r);
387  }
388  });
389 
390  for (AuthenticationFlowModel model : authenticationFlows) {
391  AuthenticationFlowRepresentation flowRep = toRepresentation(realm, model);
392  rep.getAuthenticationFlows().add(flowRep);
393  }
394 
395  List<AuthenticatorConfigModel> authenticatorConfigs = new ArrayList<>(realm.getAuthenticatorConfigs());
396  //ensure consistent ordering of authenticatorConfigs.
397  Collections.sort(authenticatorConfigs, new Comparator<AuthenticatorConfigModel>() {
398  @Override
399  public int compare(AuthenticatorConfigModel left, AuthenticatorConfigModel right) {
400  String l = left.getAlias() != null ? left.getAlias() : "\0";
401  String r = right.getAlias() != null ? right.getAlias() : "\0";
402  return l.compareTo(r);
403  }
404  });
405 
406  for (AuthenticatorConfigModel model : authenticatorConfigs) {
407  rep.getAuthenticatorConfig().add(toRepresentation(model));
408  }
409 
410  }
String getAlias()
Definition: AuthenticatorConfigModel.java:43
Definition: AuthenticatorConfigModel.java:28
List< AuthenticationFlowModel > getAuthenticationFlows()
List< AuthenticatorConfigModel > getAuthenticatorConfigs()
Definition: AuthenticationFlowModel.java:26
String getAlias()
Definition: AuthenticationFlowModel.java:43
static GroupRepresentation toRepresentation(GroupModel group, boolean full)
Definition: ModelToRepresentation.java:67

◆ exportGroups()

static void org.keycloak.models.utils.ModelToRepresentation.exportGroups ( RealmModel  realm,
RealmRepresentation  rep 
)
inlinestatic
370  {
371  List<GroupRepresentation> groups = toGroupHierarchy(realm, true);
372  rep.setGroups(groups);
373  }
static List< GroupRepresentation > toGroupHierarchy(RealmModel realm, boolean full, Integer first, Integer max)
Definition: ModelToRepresentation.java:105

◆ exportRequiredActions()

static void org.keycloak.models.utils.ModelToRepresentation.exportRequiredActions ( RealmModel  realm,
RealmRepresentation  rep 
)
inlinestatic
412  {
413 
414  rep.setRequiredActions(new LinkedList<>());
415 
416  realm.getRequiredActionProviders().forEach(action -> rep.getRequiredActions().add(toRepresentation(action)));
417  }
List< RequiredActionProviderModel > getRequiredActionProviders()
static GroupRepresentation toRepresentation(GroupModel group, boolean full)
Definition: ModelToRepresentation.java:67

◆ searchForGroupByName()

static List<GroupRepresentation> org.keycloak.models.utils.ModelToRepresentation.searchForGroupByName ( RealmModel  realm,
String  search,
Integer  first,
Integer  max 
)
inlinestatic
94  {
95  List<GroupRepresentation> result = new LinkedList<>();
96  List<GroupModel> groups = realm.searchForGroupByName(search, first, max);
97  if (Objects.isNull(groups)) return result;
98  for (GroupModel group : groups) {
99  GroupRepresentation rep = toGroupHierarchy(group, false);
100  result.add(rep);
101  }
102  return result;
103  }
static List< GroupRepresentation > toGroupHierarchy(RealmModel realm, boolean full, Integer first, Integer max)
Definition: ModelToRepresentation.java:105
List< GroupModel > searchForGroupByName(String search, Integer first, Integer max)
Definition: GroupModel.java:30

◆ toBriefRepresentation()

static UserRepresentation org.keycloak.models.utils.ModelToRepresentation.toBriefRepresentation ( UserModel  user)
inlinestatic
169  {
170  UserRepresentation rep = new UserRepresentation();
171  rep.setId(user.getId());
172  rep.setUsername(user.getUsername());
173  rep.setCreatedTimestamp(user.getCreatedTimestamp());
174  rep.setLastName(user.getLastName());
175  rep.setFirstName(user.getFirstName());
176  rep.setEmail(user.getEmail());
177  rep.setEnabled(user.isEnabled());
178  rep.setEmailVerified(user.isEmailVerified());
179  rep.setFederationLink(user.getFederationLink());
180 
181  return rep;
182  }

◆ toEventsConfigReprensetation()

static RealmEventsConfigRepresentation org.keycloak.models.utils.ModelToRepresentation.toEventsConfigReprensetation ( RealmModel  realm)
inlinestatic
419  {
420  RealmEventsConfigRepresentation rep = new RealmEventsConfigRepresentation();
421  rep.setEventsEnabled(realm.isEventsEnabled());
422 
423  if (realm.getEventsExpiration() != 0) {
424  rep.setEventsExpiration(realm.getEventsExpiration());
425  }
426 
427  if (realm.getEventsListeners() != null) {
428  rep.setEventsListeners(new LinkedList<>(realm.getEventsListeners()));
429  }
430 
431  if(realm.getEnabledEventTypes() != null) {
432  rep.setEnabledEventTypes(new LinkedList<>(realm.getEnabledEventTypes()));
433  }
434 
435  rep.setAdminEventsEnabled(realm.isAdminEventsEnabled());
436 
437  rep.setAdminEventsDetailsEnabled(realm.isAdminEventsDetailsEnabled());
438 
439  return rep;
440  }
Set< String > getEventsListeners()
Set< String > getEnabledEventTypes()

◆ toGroupHierarchy() [1/3]

static List<GroupRepresentation> org.keycloak.models.utils.ModelToRepresentation.toGroupHierarchy ( RealmModel  realm,
boolean  full,
Integer  first,
Integer  max 
)
inlinestatic
105  {
106  List<GroupRepresentation> hierarchy = new LinkedList<>();
107  List<GroupModel> groups = realm.getTopLevelGroups(first, max);
108  if (Objects.isNull(groups)) return hierarchy;
109  for (GroupModel group : groups) {
110  GroupRepresentation rep = toGroupHierarchy(group, full);
111  hierarchy.add(rep);
112  }
113  return hierarchy;
114  }
static List< GroupRepresentation > toGroupHierarchy(RealmModel realm, boolean full, Integer first, Integer max)
Definition: ModelToRepresentation.java:105
List< GroupModel > getTopLevelGroups()
Definition: GroupModel.java:30

◆ toGroupHierarchy() [2/3]

static List<GroupRepresentation> org.keycloak.models.utils.ModelToRepresentation.toGroupHierarchy ( RealmModel  realm,
boolean  full 
)
inlinestatic
116  {
117  List<GroupRepresentation> hierarchy = new LinkedList<>();
118  List<GroupModel> groups = realm.getTopLevelGroups();
119  if (Objects.isNull(groups)) return hierarchy;
120  for (GroupModel group : groups) {
121  GroupRepresentation rep = toGroupHierarchy(group, full);
122  hierarchy.add(rep);
123  }
124  return hierarchy;
125  }
static List< GroupRepresentation > toGroupHierarchy(RealmModel realm, boolean full, Integer first, Integer max)
Definition: ModelToRepresentation.java:105
List< GroupModel > getTopLevelGroups()
Definition: GroupModel.java:30

◆ toGroupHierarchy() [3/3]

static GroupRepresentation org.keycloak.models.utils.ModelToRepresentation.toGroupHierarchy ( GroupModel  group,
boolean  full 
)
inlinestatic
127  {
128  GroupRepresentation rep = toRepresentation(group, full);
129  List<GroupRepresentation> subGroups = new LinkedList<>();
130  for (GroupModel subGroup : group.getSubGroups()) {
131  subGroups.add(toGroupHierarchy(subGroup, full));
132  }
133  rep.setSubGroups(subGroups);
134  return rep;
135  }
static List< GroupRepresentation > toGroupHierarchy(RealmModel realm, boolean full, Integer first, Integer max)
Definition: ModelToRepresentation.java:105
Set< GroupModel > getSubGroups()
static GroupRepresentation toRepresentation(GroupModel group, boolean full)
Definition: ModelToRepresentation.java:67
Definition: GroupModel.java:30

◆ toRepresentation() [1/31]

static GroupRepresentation org.keycloak.models.utils.ModelToRepresentation.toRepresentation ( GroupModel  group,
boolean  full 
)
inlinestatic
67  {
68  GroupRepresentation rep = new GroupRepresentation();
69  rep.setId(group.getId());
70  rep.setName(group.getName());
71  rep.setPath(buildGroupPath(group));
72  if (!full) return rep;
73  // Role mappings
74  Set<RoleModel> roles = group.getRoleMappings();
75  List<String> realmRoleNames = new ArrayList<>();
76  Map<String, List<String>> clientRoleNames = new HashMap<>();
77  for (RoleModel role : roles) {
78  if (role.getContainer() instanceof RealmModel) {
79  realmRoleNames.add(role.getName());
80  } else {
81  ClientModel client = (ClientModel)role.getContainer();
82  String clientId = client.getClientId();
83  List<String> currentClientRoles = clientRoleNames.computeIfAbsent(clientId, k -> new ArrayList<>());
84  currentClientRoles.add(role.getName());
85  }
86  }
87  rep.setRealmRoles(realmRoleNames);
88  rep.setClientRoles(clientRoleNames);
89  Map<String, List<String>> attributes = group.getAttributes();
90  rep.setAttributes(attributes);
91  return rep;
92  }
Set< RoleModel > getRoleMappings()
Definition: RoleModel.java:26
static void buildGroupPath(StringBuilder sb, GroupModel group)
Definition: ModelToRepresentation.java:53
Map< String, List< String > > getAttributes()
Definition: ClientModel.java:27
Definition: RealmModel.java:34

◆ toRepresentation() [2/31]

static UserRepresentation org.keycloak.models.utils.ModelToRepresentation.toRepresentation ( KeycloakSession  session,
RealmModel  realm,
UserModel  user 
)
inlinestatic
137  {
138  UserRepresentation rep = new UserRepresentation();
139  rep.setId(user.getId());
140  String providerId = StorageId.resolveProviderId(user);
141  rep.setOrigin(providerId);
142  rep.setUsername(user.getUsername());
143  rep.setCreatedTimestamp(user.getCreatedTimestamp());
144  rep.setLastName(user.getLastName());
145  rep.setFirstName(user.getFirstName());
146  rep.setEmail(user.getEmail());
147  rep.setEnabled(user.isEnabled());
148  rep.setEmailVerified(user.isEmailVerified());
149  rep.setTotp(session.userCredentialManager().isConfiguredFor(realm, user, CredentialModel.OTP));
150  rep.setDisableableCredentialTypes(session.userCredentialManager().getDisableableCredentialTypes(realm, user));
151  rep.setFederationLink(user.getFederationLink());
152 
153  rep.setNotBefore(session.users().getNotBeforeOfUser(realm, user));
154 
155  List<String> reqActions = new ArrayList<String>();
156  Set<String> requiredActions = user.getRequiredActions();
157  reqActions.addAll(requiredActions);
158 
159  rep.setRequiredActions(reqActions);
160 
161  if (user.getAttributes() != null && !user.getAttributes().isEmpty()) {
162  Map<String, List<String>> attrs = new HashMap<>();
163  attrs.putAll(user.getAttributes());
164  rep.setAttributes(attrs);
165  }
166  return rep;
167  }
int getNotBeforeOfUser(RealmModel realm, UserModel user)
static final String OTP
Definition: CredentialModel.java:40
Map< String, List< String > > getAttributes()
UserCredentialManager userCredentialManager()
Set< String > getDisableableCredentialTypes(RealmModel realm, UserModel user)
boolean isConfiguredFor(RealmModel realm, UserModel user, String type)
Set< String > getRequiredActions()
Definition: CredentialModel.java:29

◆ toRepresentation() [3/31]

static EventRepresentation org.keycloak.models.utils.ModelToRepresentation.toRepresentation ( Event  event)
inlinestatic
184  {
185  EventRepresentation rep = new EventRepresentation();
186  rep.setTime(event.getTime());
187  rep.setType(event.getType().toString());
188  rep.setRealmId(event.getRealmId());
189  rep.setClientId(event.getClientId());
190  rep.setUserId(event.getUserId());
191  rep.setSessionId(event.getSessionId());
192  rep.setIpAddress(event.getIpAddress());
193  rep.setError(event.getError());
194  rep.setDetails(event.getDetails());
195  return rep;
196  }

◆ toRepresentation() [4/31]

static AdminEventRepresentation org.keycloak.models.utils.ModelToRepresentation.toRepresentation ( AdminEvent  adminEvent)
inlinestatic
198  {
199  AdminEventRepresentation rep = new AdminEventRepresentation();
200  rep.setTime(adminEvent.getTime());
201  rep.setRealmId(adminEvent.getRealmId());
202  if (adminEvent.getAuthDetails() != null) {
203  rep.setAuthDetails(toRepresentation(adminEvent.getAuthDetails()));
204  }
205  rep.setOperationType(adminEvent.getOperationType().toString());
206  if (adminEvent.getResourceType() != null) {
207  rep.setResourceType(adminEvent.getResourceType().toString());
208  }
209  rep.setResourcePath(adminEvent.getResourcePath());
210  rep.setRepresentation(adminEvent.getRepresentation());
211  rep.setError(adminEvent.getError());
212 
213  return rep;
214  }
static GroupRepresentation toRepresentation(GroupModel group, boolean full)
Definition: ModelToRepresentation.java:67

◆ toRepresentation() [5/31]

static AuthDetailsRepresentation org.keycloak.models.utils.ModelToRepresentation.toRepresentation ( AuthDetails  authDetails)
inlinestatic
216  {
217  AuthDetailsRepresentation rep = new AuthDetailsRepresentation();
218  rep.setRealmId(authDetails.getRealmId());
219  rep.setClientId(authDetails.getClientId());
220  rep.setUserId(authDetails.getUserId());
221  rep.setIpAddress(authDetails.getIpAddress());
222  return rep;
223  }

◆ toRepresentation() [6/31]

static RoleRepresentation org.keycloak.models.utils.ModelToRepresentation.toRepresentation ( RoleModel  role)
inlinestatic
225  {
226  RoleRepresentation rep = new RoleRepresentation();
227  rep.setId(role.getId());
228  rep.setName(role.getName());
229  rep.setDescription(role.getDescription());
230  rep.setComposite(role.isComposite());
231  rep.setClientRole(role.isClientRole());
232  rep.setContainerId(role.getContainerId());
233  return rep;
234  }

◆ toRepresentation() [7/31]

static RealmRepresentation org.keycloak.models.utils.ModelToRepresentation.toRepresentation ( RealmModel  realm,
boolean  internal 
)
inlinestatic
236  {
237  RealmRepresentation rep = new RealmRepresentation();
238  rep.setId(realm.getId());
239  rep.setRealm(realm.getName());
240  rep.setDisplayName(realm.getDisplayName());
241  rep.setDisplayNameHtml(realm.getDisplayNameHtml());
242  rep.setEnabled(realm.isEnabled());
243  rep.setNotBefore(realm.getNotBefore());
244  rep.setSslRequired(realm.getSslRequired().name().toLowerCase());
245  rep.setRegistrationAllowed(realm.isRegistrationAllowed());
246  rep.setRegistrationEmailAsUsername(realm.isRegistrationEmailAsUsername());
247  rep.setRememberMe(realm.isRememberMe());
248  rep.setBruteForceProtected(realm.isBruteForceProtected());
249  rep.setPermanentLockout(realm.isPermanentLockout());
250  rep.setMaxFailureWaitSeconds(realm.getMaxFailureWaitSeconds());
251  rep.setMinimumQuickLoginWaitSeconds(realm.getMinimumQuickLoginWaitSeconds());
252  rep.setWaitIncrementSeconds(realm.getWaitIncrementSeconds());
253  rep.setQuickLoginCheckMilliSeconds(realm.getQuickLoginCheckMilliSeconds());
254  rep.setMaxDeltaTimeSeconds(realm.getMaxDeltaTimeSeconds());
255  rep.setFailureFactor(realm.getFailureFactor());
256  rep.setUserManagedAccessAllowed(realm.isUserManagedAccessAllowed());
257 
258  rep.setEventsEnabled(realm.isEventsEnabled());
259  if (realm.getEventsExpiration() != 0) {
260  rep.setEventsExpiration(realm.getEventsExpiration());
261  }
262  if (realm.getEventsListeners() != null) {
263  rep.setEventsListeners(new LinkedList<String>(realm.getEventsListeners()));
264  }
265  if (realm.getEnabledEventTypes() != null) {
266  rep.setEnabledEventTypes(new LinkedList<String>(realm.getEnabledEventTypes()));
267  }
268 
269  rep.setAdminEventsEnabled(realm.isAdminEventsEnabled());
270  rep.setAdminEventsDetailsEnabled(realm.isAdminEventsDetailsEnabled());
271 
272  rep.setVerifyEmail(realm.isVerifyEmail());
273  rep.setLoginWithEmailAllowed(realm.isLoginWithEmailAllowed());
274  rep.setDuplicateEmailsAllowed(realm.isDuplicateEmailsAllowed());
275  rep.setResetPasswordAllowed(realm.isResetPasswordAllowed());
276  rep.setEditUsernameAllowed(realm.isEditUsernameAllowed());
277  rep.setDefaultSignatureAlgorithm(realm.getDefaultSignatureAlgorithm());
278  rep.setRevokeRefreshToken(realm.isRevokeRefreshToken());
279  rep.setRefreshTokenMaxReuse(realm.getRefreshTokenMaxReuse());
280  rep.setAccessTokenLifespan(realm.getAccessTokenLifespan());
281  rep.setAccessTokenLifespanForImplicitFlow(realm.getAccessTokenLifespanForImplicitFlow());
282  rep.setSsoSessionIdleTimeout(realm.getSsoSessionIdleTimeout());
283  rep.setSsoSessionMaxLifespan(realm.getSsoSessionMaxLifespan());
284  rep.setOfflineSessionIdleTimeout(realm.getOfflineSessionIdleTimeout());
285  // KEYCLOAK-7688 Offline Session Max for Offline Token
286  rep.setOfflineSessionMaxLifespanEnabled(realm.isOfflineSessionMaxLifespanEnabled());
287  rep.setOfflineSessionMaxLifespan(realm.getOfflineSessionMaxLifespan());
288  rep.setAccessCodeLifespan(realm.getAccessCodeLifespan());
289  rep.setAccessCodeLifespanUserAction(realm.getAccessCodeLifespanUserAction());
290  rep.setAccessCodeLifespanLogin(realm.getAccessCodeLifespanLogin());
291  rep.setActionTokenGeneratedByAdminLifespan(realm.getActionTokenGeneratedByAdminLifespan());
292  rep.setActionTokenGeneratedByUserLifespan(realm.getActionTokenGeneratedByUserLifespan());
293  rep.setSmtpServer(new HashMap<>(realm.getSmtpConfig()));
294  rep.setBrowserSecurityHeaders(realm.getBrowserSecurityHeaders());
295  rep.setAccountTheme(realm.getAccountTheme());
296  rep.setLoginTheme(realm.getLoginTheme());
297  rep.setAdminTheme(realm.getAdminTheme());
298  rep.setEmailTheme(realm.getEmailTheme());
299  if (realm.getPasswordPolicy() != null) {
300  rep.setPasswordPolicy(realm.getPasswordPolicy().toString());
301  }
302  OTPPolicy otpPolicy = realm.getOTPPolicy();
303  rep.setOtpPolicyAlgorithm(otpPolicy.getAlgorithm());
304  rep.setOtpPolicyPeriod(otpPolicy.getPeriod());
305  rep.setOtpPolicyDigits(otpPolicy.getDigits());
306  rep.setOtpPolicyInitialCounter(otpPolicy.getInitialCounter());
307  rep.setOtpPolicyType(otpPolicy.getType());
308  rep.setOtpPolicyLookAheadWindow(otpPolicy.getLookAheadWindow());
309  rep.setOtpSupportedApplications(otpPolicy.getSupportedApplications());
310  if (realm.getBrowserFlow() != null) rep.setBrowserFlow(realm.getBrowserFlow().getAlias());
311  if (realm.getRegistrationFlow() != null) rep.setRegistrationFlow(realm.getRegistrationFlow().getAlias());
312  if (realm.getDirectGrantFlow() != null) rep.setDirectGrantFlow(realm.getDirectGrantFlow().getAlias());
313  if (realm.getResetCredentialsFlow() != null) rep.setResetCredentialsFlow(realm.getResetCredentialsFlow().getAlias());
314  if (realm.getClientAuthenticationFlow() != null) rep.setClientAuthenticationFlow(realm.getClientAuthenticationFlow().getAlias());
315  if (realm.getDockerAuthenticationFlow() != null) rep.setDockerAuthenticationFlow(realm.getDockerAuthenticationFlow().getAlias());
316 
317  List<String> defaultRoles = realm.getDefaultRoles();
318  if (!defaultRoles.isEmpty()) {
319  List<String> roleStrings = new ArrayList<String>();
320  roleStrings.addAll(defaultRoles);
321  rep.setDefaultRoles(roleStrings);
322  }
323  List<GroupModel> defaultGroups = realm.getDefaultGroups();
324  if (!defaultGroups.isEmpty()) {
325  List<String> groupPaths = new LinkedList<>();
326  for (GroupModel group : defaultGroups) {
327  groupPaths.add(ModelToRepresentation.buildGroupPath(group));
328  }
329  rep.setDefaultGroups(groupPaths);
330  }
331 
332  List<RequiredCredentialModel> requiredCredentialModels = realm.getRequiredCredentials();
333  if (requiredCredentialModels.size() > 0) {
334  rep.setRequiredCredentials(new HashSet<String>());
335  for (RequiredCredentialModel cred : requiredCredentialModels) {
336  rep.getRequiredCredentials().add(cred.getType());
337  }
338  }
339 
340  for (IdentityProviderModel provider : realm.getIdentityProviders()) {
341  rep.addIdentityProvider(toRepresentation(realm, provider));
342  }
343 
345  rep.addIdentityProviderMapper(toRepresentation(mapper));
346  }
347 
348  rep.setInternationalizationEnabled(realm.isInternationalizationEnabled());
349  if(realm.getSupportedLocales() != null){
350  rep.setSupportedLocales(new HashSet<String>());
351  rep.getSupportedLocales().addAll(realm.getSupportedLocales());
352  }
353  rep.setDefaultLocale(realm.getDefaultLocale());
354  if (internal) {
355  exportAuthenticationFlows(realm, rep);
356  exportRequiredActions(realm, rep);
357  exportGroups(realm, rep);
358  }
359 
360  Map<String, String> attributes = realm.getAttributes();
361  rep.setAttributes(attributes);
362 
363  if (!internal) {
364  rep = StripSecretsUtils.strip(rep);
365  }
366 
367  return rep;
368  }
AuthenticationFlowModel getRegistrationFlow()
AuthenticationFlowModel getResetCredentialsFlow()
int getDigits()
Definition: OTPPolicy.java:99
static void exportRequiredActions(RealmModel realm, RealmRepresentation rep)
Definition: ModelToRepresentation.java:412
Set< String > getSupportedLocales()
List< IdentityProviderModel > getIdentityProviders()
List< String > getSupportedApplications()
Definition: OTPPolicy.java:163
Set< String > getEventsListeners()
Set< String > getEnabledEventTypes()
Definition: OTPPolicy.java:36
Definition: RequiredCredentialModel.java:29
Map< String, String > getSmtpConfig()
static void exportGroups(RealmModel realm, RealmRepresentation rep)
Definition: ModelToRepresentation.java:370
List< GroupModel > getDefaultGroups()
int getPeriod()
Definition: OTPPolicy.java:115
static void exportAuthenticationFlows(RealmModel realm, RealmRepresentation rep)
Definition: ModelToRepresentation.java:375
AuthenticationFlowModel getDirectGrantFlow()
AuthenticationFlowModel getClientAuthenticationFlow()
Definition: IdentityProviderMapperModel.java:29
String getType()
Definition: OTPPolicy.java:75
PasswordPolicy getPasswordPolicy()
String getAlgorithm()
Definition: OTPPolicy.java:83
Map< String, String > getAttributes()
Set< IdentityProviderMapperModel > getIdentityProviderMappers()
boolean isOfflineSessionMaxLifespanEnabled()
String getAlias()
Definition: AuthenticationFlowModel.java:43
AuthenticationFlowModel getBrowserFlow()
Map< String, String > getBrowserSecurityHeaders()
static GroupRepresentation toRepresentation(GroupModel group, boolean full)
Definition: ModelToRepresentation.java:67
AuthenticationFlowModel getDockerAuthenticationFlow()
String toString()
Definition: PasswordPolicy.java:107
List< RequiredCredentialModel > getRequiredCredentials()
Definition: IdentityProviderModel.java:29
int getLookAheadWindow()
Definition: OTPPolicy.java:107
int getInitialCounter()
Definition: OTPPolicy.java:91
Definition: GroupModel.java:30

◆ toRepresentation() [8/31]

static CredentialRepresentation org.keycloak.models.utils.ModelToRepresentation.toRepresentation ( UserCredentialModel  cred)
inlinestatic
442  {
443  CredentialRepresentation rep = new CredentialRepresentation();
444  rep.setType(CredentialRepresentation.SECRET);
445  rep.setValue(cred.getValue());
446  return rep;
447  }
String getValue()
Definition: UserCredentialModel.java:128

◆ toRepresentation() [9/31]

static FederatedIdentityRepresentation org.keycloak.models.utils.ModelToRepresentation.toRepresentation ( FederatedIdentityModel  socialLink)
inlinestatic
449  {
450  FederatedIdentityRepresentation rep = new FederatedIdentityRepresentation();
451  rep.setUserName(socialLink.getUserName());
452  rep.setIdentityProvider(socialLink.getIdentityProvider());
453  rep.setUserId(socialLink.getUserId());
454  return rep;
455  }
String getUserName()
Definition: FederatedIdentityModel.java:49
String getUserId()
Definition: FederatedIdentityModel.java:41
String getIdentityProvider()
Definition: FederatedIdentityModel.java:45

◆ toRepresentation() [10/31]

static UserSessionRepresentation org.keycloak.models.utils.ModelToRepresentation.toRepresentation ( UserSessionModel  session)
inlinestatic
457  {
458  UserSessionRepresentation rep = new UserSessionRepresentation();
459  rep.setId(session.getId());
460  rep.setStart(Time.toMillis(session.getStarted()));
461  rep.setLastAccess(Time.toMillis(session.getLastSessionRefresh()));
462  rep.setUsername(session.getUser().getUsername());
463  rep.setUserId(session.getUser().getId());
464  rep.setIpAddress(session.getIpAddress());
465  for (AuthenticatedClientSessionModel clientSession : session.getAuthenticatedClientSessions().values()) {
466  ClientModel client = clientSession.getClient();
467  rep.getClients().put(client.getId(), client.getClientId());
468  }
469  return rep;
470  }
Map< String, AuthenticatedClientSessionModel > getAuthenticatedClientSessions()
Definition: AuthenticatedClientSessionModel.java:28
Definition: ClientModel.java:27

◆ toRepresentation() [11/31]

static ClientScopeRepresentation org.keycloak.models.utils.ModelToRepresentation.toRepresentation ( ClientScopeModel  clientScopeModel)
inlinestatic
472  {
473  ClientScopeRepresentation rep = new ClientScopeRepresentation();
474  rep.setId(clientScopeModel.getId());
475  rep.setName(clientScopeModel.getName());
476  rep.setDescription(clientScopeModel.getDescription());
477  rep.setProtocol(clientScopeModel.getProtocol());
478  if (!clientScopeModel.getProtocolMappers().isEmpty()) {
479  List<ProtocolMapperRepresentation> mappings = new LinkedList<>();
480  for (ProtocolMapperModel model : clientScopeModel.getProtocolMappers()) {
481  mappings.add(toRepresentation(model));
482  }
483  rep.setProtocolMappers(mappings);
484  }
485 
486  rep.setAttributes(new HashMap<>(clientScopeModel.getAttributes()));
487 
488  return rep;
489  }
Definition: ProtocolMapperModel.java:29
Map< String, String > getAttributes()
Set< ProtocolMapperModel > getProtocolMappers()
static GroupRepresentation toRepresentation(GroupModel group, boolean full)
Definition: ModelToRepresentation.java:67

◆ toRepresentation() [12/31]

static ClientRepresentation org.keycloak.models.utils.ModelToRepresentation.toRepresentation ( ClientModel  clientModel,
KeycloakSession  session 
)
inlinestatic
492  {
493  ClientRepresentation rep = new ClientRepresentation();
494  rep.setId(clientModel.getId());
495  String providerId = StorageId.resolveProviderId(clientModel);
496  rep.setOrigin(providerId);
497  rep.setClientId(clientModel.getClientId());
498  rep.setName(clientModel.getName());
499  rep.setDescription(clientModel.getDescription());
500  rep.setEnabled(clientModel.isEnabled());
501  rep.setAdminUrl(clientModel.getManagementUrl());
502  rep.setPublicClient(clientModel.isPublicClient());
503  rep.setFrontchannelLogout(clientModel.isFrontchannelLogout());
504  rep.setProtocol(clientModel.getProtocol());
505  rep.setAttributes(clientModel.getAttributes());
506  rep.setAuthenticationFlowBindingOverrides(clientModel.getAuthenticationFlowBindingOverrides());
507  rep.setFullScopeAllowed(clientModel.isFullScopeAllowed());
508  rep.setBearerOnly(clientModel.isBearerOnly());
509  rep.setConsentRequired(clientModel.isConsentRequired());
510  rep.setStandardFlowEnabled(clientModel.isStandardFlowEnabled());
511  rep.setImplicitFlowEnabled(clientModel.isImplicitFlowEnabled());
512  rep.setDirectAccessGrantsEnabled(clientModel.isDirectAccessGrantsEnabled());
513  rep.setServiceAccountsEnabled(clientModel.isServiceAccountsEnabled());
514  rep.setSurrogateAuthRequired(clientModel.isSurrogateAuthRequired());
515  rep.setRootUrl(clientModel.getRootUrl());
516  rep.setBaseUrl(clientModel.getBaseUrl());
517  rep.setNotBefore(clientModel.getNotBefore());
518  rep.setNodeReRegistrationTimeout(clientModel.getNodeReRegistrationTimeout());
519  rep.setClientAuthenticatorType(clientModel.getClientAuthenticatorType());
520 
521  rep.setDefaultClientScopes(new LinkedList<>(clientModel.getClientScopes(true, false).keySet()));
522  rep.setOptionalClientScopes(new LinkedList<>(clientModel.getClientScopes(false, false).keySet()));
523 
524  Set<String> redirectUris = clientModel.getRedirectUris();
525  if (redirectUris != null) {
526  rep.setRedirectUris(new LinkedList<>(redirectUris));
527  }
528 
529  Set<String> webOrigins = clientModel.getWebOrigins();
530  if (webOrigins != null) {
531  rep.setWebOrigins(new LinkedList<>(webOrigins));
532  }
533 
534  if (!clientModel.getDefaultRoles().isEmpty()) {
535  rep.setDefaultRoles(clientModel.getDefaultRoles().toArray(new String[0]));
536  }
537 
538  if (!clientModel.getRegisteredNodes().isEmpty()) {
539  rep.setRegisteredNodes(new HashMap<>(clientModel.getRegisteredNodes()));
540  }
541 
542  if (!clientModel.getProtocolMappers().isEmpty()) {
543  List<ProtocolMapperRepresentation> mappings = new LinkedList<>();
544  for (ProtocolMapperModel model : clientModel.getProtocolMappers()) {
545  mappings.add(toRepresentation(model));
546  }
547  rep.setProtocolMappers(mappings);
548  }
549 
550  if (Profile.isFeatureEnabled(Profile.Feature.AUTHORIZATION)) {
551  AuthorizationProvider authorization = session.getProvider(AuthorizationProvider.class);
552  ResourceServer resourceServer = authorization.getStoreFactory().getResourceServerStore().findById(clientModel.getId());
553 
554  if (resourceServer != null) {
555  rep.setAuthorizationServicesEnabled(true);
556  }
557  }
558 
559  return rep;
560  }
Map< String, Integer > getRegisteredNodes()
Definition: ProtocolMapperModel.java:29
Set< ProtocolMapperModel > getProtocolMappers()
Map< String, ClientScopeModel > getClientScopes(boolean defaultScope, boolean filterByProtocol)
Map< String, String > getAuthenticationFlowBindingOverrides()
< T extends Provider > T getProvider(Class< T > clazz)
Map< String, String > getAttributes()
static GroupRepresentation toRepresentation(GroupModel group, boolean full)
Definition: ModelToRepresentation.java:67

◆ toRepresentation() [13/31]

static IdentityProviderRepresentation org.keycloak.models.utils.ModelToRepresentation.toRepresentation ( RealmModel  realm,
IdentityProviderModel  identityProviderModel 
)
inlinestatic
562  {
563  IdentityProviderRepresentation providerRep = new IdentityProviderRepresentation();
564 
565  providerRep.setInternalId(identityProviderModel.getInternalId());
566  providerRep.setProviderId(identityProviderModel.getProviderId());
567  providerRep.setAlias(identityProviderModel.getAlias());
568  providerRep.setDisplayName(identityProviderModel.getDisplayName());
569  providerRep.setEnabled(identityProviderModel.isEnabled());
570  providerRep.setLinkOnly(identityProviderModel.isLinkOnly());
571  providerRep.setStoreToken(identityProviderModel.isStoreToken());
572  providerRep.setTrustEmail(identityProviderModel.isTrustEmail());
573  providerRep.setAuthenticateByDefault(identityProviderModel.isAuthenticateByDefault());
574  Map<String, String> config = new HashMap<>();
575  config.putAll(identityProviderModel.getConfig());
576  providerRep.setConfig(config);
577  providerRep.setAddReadTokenRoleOnCreate(identityProviderModel.isAddReadTokenRoleOnCreate());
578 
579  String firstBrokerLoginFlowId = identityProviderModel.getFirstBrokerLoginFlowId();
580  if (firstBrokerLoginFlowId != null) {
581  AuthenticationFlowModel flow = realm.getAuthenticationFlowById(firstBrokerLoginFlowId);
582  if (flow == null) {
583  throw new ModelException("Couldn't find authentication flow with id " + firstBrokerLoginFlowId);
584  }
585  providerRep.setFirstBrokerLoginFlowAlias(flow.getAlias());
586  }
587 
588  String postBrokerLoginFlowId = identityProviderModel.getPostBrokerLoginFlowId();
589  if (postBrokerLoginFlowId != null) {
590  AuthenticationFlowModel flow = realm.getAuthenticationFlowById(postBrokerLoginFlowId);
591  if (flow == null) {
592  throw new ModelException("Couldn't find authentication flow with id " + postBrokerLoginFlowId);
593  }
594  providerRep.setPostBrokerLoginFlowAlias(flow.getAlias());
595  }
596 
597  return providerRep;
598  }
boolean isTrustEmail()
Definition: IdentityProviderModel.java:182
Definition: ModelException.java:23
boolean isEnabled()
Definition: IdentityProviderModel.java:116
String getPostBrokerLoginFlowId()
Definition: IdentityProviderModel.java:158
String getDisplayName()
Definition: IdentityProviderModel.java:190
String getFirstBrokerLoginFlowId()
Definition: IdentityProviderModel.java:150
String getInternalId()
Definition: IdentityProviderModel.java:92
AuthenticationFlowModel getAuthenticationFlowById(String id)
boolean isAddReadTokenRoleOnCreate()
Definition: IdentityProviderModel.java:174
boolean isLinkOnly()
Definition: IdentityProviderModel.java:132
String getAlias()
Definition: IdentityProviderModel.java:100
Definition: AuthenticationFlowModel.java:26
String getAlias()
Definition: AuthenticationFlowModel.java:43
Map< String, String > getConfig()
Definition: IdentityProviderModel.java:166
boolean isAuthenticateByDefault()
Definition: IdentityProviderModel.java:141
String getProviderId()
Definition: IdentityProviderModel.java:108
boolean isStoreToken()
Definition: IdentityProviderModel.java:124

◆ toRepresentation() [14/31]

static ProtocolMapperRepresentation org.keycloak.models.utils.ModelToRepresentation.toRepresentation ( ProtocolMapperModel  model)
inlinestatic
600  {
601  ProtocolMapperRepresentation rep = new ProtocolMapperRepresentation();
602  rep.setId(model.getId());
603  rep.setProtocol(model.getProtocol());
604  Map<String, String> config = new HashMap<String, String>();
605  config.putAll(model.getConfig());
606  rep.setConfig(config);
607  rep.setName(model.getName());
608  rep.setProtocolMapper(model.getProtocolMapper());
609  return rep;
610  }
String getProtocol()
Definition: ProtocolMapperModel.java:56
Map< String, String > getConfig()
Definition: ProtocolMapperModel.java:72
String getName()
Definition: ProtocolMapperModel.java:48
String getProtocolMapper()
Definition: ProtocolMapperModel.java:64
String getId()
Definition: ProtocolMapperModel.java:40

◆ toRepresentation() [15/31]

static IdentityProviderMapperRepresentation org.keycloak.models.utils.ModelToRepresentation.toRepresentation ( IdentityProviderMapperModel  model)
inlinestatic
612  {
613  IdentityProviderMapperRepresentation rep = new IdentityProviderMapperRepresentation();
614  rep.setId(model.getId());
615  rep.setIdentityProviderMapper(model.getIdentityProviderMapper());
616  rep.setIdentityProviderAlias(model.getIdentityProviderAlias());
617  Map<String, String> config = new HashMap<String, String>();
618  config.putAll(model.getConfig());
619  rep.setConfig(config);
620  rep.setName(model.getName());
621  return rep;
622  }
String getIdentityProviderAlias()
Definition: IdentityProviderMapperModel.java:54
Map< String, String > getConfig()
Definition: IdentityProviderMapperModel.java:70
String getIdentityProviderMapper()
Definition: IdentityProviderMapperModel.java:62
String getName()
Definition: IdentityProviderMapperModel.java:46
String getId()
Definition: IdentityProviderMapperModel.java:38

◆ toRepresentation() [16/31]

static UserConsentRepresentation org.keycloak.models.utils.ModelToRepresentation.toRepresentation ( UserConsentModel  model)
inlinestatic
624  {
625  String clientId = model.getClient().getClientId();
626 
627  List<String> grantedClientScopes = new LinkedList<>();
628  for (ClientScopeModel clientScope : model.getGrantedClientScopes()) {
629  grantedClientScopes.add(clientScope.getName());
630  }
631 
632  UserConsentRepresentation consentRep = new UserConsentRepresentation();
633  consentRep.setClientId(clientId);
634  consentRep.setGrantedClientScopes(grantedClientScopes);
635  consentRep.setCreatedDate(model.getCreatedDate());
636  consentRep.setLastUpdatedDate(model.getLastUpdatedDate());
637  return consentRep;
638  }
Definition: ClientScopeModel.java:26
ClientModel getClient()
Definition: UserConsentModel.java:37
Set< ClientScopeModel > getGrantedClientScopes()
Definition: UserConsentModel.java:45
Long getCreatedDate()
Definition: UserConsentModel.java:57
Long getLastUpdatedDate()
Definition: UserConsentModel.java:65

◆ toRepresentation() [17/31]

static AuthenticationFlowRepresentation org.keycloak.models.utils.ModelToRepresentation.toRepresentation ( RealmModel  realm,
AuthenticationFlowModel  model 
)
inlinestatic
640  {
641  AuthenticationFlowRepresentation rep = new AuthenticationFlowRepresentation();
642  rep.setId(model.getId());
643  rep.setBuiltIn(model.isBuiltIn());
644  rep.setTopLevel(model.isTopLevel());
645  rep.setProviderId(model.getProviderId());
646  rep.setAlias(model.getAlias());
647  rep.setDescription(model.getDescription());
648  rep.setAuthenticationExecutions(new LinkedList<AuthenticationExecutionExportRepresentation>());
649  for (AuthenticationExecutionModel execution : realm.getAuthenticationExecutions(model.getId())) {
650  rep.getAuthenticationExecutions().add(toRepresentation(realm, execution));
651  }
652  return rep;
653 
654  }
Definition: AuthenticationExecutionModel.java:27
String getProviderId()
Definition: AuthenticationFlowModel.java:59
boolean isBuiltIn()
Definition: AuthenticationFlowModel.java:75
String getId()
Definition: AuthenticationFlowModel.java:35
String getDescription()
Definition: AuthenticationFlowModel.java:51
String getAlias()
Definition: AuthenticationFlowModel.java:43
static GroupRepresentation toRepresentation(GroupModel group, boolean full)
Definition: ModelToRepresentation.java:67
boolean isTopLevel()
Definition: AuthenticationFlowModel.java:67
List< AuthenticationExecutionModel > getAuthenticationExecutions(String flowId)

◆ toRepresentation() [18/31]

static AuthenticationExecutionExportRepresentation org.keycloak.models.utils.ModelToRepresentation.toRepresentation ( RealmModel  realm,
AuthenticationExecutionModel  model 
)
inlinestatic
656  {
657  AuthenticationExecutionExportRepresentation rep = new AuthenticationExecutionExportRepresentation();
658  if (model.getAuthenticatorConfig() != null) {
660  rep.setAuthenticatorConfig(config.getAlias());
661  }
662  rep.setAuthenticator(model.getAuthenticator());
663  rep.setAutheticatorFlow(model.isAuthenticatorFlow());
664  if (model.getFlowId() != null) {
666  rep.setFlowAlias(flow.getAlias());
667  }
668  rep.setPriority(model.getPriority());
669  rep.setRequirement(model.getRequirement().name());
670  return rep;
671  }
String getAlias()
Definition: AuthenticatorConfigModel.java:43
Definition: AuthenticatorConfigModel.java:28
int getPriority()
Definition: AuthenticationExecutionModel.java:79
AuthenticationFlowModel getAuthenticationFlowById(String id)
AuthenticatorConfigModel getAuthenticatorConfigById(String id)
String getFlowId()
Definition: AuthenticationExecutionModel.java:100
Definition: AuthenticationFlowModel.java:26
boolean isAuthenticatorFlow()
Definition: AuthenticationExecutionModel.java:113
String getAuthenticator()
Definition: AuthenticationExecutionModel.java:63
String getAlias()
Definition: AuthenticationFlowModel.java:43
String getAuthenticatorConfig()
Definition: AuthenticationExecutionModel.java:55
Requirement getRequirement()
Definition: AuthenticationExecutionModel.java:71

◆ toRepresentation() [19/31]

static AuthenticatorConfigRepresentation org.keycloak.models.utils.ModelToRepresentation.toRepresentation ( AuthenticatorConfigModel  model)
inlinestatic
673  {
674  AuthenticatorConfigRepresentation rep = new AuthenticatorConfigRepresentation();
675  rep.setId(model.getId());
676  rep.setAlias(model.getAlias());
677  rep.setConfig(model.getConfig());
678  return rep;
679  }
String getId()
Definition: AuthenticatorConfigModel.java:35
String getAlias()
Definition: AuthenticatorConfigModel.java:43
Map< String, String > getConfig()
Definition: AuthenticatorConfigModel.java:53

◆ toRepresentation() [20/31]

static RequiredActionProviderRepresentation org.keycloak.models.utils.ModelToRepresentation.toRepresentation ( RequiredActionProviderModel  model)
inlinestatic
681  {
682  RequiredActionProviderRepresentation rep = new RequiredActionProviderRepresentation();
683  rep.setAlias(model.getAlias());
684  rep.setDefaultAction(model.isDefaultAction());
685  rep.setEnabled(model.isEnabled());
686  rep.setConfig(model.getConfig());
687  rep.setName(model.getName());
688  rep.setProviderId(model.getProviderId());
689  rep.setPriority(model.getPriority());
690  return rep;
691  }
Map< String, String > getConfig()
Definition: RequiredActionProviderModel.java:116
boolean isDefaultAction()
Definition: RequiredActionProviderModel.java:92
String getProviderId()
Definition: RequiredActionProviderModel.java:100
String getAlias()
Definition: RequiredActionProviderModel.java:62
int getPriority()
Definition: RequiredActionProviderModel.java:108
String getName()
Definition: RequiredActionProviderModel.java:76
boolean isEnabled()
Definition: RequiredActionProviderModel.java:84

◆ toRepresentation() [21/31]

static List<ConfigPropertyRepresentation> org.keycloak.models.utils.ModelToRepresentation.toRepresentation ( List< ProviderConfigProperty configProperties)
inlinestatic
693  {
694  List<ConfigPropertyRepresentation> propertiesRep = new LinkedList<>();
695  for (ProviderConfigProperty prop : configProperties) {
696  ConfigPropertyRepresentation propRep = toRepresentation(prop);
697  propertiesRep.add(propRep);
698  }
699  return propertiesRep;
700  }
static GroupRepresentation toRepresentation(GroupModel group, boolean full)
Definition: ModelToRepresentation.java:67

◆ toRepresentation() [22/31]

static ConfigPropertyRepresentation org.keycloak.models.utils.ModelToRepresentation.toRepresentation ( ProviderConfigProperty  prop)
inlinestatic
702  {
703  ConfigPropertyRepresentation propRep = new ConfigPropertyRepresentation();
704  propRep.setName(prop.getName());
705  propRep.setLabel(prop.getLabel());
706  propRep.setType(prop.getType());
707  propRep.setDefaultValue(prop.getDefaultValue());
708  propRep.setOptions(prop.getOptions());
709  propRep.setHelpText(prop.getHelpText());
710  propRep.setSecret(prop.isSecret());
711  return propRep;
712  }

◆ toRepresentation() [23/31]

static ComponentRepresentation org.keycloak.models.utils.ModelToRepresentation.toRepresentation ( KeycloakSession  session,
ComponentModel  component,
boolean  internal 
)
inlinestatic
714  {
715  ComponentRepresentation rep = toRepresentationWithoutConfig(component);
716  if (!internal) {
717  rep = StripSecretsUtils.strip(session, rep);
718  }
719  return rep;
720  }
static ComponentRepresentation toRepresentationWithoutConfig(ComponentModel component)
Definition: ModelToRepresentation.java:722

◆ toRepresentation() [24/31]

static ScopeRepresentation org.keycloak.models.utils.ModelToRepresentation.toRepresentation ( Scope  model)
inlinestatic
734  {
735  ScopeRepresentation scope = new ScopeRepresentation();
736 
737  scope.setId(model.getId());
738  scope.setName(model.getName());
739  scope.setDisplayName(model.getDisplayName());
740  scope.setIconUri(model.getIconUri());
741 
742  return scope;
743  }

◆ toRepresentation() [25/31]

static ResourceServerRepresentation org.keycloak.models.utils.ModelToRepresentation.toRepresentation ( ResourceServer  model,
ClientModel  client 
)
inlinestatic
745  {
746  ResourceServerRepresentation server = new ResourceServerRepresentation();
747 
748  server.setId(model.getId());
749  server.setClientId(model.getId());
750  server.setName(client.getClientId());
751  server.setAllowRemoteResourceManagement(model.isAllowRemoteResourceManagement());
752  server.setPolicyEnforcementMode(model.getPolicyEnforcementMode());
753 
754  return server;
755  }

◆ toRepresentation() [26/31]

static <R extends AbstractPolicyRepresentation> R org.keycloak.models.utils.ModelToRepresentation.toRepresentation ( Policy  policy,
AuthorizationProvider  authorization 
)
inlinestatic
757  {
758  return toRepresentation(policy, authorization, false, true);
759  }
static GroupRepresentation toRepresentation(GroupModel group, boolean full)
Definition: ModelToRepresentation.java:67

◆ toRepresentation() [27/31]

static <R extends AbstractPolicyRepresentation> R org.keycloak.models.utils.ModelToRepresentation.toRepresentation ( Policy  policy,
AuthorizationProvider  authorization,
boolean  genericRepresentation,
boolean  export 
)
inlinestatic
761  {
762  PolicyProviderFactory providerFactory = authorization.getProviderFactory(policy.getType());
763  R representation;
764 
765  if (genericRepresentation || export) {
766  representation = (R) new PolicyRepresentation();
767  PolicyRepresentation.class.cast(representation).setConfig(policy.getConfig());
768  if (export) {
769  providerFactory.onExport(policy, PolicyRepresentation.class.cast(representation), authorization);
770  }
771  } else {
772  try {
773  representation = (R) providerFactory.toRepresentation(policy, authorization);
774  } catch (Exception cause) {
775  throw new RuntimeException("Could not create policy [" + policy.getType() + "] representation", cause);
776  }
777  }
778 
779  representation.setId(policy.getId());
780  representation.setName(policy.getName());
781  representation.setDescription(policy.getDescription());
782  representation.setType(policy.getType());
783  representation.setDecisionStrategy(policy.getDecisionStrategy());
784  representation.setLogic(policy.getLogic());
785 
786  return representation;
787  }

◆ toRepresentation() [28/31]

static ResourceRepresentation org.keycloak.models.utils.ModelToRepresentation.toRepresentation ( Resource  model,
ResourceServer  resourceServer,
AuthorizationProvider  authorization 
)
inlinestatic
789  {
790  return toRepresentation(model, resourceServer, authorization, true);
791  }
static GroupRepresentation toRepresentation(GroupModel group, boolean full)
Definition: ModelToRepresentation.java:67

◆ toRepresentation() [29/31]

static ResourceRepresentation org.keycloak.models.utils.ModelToRepresentation.toRepresentation ( Resource  model,
ResourceServer  resourceServer,
AuthorizationProvider  authorization,
Boolean  deep 
)
inlinestatic
793  {
794  ResourceRepresentation resource = new ResourceRepresentation();
795 
796  resource.setId(model.getId());
797  resource.setType(model.getType());
798  resource.setName(model.getName());
799  resource.setDisplayName(model.getDisplayName());
800  resource.setUris(model.getUris());
801  resource.setIconUri(model.getIconUri());
802  resource.setOwnerManagedAccess(model.isOwnerManagedAccess());
803 
804  ResourceOwnerRepresentation owner = new ResourceOwnerRepresentation();
805 
806  owner.setId(model.getOwner());
807 
808  KeycloakSession keycloakSession = authorization.getKeycloakSession();
809  RealmModel realm = authorization.getRealm();
810 
811  if (owner.getId().equals(resourceServer.getId())) {
812  ClientModel clientModel = realm.getClientById(resourceServer.getId());
813  owner.setName(clientModel.getClientId());
814  } else {
815  UserModel userModel = keycloakSession.users().getUserById(owner.getId(), realm);
816 
817  if (userModel == null) {
818  throw new RuntimeException("Could not find the user [" + owner.getId() + "] who owns the Resource [" + resource.getId() + "].");
819  }
820 
821  owner.setName(userModel.getUsername());
822  }
823 
824  resource.setOwner(owner);
825 
826  if (deep) {
827  resource.setScopes(model.getScopes().stream().map(model1 -> {
828  ScopeRepresentation scope = new ScopeRepresentation();
829  scope.setId(model1.getId());
830  scope.setName(model1.getName());
831  String iconUri = model1.getIconUri();
832  if (iconUri != null) {
833  scope.setIconUri(iconUri);
834  }
835  return scope;
836  }).collect(Collectors.toSet()));
837 
838  resource.setAttributes(new HashMap<>(model.getAttributes()));
839  }
840 
841  return resource;
842  }
Definition: UserModel.java:30
UserModel getUserById(String id, RealmModel realm)
ClientModel getClientById(String id)
Definition: ClientModel.java:27
Definition: RealmModel.java:34
Definition: KeycloakSession.java:32

◆ toRepresentation() [30/31]

static PermissionTicketRepresentation org.keycloak.models.utils.ModelToRepresentation.toRepresentation ( PermissionTicket  ticket,
AuthorizationProvider  authorization 
)
inlinestatic
844  {
845  return toRepresentation(ticket, authorization, false);
846  }
static GroupRepresentation toRepresentation(GroupModel group, boolean full)
Definition: ModelToRepresentation.java:67

◆ toRepresentation() [31/31]

static PermissionTicketRepresentation org.keycloak.models.utils.ModelToRepresentation.toRepresentation ( PermissionTicket  ticket,
AuthorizationProvider  authorization,
boolean  returnNames 
)
inlinestatic
848  {
849  PermissionTicketRepresentation representation = new PermissionTicketRepresentation();
850 
851  representation.setId(ticket.getId());
852  representation.setGranted(ticket.isGranted());
853  representation.setOwner(ticket.getOwner());
854  representation.setRequester(ticket.getRequester());
855 
856  Resource resource = ticket.getResource();
857 
858  representation.setResource(resource.getId());
859 
860  if (returnNames) {
861  representation.setResourceName(resource.getName());
862  KeycloakSession keycloakSession = authorization.getKeycloakSession();
863  RealmModel realm = authorization.getRealm();
864  UserModel owner = keycloakSession.users().getUserById(ticket.getOwner(), realm);
865  UserModel requester = keycloakSession.users().getUserById(ticket.getRequester(), realm);
866  representation.setRequesterName(requester.getUsername());
867  representation.setOwnerName(owner.getUsername());
868  }
869 
870  Scope scope = ticket.getScope();
871 
872  if (scope != null) {
873  representation.setScope(scope.getId());
874  if (returnNames) {
875  representation.setScopeName(scope.getName());
876  }
877  }
878 
879  return representation;
880  }
Definition: UserModel.java:30
UserModel getUserById(String id, RealmModel realm)
Definition: RealmModel.java:34
Definition: KeycloakSession.java:32

◆ toRepresentationWithoutConfig()

static ComponentRepresentation org.keycloak.models.utils.ModelToRepresentation.toRepresentationWithoutConfig ( ComponentModel  component)
inlinestatic
722  {
723  ComponentRepresentation rep = new ComponentRepresentation();
724  rep.setId(component.getId());
725  rep.setName(component.getName());
726  rep.setProviderId(component.getProviderId());
727  rep.setProviderType(component.getProviderType());
728  rep.setSubType(component.getSubType());
729  rep.setParentId(component.getParentId());
730  rep.setConfig(new MultivaluedHashMap<>(component.getConfig()));
731  return rep;
732  }
String getProviderType()
Definition: ComponentModel.java:143
MultivaluedHashMap< String, String > getConfig()
Definition: ComponentModel.java:71
String getSubType()
Definition: ComponentModel.java:159
String getName()
Definition: ComponentModel.java:63
String getParentId()
Definition: ComponentModel.java:151
String getId()
Definition: ComponentModel.java:55
String getProviderId()
Definition: ComponentModel.java:135

このクラス詳解は次のファイルから抽出されました: