Search in sources :

Example 16 with ObjectFactory

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;
}
Also used : PasswordException(org.apache.directory.fortress.core.PasswordException) FinderException(org.apache.directory.fortress.core.FinderException) LdapAuthenticationException(org.apache.directory.api.ldap.model.exception.LdapAuthenticationException) ObjectFactory(org.apache.directory.fortress.core.model.ObjectFactory) PasswordPolicy(org.apache.directory.api.ldap.extras.controls.ppolicy.PasswordPolicy) BindResponse(org.apache.directory.api.ldap.model.message.BindResponse) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) Session(org.apache.directory.fortress.core.model.Session) LdapConnection(org.apache.directory.ldap.client.api.LdapConnection)

Example 17 with ObjectFactory

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;
}
Also used : ObjectFactory(org.apache.directory.fortress.core.model.ObjectFactory) Permission(org.apache.directory.fortress.core.model.Permission)

Example 18 with ObjectFactory

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;
}
Also used : PermissionAttributeSet(org.apache.directory.fortress.core.model.PermissionAttributeSet) ObjectFactory(org.apache.directory.fortress.core.model.ObjectFactory)

Example 19 with ObjectFactory

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;
}
Also used : AdminRole(org.apache.directory.fortress.core.model.AdminRole) Role(org.apache.directory.fortress.core.model.Role) ObjectFactory(org.apache.directory.fortress.core.model.ObjectFactory)

Example 20 with ObjectFactory

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;
}
Also used : ObjectFactory(org.apache.directory.fortress.core.model.ObjectFactory) AdminRole(org.apache.directory.fortress.core.model.AdminRole)

Aggregations

ObjectFactory (org.apache.directory.fortress.core.model.ObjectFactory)25 Role (org.apache.directory.fortress.core.model.Role)3 UserRole (org.apache.directory.fortress.core.model.UserRole)3 ArrayList (java.util.ArrayList)2 AdminRole (org.apache.directory.fortress.core.model.AdminRole)2 Constraint (org.apache.directory.fortress.core.model.Constraint)2 OrgUnit (org.apache.directory.fortress.core.model.OrgUnit)2 SDSet (org.apache.directory.fortress.core.model.SDSet)2 Session (org.apache.directory.fortress.core.model.Session)2 User (org.apache.directory.fortress.core.model.User)2 HashMap (java.util.HashMap)1 PasswordPolicy (org.apache.directory.api.ldap.extras.controls.ppolicy.PasswordPolicy)1 LdapAuthenticationException (org.apache.directory.api.ldap.model.exception.LdapAuthenticationException)1 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)1 BindResponse (org.apache.directory.api.ldap.model.message.BindResponse)1 FinderException (org.apache.directory.fortress.core.FinderException)1 PasswordException (org.apache.directory.fortress.core.PasswordException)1 SecurityException (org.apache.directory.fortress.core.SecurityException)1 ValidationException (org.apache.directory.fortress.core.ValidationException)1 Address (org.apache.directory.fortress.core.model.Address)1