Commit 73948bac authored by Jeff Burke's avatar Jeff Burke
Browse files

s1890: updated LdapUserDAO for new User model

parent b498d64c
Loading
Loading
Loading
Loading
+11 −11
Original line number Diff line number Diff line
@@ -145,9 +145,9 @@ public interface UserPersistence
            TransientException, AccessControlException;

    /**
     * Get the user specified by userID whose account is pending approval.
     * Get the user with the specified Principal whose account is pending approval.
     *
     * @param userID The userID.
     * @param userID A Principal of the User.
     *
     * @return User instance.
     *
@@ -160,9 +160,9 @@ public interface UserPersistence
        AccessControlException;

    /**
     * Get the user specified by userID with all of the users identities.
     * Get the user with the specified Principal with all of the users identities.
     *
     * @param userID The userID.
     * @param userID A Principal of the User.
     *
     * @return User instance.
     *
@@ -195,10 +195,10 @@ public interface UserPersistence
        throws TransientException, AccessControlException;

    /**
     * Move the pending user specified by userID from the
     * Move the pending user with the specified Principal from the
     * pending users tree to the active users tree.
     *
     * @param userID      The userID.
     * @param userID A Principal of the User.
     *
     * @return User instance.
     *
@@ -211,7 +211,7 @@ public interface UserPersistence
        AccessControlException;

    /**
     * Update the user specified by userID in the active users tree.
     * Update the user with the specified Principal in the active users tree.
     *
     * @param user      The user instance to modify.
     *
@@ -226,9 +226,9 @@ public interface UserPersistence
               AccessControlException;

    /**
     * Delete the user specified by userID from the active users tree.
     * Delete the user with the specified Principal from the active users tree.
     *
     * @param userID The userID.
     * @param userID A Principal of the User.
     *
     * @throws UserNotFoundException when the user is not found.
     * @throws TransientException If an temporary, unexpected problem occurred.
@@ -239,9 +239,9 @@ public interface UserPersistence
               AccessControlException;

    /**
     * Delete the user specified by userID from the pending users tree.
     * Delete the user with the specified Principal from the pending users tree.
     *
     * @param userID The userID.
     * @param userID A Principal of the User.
     *
     * @throws UserNotFoundException when the user is not found.
     * @throws TransientException If an temporary, unexpected problem occurred.
+1 −1
Original line number Diff line number Diff line
@@ -500,7 +500,7 @@ public class LdapGroupDAO extends LdapDAO
                    DN memberDN = new DN(member);
                    if (memberDN.isDescendantOf(config.getUsersDN(), false))
                    {
                        User<X500Principal> user;
                        User user;
                        try
                        {
                            user = userDAO.getX500User(memberDN);
+4 −4
Original line number Diff line number Diff line
@@ -174,8 +174,8 @@ public class LdapGroupPersistence extends LdapPersistence implements GroupPersis
               GroupNotFoundException
    {
        Subject caller = AuthenticationUtil.getCurrentSubject();
        User owner = getUser(caller);
        group.setOwner(owner);
//        Principal owner = getUser(caller);
//        group.setOwner(owner);

        LdapConnections conns = new LdapConnections(this);
        try
@@ -382,7 +382,7 @@ public class LdapGroupPersistence extends LdapPersistence implements GroupPersis
        return ds.iterator().next();
    }

    private User getUser(Subject caller)
    private Principal getUser(Subject caller)
    {
        if (caller == null || AuthMethod.ANON.equals(AuthenticationUtil.getAuthMethod(caller)))
            throw new AccessControlException("Caller is not authenticated");
@@ -391,6 +391,6 @@ public class LdapGroupPersistence extends LdapPersistence implements GroupPersis
        if (gset == null || gset.isEmpty())
            throw new RuntimeException("BUG: no GroupMemberships cache in Subject");
        GroupMemberships gms = gset.iterator().next();
        return gms.getUser();
        return gms.getUserID();
    }
}
+215 −138

File changed.

Preview size limit exceeded, changes collapsed.

+4 −5
Original line number Diff line number Diff line
@@ -476,7 +476,7 @@ public class LdapUserPersistence extends LdapPersistence implements UserPersiste
    /**
     * Update a user's password. The given user and authenticating user must match.
     *
     * @param user
     * @param userID        the user.
     * @param oldPassword   current password.
     * @param newPassword   new password.
     * @throws UserNotFoundException If the given user does not exist.
@@ -510,8 +510,7 @@ public class LdapUserPersistence extends LdapPersistence implements UserPersiste
    /**
     * Reset a user's password. The given user and authenticating user must match.
     *
     * @param user
     * @param oldPassword   current password.
     * @param userID        The user.
     * @param newPassword   new password.
     * @throws UserNotFoundException If the given user does not exist.
     * @throws TransientException   If an temporary, unexpected problem occurred.
@@ -559,14 +558,14 @@ public class LdapUserPersistence extends LdapPersistence implements UserPersiste
        return false;
    }

    private boolean isMatch(Subject caller, Principal userID)
    private boolean isMatch(Subject caller, Principal identity)
    {
        if (caller == null || AuthMethod.ANON.equals(AuthenticationUtil.getAuthMethod(caller)))
            throw new AccessControlException("Caller is not authenticated");

        for (Principal pc : caller.getPrincipals())
        {
            if (AuthenticationUtil.equals(pc, userID))
            if (AuthenticationUtil.equals(pc, identity))
                return true;
        }
        return false;
Loading