Search in sources :

Example 1 with IPermissionMask

use of org.pentaho.platform.api.engine.IPermissionMask 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 2 with IPermissionMask

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

the class SpringSecurityPermissionMgr method transformEntries.

/**
 * Converts from List&lt;IPentahoAclEntry&gt; to Map&lt;IPermissionRecipient, IPermissionMask&gt;.
 */
@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;
}
Also used : SimpleGrantedAuthority(org.springframework.security.core.authority.SimpleGrantedAuthority) IPermissionRecipient(org.pentaho.platform.api.engine.IPermissionRecipient) IPermissionMask(org.pentaho.platform.api.engine.IPermissionMask) IPentahoAclEntry(org.pentaho.platform.api.engine.IPentahoAclEntry) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

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