use of org.apache.directory.fortress.core.model.ObjectFactory in project directory-fortress-core by apache.
the class RoleDAO method unloadLdapEntry.
/**
* @param le
* @param sequence
* @param contextId
* @return
* @throws LdapInvalidAttributeValueException
* @throws LdapException
*/
private Role unloadLdapEntry(Entry le, long sequence, String contextId) throws LdapInvalidAttributeValueException {
Role entity = new ObjectFactory().createRole();
entity.setSequenceId(sequence);
entity.setId(getAttribute(le, GlobalIds.FT_IID));
entity.setName(getAttribute(le, ROLE_NM));
entity.setDescription(getAttribute(le, SchemaConstants.DESCRIPTION_AT));
entity.setOccupants(getAttributes(le, SchemaConstants.ROLE_OCCUPANT_AT));
// entity.setParents(RoleUtil.getParents(entity.getName().toUpperCase(), contextId));
entity.setChildren(RoleUtil.getInstance().getChildren(entity.getName().toUpperCase(), contextId));
entity.setParents(getAttributeSet(le, GlobalIds.PARENT_NODES));
unloadTemporal(le, entity);
entity.setDn(le.getDn().getName());
entity.addProperties(PropUtil.getProperties(getAttributes(le, GlobalIds.PROPS)));
return entity;
}
use of org.apache.directory.fortress.core.model.ObjectFactory in project directory-fortress-core by apache.
the class AuditDAO method getBindEntityFromLdapEntry.
/**
* @param le
* @return
* @throws LdapInvalidAttributeValueException
* @throws LdapException
*/
private Bind getBindEntityFromLdapEntry(Entry le, long sequence) throws LdapInvalidAttributeValueException {
Bind auditBind = new ObjectFactory().createBind();
auditBind.setSequenceId(sequence);
auditBind.setCreateTimestamp(getAttribute(le, CREATETIMESTAMP));
auditBind.setCreatorsName(getAttribute(le, CREATORSNAME));
auditBind.setEntryCSN(getAttribute(le, ENTRYCSN));
auditBind.setEntryDN(getAttribute(le, ENTRYDN));
auditBind.setEntryUUID(getAttribute(le, ENTRYUUID));
auditBind.setHasSubordinates(getAttribute(le, HASSUBORDINATES));
auditBind.setModifiersName(getAttribute(le, MODIFIERSNAME));
auditBind.setModifyTimestamp(getAttribute(le, MODIFYTIMESTAMP));
auditBind.setObjectClass(getAttribute(le, OBJECTCLASS));
auditBind.setReqAuthzID(getAttribute(le, REQUAUTHZID));
auditBind.setReqControls(getAttribute(le, REQCONTROLS));
auditBind.setReqDN(getAttribute(le, REQDN));
auditBind.setReqEnd(getAttribute(le, REQEND));
auditBind.setReqMethod(getAttribute(le, REQMETHOD));
auditBind.setReqResult(getAttribute(le, REQRESULT));
auditBind.setReqSession(getAttribute(le, REQSESSION));
auditBind.setReqStart(getAttribute(le, REQSTART));
auditBind.setReqType(getAttribute(le, REQTYPE));
auditBind.setReqVersion(getAttribute(le, REQVERSION));
auditBind.setStructuralObjectClass(getAttribute(le, STRUCTURALOBJECTCLASS));
return auditBind;
}
use of org.apache.directory.fortress.core.model.ObjectFactory in project directory-fortress-core by apache.
the class AuditDAO method getModEntityFromLdapEntry.
private Mod getModEntityFromLdapEntry(Entry le, long sequence) throws LdapInvalidAttributeValueException {
Mod mod = new ObjectFactory().createMod();
mod.setSequenceId(sequence);
mod.setObjectClass(getAttribute(le, OBJECTCLASS));
mod.setReqAuthzID(getAttribute(le, REQUAUTHZID));
mod.setReqDN(getAttribute(le, REQDN));
mod.setReqEnd(getAttribute(le, REQEND));
mod.setReqResult(getAttribute(le, REQRESULT));
mod.setReqSession(getAttribute(le, REQSESSION));
mod.setReqStart(getAttribute(le, REQSTART));
mod.setReqType(getAttribute(le, REQTYPE));
mod.setReqMod(getAttributes(le, REQMOD));
return mod;
}
use of org.apache.directory.fortress.core.model.ObjectFactory in project directory-fortress-core by apache.
the class AuditDAO method getAuthzEntityFromLdapEntry.
/**
* @param le
* @return
* @throws LdapInvalidAttributeValueException
* @throws LdapException
*/
private AuthZ getAuthzEntityFromLdapEntry(Entry le, long sequence) throws LdapInvalidAttributeValueException {
// these attrs also on audit bind OC:
AuthZ authZ = new ObjectFactory().createAuthZ();
authZ.setSequenceId(sequence);
authZ.setCreateTimestamp(getAttribute(le, CREATETIMESTAMP));
authZ.setCreatorsName(getAttribute(le, CREATORSNAME));
authZ.setEntryCSN(getAttribute(le, ENTRYCSN));
authZ.setEntryDN(getAttribute(le, ENTRYDN));
authZ.setEntryUUID(getAttribute(le, ENTRYUUID));
authZ.setHasSubordinates(getAttribute(le, HASSUBORDINATES));
authZ.setModifiersName(getAttribute(le, MODIFIERSNAME));
authZ.setModifyTimestamp(getAttribute(le, MODIFYTIMESTAMP));
authZ.setObjectClass(getAttribute(le, OBJECTCLASS));
authZ.setReqAuthzID(getAttribute(le, REQUAUTHZID));
authZ.setReqControls(getAttribute(le, REQCONTROLS));
authZ.setReqDN(getAttribute(le, REQDN));
authZ.setReqEnd(getAttribute(le, REQEND));
authZ.setReqResult(getAttribute(le, REQRESULT));
authZ.setReqSession(getAttribute(le, REQSESSION));
authZ.setReqStart(getAttribute(le, REQSTART));
authZ.setReqType(getAttribute(le, REQTYPE));
authZ.setStructuralObjectClass(getAttribute(le, STRUCTURALOBJECTCLASS));
// these attrs only on audit search OC:
authZ.setReqAttr(getAttribute(le, REQATTR));
authZ.setReqAttrsOnly(getAttribute(le, REQATTRSONLY));
authZ.setReqDerefAliases(getAttribute(le, REQDREFALIASES));
authZ.setReqEntries(getAttribute(le, REQENTRIES));
authZ.setReqFilter(getAttribute(le, REQFILTER));
authZ.setReqScope(getAttribute(le, REQSCOPE));
authZ.setReqSizeLimit(getAttribute(le, REQSIZELIMIT));
authZ.setReqTimeLimit(getAttribute(le, REQTIMELIMIT));
return authZ;
}
use of org.apache.directory.fortress.core.model.ObjectFactory in project directory-fortress-core by apache.
the class DSDChecker method validate.
/**
* This method is called during entity activation, {@link org.apache.directory.fortress.core.util.VUtil#validateConstraints} and ensures the role does not violate dynamic separation of duty constraints.
*
* @param session contains list of RBAC roles {@link org.apache.directory.fortress.core.model.UserRole} targeted for activation.
* @param constraint required for Validator interface, not used here..
* @param time required for Validator interface, not used here.
* @param type required by interface, not used here.
* @return '0' if validation succeeds else {@link org.apache.directory.fortress.core.GlobalErrIds#ACTV_FAILED_DSD} if failed.
*/
@Override
public int validate(Session session, Constraint constraint, Time time, VUtil.ConstraintType type) throws org.apache.directory.fortress.core.SecurityException {
int rc = 0;
int matchCount;
// get all candidate activated roles user:
List<UserRole> activeRoleList = session.getRoles();
if (activeRoleList == null || activeRoleList.size() == 0) {
return rc;
}
// Depending on if session is group or user session, fill objects
String contextId = session.isGroupSession() ? session.getGroup().getContextId() : session.getUser().getContextId();
String entityId = session.isGroupSession() ? session.getGroupName() : session.getUserId();
String entityType = session.isGroupSession() ? "groupName" : "userId";
// get the list of authorized roles for this user/group:
Set<String> authorizedRoleSet = RoleUtil.getInstance().getInheritedRoles(activeRoleList, contextId);
// only need to check DSD constraints if more than one role is being activated:
if (authorizedRoleSet != null && authorizedRoleSet.size() > 1) {
// get all DSD sets that contain the candidate activated and authorized roles,
// If DSD cache is disabled, this will search the directory using authorizedRoleSet
Set<SDSet> dsdSets = SDUtil.getInstance().getDsdCache(authorizedRoleSet, contextId);
if (dsdSets != null && dsdSets.size() > 0) {
for (SDSet dsd : dsdSets) {
Iterator<UserRole> activatedRoles = activeRoleList.iterator();
matchCount = 0;
Set<String> map = dsd.getMembers();
// now check the DSD on every role activation candidate contained within session object:
while (activatedRoles.hasNext()) {
UserRole activatedRole = activatedRoles.next();
if (map.contains(activatedRole.getName())) {
matchCount++;
if (matchCount >= dsd.getCardinality()) {
activatedRoles.remove();
String warning = "validate " + entityType + " [" + entityId + "] failed activation of assignedRole [" + activatedRole.getName() + "] validates DSD Set Name:" + dsd.getName() + " Cardinality:" + dsd.getCardinality();
LOG.warn(warning);
rc = GlobalErrIds.ACTV_FAILED_DSD;
session.setWarning(new ObjectFactory().createWarning(rc, warning, Warning.Type.ROLE, activatedRole.getName()));
}
} else {
Set<String> parentSet = RoleUtil.getInstance().getAscendants(activatedRole.getName(), contextId);
// now check for every role inherited from this activated role:
for (String parentRole : parentSet) {
if (map.contains(parentRole)) {
matchCount++;
if (matchCount >= dsd.getCardinality()) {
String warning = "validate " + entityType + " [" + entityId + "] assignedRole [" + activatedRole.getName() + "] parentRole [" + parentRole + "] validates DSD Set Name:" + dsd.getName() + " Cardinality:" + dsd.getCardinality();
rc = GlobalErrIds.ACTV_FAILED_DSD;
// remove the assigned role from session (not the authorized role):
activatedRoles.remove();
session.setWarning(new ObjectFactory().createWarning(rc, warning, Warning.Type.ROLE, activatedRole.getName()));
LOG.warn(warning);
// Breaking out of the loop because assigned role has been removed from session.
break;
}
}
}
}
}
}
}
}
return rc;
}
Aggregations