Search in sources :

Example 16 with SDSet

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

the class AdminMgrImplTest method assignUsersDSD.

/**
 * @param msg
 * @param uArray
 * @param sArray
 */
public static void assignUsersDSD(String msg, String[][] uArray, String[][] sArray) {
    LogUtil.logIt(msg);
    try {
        AdminMgr adminMgr = getManagedAdminMgr();
        int i = 0;
        for (String[] usr : uArray) {
            SDSet dsd = RoleTestData.getSDSet(sArray[i++]);
            Set<String> roles = dsd.getMembers();
            User user = UserTestData.getUser(usr);
            int j = 0;
            for (String role : roles) {
                j++;
                UserRole uRole = new UserRole(user.getUserId(), role);
                try {
                    adminMgr.assignUser(uRole);
                } catch (SecurityException ex) {
                    LOG.error("assignUsersDSD caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
                    fail(CLS_NM + "assignUsersDSD user [" + user.getUserId() + "] role [" + role + "] dsd [" + dsd.getName() + "] failed");
                }
            }
        }
    } catch (SecurityException ex) {
        LOG.error("assignUsersDSD caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : SDSet(org.apache.directory.fortress.core.model.SDSet) User(org.apache.directory.fortress.core.model.User) UserRole(org.apache.directory.fortress.core.model.UserRole) SecurityException(org.apache.directory.fortress.core.SecurityException) RoleConstraint(org.apache.directory.fortress.core.model.RoleConstraint) AdminMgr(org.apache.directory.fortress.core.AdminMgr)

Example 17 with SDSet

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

the class AdminMgrImplTest method createDsdSet.

/**
 * @param sArray
 */
public static void createDsdSet(String msg, String[][] sArray) {
    LogUtil.logIt(msg);
    try {
        AdminMgr adminMgr = getManagedAdminMgr();
        for (String[] dsdle : sArray) {
            SDSet dsd = RoleTestData.getSDSet(dsdle);
            SDSet entity = adminMgr.createDsdSet(dsd);
            LOG.debug("createDsdSet DSD [" + entity.getName() + "] successful");
        }
    } catch (SecurityException ex) {
        LOG.error("createDsdSet caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : SDSet(org.apache.directory.fortress.core.model.SDSet) SecurityException(org.apache.directory.fortress.core.SecurityException) AdminMgr(org.apache.directory.fortress.core.AdminMgr)

Example 18 with SDSet

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

the class AdminMgrImplTest method deleteSsdSet.

/**
 * @param sArray
 */
private void deleteSsdSet(String msg, String[][] sArray) {
    LogUtil.logIt(msg);
    try {
        AdminMgr adminMgr = getManagedAdminMgr();
        for (String[] ssdle : sArray) {
            SDSet ssd = RoleTestData.getSDSet(ssdle);
            adminMgr.deleteSsdSet(ssd);
            LOG.debug("deleteSsdSet role [" + ssd.getName() + "] successful");
        }
    } catch (SecurityException ex) {
        LOG.error("deleteSsdSet caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : SDSet(org.apache.directory.fortress.core.model.SDSet) SecurityException(org.apache.directory.fortress.core.SecurityException) AdminMgr(org.apache.directory.fortress.core.AdminMgr)

Example 19 with SDSet

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

the class AdminMgrImplTest method deleteDsdRoleMember.

/**
 * @param sArray
 */
private void deleteDsdRoleMember(String msg, String[][] sArray, String[][] rArray) {
    LogUtil.logIt(msg);
    try {
        AdminMgr adminMgr = getManagedAdminMgr();
        ReviewMgr reviewMgr = ReviewMgrImplTest.getManagedReviewMgr();
        for (String[] dsdle : sArray) {
            SDSet dsd = RoleTestData.getSDSet(dsdle);
            // first add all of the roles as members of SSD entity:
            for (String[] rle : rArray) {
                Role role = RoleTestData.getRole(rle);
                dsd.addMember(role.getName());
            }
            // now iterate over roles and remove from DSD set one at a time.
            for (String[] rle : rArray) {
                Role role = RoleTestData.getRole(rle);
                adminMgr.deleteDsdRoleMember(dsd, role);
                List<SDSet> dsdSets = reviewMgr.dsdRoleSets(role);
                assertTrue(CLS_NM + "deleteDsdRoleMember list size check", dsdSets.size() == 0);
            }
            adminMgr.deleteDsdSet(dsd);
            LOG.debug("deletedsdRoleMember DSD [" + dsd.getName() + "] successful");
        }
    } catch (SecurityException ex) {
        LOG.error("deleteDsdRoleMember caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : SDSet(org.apache.directory.fortress.core.model.SDSet) Role(org.apache.directory.fortress.core.model.Role) UserRole(org.apache.directory.fortress.core.model.UserRole) ReviewMgr(org.apache.directory.fortress.core.ReviewMgr) SecurityException(org.apache.directory.fortress.core.SecurityException) AdminMgr(org.apache.directory.fortress.core.AdminMgr)

Example 20 with SDSet

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

the class AdminMgrImplTest method addDsdRoleMember.

/**
 * @param sArray
 */
public static void addDsdRoleMember(String msg, String[][] sArray, String[][] rArray) {
    LogUtil.logIt(msg);
    try {
        AdminMgr adminMgr = getManagedAdminMgr();
        ReviewMgr reviewMgr = ReviewMgrImplTest.getManagedReviewMgr();
        for (String[] dsdle : sArray) {
            SDSet dsd = RoleTestData.getSDSet(dsdle);
            SDSet entity = adminMgr.createDsdSet(dsd);
            LOG.debug("addDsdRoleMember DSD [" + entity.getName() + "] successful");
            for (String[] rle : rArray) {
                Role role = RoleTestData.getRole(rle);
                adminMgr.addDsdRoleMember(dsd, role);
                List<SDSet> dsdSets = reviewMgr.dsdRoleSets(role);
                assertNotNull(dsdSets);
                assertTrue(CLS_NM + "addDsdRoleMember list size check", dsdSets.size() == 1);
                SDSet dsd2 = dsdSets.get(0);
                assertTrue(CLS_NM + "addDsdRoleMember DSD name check", dsd.getName().equals(dsd2.getName()));
                assertTrue(CLS_NM + "addDsdRoleMember DSD role check", dsd2.getMembers().contains(role.getName()));
            // assertTrue(CLS_NM + "addDsdRoleMember DSD role check", dsd2.getMembers().containsKey(role.getName()));
            }
        }
    } catch (SecurityException ex) {
        LOG.error("addDsdRoleMember caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : SDSet(org.apache.directory.fortress.core.model.SDSet) Role(org.apache.directory.fortress.core.model.Role) UserRole(org.apache.directory.fortress.core.model.UserRole) ReviewMgr(org.apache.directory.fortress.core.ReviewMgr) SecurityException(org.apache.directory.fortress.core.SecurityException) AdminMgr(org.apache.directory.fortress.core.AdminMgr)

Aggregations

SDSet (org.apache.directory.fortress.core.model.SDSet)58 SecurityException (org.apache.directory.fortress.core.SecurityException)37 FortRequest (org.apache.directory.fortress.core.model.FortRequest)20 FortResponse (org.apache.directory.fortress.core.model.FortResponse)20 AdminMgr (org.apache.directory.fortress.core.AdminMgr)12 UserRole (org.apache.directory.fortress.core.model.UserRole)12 AdminPermissionOperation (org.apache.directory.fortress.annotation.AdminPermissionOperation)8 ReviewMgr (org.apache.directory.fortress.core.ReviewMgr)8 Role (org.apache.directory.fortress.core.model.Role)7 User (org.apache.directory.fortress.core.model.User)5 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)4 FinderException (org.apache.directory.fortress.core.FinderException)4 RoleConstraint (org.apache.directory.fortress.core.model.RoleConstraint)4 LdapConnection (org.apache.directory.ldap.client.api.LdapConnection)4 CursorException (org.apache.directory.api.ldap.model.cursor.CursorException)3 SearchCursor (org.apache.directory.api.ldap.model.cursor.SearchCursor)3 Constraint (org.apache.directory.fortress.core.model.Constraint)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 AccessMgr (org.apache.directory.fortress.core.AccessMgr)2