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