Search in sources :

Example 36 with Permission

use of org.apache.directory.fortress.core.model.Permission in project directory-fortress-core by apache.

the class DelegatedAdminMgrConsole method revokePermission.

protected void revokePermission(boolean isRole) {
    try {
        ReaderUtil.clearScreen();
        System.out.println("Enter perm object");
        String object = ReaderUtil.readLn();
        System.out.println("Enter perm operation");
        String operation = ReaderUtil.readLn();
        Permission pOp = new Permission(object, operation);
        pOp.setAdmin(true);
        String name;
        if (isRole) {
            System.out.println("Enter role name");
            name = ReaderUtil.readLn();
            aMgr.revokePermission(pOp, new Role(name));
        } else {
            System.out.println("Enter userId");
            name = ReaderUtil.readLn();
            aMgr.revokePermission(pOp, new User(name));
        }
        System.out.println("perm object [" + object + "] operation [" + operation + "] has been granted to [" + name + "]");
        System.out.println("has been revoked.");
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("revokePermission caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : AdminRole(org.apache.directory.fortress.core.model.AdminRole) Role(org.apache.directory.fortress.core.model.Role) UserAdminRole(org.apache.directory.fortress.core.model.UserAdminRole) User(org.apache.directory.fortress.core.model.User) Permission(org.apache.directory.fortress.core.model.Permission)

Example 37 with Permission

use of org.apache.directory.fortress.core.model.Permission in project directory-fortress-core by apache.

the class PermTestData method getOp.

/**
 * @param objName
 * @param op
 * @return
 */
public static Permission getOp(String objName, String[] op) {
    Permission pOp = new Permission();
    pOp.setObjName(objName);
    pOp.setObjId(getObjId(op));
    pOp.setOpName(getName(op));
    pOp.setDescription(getDescription(op));
    // pOp.setAbstractName(pOp.getObjName() + "." + pOp.getOpName());
    pOp.setType(getType(op));
    pOp.setAdmin(isOpAdmin(op));
    return pOp;
}
Also used : Permission(org.apache.directory.fortress.core.model.Permission)

Example 38 with Permission

use of org.apache.directory.fortress.core.model.Permission in project directory-fortress-core by apache.

the class PropertyMgrImplTest method testCrudProperties.

public void testCrudProperties() {
    Role role = RoleTestData.getRole(RoleTestData.ROLES_TR1[0]);
    AdminRole adminRole = AdminRoleTestData.getRole(AdminRoleTestData.AROLES_TR1[0]);
    PermObj permObj = PermTestData.getObj(PermTestData.OBJS_TOB1[0]);
    Permission permOp = PermTestData.getOp(permObj.getObjName(), PermTestData.OPS_TOP1[0]);
    Group group = GroupTestData.TEST_GROUP1;
    addProperties("ADD-PROP-RLE", role, PROPS);
    addProperties("ADD-PROP-ADMRLE", adminRole, PROPS);
    addProperties("ADD-PROP-POBJ", permObj, PROPS);
    addProperties("ADD-PROP-POP", permOp, PROPS);
    addProperties("ADD-PROP-GRP", group, PROPS);
    updateProperties("UPD-PROP-RLE", role, PROPS_UPDATED[0]);
    updateProperties("UPD-PROP-ADMRLE", adminRole, PROPS_UPDATED[0]);
    updateProperties("UPD-PROP-POBJ", permObj, PROPS_UPDATED[0]);
    updateProperties("UPD-PROP-POP", permOp, PROPS_UPDATED[0]);
    updateProperties("UPD-PROP-POP", group, PROPS_UPDATED[0]);
    deleteProperties("DEL-PROP-RLE", role, PROPS_UPDATED[0]);
    deleteProperties("DEL-PROP-ADMRLE", adminRole, PROPS_UPDATED[0]);
    deleteProperties("DEL-PROP-POBJ", permObj, PROPS_UPDATED[0]);
    deleteProperties("DEL-PROP-POP", permOp, PROPS_UPDATED[0]);
    deleteProperties("DEL-PROP-POP", group, PROPS_UPDATED[0]);
}
Also used : AdminRole(org.apache.directory.fortress.core.model.AdminRole) Role(org.apache.directory.fortress.core.model.Role) Group(org.apache.directory.fortress.core.model.Group) PermObj(org.apache.directory.fortress.core.model.PermObj) Permission(org.apache.directory.fortress.core.model.Permission) AdminRole(org.apache.directory.fortress.core.model.AdminRole)

Example 39 with Permission

use of org.apache.directory.fortress.core.model.Permission in project directory-fortress-core by apache.

the class ReviewMgrConsole method readPermission.

/**
 *  Description of the Method
 *
 *@param  pmap  Description of the Parameter
 */
/*    private final void prettyPrintFinePermissions(Map pmap)
        {
            if (pmap != null)
            {
                Set pset = pmap.keySet();
                Iterator piter = pset.iterator();
                while (piter.hasNext())
                {
                    FinePerm perm = (FinePerm) pmap.get(piter.next());
                    System.out.println("Fine Perm objectname:" + perm.getObjName());
                    if (perm.getRoles() != null && perm.getRoles().size() > 0)
                    {
                        List roles = perm.getRoles();
                        for (int i = 0; i < roles.size(); i++)
                        {
                            String name = (String) roles.get(i);
                            System.out.println("Fine Perm name: " + name);
                        }
                    }
                    if (perm.getUsers() != null && perm.getUsers().size() > 0)
                    {
                        List users = perm.getUsers();
                        for (int i = 0; i < users.size(); i++)
                        {
                            String user = (String) users.get(i);
                            System.out.println("Fine Perm user: " + user);
                        }
                    }
                    if (perm.getGroups() != null && perm.getGroups().size() > 0)
                    {
                        List groups = perm.getGroups();
                        for (int i = 0; i < groups.size(); i++)
                        {
                            String group = (String) groups.get(i);
                            System.out.println("Fine Perm group: " + group);
                        }
                    }
                }
            }
        }
        */
/**
 * Description of the Method
 */
void readPermission() {
    Permission pe;
    try {
        Permission permission = new Permission();
        ReaderUtil.clearScreen();
        System.out.println("Enter perm object name:");
        String name = ReaderUtil.readLn();
        permission.setObjName(name);
        System.out.println("Enter perm object id or null for none:");
        String oid = ReaderUtil.readLn();
        permission.setObjId(oid);
        System.out.println("Enter perm operation name:");
        String op = ReaderUtil.readLn();
        permission.setOpName(op);
        pe = rm.readPermission(permission);
        if (pe != null) {
            // System.out.println("perm operation [" + pe.operation + "]");
            System.out.println("object name [" + pe.getObjName() + "]");
            System.out.println("object id [" + pe.getObjId() + "]");
            System.out.println("operation name [" + pe.getOpName() + "]");
            System.out.println("abstract perm name [" + pe.getAbstractName() + "]");
            System.out.println("internalId [" + pe.getInternalId() + "]");
            if (pe.getUsers() != null && pe.getUsers().size() > 0) {
                int ctr = 0;
                for (String user : pe.getUsers()) {
                    System.out.println("user[" + ctr++ + "]=" + user);
                }
            }
            if (pe.getRoles() != null && pe.getRoles().size() > 0) {
                int ctr = 0;
                for (String role : pe.getRoles()) {
                    System.out.println("name[" + ctr++ + "]=" + role);
                }
            }
            if (pe.getProperties() != null && pe.getProperties().size() > 0) {
                int ctr = 0;
                for (Enumeration e = pe.getProperties().propertyNames(); e.hasMoreElements(); ) {
                    String key = (String) e.nextElement();
                    String val = pe.getProperty(key);
                    System.out.println("prop key[" + ctr + "]=" + key);
                    System.out.println("prop value[" + ctr++ + "]=" + val);
                }
            }
            System.out.println("**");
            System.out.println("read operation complete");
            System.out.println("ENTER to continue");
        }
    } catch (SecurityException e) {
        LOG.error("readPermission caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : Enumeration(java.util.Enumeration) Permission(org.apache.directory.fortress.core.model.Permission) Constraint(org.apache.directory.fortress.core.model.Constraint)

Example 40 with Permission

use of org.apache.directory.fortress.core.model.Permission in project directory-fortress-core by apache.

the class ReviewMgrConsole method permissionUsers.

void permissionUsers() {
    Permission pe;
    try {
        Permission permission = new Permission();
        ReaderUtil.clearScreen();
        System.out.println("Enter perm object name:");
        String name = ReaderUtil.readLn();
        permission.setObjName(name);
        System.out.println("Enter perm object id or null for none:");
        String oid = ReaderUtil.readLn();
        permission.setObjId(oid);
        System.out.println("Enter perm operation name:");
        String op = ReaderUtil.readLn();
        permission.setOpName(op);
        pe = rm.readPermission(permission);
        if (pe != null) {
            // System.out.println("perm operation [" + pe.operation + "]");
            System.out.println("object name [" + pe.getObjName() + "]");
            System.out.println("object id [" + pe.getObjId() + "]");
            System.out.println("operation name [" + pe.getOpName() + "]");
            System.out.println("abstract perm name [" + pe.getAbstractName() + "]");
            System.out.println("internalId [" + pe.getInternalId() + "]");
            if (pe.getUsers() != null && pe.getUsers().size() > 0) {
                int ctr = 0;
                for (String user : pe.getUsers()) {
                    System.out.println("user[" + ctr++ + "]=" + user);
                }
            }
            System.out.println("**");
            System.out.println("read operation complete");
            System.out.println("ENTER to continue");
        }
    } catch (SecurityException e) {
        LOG.error("permissionUsers caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : Permission(org.apache.directory.fortress.core.model.Permission) Constraint(org.apache.directory.fortress.core.model.Constraint)

Aggregations

Permission (org.apache.directory.fortress.core.model.Permission)99 SecurityException (org.apache.directory.fortress.core.SecurityException)58 Role (org.apache.directory.fortress.core.model.Role)24 User (org.apache.directory.fortress.core.model.User)24 AdminMgr (org.apache.directory.fortress.core.AdminMgr)18 UserRole (org.apache.directory.fortress.core.model.UserRole)17 ReviewMgr (org.apache.directory.fortress.core.ReviewMgr)16 Session (org.apache.directory.fortress.core.model.Session)12 FortRequest (org.apache.directory.fortress.core.model.FortRequest)11 FortResponse (org.apache.directory.fortress.core.model.FortResponse)11 RoleConstraint (org.apache.directory.fortress.core.model.RoleConstraint)11 ArrayList (java.util.ArrayList)10 FinderException (org.apache.directory.fortress.core.FinderException)10 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)9 AdminRole (org.apache.directory.fortress.core.model.AdminRole)9 UserAdminRole (org.apache.directory.fortress.core.model.UserAdminRole)9 LdapConnection (org.apache.directory.ldap.client.api.LdapConnection)9 CursorException (org.apache.directory.api.ldap.model.cursor.CursorException)7 SearchCursor (org.apache.directory.api.ldap.model.cursor.SearchCursor)7 AccessMgr (org.apache.directory.fortress.core.AccessMgr)7