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