Search in sources :

Example 36 with Role

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

the class AdminMgrConsole method revokePermission.

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);
        String name;
        if (isRole) {
            System.out.println("Enter role name");
            name = ReaderUtil.readLn();
            am.revokePermission(pOp, new Role(name));
        } else {
            System.out.println("Enter userId");
            name = ReaderUtil.readLn();
            am.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 : Role(org.apache.directory.fortress.core.model.Role) UserRole(org.apache.directory.fortress.core.model.UserRole) User(org.apache.directory.fortress.core.model.User) Permission(org.apache.directory.fortress.core.model.Permission)

Example 37 with Role

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

the class AdminMgrConsole method addRoleAscendant.

/**
 */
void addRoleAscendant() {
    try {
        Role cre = new Role();
        Role pre = new Role();
        ReaderUtil.clearScreen();
        System.out.println("Enter child role name:");
        cre.setName(ReaderUtil.readLn());
        System.out.println("Enter parent role name to add to repo:");
        pre.setName(ReaderUtil.readLn());
        System.out.println("Enter parent role description:");
        pre.setDescription(ReaderUtil.readLn());
        am.addAscendant(cre, pre);
        System.out.println("child role [" + cre.getName() + "]");
        System.out.println("parent role [" + pre.getName() + "]");
        System.out.println("parent role and inheritance relationship has been added");
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("addRoleAscendant 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)

Example 38 with Role

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

the class AdminMgrConsole method addRole.

void addRole() {
    Role re = new Role();
    try {
        ReaderUtil.clearScreen();
        System.out.println("Enter role name:");
        re.setName(ReaderUtil.readLn());
        System.out.println("Enter Role's description field");
        re.setDescription(ReaderUtil.readLn());
        Role re2 = am.addRole(re);
        System.out.println("name [" + re2.getName() + "]");
        System.out.println("internalId [" + re2.getId() + "]");
        System.out.println("name description [" + re2.getDescription() + "]");
        System.out.println("has been added");
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("addRole 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)

Example 39 with Role

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

the class AdminMgrConsole method removeRoleInheritance.

/**
 */
void removeRoleInheritance() {
    try {
        Role cre = new Role();
        Role pre = new Role();
        ReaderUtil.clearScreen();
        System.out.println("Enter child role name:");
        cre.setName(ReaderUtil.readLn());
        System.out.println("Enter parent role name:");
        pre.setName(ReaderUtil.readLn());
        am.deleteInheritance(pre, cre);
        System.out.println("child role [" + cre.getName() + "]");
        System.out.println("parent role [" + pre.getName() + "]");
        System.out.println("inheritance relationship has been removed");
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("removeRoleInheritance 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)

Example 40 with Role

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

the class DelegatedAccessMgrConsole method canAssign.

/**
 */
void canAssign() {
    try {
        ReaderUtil.clearScreen();
        System.out.println("Enter userId:");
        User user = new User(ReaderUtil.readLn());
        System.out.println("Enter role name:");
        Role role = new Role(ReaderUtil.readLn());
        boolean result = dAmgr.canAssign(session, user, role);
        System.out.println("Can Assign User [" + user.getUserId() + "] Role [" + role.getName() + "] return [" + result + "]");
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("canAssign caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : Role(org.apache.directory.fortress.core.model.Role) User(org.apache.directory.fortress.core.model.User)

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