Search in sources :

Example 26 with SDSet

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

the class AdminMgrConsole method addDsd.

/**
 */
void addDsd() {
    SDSet se = new SDSet();
    try {
        ReaderUtil.clearScreen();
        System.out.println("Enter DSD Set name:");
        se.setName(ReaderUtil.readLn());
        System.out.println("Enter DSD's description field");
        se.setDescription(ReaderUtil.readLn());
        System.out.println("Enter role member, or null to skip:");
        String role = ReaderUtil.readLn();
        for (; ; ) {
            if (role != null && role.length() > 0) {
                se.addMember(role);
            } else {
                break;
            }
            System.out.println("Enter another role member, or null to skip:");
            role = ReaderUtil.readLn();
        }
        System.out.println("Enter DSD Set cardinality:");
        int cardinality = ReaderUtil.readInt();
        se.setCardinality(cardinality);
        SDSet se2 = am.createDsdSet(se);
        System.out.println("name [" + se2.getName() + "]");
        System.out.println("internalId [" + se2.getId() + "]");
        System.out.println("name description [" + se2.getDescription() + "]");
        System.out.println("has been added");
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("addDsd caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : SDSet(org.apache.directory.fortress.core.model.SDSet) Constraint(org.apache.directory.fortress.core.model.Constraint)

Example 27 with SDSet

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

the class AdminMgrConsole method addSsd.

/**
 */
void addSsd() {
    SDSet se = new SDSet();
    try {
        ReaderUtil.clearScreen();
        System.out.println("Enter SSD Set name:");
        se.setName(ReaderUtil.readLn());
        System.out.println("Enter SSD's description field");
        se.setDescription(ReaderUtil.readLn());
        System.out.println("Enter role member, or null to skip:");
        String role = ReaderUtil.readLn();
        for (; ; ) {
            if (role != null && role.length() > 0) {
                se.addMember(role);
            } else {
                break;
            }
            System.out.println("Enter another role member, or null to skip:");
            role = ReaderUtil.readLn();
        }
        System.out.println("Enter SSD Set cardinality:");
        int cardinality = ReaderUtil.readInt();
        se.setCardinality(cardinality);
        SDSet se2 = am.createSsdSet(se);
        System.out.println("name [" + se2.getName() + "]");
        System.out.println("internalId [" + se2.getId() + "]");
        System.out.println("name description [" + se2.getDescription() + "]");
        System.out.println("has been added");
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("addSsd caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : SDSet(org.apache.directory.fortress.core.model.SDSet) Constraint(org.apache.directory.fortress.core.model.Constraint)

Example 28 with SDSet

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

the class Options method getSdSet.

/**
 */
public SDSet getSdSet() {
    SDSet sdSet = new SDSet();
    sdSet.setName(getName());
    sdSet.setDescription(getDescription());
    updateRoleAssigns(sdSet);
    try {
        Integer cardinality = Integer.valueOf(getCardinality());
        sdSet.setCardinality(cardinality);
    } catch (NumberFormatException ne) {
        // default is '2'.
        sdSet.setCardinality(2);
    }
    return sdSet;
}
Also used : SDSet(org.apache.directory.fortress.core.model.SDSet)

Example 29 with SDSet

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

the class AccessMgrImplTest method addActiveRolesDSD.

public static void addActiveRolesDSD(String msg, String[][] uArray, String[][] sArray) {
    LogUtil.logIt(msg);
    try {
        AccessMgr accessMgr = AccessMgrFactory.createInstance(TestUtils.getContext());
        int i = 0;
        for (String[] usr : uArray) {
            SDSet dsd = RoleTestData.getSDSet(sArray[i++]);
            // Set<String> roles = dsd.getMembers().keySet();
            Set<String> roles = dsd.getMembers();
            User user = UserTestData.getUser(usr);
            Session session = accessMgr.authenticate(user.getUserId(), user.getPassword());
            int j = 0;
            for (String role : roles) {
                j++;
                try {
                    assertNotNull(session);
                    // Activate Role(s):
                    accessMgr.addActiveRole(session, new UserRole(role));
                    if (j >= dsd.getCardinality()) {
                        fail(CLS_NM + ".addActiveRolesDSD user [" + user.getUserId() + "] role [" + role + "] ssd [" + dsd.getName() + "] cardinality [" + dsd.getCardinality() + "] count [" + j + "] failed");
                    }
                } catch (SecurityException ex) {
                    assertTrue(CLS_NM + ".addActiveRolesDSD cardinality test failed user [" + user.getUserId() + "] role [" + role + "] ssd [" + dsd.getName() + "] cardinality [" + dsd.getCardinality() + "] count [" + j + "]", j >= (dsd.getCardinality()));
                    assertTrue(CLS_NM + ".addActiveRolesDSD cardinality test failed [" + UserTestData.getUserId(usr) + "]", ex.getErrorId() == GlobalErrIds.DSD_VALIDATION_FAILED);
                    // still good, break from loop, we're done here
                    break;
                }
            }
        }
    } catch (SecurityException ex) {
        LOG.error("addActiveRolesDSD 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) AccessMgr(org.apache.directory.fortress.core.AccessMgr) UserRole(org.apache.directory.fortress.core.model.UserRole) SecurityException(org.apache.directory.fortress.core.SecurityException) Session(org.apache.directory.fortress.core.model.Session)

Example 30 with SDSet

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

the class AdminMgrImplTest method addSsdRoleMember.

/**
 * @param sArray
 */
public static void addSsdRoleMember(String msg, String[][] sArray, String[][] rArray) {
    LogUtil.logIt(msg);
    try {
        AdminMgr adminMgr = getManagedAdminMgr();
        ReviewMgr reviewMgr = ReviewMgrImplTest.getManagedReviewMgr();
        for (String[] ssdle : sArray) {
            SDSet ssd = RoleTestData.getSDSet(ssdle);
            SDSet entity = adminMgr.createSsdSet(ssd);
            LOG.debug("addSsdRoleMember SSD [" + entity.getName() + "] successful");
            for (String[] rle : rArray) {
                Role role = RoleTestData.getRole(rle);
                adminMgr.addSsdRoleMember(ssd, role);
                List<SDSet> ssdSets = reviewMgr.ssdRoleSets(role);
                assertNotNull(ssdSets);
                assertTrue(CLS_NM + "addSsdRoleMember list size check", ssdSets.size() == 1);
                SDSet ssd2 = ssdSets.get(0);
                assertTrue(CLS_NM + "addSsdRoleMember SSD name check", ssd.getName().equals(ssd2.getName()));
                assertTrue(CLS_NM + "addSsdRoleMember SSD role check", ssd2.getMembers().contains(role.getName()));
            }
        }
    } catch (SecurityException ex) {
        LOG.error("addSsdRoleMember 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