Search in sources :

Example 1 with IAclHolder

use of org.pentaho.platform.api.engine.IAclHolder in project pentaho-platform by pentaho.

the class SpringSecurityPermissionMgr method getEffectivePermissions.

public Map<IPermissionRecipient, IPermissionMask> getEffectivePermissions(Object domainInstance) {
    IAclHolder aclHolder = (IAclHolder) domainInstance;
    List<IPentahoAclEntry> aclList = aclHolder.getEffectiveAccessControls();
    return transformEntries(aclList);
}
Also used : IPentahoAclEntry(org.pentaho.platform.api.engine.IPentahoAclEntry) IAclHolder(org.pentaho.platform.api.engine.IAclHolder)

Example 2 with IAclHolder

use of org.pentaho.platform.api.engine.IAclHolder in project pentaho-platform by pentaho.

the class SpringSecurityPermissionMgr method setPermission.

@SuppressWarnings("deprecation")
public void setPermission(final IPermissionRecipient permissionRecipient, final IPermissionMask permission, final Object object) {
    if (object == null || !(object instanceof IAclHolder)) {
        // i would argue that the "object" parameter should be IAclHolder!
        return;
    }
    IAclHolder aclHolder = (IAclHolder) object;
    PentahoAclEntry entry = new PentahoAclEntry();
    // TODO mlowery instanceof is undesirable as it doesn't allow new concrete classes.
    if (permissionRecipient instanceof SimpleRole) {
        entry.setRecipient(new SimpleGrantedAuthority(permissionRecipient.getName()));
    } else {
        entry.setRecipient(permissionRecipient.getName());
    }
    entry.addPermission(permission.getMask());
    // HibernateUtil.beginTransaction(); - This is now handled by the RepositoryFile
    aclHolder.getAccessControls().add(entry);
// HibernateUtil.commitTransaction(); - This should be covered by the exitPoint call
}
Also used : SimpleGrantedAuthority(org.springframework.security.core.authority.SimpleGrantedAuthority) PentahoAclEntry(org.pentaho.platform.engine.security.acls.PentahoAclEntry) IPentahoAclEntry(org.pentaho.platform.api.engine.IPentahoAclEntry) IAclHolder(org.pentaho.platform.api.engine.IAclHolder)

Example 3 with IAclHolder

use of org.pentaho.platform.api.engine.IAclHolder 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
}
Also used : SimpleGrantedAuthority(org.springframework.security.core.authority.SimpleGrantedAuthority) PentahoAclEntry(org.pentaho.platform.engine.security.acls.PentahoAclEntry) Entry(java.util.Map.Entry) IPentahoAclEntry(org.pentaho.platform.api.engine.IPentahoAclEntry) IPermissionRecipient(org.pentaho.platform.api.engine.IPermissionRecipient) ArrayList(java.util.ArrayList) IPermissionMask(org.pentaho.platform.api.engine.IPermissionMask) IPentahoAclEntry(org.pentaho.platform.api.engine.IPentahoAclEntry) PentahoAclEntry(org.pentaho.platform.engine.security.acls.PentahoAclEntry) IPentahoAclEntry(org.pentaho.platform.api.engine.IPentahoAclEntry) IAclHolder(org.pentaho.platform.api.engine.IAclHolder)

Example 4 with IAclHolder

use of org.pentaho.platform.api.engine.IAclHolder in project pentaho-platform by pentaho.

the class SpringSecurityPermissionMgr method getPermissions.

public Map<IPermissionRecipient, IPermissionMask> getPermissions(final Object domainInstance) {
    IAclHolder aclHolder = (IAclHolder) domainInstance;
    List<IPentahoAclEntry> aclList = aclHolder.getAccessControls();
    return transformEntries(aclList);
}
Also used : IPentahoAclEntry(org.pentaho.platform.api.engine.IPentahoAclEntry) IAclHolder(org.pentaho.platform.api.engine.IAclHolder)

Aggregations

IAclHolder (org.pentaho.platform.api.engine.IAclHolder)4 IPentahoAclEntry (org.pentaho.platform.api.engine.IPentahoAclEntry)4 PentahoAclEntry (org.pentaho.platform.engine.security.acls.PentahoAclEntry)2 SimpleGrantedAuthority (org.springframework.security.core.authority.SimpleGrantedAuthority)2 ArrayList (java.util.ArrayList)1 Entry (java.util.Map.Entry)1 IPermissionMask (org.pentaho.platform.api.engine.IPermissionMask)1 IPermissionRecipient (org.pentaho.platform.api.engine.IPermissionRecipient)1