Search in sources :

Example 21 with Permission

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

the class AdminMgrImplTest method addRoleGrants.

/**
 * @param rArray
 * @param objArray
 * @param opArray
 */
public static void addRoleGrants(String msg, String[][] rArray, String[][] objArray, String[][] opArray, boolean isAdmin, boolean canFail) {
    LogUtil.logIt(msg);
    Permission pOp = new Permission();
    Role role = new Role();
    try {
        AdminMgr adminMgr;
        if (isAdmin) {
            adminMgr = getManagedAdminMgr();
        } else {
            adminMgr = AdminMgrFactory.createInstance(TestUtils.getContext());
        }
        for (String[] rle : rArray) {
            for (String[] obj : objArray) {
                for (String[] op : opArray) {
                    role = new Role(RoleTestData.getName(rle));
                    pOp = PermTestData.getOp(PermTestData.getName(obj), op);
                    adminMgr.grantPermission(pOp, role);
                    LOG.debug("addRoleGrants role name [" + role.getName() + "] objName [" + pOp.getObjName() + "] objectId [" + pOp.getObjId() + "] operation name [" + pOp.getOpName() + "] successful");
                }
            }
        }
    } catch (SecurityException ex) {
        if (!canFail) {
            LOG.error("addRoleGrants role name [" + role.getName() + "] objName [" + pOp.getObjName() + "] objectId [" + pOp.getObjId() + "] operation name [" + pOp.getOpName() + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
            fail(ex.getMessage());
        }
    }
}
Also used : Role(org.apache.directory.fortress.core.model.Role) UserRole(org.apache.directory.fortress.core.model.UserRole) Permission(org.apache.directory.fortress.core.model.Permission) SecurityException(org.apache.directory.fortress.core.SecurityException) AdminMgr(org.apache.directory.fortress.core.AdminMgr)

Example 22 with Permission

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

the class AdminMgrImplTest method delRoleGrantsH.

/**
 * @param msg
 * @param rArray
 * @param objArray
 * @param opArray
 */
private void delRoleGrantsH(String msg, String[][] rArray, String[][] objArray, String[][] opArray) {
    LogUtil.logIt(msg);
    Permission pOp = new Permission();
    Role role = new Role();
    try {
        AdminMgr adminMgr = getManagedAdminMgr();
        int i = 0;
        for (String[] obj : objArray) {
            role = new Role(RoleTestData.getName(rArray[i++]));
            for (String[] op : opArray) {
                pOp = PermTestData.getOp(PermTestData.getName(obj), op);
                adminMgr.revokePermission(pOp, role);
                LOG.debug("delRoleGrantsH role name [" + role.getName() + "] objName [" + pOp.getObjName() + "] objectId [" + pOp.getObjId() + "] operation name [" + pOp.getOpName() + "] successful");
            }
        }
    } catch (SecurityException ex) {
        LOG.error("delRoleGrantsH role name [" + role.getName() + "] objName [" + pOp.getObjName() + "] objectId [" + pOp.getObjId() + "] operation name [" + pOp.getOpName() + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : Role(org.apache.directory.fortress.core.model.Role) UserRole(org.apache.directory.fortress.core.model.UserRole) Permission(org.apache.directory.fortress.core.model.Permission) SecurityException(org.apache.directory.fortress.core.SecurityException) RoleConstraint(org.apache.directory.fortress.core.model.RoleConstraint) AdminMgr(org.apache.directory.fortress.core.AdminMgr)

Example 23 with Permission

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

the class AdminMgrImplTest method addPermOps.

/**
 * @param objArray
 * @param opArray
 */
public static void addPermOps(String msg, String[][] objArray, String[][] opArray, boolean isAdmin, boolean canFail) {
    LogUtil.logIt(msg);
    Permission pOp = new Permission();
    try {
        AdminMgr adminMgr;
        if (isAdmin) {
            adminMgr = getManagedAdminMgr();
        } else {
            adminMgr = AdminMgrFactory.createInstance(TestUtils.getContext());
        }
        for (String[] obj : objArray) {
            for (String[] op : opArray) {
                pOp = PermTestData.getOp(PermTestData.getName(obj), op);
                adminMgr.addPermission(pOp);
                LOG.debug("addPermOp objName [" + pOp.getObjName() + "] opName [" + pOp.getOpName() + "]  objectId [" + pOp.getObjId() + "] successful");
            }
        }
    } catch (SecurityException ex) {
        if (!canFail) {
            LOG.error("addPermOp objName [" + pOp.getObjName() + "] opName [" + pOp.getOpName() + "]  objectId [" + pOp.getObjId() + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
            fail(ex.getMessage());
        }
    }
}
Also used : Permission(org.apache.directory.fortress.core.model.Permission) SecurityException(org.apache.directory.fortress.core.SecurityException) AdminMgr(org.apache.directory.fortress.core.AdminMgr)

Example 24 with Permission

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

the class AdminMgrImplTest method addRoleGrantsH.

/**
 * @param msg
 * @param rArray
 * @param objArray
 * @param opArray
 */
public static void addRoleGrantsH(String msg, String[][] rArray, String[][] objArray, String[][] opArray) {
    LogUtil.logIt(msg);
    Permission pOp = new Permission();
    Role role = new Role();
    try {
        AdminMgr adminMgr = getManagedAdminMgr();
        int i = 0;
        for (String[] obj : objArray) {
            role = new Role(RoleTestData.getName(rArray[i++]));
            for (String[] op : opArray) {
                pOp = PermTestData.getOp(PermTestData.getName(obj), op);
                adminMgr.grantPermission(pOp, role);
                LOG.debug("addRoleGrantsH role name [" + role.getName() + "] objName [" + pOp.getObjName() + "] objectId [" + pOp.getObjId() + "] operation name [" + pOp.getOpName() + "] successful");
            }
        }
    } catch (SecurityException ex) {
        LOG.error("addRoleGrantsH role name [" + role.getName() + "] objName [" + pOp.getObjName() + "] objectId [" + pOp.getObjId() + "] operation name [" + pOp.getOpName() + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : Role(org.apache.directory.fortress.core.model.Role) UserRole(org.apache.directory.fortress.core.model.UserRole) Permission(org.apache.directory.fortress.core.model.Permission) SecurityException(org.apache.directory.fortress.core.SecurityException) RoleConstraint(org.apache.directory.fortress.core.model.RoleConstraint) AdminMgr(org.apache.directory.fortress.core.AdminMgr)

Example 25 with Permission

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

the class AdminMgrImplTest method addUserGrants.

/**
 * @param uArray
 * @param objArray
 * @param opArray
 */
public static void addUserGrants(String msg, String[][] uArray, String[][] objArray, String[][] opArray) {
    LogUtil.logIt(msg);
    Permission pOp = new Permission();
    User user = new User();
    try {
        AdminMgr adminMgr = getManagedAdminMgr();
        for (String[] usr : uArray) {
            for (String[] obj : objArray) {
                for (String[] op : opArray) {
                    user = new User(UserTestData.getUserId(usr));
                    pOp = PermTestData.getOp(PermTestData.getName(obj), op);
                    adminMgr.grantPermission(pOp, user);
                    LOG.debug("addUserGrants userId [" + user.getUserId() + "] objName [" + pOp.getObjName() + "] objectId [" + pOp.getObjId() + "] operation name [" + pOp.getOpName() + "] successful");
                }
            }
        }
    } catch (SecurityException ex) {
        LOG.error("addUserGrants userId [" + user.getUserId() + "] objName [" + pOp.getObjName() + "] objectId [" + pOp.getObjId() + "] operation name [" + pOp.getOpName() + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : User(org.apache.directory.fortress.core.model.User) Permission(org.apache.directory.fortress.core.model.Permission) SecurityException(org.apache.directory.fortress.core.SecurityException) AdminMgr(org.apache.directory.fortress.core.AdminMgr)

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