Revision 68369e5d
Added by Andreas Kohlbecker almost 5 years ago
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/utility/CdmUserHelper.java | ||
---|---|---|
409 | 409 |
return matches; |
410 | 410 |
} |
411 | 411 |
|
412 |
// @Override |
|
413 |
public <T extends CdmBase> Collection<CdmAuthority> findUserPermissions(Class<T> cdmType, EnumSet<CRUD> crud) { |
|
414 |
Set<CdmAuthority> matches = new HashSet<>(); |
|
415 |
CdmPermissionClass permissionClass = CdmPermissionClass.getValueOf(cdmType); |
|
416 |
Collection<? extends GrantedAuthority> authorities = getAuthentication().getAuthorities(); |
|
417 |
for(GrantedAuthority ga : authorities){ |
|
418 |
try { |
|
419 |
CdmAuthority cdmAuthority = CdmAuthority.fromGrantedAuthority(ga); |
|
420 |
if(cdmAuthority.getPermissionClass().equals(permissionClass)){ |
|
421 |
if(cdmAuthority.getOperation().containsAll(crud)){ |
|
422 |
matches.add(cdmAuthority); |
|
423 |
} |
|
424 |
} |
|
425 |
} catch (CdmAuthorityParsingException e) { |
|
426 |
continue; |
|
427 |
} |
|
428 |
} |
|
429 |
return matches; |
|
430 |
} |
|
431 |
|
|
412 | 432 |
/** |
413 | 433 |
* @param securityContextAccess the securityContextAccess to set |
414 | 434 |
*/ |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/utility/UserHelper.java | ||
---|---|---|
123 | 123 |
*/ |
124 | 124 |
public Collection<CdmAuthority> findUserPermissions(CdmBase cdmEntity, EnumSet<CRUD> crud); |
125 | 125 |
|
126 |
/** |
|
127 |
* Scans the currently authenticated user for CdmAuthorities which match the given parameters |
|
128 |
* |
|
129 |
* @param cdmType |
|
130 |
* @param crud |
|
131 |
* @return |
|
132 |
*/ |
|
133 |
public <T extends CdmBase> Collection<CdmAuthority> findUserPermissions(Class<T> cdmType, EnumSet<CRUD> crud); |
|
134 |
|
|
126 | 135 |
/** |
127 | 136 |
* @param newAuthority |
128 | 137 |
*/ |
Also available in: Unified diff
ref #7833 another method for UserHelper to scan for permissions