Search in sources :

Example 86 with Permission

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

the class DelAdminMgrRestImpl method updatePermission.

/**
 * {@inheritDoc}
 */
@Override
public Permission updatePermission(Permission perm) throws SecurityException {
    VUtil.assertNotNull(perm, GlobalErrIds.PERM_OPERATION_NULL, CLS_NM + ".updatePermission");
    Permission retPerm;
    FortRequest request = new FortRequest();
    request.setContextId(this.contextId);
    perm.setAdmin(true);
    request.setEntity(perm);
    if (this.adminSess != null) {
        request.setSession(adminSess);
    }
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.PERM_UPDATE);
    FortResponse response = RestUtils.unmarshall(szResponse);
    if (response.getErrorCode() == 0) {
        retPerm = (Permission) response.getEntity();
    } else {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
    return retPerm;
}
Also used : Permission(org.apache.directory.fortress.core.model.Permission) FortResponse(org.apache.directory.fortress.core.model.FortResponse) SecurityException(org.apache.directory.fortress.core.SecurityException) FortRequest(org.apache.directory.fortress.core.model.FortRequest)

Example 87 with Permission

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

the class DelAdminMgrRestImpl method addPermission.

/**
 * {@inheritDoc}
 */
@Override
public Permission addPermission(Permission perm) throws SecurityException {
    VUtil.assertNotNull(perm, GlobalErrIds.PERM_OPERATION_NULL, CLS_NM + ".addPermission");
    Permission retPerm;
    FortRequest request = new FortRequest();
    request.setContextId(this.contextId);
    perm.setAdmin(true);
    request.setEntity(perm);
    if (this.adminSess != null) {
        request.setSession(adminSess);
    }
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.PERM_ADD);
    FortResponse response = RestUtils.unmarshall(szResponse);
    if (response.getErrorCode() == 0) {
        retPerm = (Permission) response.getEntity();
    } else {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
    return retPerm;
}
Also used : Permission(org.apache.directory.fortress.core.model.Permission) FortResponse(org.apache.directory.fortress.core.model.FortResponse) SecurityException(org.apache.directory.fortress.core.SecurityException) FortRequest(org.apache.directory.fortress.core.model.FortRequest)

Example 88 with Permission

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

the class AdminMgrRestImpl method addPermission.

/**
 * {@inheritDoc}
 */
@Override
public Permission addPermission(Permission perm) throws SecurityException {
    VUtil.assertNotNull(perm, GlobalErrIds.PERM_OPERATION_NULL, CLS_NM + ".addPermission");
    Permission retPerm;
    FortRequest request = RestUtils.getRequest(this.contextId);
    request.setEntity(perm);
    if (this.adminSess != null) {
        request.setSession(adminSess);
    }
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.PERM_ADD);
    FortResponse response = RestUtils.unmarshall(szResponse);
    if (response.getErrorCode() == 0) {
        retPerm = (Permission) response.getEntity();
    } else {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
    return retPerm;
}
Also used : Permission(org.apache.directory.fortress.core.model.Permission) FortResponse(org.apache.directory.fortress.core.model.FortResponse) SecurityException(org.apache.directory.fortress.core.SecurityException) FortRequest(org.apache.directory.fortress.core.model.FortRequest)

Example 89 with Permission

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

the class ReviewMgrConsole method rolePermissions.

/**
 */
void rolePermissions() {
    try {
        System.out.println("Enter role name:");
        String name = ReaderUtil.readLn();
        List<Permission> list = rm.rolePermissions(new Role(name));
        if (list != null) {
            int ctr = 0;
            for (Permission pe : list) {
                System.out.println("**perm:" + (++ctr) + "***");
                // System.out.println("perm operation [" + pe.operation + "]");
                System.out.println("object name [" + pe.getObjName() + "]");
                System.out.println("object id [" + pe.getObjId() + "]");
                System.out.println("operation name [" + pe.getOpName() + "]");
                System.out.println("abstract perm name [" + pe.getAbstractName() + "]");
                System.out.println("internalId [" + pe.getInternalId() + "]");
                if (pe.getUsers() != null && pe.getUsers().size() > 0) {
                    int ctr2 = 0;
                    for (String user : pe.getUsers()) {
                        System.out.println("user[" + ctr2++ + "]=" + user);
                    }
                }
                if (pe.getRoles() != null && pe.getRoles().size() > 0) {
                    int ctr2 = 0;
                    for (String role : pe.getRoles()) {
                        System.out.println("name[" + ctr2++ + "]=" + role);
                    }
                }
                if (pe.getProperties() != null && pe.getProperties().size() > 0) {
                    int pctr = 0;
                    for (Enumeration e = pe.getProperties().propertyNames(); e.hasMoreElements(); ) {
                        String key = (String) e.nextElement();
                        String val = pe.getProperty(key);
                        System.out.println("prop key[" + pctr + "]=" + key);
                        System.out.println("prop value[" + pctr++ + "]=" + val);
                    }
                }
                // prettyPrintFinePermissions(pe.getFinePerms());
                System.out.println("**");
            }
            System.out.println("search complete");
            System.out.println("ENTER to continue");
        }
    } catch (SecurityException e) {
        LOG.error("rolePermissions 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) Enumeration(java.util.Enumeration) Permission(org.apache.directory.fortress.core.model.Permission) Constraint(org.apache.directory.fortress.core.model.Constraint)

Example 90 with Permission

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

the class ReviewMgrConsole method permissionRoles.

/**
 * Description of the Method
 */
void permissionRoles() {
    Permission pe;
    try {
        Permission permission = new Permission();
        ReaderUtil.clearScreen();
        System.out.println("Enter perm object name:");
        String name = ReaderUtil.readLn();
        permission.setObjName(name);
        System.out.println("Enter perm object id or null for none:");
        String oid = ReaderUtil.readLn();
        permission.setObjId(oid);
        System.out.println("Enter perm operation name:");
        String op = ReaderUtil.readLn();
        permission.setOpName(op);
        pe = rm.readPermission(permission);
        if (pe != null) {
            // System.out.println("perm operation [" + pe.operation + "]");
            System.out.println("object name [" + pe.getObjName() + "]");
            System.out.println("object id [" + pe.getObjId() + "]");
            System.out.println("operation name [" + pe.getOpName() + "]");
            System.out.println("abstract perm name [" + pe.getAbstractName() + "]");
            System.out.println("internalId [" + pe.getInternalId() + "]");
            if (pe.getRoles() != null && pe.getRoles().size() > 0) {
                int ctr = 0;
                for (String role : pe.getRoles()) {
                    System.out.println("name[" + ctr++ + "]=" + role);
                }
            }
            System.out.println("**");
            System.out.println("read operation complete");
            System.out.println("ENTER to continue");
        }
    } catch (SecurityException e) {
        LOG.error("permissionRoles caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : Permission(org.apache.directory.fortress.core.model.Permission) Constraint(org.apache.directory.fortress.core.model.Constraint)

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