I have a thought, let me know if you think it's valid.
the worst thing I see on this approach is having to send the username on
every request, like this:
keycloak.userService().grantRoles(username, roles);
keycloak.userService().logoutFromAllSessions(username);
What if there was a specific class for when you want to manipulate a
specific user, like this:
UserSomething user = keycloak.user(username);
user.grantRoles(roles);
user.logoutFromAllSessions();
And maybe the first one could be called as keycloak.users() and the latter
as keycloak.user(username).
Or it could be better to keep it as userSerivce, I'm not really sure what
would be semantically better.
Any thoughts?
On Thu, Jul 3, 2014 at 10:02 AM, Stian Thorgersen <stian(a)redhat.com> wrote:
Arguments for not extending the representation makes sense, and the
example you include looks good as well.
Nice stuff, look forward to looking at it once it's ready.
----- Original Message -----
> From: "Rodrigo Sasaki" <rodrigopsasaki(a)gmail.com>
> To: "Stian Thorgersen" <stian(a)redhat.com>
> Cc: keycloak-user(a)lists.jboss.org
> Sent: Thursday, 3 July, 2014 1:40:40 PM
> Subject: Re: [keycloak-user] Java Keycloak REST API Wrapper
>
> We have something working here, we're about to start using it, although
it
> still isn't finished,
>
> I had some conversations with my superior, and he asked me to do some
> alterations, and as soon as we have it tested better, I'll request him to
> make the github repo public. I would really like to be able to contribute
> to Keycloak with this, so please let me know of any alterations you see
fit
> as soon as you can see the code.
>
> But just so you can have a better feel (and maybe suggest something),
this
> is an example of usage:
>
> Keycloak keycloak = Keycloak.getInstance(SERVER_URL, REALM, USERNAME,
> PASSWORD, CLIENT_ID, CLIENT_SECRET);
>
> // Create a new user
> UserRepresentation stian = new UserRepresentation();
> stian.setUsername("stian");
> keycloak.userService().create(stian);
>
> // Grant roles to user
> keycloak.userService().grantRoles("stian", roles);
>
> // Find all users
> List<UserRepresentation> users = keycloak.userService().findAll();
>
> My superior thought it was confusing to extend the representation,
because
> some methods would only alter the values in the class, while others would
> actually access the REST API, so he suggested that we do it like the
> examples above.
>
> Any thoughts?
>
>
> On Thu, Jul 3, 2014 at 5:36 AM, Stian Thorgersen <stian(a)redhat.com>
wrote:
>
> > How are you getting along with this?
> >
> > BTW Don't use the model API as I suggested, that's an internal API so
> > wouldn't make much sense. Extending the *Representation classes sounds
like
> > a good option.
> >
> > ----- Original Message -----
> > > From: "Stian Thorgersen" <stian(a)redhat.com>
> > > To: "Rodrigo Sasaki" <rodrigopsasaki(a)gmail.com>
> > > Cc: keycloak-user(a)lists.jboss.org
> > > Sent: Monday, 23 June, 2014 9:42:44 AM
> > > Subject: Re: [keycloak-user] Java Keycloak REST API Wrapper
> > >
> > > That's great! Absolutely something we want. Once it's in a usable
state
> > I'd
> > > like to pull it in to our main Keycloak repo and include it as part
of
> > our
> > > build and release.
> > >
> > > ----- Original Message -----
> > > > From: "Rodrigo Sasaki" <rodrigopsasaki(a)gmail.com>
> > > > To: keycloak-user(a)lists.jboss.org
> > > > Sent: Friday, 20 June, 2014 9:00:57 PM
> > > > Subject: [keycloak-user] Java Keycloak REST API Wrapper
> > > >
> > > > Hi,
> > > >
> > > > I'm working on a Java-based wrapper for the REST API, to make it
look
> > more
> > > > OO, abstracting the access to servers.
> > > >
> > > > It uses methods such as
> > > >
> > > > User bill = realm.getUser("bburke")
> > > > List<RoleRepresentation> roles =
> > > > bill.getApplicationRoleMappings("customer-portal");
> > > >
> > > > It's still in it's early stages, but if you find it
interesting,
I'd be
> > > > happy
> > > > to create a repo for other Java users to use it, and adapt it
based on
> > > > suggestions aswell.
> > > >
> > > > Best regards,
> > > >
> > > > --
> > > > Rodrigo Sasaki
> > > >
> > > > _______________________________________________
> > > > keycloak-user mailing list
> > > > keycloak-user(a)lists.jboss.org
> > > >
https://lists.jboss.org/mailman/listinfo/keycloak-user
> > > _______________________________________________
> > > keycloak-user mailing list
> > > keycloak-user(a)lists.jboss.org
> > >
https://lists.jboss.org/mailman/listinfo/keycloak-user
> > >
> >
>
>
>
> --
> Rodrigo Sasaki
>