[keycloak-user] How to get specific client role programmatically

Okie Oth okie.othsam at gmail.com
Tue Jun 7 03:54:01 EDT 2016


In this example I play around with keycloak-admin-client. The following 
example access the client roles and add new roles to a already defined 
client.

Maybe it helps

https://github.com/OkieOth/grantMaster/blob/master/InitKeycloakServer/src/main/java/de/oth/keycloak/impl/KeycloakAccess.java#L287

Kind regards
Eiko

Am 07.06.2016 um 07:31 schrieb Haim Vana:
>
> Thanks and sorry about the repetition.
>
> *From:*Stian Thorgersen [mailto:sthorger at redhat.com]
> *Sent:* Tuesday, June 07, 2016 8:23 AM
> *To:* Haim Vana <haimv at perfectomobile.com>
> *Cc:* keycloak-user at lists.jboss.org
> *Subject:* Re: [keycloak-user] How to get specific client role 
> programmatically
>
> Please don't repeat your question, if you're not getting an answer 
> straight away it means we're busy.
>
> realm.clients().get("client-uuid").roles().get("rolename").toRepresentation()
>
> On 7 June 2016 at 07:02, Haim Vana <haimv at perfectomobile.com 
> <mailto:haimv at perfectomobile.com>> wrote:
>
>     Hi,
>
>     Any idea regarding the below ?
>
>     *From:*keycloak-user-bounces at lists.jboss.org
>     <mailto:keycloak-user-bounces at lists.jboss.org>
>     [mailto:keycloak-user-bounces at lists.jboss.org
>     <mailto:keycloak-user-bounces at lists.jboss.org>] *On Behalf Of
>     *Haim Vana
>     *Sent:* Monday, May 30, 2016 10:22 PM
>     *To:* stian at redhat.com <mailto:stian at redhat.com>
>     *Cc:* keycloak-user at lists.jboss.org
>     <mailto:keycloak-user at lists.jboss.org>
>     *Subject:* Re: [keycloak-user] How to get specific client role
>     programmatically
>
>     But the ClientRepresentation doesn’t have any getRole method, so
>     how should I do it ?
>
>     Here is my code:
>
>     ClientRepresentation clientRepresentation =
>     masterRealm.clients().findByClientId(realmName + *"-realm"*).get(0);
>
>     Thanks,
>
>     Haim.
>
>     *From:*Stian Thorgersen [mailto:sthorger at redhat.com]
>     *Sent:* Monday, May 30, 2016 10:27 AM
>     *To:* Haim Vana <haimv at perfectomobile.com
>     <mailto:haimv at perfectomobile.com>>
>     *Cc:* keycloak-user at lists.jboss.org
>     <mailto:keycloak-user at lists.jboss.org>
>     *Subject:* Re: [keycloak-user] How to get specific client role
>     programmatically
>
>     To get a specific role for a client you need to get the client,
>     then the role from that client. It's not available through the
>     user resource.
>
>         *From:* keycloak-user-bounces at lists.jboss.org
>         <mailto:keycloak-user-bounces at lists.jboss.org>
>         [mailto:keycloak-user-bounces at lists.jboss.org
>         <mailto:keycloak-user-bounces at lists.jboss.org>] *On Behalf Of
>         *Haim Vana
>         *Sent:* Wednesday, May 25, 2016 10:53 PM
>         *To:* keycloak-user at lists.jboss.org
>         <mailto:keycloak-user at lists.jboss.org>
>         *Subject:* [keycloak-user] How to get specific client role
>         programmatically
>
>         Hi,
>
>         I am using the KeyCloak API to create admin users and update
>         their roles, I am able to add to an admin user all the
>         available client roles, however how can I add a specific one ?
>
>         This is my code to get all the available client roles:
>
>         userResource.roles().clientLevel(userRealmClientId).listAvailable()
>
>         How can I get specific one and not all ?
>
>         Any advice will be appreciated,
>
>         Haim.
>
>         The information contained in this message is proprietary to
>         the sender, protected from disclosure, and may be privileged.
>         The information is intended to be conveyed only to the
>         designated recipient(s) of the message. If the reader of this
>         message is not the intended recipient, you are hereby notified
>         that any dissemination, use, distribution or copying of this
>         communication is strictly prohibited and may be unlawful. If
>         you have received this communication in error, please notify
>         us immediately by replying to the message and deleting it from
>         your computer. Thank you.
>
>         The information contained in this message is proprietary to
>         the sender, protected from disclosure, and may be privileged.
>         The information is intended to be conveyed only to the
>         designated recipient(s) of the message. If the reader of this
>         message is not the intended recipient, you are hereby notified
>         that any dissemination, use, distribution or copying of this
>         communication is strictly prohibited and may be unlawful. If
>         you have received this communication in error, please notify
>         us immediately by replying to the message and deleting it from
>         your computer. Thank you.
>
>
>         _______________________________________________
>         keycloak-user mailing list
>         keycloak-user at lists.jboss.org
>         <mailto:keycloak-user at lists.jboss.org>
>         https://lists.jboss.org/mailman/listinfo/keycloak-user
>         <https://emea01.safelinks.protection.outlook.com/?url=https%3a%2f%2flists.jboss.org%2fmailman%2flistinfo%2fkeycloak-user&data=01%7c01%7chaimv%40perfectomobile.com%7c23e84d6917a8405f7ae308d38e93c7a1%7cceb4c662d6994e7da0bd272619a46977%7c1&sdata=sLhYtllxBuSVwgemvc7335ro0x%2fKsvw75pDs%2bHTX3OE%3d>
>
>     The information contained in this message is proprietary to the
>     sender, protected from disclosure, and may be privileged. The
>     information is intended to be conveyed only to the designated
>     recipient(s) of the message. If the reader of this message is not
>     the intended recipient, you are hereby notified that any
>     dissemination, use, distribution or copying of this communication
>     is strictly prohibited and may be unlawful. If you have received
>     this communication in error, please notify us immediately by
>     replying to the message and deleting it from your computer. Thank
>     you.
>
>     The information contained in this message is proprietary to the
>     sender, protected from disclosure, and may be privileged. The
>     information is intended to be conveyed only to the designated
>     recipient(s) of the message. If the reader of this message is not
>     the intended recipient, you are hereby notified that any
>     dissemination, use, distribution or copying of this communication
>     is strictly prohibited and may be unlawful. If you have received
>     this communication in error, please notify us immediately by
>     replying to the message and deleting it from your computer. Thank
>     you.
>
> The information contained in this message is proprietary to the 
> sender, protected from disclosure, and may be privileged. The 
> information is intended to be conveyed only to the designated 
> recipient(s) of the message. If the reader of this message is not the 
> intended recipient, you are hereby notified that any dissemination, 
> use, distribution or copying of this communication is strictly 
> prohibited and may be unlawful. If you have received this 
> communication in error, please notify us immediately by replying to 
> the message and deleting it from your computer. Thank you.
>
>
> _______________________________________________
> keycloak-user mailing list
> keycloak-user at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-user

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/keycloak-user/attachments/20160607/27c57d19/attachment-0001.html 


More information about the keycloak-user mailing list