use of org.pentaho.platform.api.engine.IPermissionRecipient in project pentaho-platform by pentaho.
the class SpringSecurityPermissionMgr method setPermissions.
@SuppressWarnings("deprecation")
public void setPermissions(final Map<IPermissionRecipient, IPermissionMask> permissionsMap, final Object object) {
if (object == null || !(object instanceof IAclHolder)) {
// i would argue that the "object" parameter should be IAclHolder!
return;
}
IAclHolder aclHolder = (IAclHolder) object;
Set<Map.Entry<IPermissionRecipient, IPermissionMask>> mapEntrySet = permissionsMap.entrySet();
ArrayList<IPentahoAclEntry> aclList = new ArrayList<IPentahoAclEntry>();
for (Entry<IPermissionRecipient, IPermissionMask> mapEntry : mapEntrySet) {
PentahoAclEntry pentahoAclEntry = new PentahoAclEntry();
IPermissionRecipient permissionRecipient = mapEntry.getKey();
if (permissionRecipient instanceof SimpleRole) {
pentahoAclEntry.setRecipient(new SimpleGrantedAuthority(permissionRecipient.getName()));
} else {
pentahoAclEntry.setRecipient(permissionRecipient.getName());
}
pentahoAclEntry.addPermission(mapEntry.getValue().getMask());
aclList.add(pentahoAclEntry);
}
// HibernateUtil.beginTransaction(); - This is now handled in the RepositoryFile
aclHolder.resetAccessControls(aclList);
// HibernateUtil.commitTransaction(); - This is covered by the exitPoint
}
use of org.pentaho.platform.api.engine.IPermissionRecipient in project pentaho-platform by pentaho.
the class SpringSecurityPermissionMgr method transformEntries.
/**
* Converts from List<IPentahoAclEntry> to Map<IPermissionRecipient, IPermissionMask>.
*/
@SuppressWarnings("deprecation")
protected Map<IPermissionRecipient, IPermissionMask> transformEntries(List<IPentahoAclEntry> entriesFromHolder) {
Map<IPermissionRecipient, IPermissionMask> permissionsMap = new LinkedHashMap<IPermissionRecipient, IPermissionMask>();
for (IPentahoAclEntry pentahoAclEntry : entriesFromHolder) {
IPermissionRecipient permissionRecipient = null;
if (pentahoAclEntry.getRecipient() instanceof SimpleGrantedAuthority) {
SimpleGrantedAuthority grantedAuthorityImpl = (SimpleGrantedAuthority) pentahoAclEntry.getRecipient();
permissionRecipient = new SimpleRole(grantedAuthorityImpl.toString());
} else if (pentahoAclEntry.getRecipient() instanceof SimpleRole) {
permissionRecipient = new SimpleRole((String) pentahoAclEntry.getRecipient());
} else {
permissionRecipient = new SimpleUser((String) pentahoAclEntry.getRecipient());
}
IPermissionMask permissionMask = new SimplePermissionMask(pentahoAclEntry.getMask());
permissionsMap.put(permissionRecipient, permissionMask);
}
return permissionsMap;
}
Aggregations