use of io.joynr.accesscontrol.primarykey.UserRoleKey in project joynr by bmwcarit.
the class DomainAccessControlStoreEhCache method updateDomainRole.
@Override
public Boolean updateDomainRole(@Nonnull DomainRoleEntry updatedEntry) {
boolean updateSuccess = false;
Cache cache = getCache(CacheId.DOMAIN_ROLES);
UserRoleKey dreKey = new UserRoleKey(updatedEntry.getUid(), updatedEntry.getRole());
try {
cache.put(new Element(dreKey, updatedEntry));
updateSuccess = true;
} catch (IllegalArgumentException | IllegalStateException | CacheException e) {
logger.error("updateDomainRole failed.", e);
}
return updateSuccess;
}
use of io.joynr.accesscontrol.primarykey.UserRoleKey in project joynr by bmwcarit.
the class DomainAccessControlStoreEhCache method getEditableAces.
private <T extends ControlEntry> List<T> getEditableAces(String uid, CacheId cacheId, Role role) {
List<T> aces = new ArrayList<T>();
// find out first on which domains uid has specified role
Cache drtCache = getCache(CacheId.DOMAIN_ROLES);
UserRoleKey dreKey = new UserRoleKey(uid, role);
String[] uidDomains = null;
// read domains from DRE
if (drtCache.isKeyInCache(dreKey)) {
DomainRoleEntry dre = DomainAccessControlStoreEhCache.<DomainRoleEntry>getElementValue(drtCache.get(dreKey));
uidDomains = dre.getDomains();
}
// if uid has no domains with specified role return empty list
if (uidDomains == null || uidDomains.length == 0) {
return aces;
}
Cache cache = getCache(cacheId);
// here should search on uid and domain take place
Attribute<String> uidAttribute = cache.getSearchAttribute(UserDomainInterfaceOperationKey.USER_ID);
Attribute<String> domainAttribute = cache.getSearchAttribute(UserDomainInterfaceOperationKey.DOMAIN);
for (String domain : uidDomains) {
Query query = cache.createQuery().addCriteria(uidAttribute.eq(uid).and(domainAttribute.eq(domain))).includeKeys().end();
Results results = query.execute();
for (Result result : results.all()) {
aces.add(DomainAccessControlStoreEhCache.<T>getElementValue(cache.get(result.getKey())));
}
}
return aces;
}
Aggregations