keycloak-service
クラス | 公開メンバ関数 | 非公開メンバ関数 | 非公開変数類 | 全メンバ一覧
org.keycloak.forms.account.freemarker.model.AuthorizationBean クラス
org.keycloak.forms.account.freemarker.model.AuthorizationBean 連携図
Collaboration graph

クラス

class  ManagedPermissionBean
 
class  PermissionScopeBean
 
class  RequesterBean
 
class  ResourceBean
 
class  ResourceServerBean
 

公開メンバ関数

 AuthorizationBean (KeycloakSession session, UserModel user, UriInfo uriInfo)
 
Collection< ResourceBeangetResourcesWaitingOthersApproval ()
 
Collection< ResourceBeangetResourcesWaitingApproval ()
 
List< ResourceBeangetResources ()
 
Collection< ResourceBeangetSharedResources ()
 
ResourceBean getResource ()
 

非公開メンバ関数

ResourceBean getResource (String id)
 
Collection< RequesterBeantoPermissionRepresentation (List< PermissionTicket > permissionRequests)
 
Collection< ResourceBeantoResourceRepresentation (List< PermissionTicket > tickets)
 
List< PermissionTicket > findPermissions (Map< String, String > filters)
 

非公開変数類

final UserModel user
 
final AuthorizationProvider authorization
 
final UriInfo uriInfo
 
ResourceBean resource
 
List< ResourceBeanresources
 
Collection< ResourceBeanuserSharedResources
 
Collection< ResourceBeanrequestsWaitingPermission
 
Collection< ResourceBeanresourcesWaitingOthersApproval
 

詳解

著者
Stian Thorgersen

構築子と解体子

◆ AuthorizationBean()

org.keycloak.forms.account.freemarker.model.AuthorizationBean.AuthorizationBean ( KeycloakSession  session,
UserModel  user,
UriInfo  uriInfo 
)
inline
60  {
61  this.user = user;
62  this.uriInfo = uriInfo;
63  authorization = session.getProvider(AuthorizationProvider.class);
64  List<String> pathParameters = uriInfo.getPathParameters().get("resource_id");
65 
66  if (pathParameters != null && !pathParameters.isEmpty()) {
67  Resource resource = authorization.getStoreFactory().getResourceStore().findById(pathParameters.get(0), null);
68 
69  if (resource != null && !resource.getOwner().equals(user.getId())) {
70  throw new RuntimeException("User [" + user.getUsername() + "] can not access resource [" + resource.getId() + "]");
71  }
72  }
73  }
final AuthorizationProvider authorization
Definition: AuthorizationBean.java:52
final UserModel user
Definition: AuthorizationBean.java:51
final UriInfo uriInfo
Definition: AuthorizationBean.java:53
ResourceBean resource
Definition: AuthorizationBean.java:54

関数詳解

◆ findPermissions()

List<PermissionTicket> org.keycloak.forms.account.freemarker.model.AuthorizationBean.findPermissions ( Map< String, String >  filters)
inlineprivate
344  {
345  return authorization.getStoreFactory().getPermissionTicketStore().find(filters, null, -1, -1);
346  }
final AuthorizationProvider authorization
Definition: AuthorizationBean.java:52

◆ getResource() [1/2]

ResourceBean org.keycloak.forms.account.freemarker.model.AuthorizationBean.getResource ( )
inline
125  {
126  if (resource == null) {
127  String resourceId = uriInfo.getPathParameters().getFirst("resource_id");
128 
129  if (resourceId != null) {
130  resource = getResource(resourceId);
131  }
132  }
133 
134  return resource;
135  }
final UriInfo uriInfo
Definition: AuthorizationBean.java:53
ResourceBean getResource()
Definition: AuthorizationBean.java:125
ResourceBean resource
Definition: AuthorizationBean.java:54

◆ getResource() [2/2]

ResourceBean org.keycloak.forms.account.freemarker.model.AuthorizationBean.getResource ( String  id)
inlineprivate
137  {
138  return new ResourceBean(authorization.getStoreFactory().getResourceStore().findById(id, null));
139  }
final AuthorizationProvider authorization
Definition: AuthorizationBean.java:52

◆ getResources()

List<ResourceBean> org.keycloak.forms.account.freemarker.model.AuthorizationBean.getResources ( )
inline
101  {
102  if (resources == null) {
103  resources = authorization.getStoreFactory().getResourceStore().findByOwner(user.getId(), null).stream()
104  .filter(Resource::isOwnerManagedAccess)
105  .map(ResourceBean::new)
106  .collect(Collectors.toList());
107  }
108  return resources;
109  }
final AuthorizationProvider authorization
Definition: AuthorizationBean.java:52
final UserModel user
Definition: AuthorizationBean.java:51
List< ResourceBean > resources
Definition: AuthorizationBean.java:55

◆ getResourcesWaitingApproval()

Collection<ResourceBean> org.keycloak.forms.account.freemarker.model.AuthorizationBean.getResourcesWaitingApproval ( )
inline
88  {
89  if (requestsWaitingPermission == null) {
90  HashMap<String, String> filters = new HashMap<>();
91 
92  filters.put(PermissionTicket.OWNER, user.getId());
93  filters.put(PermissionTicket.GRANTED, Boolean.FALSE.toString());
94 
96  }
97 
99  }
Collection< ResourceBean > toResourceRepresentation(List< PermissionTicket > tickets)
Definition: AuthorizationBean.java:328
Collection< ResourceBean > requestsWaitingPermission
Definition: AuthorizationBean.java:57
final UserModel user
Definition: AuthorizationBean.java:51
List< PermissionTicket > findPermissions(Map< String, String > filters)
Definition: AuthorizationBean.java:344

◆ getResourcesWaitingOthersApproval()

Collection<ResourceBean> org.keycloak.forms.account.freemarker.model.AuthorizationBean.getResourcesWaitingOthersApproval ( )
inline
75  {
76  if (resourcesWaitingOthersApproval == null) {
77  HashMap<String, String> filters = new HashMap<>();
78 
79  filters.put(PermissionTicket.REQUESTER, user.getId());
80  filters.put(PermissionTicket.GRANTED, Boolean.FALSE.toString());
81 
83  }
84 
86  }
Collection< ResourceBean > toResourceRepresentation(List< PermissionTicket > tickets)
Definition: AuthorizationBean.java:328
final UserModel user
Definition: AuthorizationBean.java:51
Collection< ResourceBean > resourcesWaitingOthersApproval
Definition: AuthorizationBean.java:58
List< PermissionTicket > findPermissions(Map< String, String > filters)
Definition: AuthorizationBean.java:344

◆ getSharedResources()

Collection<ResourceBean> org.keycloak.forms.account.freemarker.model.AuthorizationBean.getSharedResources ( )
inline
111  {
112  if (userSharedResources == null) {
113  HashMap<String, String> filters = new HashMap<>();
114 
115  filters.put(PermissionTicket.REQUESTER, user.getId());
116  filters.put(PermissionTicket.GRANTED, Boolean.TRUE.toString());
117 
118  PermissionTicketStore ticketStore = authorization.getStoreFactory().getPermissionTicketStore();
119 
120  userSharedResources = toResourceRepresentation(ticketStore.find(filters, null, -1, -1));
121  }
122  return userSharedResources;
123  }
final AuthorizationProvider authorization
Definition: AuthorizationBean.java:52
Collection< ResourceBean > toResourceRepresentation(List< PermissionTicket > tickets)
Definition: AuthorizationBean.java:328
final UserModel user
Definition: AuthorizationBean.java:51
Collection< ResourceBean > userSharedResources
Definition: AuthorizationBean.java:56

◆ toPermissionRepresentation()

Collection<RequesterBean> org.keycloak.forms.account.freemarker.model.AuthorizationBean.toPermissionRepresentation ( List< PermissionTicket >  permissionRequests)
inlineprivate
312  {
313  Map<String, RequesterBean> requests = new HashMap<>();
314 
315  for (PermissionTicket ticket : permissionRequests) {
316  Resource resource = ticket.getResource();
317 
318  if (!resource.isOwnerManagedAccess()) {
319  continue;
320  }
321 
322  requests.computeIfAbsent(ticket.getRequester(), resourceId -> new RequesterBean(ticket, authorization)).addScope(ticket);
323  }
324 
325  return requests.values();
326  }
final AuthorizationProvider authorization
Definition: AuthorizationBean.java:52
ResourceBean resource
Definition: AuthorizationBean.java:54

◆ toResourceRepresentation()

Collection<ResourceBean> org.keycloak.forms.account.freemarker.model.AuthorizationBean.toResourceRepresentation ( List< PermissionTicket >  tickets)
inlineprivate
328  {
329  Map<String, ResourceBean> requests = new HashMap<>();
330 
331  for (PermissionTicket ticket : tickets) {
332  Resource resource = ticket.getResource();
333 
334  if (!resource.isOwnerManagedAccess()) {
335  continue;
336  }
337 
338  requests.computeIfAbsent(resource.getId(), resourceId -> getResource(resourceId)).addPermission(ticket, authorization);
339  }
340 
341  return requests.values();
342  }
final AuthorizationProvider authorization
Definition: AuthorizationBean.java:52
ResourceBean getResource()
Definition: AuthorizationBean.java:125
ResourceBean resource
Definition: AuthorizationBean.java:54

メンバ詳解

◆ authorization

final AuthorizationProvider org.keycloak.forms.account.freemarker.model.AuthorizationBean.authorization
private

◆ requestsWaitingPermission

Collection<ResourceBean> org.keycloak.forms.account.freemarker.model.AuthorizationBean.requestsWaitingPermission
private

◆ resource

ResourceBean org.keycloak.forms.account.freemarker.model.AuthorizationBean.resource
private

◆ resources

List<ResourceBean> org.keycloak.forms.account.freemarker.model.AuthorizationBean.resources
private

◆ resourcesWaitingOthersApproval

Collection<ResourceBean> org.keycloak.forms.account.freemarker.model.AuthorizationBean.resourcesWaitingOthersApproval
private

◆ uriInfo

final UriInfo org.keycloak.forms.account.freemarker.model.AuthorizationBean.uriInfo
private

◆ user

final UserModel org.keycloak.forms.account.freemarker.model.AuthorizationBean.user
private

◆ userSharedResources

Collection<ResourceBean> org.keycloak.forms.account.freemarker.model.AuthorizationBean.userSharedResources
private

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