Search in sources :

Example 41 with Role

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

the class DelegatedAdminMgrConsole method grantPermission.

protected void grantPermission(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.grantPermission(pOp, new Role(name));
        } else {
            System.out.println("Enter userId");
            name = ReaderUtil.readLn();
            aMgr.grantPermission(pOp, new User(name));
        }
        System.out.println("perm object [" + object + "] operation [" + operation + "] has been granted to [" + name + "]");
        System.out.println("has been granted");
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("grantPermission 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 42 with Role

use of org.apache.directory.fortress.core.model.Role 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 43 with Role

use of org.apache.directory.fortress.core.model.Role 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 44 with Role

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

the class ReviewMgrConsole method findRoles.

void findRoles() {
    ReaderUtil.clearScreen();
    try {
        System.out.println("");
        System.out.println("Enter value to search Roles with:");
        String val = ReaderUtil.readLn();
        List<Role> list = rm.findRoles(val);
        if (list != null && list.size() > 0) {
            for (int i = 0; i < list.size(); i++) {
                Role re = list.get(i);
                System.out.println("ROLE OBJECT [" + i + "]:");
                System.out.println("    name      [" + re.getName() + "]");
                System.out.println("    internalId  [" + re.getId() + "]");
                System.out.println("    description [" + re.getDescription() + "]");
                System.out.println("    parents [" + re.getParents() + "]");
                printTemporal(re, "RBACROLE");
            }
        } else {
            System.out.println("name [" + val + "] was not found");
        }
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("findRoles caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : Role(org.apache.directory.fortress.core.model.Role) UserRole(org.apache.directory.fortress.core.model.UserRole) UserAdminRole(org.apache.directory.fortress.core.model.UserAdminRole) Constraint(org.apache.directory.fortress.core.model.Constraint)

Example 45 with Role

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

the class ReviewMgrConsole method readRole.

/**
 */
void readRole() {
    ReaderUtil.clearScreen();
    try {
        System.out.println("Enter Role name to read:");
        Role role = new Role();
        role.setName(ReaderUtil.readLn());
        Role re = rm.readRole(role);
        if (re != null) {
            System.out.println("ROLE OBJECT:");
            System.out.println("    name      [" + re.getName() + "]");
            System.out.println("    internalId  [" + re.getId() + "]");
            System.out.println("    description [" + re.getDescription() + "]");
            System.out.println("    parents [" + re.getParents() + "]");
            printTemporal(re, "RBACROLE");
        } else {
            System.out.println("    name [" + role.getName() + "] was not found");
        }
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("readRole caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : Role(org.apache.directory.fortress.core.model.Role) UserRole(org.apache.directory.fortress.core.model.UserRole) UserAdminRole(org.apache.directory.fortress.core.model.UserAdminRole)

Aggregations

Role (org.apache.directory.fortress.core.model.Role)117 UserRole (org.apache.directory.fortress.core.model.UserRole)83 SecurityException (org.apache.directory.fortress.core.SecurityException)66 AdminMgr (org.apache.directory.fortress.core.AdminMgr)40 ReviewMgr (org.apache.directory.fortress.core.ReviewMgr)30 User (org.apache.directory.fortress.core.model.User)30 AdminRole (org.apache.directory.fortress.core.model.AdminRole)25 Permission (org.apache.directory.fortress.core.model.Permission)24 RoleConstraint (org.apache.directory.fortress.core.model.RoleConstraint)17 AdminPermissionOperation (org.apache.directory.fortress.annotation.AdminPermissionOperation)15 UserAdminRole (org.apache.directory.fortress.core.model.UserAdminRole)15 Relationship (org.apache.directory.fortress.core.model.Relationship)7 SDSet (org.apache.directory.fortress.core.model.SDSet)7 FinderException (org.apache.directory.fortress.core.FinderException)6 PermObj (org.apache.directory.fortress.core.model.PermObj)6 ArrayList (java.util.ArrayList)5 Group (org.apache.directory.fortress.core.model.Group)5 Constraint (org.apache.directory.fortress.core.model.Constraint)4 FortRequest (org.apache.directory.fortress.core.model.FortRequest)4 FortResponse (org.apache.directory.fortress.core.model.FortResponse)4