Search in sources :

Example 6 with PermissionAttributeSet

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

the class AdminMgrImplTest method delPermAttrSet.

public static void delPermAttrSet(String msg, String name) {
    LogUtil.logIt(msg);
    PermissionAttributeSet paSet = new PermissionAttributeSet(name);
    try {
        AdminMgr adminMgr = AdminMgrFactory.createInstance(TestUtils.getContext());
        adminMgr.deletePermissionAttributeSet(paSet);
        LOG.debug("delPermAttrSet name [" + paSet.getName() + "] successful");
    } catch (SecurityException ex) {
        LOG.error("delPermAttrSet 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 7 with PermissionAttributeSet

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

the class AdminMgrRestImpl method addPermissionAttributeSet.

/**
 * {@inheritDoc}
 */
@Override
public PermissionAttributeSet addPermissionAttributeSet(PermissionAttributeSet permAttributeSet) throws SecurityException {
    VUtil.assertNotNull(permAttributeSet, GlobalErrIds.PERM_ATTRIBUTE_SET_NULL, CLS_NM + ".addPermissionAttributeSet");
    PermissionAttributeSet retSet;
    FortRequest request = RestUtils.getRequest(this.contextId);
    request.setEntity(permAttributeSet);
    if (this.adminSess != null) {
        request.setSession(adminSess);
    }
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.PERM_ADD_ATTRIBUTE_SET);
    FortResponse response = RestUtils.unmarshall(szResponse);
    if (response.getErrorCode() == 0) {
        retSet = (PermissionAttributeSet) response.getEntity();
    } else {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
    return retSet;
}
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 8 with PermissionAttributeSet

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

the class PermDAO method unloadPASetLdapEntry.

private PermissionAttributeSet unloadPASetLdapEntry(Entry le, long sequence) throws LdapInvalidAttributeValueException {
    PermissionAttributeSet entity = new ObjectFactory().createPermissionAttributeSet();
    entity.setSequenceId(sequence);
    entity.setName(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.setType(getAttribute(le, GlobalIds.FT_PERMISSION_ATTRIBUTE_SET_TYPE));
    return entity;
}
Also used : PermissionAttributeSet(org.apache.directory.fortress.core.model.PermissionAttributeSet) ObjectFactory(org.apache.directory.fortress.core.model.ObjectFactory)

Example 9 with PermissionAttributeSet

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

the class PermP method validatePaSet.

/*
     * Ensure the paSet is present and name is safe.
     */
void validatePaSet(String paSetName, String contextId) throws ValidationException {
    try {
        PermissionAttributeSet paSet = new PermissionAttributeSet(paSetName);
        paSet.setContextId(contextId);
        read(paSet);
        VUtil.safeText(paSetName, GlobalIds.DESC_LEN);
    } catch (SecurityException e) {
        String error = "validatePaSet - paSetName not found with name [" + paSetName + "] caught SecurityException=" + e;
        throw new ValidationException(GlobalErrIds.PERM_ATTRIBUTE_SET_NOT_FOUND, error);
    }
}
Also used : PermissionAttributeSet(org.apache.directory.fortress.core.model.PermissionAttributeSet) ValidationException(org.apache.directory.fortress.core.ValidationException) SecurityException(org.apache.directory.fortress.core.SecurityException)

Example 10 with PermissionAttributeSet

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

the class ReviewMgrImpl method rolePermissionAttributeSets.

/**
 * {@inheritDoc}
 */
@Override
public List<PermissionAttributeSet> rolePermissionAttributeSets(Role role, boolean noInhertiance) throws SecurityException {
    Map<String, PermissionAttributeSet> permAttributeSets = new HashMap<String, PermissionAttributeSet>();
    // look through all permissions in the role
    List<Permission> permissions = this.rolePermissions(role, noInhertiance);
    for (Permission perm : permissions) {
        if (CollectionUtils.isNotEmpty(perm.getPaSets())) {
            for (String paSetName : perm.getPaSets()) {
                if (!permAttributeSets.containsKey(paSetName)) {
                    PermissionAttributeSet paSet = new PermissionAttributeSet(paSetName);
                    paSet.setContextId(this.contextId);
                    PermissionAttributeSet permAttributeSet = permP.read(paSet);
                    permAttributeSets.put(paSetName, permAttributeSet);
                }
            }
        }
    }
    return new ArrayList<>(permAttributeSets.values());
}
Also used : PermissionAttributeSet(org.apache.directory.fortress.core.model.PermissionAttributeSet) HashMap(java.util.HashMap) Permission(org.apache.directory.fortress.core.model.Permission) ArrayList(java.util.ArrayList)

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