Commit 3b1a22fd authored by Matija Obreza's avatar Matija Obreza

Utility method to make entities publicly readable

parent 1ae92a77
......@@ -210,5 +210,13 @@ public interface CustomAclService {
*/
List<Long> listObjectIdentityIdsForSid(Class<? extends AclAwareModel> clazz, AclSid sid, Permission permission);
/**
* Make entity publicly readable (or not)
*
* @param entity The entity
* @param publiclyReadable true or false?
* @since 1.4
*/
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(entity, 'ADMINISTRATION')")
void makePubliclyReadable(AclAwareModel entity, boolean publiclyReadable);
}
/*
* Copyright 2017 Global Crop Diversity Trust
* Copyright 2018 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -497,4 +497,18 @@ public class CustomAclServiceImpl implements CustomAclService {
return aclEntryPersistence.findObjectIdentitiesForSidAndAclClassAndMask(sid, clazz.getName(), permission.getMask());
}
/* (non-Javadoc)
* @see org.genesys.blocks.security.service.CustomAclService#makePubliclyReadable(org.genesys.blocks.security.model.AclAwareModel, boolean)
*/
@Override
@Transactional(propagation = Propagation.REQUIRED)
public void makePubliclyReadable(AclAwareModel entity, boolean publiclyReadable) {
AclSid roleEveryone = getAuthoritySid("ROLE_EVERYONE");
Permissions readPermissions = new Permissions().grantNone();
readPermissions.read = publiclyReadable;
setPermissions(entity, roleEveryone, readPermissions);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment