Search in sources :

Example 1 with PermissionAttributeSet

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

the class PermDAO method getPermAttributeSet.

PermissionAttributeSet getPermAttributeSet(PermissionAttributeSet permAttributeSet) throws FinderException {
    PermissionAttributeSet entity = null;
    LdapConnection ld = null;
    String dn = getDn(permAttributeSet, permAttributeSet.getContextId());
    try {
        ld = getAdminConnection();
        Entry findEntry = read(ld, dn, PERMISION_ATTRIBUTE_SET_ATRS);
        if (findEntry == null) {
            String warning = "getPermAttributeSet no entry found dn [" + dn + "]";
            throw new FinderException(GlobalErrIds.PERM_ATTRIBUTE_SET_NOT_FOUND, warning);
        }
        entity = unloadPASetLdapEntry(findEntry, 0);
        // find permission attributes for this set
        entity.setAttributes(this.findPermissionAttributes(entity));
    } catch (LdapNoSuchObjectException e) {
        String warning = "getPermAttributeSet COULD NOT FIND ENTRY for dn [" + dn + "]";
        throw new FinderException(GlobalErrIds.PERM_ATTRIBUTE_SET_NOT_FOUND, warning);
    } catch (LdapException e) {
        String error = "getPermAttributeSet dn [" + dn + "] caught LdapException=" + e.getMessage();
        throw new FinderException(GlobalErrIds.PERM_ATTRIBUTE_SET_NOT_FOUND, error, e);
    } finally {
        closeAdminConnection(ld);
    }
    return entity;
}
Also used : LdapNoSuchObjectException(org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException) PermissionAttributeSet(org.apache.directory.fortress.core.model.PermissionAttributeSet) FinderException(org.apache.directory.fortress.core.FinderException) DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry) Entry(org.apache.directory.api.ldap.model.entry.Entry) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) LdapConnection(org.apache.directory.ldap.client.api.LdapConnection)

Example 2 with PermissionAttributeSet

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

the class ReviewMgrRestImpl method rolePermissionAttributeSets.

/**
 * {@inheritDoc}
 */
@Override
public List<PermissionAttributeSet> rolePermissionAttributeSets(Role role, boolean noInhertiance) throws SecurityException {
    VUtil.assertNotNull(role, GlobalErrIds.ROLE_NULL, CLS_NM + ".rolePermissionAttributeSets");
    List<PermissionAttributeSet> retAttrSets;
    FortRequest request = new FortRequest();
    request.setContextId(this.contextId);
    request.setEntity(role);
    request.setIsFlag(noInhertiance);
    if (this.adminSess != null) {
        request.setSession(adminSess);
    }
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ROLE_PERM_ATTR_SETS);
    FortResponse response = RestUtils.unmarshall(szResponse);
    if (response.getErrorCode() == 0) {
        retAttrSets = response.getEntities();
    } else {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
    return retAttrSets;
}
Also used : PermissionAttributeSet(org.apache.directory.fortress.core.model.PermissionAttributeSet) FortResponse(org.apache.directory.fortress.core.model.FortResponse) SecurityException(org.apache.directory.fortress.core.SecurityException) FortRequest(org.apache.directory.fortress.core.model.FortRequest)

Example 3 with PermissionAttributeSet

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

the class ReviewMgrImplTest method readPermissionAttributeSet.

public static void readPermissionAttributeSet(String msg, String name, Set<PermissionAttribute> permAttributes) {
    LogUtil.logIt(msg);
    try {
        ReviewMgr reviewMgr = getManagedReviewMgr();
        PermissionAttributeSet entity = reviewMgr.readPermAttributeSet(new PermissionAttributeSet(name));
        assertNotNull(entity);
        assertEquals(name, entity.getName());
        assertEquals(PermTestData.TPA_SET_TYPE, entity.getType());
        for (PermissionAttribute pa : permAttributes) {
            assertTrue(entity.getAttributes().contains(pa));
        }
        LOG.debug("readPermissionAttributeSet name [" + name + "] successful");
    } catch (SecurityException ex) {
        LOG.error("readPermissionAttributeSet name [" + name + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage() + ex);
        fail(ex.getMessage());
    }
}
Also used : PermissionAttributeSet(org.apache.directory.fortress.core.model.PermissionAttributeSet) ReviewMgr(org.apache.directory.fortress.core.ReviewMgr) PermissionAttribute(org.apache.directory.fortress.core.model.PermissionAttribute) SecurityException(org.apache.directory.fortress.core.SecurityException)

Example 4 with PermissionAttributeSet

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

the class AdminMgrImplTest method addPermissionAttributeSet.

public static void addPermissionAttributeSet(String msg, String name, Set<PermissionAttribute> permAttr) {
    LogUtil.logIt(msg);
    PermissionAttributeSet paSet = new PermissionAttributeSet(name);
    paSet.setType(PermTestData.TPA_SET_TYPE);
    try {
        paSet.setAttributes(permAttr);
        AdminMgr adminMgr = AdminMgrFactory.createInstance(TestUtils.getContext());
        adminMgr.addPermissionAttributeSet(paSet);
        LOG.debug("addPermissionAttributeSet name [" + paSet.getName() + "] successful");
    } catch (SecurityException ex) {
        LOG.error("addPermissionAttributeSet name [" + paSet.getName() + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : PermissionAttributeSet(org.apache.directory.fortress.core.model.PermissionAttributeSet) SecurityException(org.apache.directory.fortress.core.SecurityException) AdminMgr(org.apache.directory.fortress.core.AdminMgr)

Example 5 with PermissionAttributeSet

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

the class AdminMgrImplTest method addPermissionAttributeToSet.

public static void addPermissionAttributeToSet(String msg, String name, PermissionAttribute permAttr) {
    LogUtil.logIt(msg);
    PermissionAttributeSet paSet = new PermissionAttributeSet(name);
    try {
        AdminMgr adminMgr = AdminMgrFactory.createInstance(TestUtils.getContext());
        adminMgr.addPermissionAttributeToSet(permAttr, name);
        LOG.debug("addPermissionAttributeToSet name [" + paSet.getName() + "] successful");
    } catch (SecurityException ex) {
        LOG.error("addPermissionAttributeToSet name [" + paSet.getName() + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : PermissionAttributeSet(org.apache.directory.fortress.core.model.PermissionAttributeSet) SecurityException(org.apache.directory.fortress.core.SecurityException) AdminMgr(org.apache.directory.fortress.core.AdminMgr)

Aggregations

PermissionAttributeSet (org.apache.directory.fortress.core.model.PermissionAttributeSet)10 SecurityException (org.apache.directory.fortress.core.SecurityException)7 AdminMgr (org.apache.directory.fortress.core.AdminMgr)3 FortRequest (org.apache.directory.fortress.core.model.FortRequest)2 FortResponse (org.apache.directory.fortress.core.model.FortResponse)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 DefaultEntry (org.apache.directory.api.ldap.model.entry.DefaultEntry)1 Entry (org.apache.directory.api.ldap.model.entry.Entry)1 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)1 LdapNoSuchObjectException (org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException)1 FinderException (org.apache.directory.fortress.core.FinderException)1 ReviewMgr (org.apache.directory.fortress.core.ReviewMgr)1 ValidationException (org.apache.directory.fortress.core.ValidationException)1 ObjectFactory (org.apache.directory.fortress.core.model.ObjectFactory)1 Permission (org.apache.directory.fortress.core.model.Permission)1 PermissionAttribute (org.apache.directory.fortress.core.model.PermissionAttribute)1 LdapConnection (org.apache.directory.ldap.client.api.LdapConnection)1