jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sheena <destinee...@gmail.com>
Subject Re: getting users
Date Wed, 30 Jun 2010 15:29:30 GMT
hi Ulrich

Thanks for posting these methods...i will surely try them & let you
know about any further developments...

Regards.

Shivalika

On Wed, Jun 30, 2010 at 4:10 PM, Cech. Ulrich <Ulrich.Cech@aeb.de> wrote:
> Hi,
>
> here are the methods to retrieve a created user:
>
>
>   public User getUser(Session session, String userId)
>            throws RepositoryException {
>        UserManager um = getUserManager(session);
>        Authorizable auth = um.getAuthorizable(userId);
>        if (auth instanceof User) {
>            return (User) um.getAuthorizable(userId);
>        } else {
>            throw new RepositoryException("The userid '" + userId
>                    + "' is no valid repository user.");
>        }
>    }
>
>    private UserManager getUserManager(Session session)
>            throws RepositoryException {
>        if (session instanceof JackrabbitSession) {
>            return ((JackrabbitSession) session).getUserManager();
>        } else {
>            throw new RepositoryException(
>                    "This JCR implementation does not have a UserManager.");
>        }
>    }
>
>   public List<String> getAllRegisteredUsers(Session session)
>            throws RepositoryException {
>        List<String> list = new ArrayList<String>();
>        int type = UserManager.SEARCH_TYPE_USER; // or group or user
>        Iterator<Authorizable> auths =
>                getUserManager(session).findAuthorizables("rep:principalName",
>                        null, type);
>        while (auths.hasNext()) {
>            Authorizable authorizable = (Authorizable) auths.next();
>            list.add(authorizable.getID());
>        }
>        return list;
>    }
>
> Bye,
> Ulrich
>
>
>

Mime
View raw message