use of org.apache.directory.fortress.core.model.ObjectFactory in project directory-fortress-core by apache.
the class UserDAO method checkPassword.
/**
* @param user
* @return
* @throws org.apache.directory.fortress.core.FinderException, org.apache.directory.fortress.core.PasswordException
*/
Session checkPassword(User user) throws FinderException, PasswordException {
Session session = null;
LdapConnection ld = null;
String userDn = getDn(user.getUserId(), user.getContextId());
try {
session = new ObjectFactory().createSession();
session.setAuthenticated(false);
session.setUserId(user.getUserId());
ld = getUserConnection();
BindResponse bindResponse = bind(ld, userDn, user.getPassword());
String info;
if (bindResponse.getLdapResult().getResultCode() != ResultCodeEnum.SUCCESS) {
info = "PASSWORD INVALID for userId [" + user.getUserId() + "], resultCode [" + bindResponse.getLdapResult().getResultCode() + "]";
session.setMsg(info);
session.setErrorId(GlobalErrIds.USER_PW_INVLD);
}
PasswordPolicy respCtrl = getPwdRespCtrl(bindResponse);
if (respCtrl != null) {
// check IETF password policies here
checkPwPolicies(session, respCtrl);
}
if (session.getErrorId() == 0) {
session.setAuthenticated(true);
} else {
// pw invalid or pw policy violation:
throw new PasswordException(session.getErrorId(), session.getMsg());
}
} catch (LdapAuthenticationException e) {
String info = "checkPassword INVALID PASSWORD for userId [" + user.getUserId() + "] exception [" + e + "]";
throw new PasswordException(GlobalErrIds.USER_PW_INVLD, info);
} catch (LdapException e) {
String error = "checkPassword userId [" + user.getUserId() + "] caught LDAPException=" + e.getMessage();
throw new FinderException(GlobalErrIds.USER_READ_FAILED, error, e);
} finally {
closeUserConnection(ld);
}
return session;
}
use of org.apache.directory.fortress.core.model.ObjectFactory in project directory-fortress-core by apache.
the class PermDAO method unloadPopLdapEntry.
/**
* @param le
* @param sequence
* @return
* @throws LdapInvalidAttributeValueException
* @throws LdapException
*/
private Permission unloadPopLdapEntry(Entry le, long sequence, boolean isAdmin) throws LdapInvalidAttributeValueException {
Permission entity = new ObjectFactory().createPermission();
entity.setSequenceId(sequence);
entity.setAbstractName(getAttribute(le, PERM_NAME));
entity.setObjName(getAttribute(le, GlobalIds.POBJ_NAME));
entity.setObjId(getAttribute(le, GlobalIds.POBJ_ID));
entity.setOpName(getAttribute(le, GlobalIds.POP_NAME));
entity.setInternalId(getAttribute(le, GlobalIds.FT_IID));
entity.setRoles(getAttributeSet(le, ROLES));
entity.setUsers(getAttributeSet(le, USERS));
entity.setType(getAttribute(le, GlobalIds.TYPE));
entity.setDescription(getAttribute(le, SchemaConstants.DESCRIPTION_AT));
entity.addProperties(PropUtil.getProperties(getAttributes(le, GlobalIds.PROPS)));
entity.setAdmin(isAdmin);
entity.setPaSets(getAttributeSet(le, GlobalIds.FT_PERMISSION_ATTRIBUTE_SET));
if (le != null) {
entity.setDn(le.getDn().getNormName());
}
return entity;
}
use of org.apache.directory.fortress.core.model.ObjectFactory 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;
}
use of org.apache.directory.fortress.core.model.ObjectFactory in project directory-fortress-core by apache.
the class AdminRoleDAO method unloadDescendants.
/**
* @param le
* @param sequence
* @return
* @throws LdapInvalidAttributeValueException
* @throws LdapException
*/
private Graphable unloadDescendants(Entry le, long sequence) throws LdapInvalidAttributeValueException {
Role entity = new ObjectFactory().createRole();
entity.setSequenceId(sequence);
entity.setName(getAttribute(le, ROLE_NM));
entity.setParents(getAttributeSet(le, GlobalIds.PARENT_NODES));
return entity;
}
use of org.apache.directory.fortress.core.model.ObjectFactory in project directory-fortress-core by apache.
the class AdminRoleDAO method unloadLdapEntry.
/**
* @param le
* @return
* @throws LdapInvalidAttributeValueException
* @throws LdapException
*/
private AdminRole unloadLdapEntry(Entry le, long sequence, String contextId) throws LdapInvalidAttributeValueException {
AdminRole entity = new ObjectFactory().createAdminRole();
entity.setSequenceId(sequence);
entity.setId(getAttribute(le, GlobalIds.FT_IID));
entity.setDescription(getAttribute(le, SchemaConstants.DESCRIPTION_AT));
entity.setOccupants(getAttributes(le, ROLE_OCCUPANT));
entity.setOsPSet(getAttributeSet(le, ROLE_OSP));
entity.setOsUSet(getAttributeSet(le, ROLE_OSU));
entity.setName(getAttribute(le, SchemaConstants.CN_AT));
unloadTemporal(le, entity);
entity.setRoleRangeRaw(getAttribute(le, ROLE_RANGE));
entity.setParents(getAttributeSet(le, GlobalIds.PARENT_NODES));
entity.setChildren(AdminRoleUtil.getChildren(entity.getName().toUpperCase(), contextId));
return entity;
}
Aggregations