Search in sources :

Example 1 with PermissionAttribute

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

the class PermDAO method unloadPALdapEntry.

private PermissionAttribute unloadPALdapEntry(Entry le, long sequence) throws LdapInvalidAttributeValueException {
    PermissionAttribute entity = new ObjectFactory().createPermissionAttribute();
    entity.setSequenceId(sequence);
    entity.setAttributeName(getAttribute(le, SchemaConstants.CN_AT));
    entity.setDn(le.getDn().getName());
    entity.setInternalId(getAttribute(le, GlobalIds.FT_IID));
    entity.setDescription(getAttribute(le, SchemaConstants.DESCRIPTION_AT));
    entity.setDataType(getAttribute(le, GlobalIds.FT_PERMISSION_ATTRIBUTE_DATA_TYPE));
    entity.setDefaultOperator(getAttribute(le, GlobalIds.FT_PERMISSION_ATTRIBUTE_DEFAULT_OPERATOR));
    entity.setDefaultStrategy(getAttribute(le, GlobalIds.FT_PERMISSION_ATTRIBUTE_DEFAULT_STRATEGY));
    entity.setDefaultValue(getAttribute(le, GlobalIds.FT_PERMISSION_ATTRIBUTE_DEFAULT_VALUE));
    List<String> validValues = getAttributes(le, GlobalIds.FT_PERMISSION_ATTRIBUTE_VALID_VALUES);
    if (validValues != null) {
        for (String value : validValues) {
            entity.getValidValues().add(value);
        }
    }
    return entity;
}
Also used : ObjectFactory(org.apache.directory.fortress.core.model.ObjectFactory) PermissionAttribute(org.apache.directory.fortress.core.model.PermissionAttribute)

Example 2 with PermissionAttribute

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

the class PermTestData method getPA.

public static PermissionAttribute getPA(String[] pa) {
    PermissionAttribute permAttr = new PermissionAttribute();
    permAttr.setAttributeName(pa[0]);
    permAttr.setDataType(pa[2]);
    permAttr.setDefaultOperator(ComparisonOperator.valueOf(pa[3]).name());
    permAttr.getValidValues().add(pa[4]);
    return permAttr;
}
Also used : PermissionAttribute(org.apache.directory.fortress.core.model.PermissionAttribute)

Example 3 with PermissionAttribute

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

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

the class PermTestData method loadPermissionAttributes.

public static Set<PermissionAttribute> loadPermissionAttributes(String[][] objArray) {
    Set<PermissionAttribute> permAttrs = new HashSet<PermissionAttribute>();
    for (String[] obj : objArray) {
        PermissionAttribute pa = PermTestData.getPA(obj);
        permAttrs.add(pa);
    }
    return permAttrs;
}
Also used : PermissionAttribute(org.apache.directory.fortress.core.model.PermissionAttribute) HashSet(java.util.HashSet)

Example 5 with PermissionAttribute

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

the class AdminMgrRestImpl method updatePermissionAttributeInSet.

/**
 * {@inheritDoc}
 */
@Override
public void updatePermissionAttributeInSet(PermissionAttribute permAttribute, String attributeSetName, boolean replaceValidValues) throws SecurityException {
    VUtil.assertNotNull(permAttribute, GlobalErrIds.PERM_ATTRIBUTE_SET_NULL, CLS_NM + ".updatePermissionAttributeInSet");
    VUtil.assertNotNull(attributeSetName, GlobalErrIds.PERM_ATTRIBUTE_SET_NM_NULL, CLS_NM + ".updatePermissionAttributeInSet");
    PermissionAttribute retAttr;
    FortRequest request = RestUtils.getRequest(this.contextId);
    request.setEntity(permAttribute);
    request.setValue(attributeSetName);
    request.setIsFlag(replaceValidValues);
    if (this.adminSess != null) {
        request.setSession(adminSess);
    }
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.PERM_UPDATE_PERM_ATTRIBUTE_IN_SET);
    FortResponse response = RestUtils.unmarshall(szResponse);
    if (response.getErrorCode() != 0) {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
}
Also used : FortResponse(org.apache.directory.fortress.core.model.FortResponse) PermissionAttribute(org.apache.directory.fortress.core.model.PermissionAttribute) SecurityException(org.apache.directory.fortress.core.SecurityException) FortRequest(org.apache.directory.fortress.core.model.FortRequest)

Aggregations

PermissionAttribute (org.apache.directory.fortress.core.model.PermissionAttribute)8 SecurityException (org.apache.directory.fortress.core.SecurityException)3 HashSet (java.util.HashSet)2 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)2 FortRequest (org.apache.directory.fortress.core.model.FortRequest)2 FortResponse (org.apache.directory.fortress.core.model.FortResponse)2 LdapConnection (org.apache.directory.ldap.client.api.LdapConnection)2 CursorException (org.apache.directory.api.ldap.model.cursor.CursorException)1 SearchCursor (org.apache.directory.api.ldap.model.cursor.SearchCursor)1 DefaultEntry (org.apache.directory.api.ldap.model.entry.DefaultEntry)1 Entry (org.apache.directory.api.ldap.model.entry.Entry)1 CreateException (org.apache.directory.fortress.core.CreateException)1 FinderException (org.apache.directory.fortress.core.FinderException)1 ReviewMgr (org.apache.directory.fortress.core.ReviewMgr)1 ObjectFactory (org.apache.directory.fortress.core.model.ObjectFactory)1 PermissionAttributeSet (org.apache.directory.fortress.core.model.PermissionAttributeSet)1