public class UsersResource extends Object
Modifier and Type | Field and Description |
---|---|
protected ClientConnection |
clientConnection |
protected static org.jboss.logging.Logger |
logger |
protected RealmModel |
realm |
protected KeycloakSession |
session |
protected javax.ws.rs.core.UriInfo |
uriInfo |
Constructor and Description |
---|
UsersResource(RealmModel realm,
RealmAuth auth,
TokenManager tokenManager) |
Modifier and Type | Method and Description |
---|---|
void |
addRealmRoleMappings(String username,
List<RoleRepresentation> roles)
Add realm-level role mappings
|
javax.ws.rs.core.Response |
addSocialLink(String username,
String provider,
SocialLinkRepresentation rep) |
javax.ws.rs.core.Response |
createUser(javax.ws.rs.core.UriInfo uriInfo,
UserRepresentation rep)
Create a new user.
|
void |
deleteRealmRoleMappings(String username,
List<RoleRepresentation> roles)
Delete realm-level role mappings
|
javax.ws.rs.core.Response |
deleteUser(String username)
delete this user
|
List<RoleRepresentation> |
getAvailableRealmRoleMappings(String username)
Realm-level roles that can be mapped to this user
|
List<RoleRepresentation> |
getCompositeRealmRoleMappings(String username)
Effective realm-level role mappings for this user.
|
List<RoleRepresentation> |
getRealmRoleMappings(String username)
Get realm-level role mappings for this user
|
MappingsRepresentation |
getRoleMappings(String username)
Get role mappings for this user
|
List<UserSessionRepresentation> |
getSessions(String username)
List set of sessions associated with this user.
|
List<SocialLinkRepresentation> |
getSocialLinks(String username)
List set of social logins associated with this user.
|
UserRepresentation |
getUser(String username)
Get represenation of the user
|
UserApplicationRoleMappingsResource |
getUserApplicationRoleMappingsResource(String username,
String appName) |
UserApplicationRoleMappingsResource |
getUserApplicationRoleMappingsResourceById(String username,
String appId) |
List<UserRepresentation> |
getUsers(String search,
String last,
String first,
String email,
String username,
Integer firstResult,
Integer maxResults)
Query list of users.
|
void |
logout(String username)
Remove all user sessions associated with this user.
|
void |
removeSocialLink(String username,
String provider) |
void |
removeTotp(String username) |
void |
resetPassword(String username,
CredentialRepresentation pass)
Set up a temporary password for this user.
|
javax.ws.rs.core.Response |
resetPasswordEmail(String username)
Send an email to the user with a link they can click to reset their password
|
javax.ws.rs.core.Response |
updateUser(String username,
UserRepresentation rep)
Update the user
|
protected static final org.jboss.logging.Logger logger
protected RealmModel realm
@Context protected ClientConnection clientConnection
@Context protected javax.ws.rs.core.UriInfo uriInfo
@Context protected KeycloakSession session
public UsersResource(RealmModel realm, RealmAuth auth, TokenManager tokenManager)
@Path(value="{username}") @PUT @Consumes(value="application/json") public javax.ws.rs.core.Response updateUser(@PathParam(value="username") String username, UserRepresentation rep)
username
- user name (not id!)rep
- @POST @Consumes(value="application/json") public javax.ws.rs.core.Response createUser(@Context javax.ws.rs.core.UriInfo uriInfo, UserRepresentation rep)
uriInfo
- rep
- @Path(value="{username}") @GET @Produces(value="application/json") public UserRepresentation getUser(@PathParam(value="username") String username)
username
- username (not id!)@Path(value="{username}/sessions") @GET @Produces(value="application/json") public List<UserSessionRepresentation> getSessions(@PathParam(value="username") String username)
username
- @Path(value="{username}/social-links") @GET @Produces(value="application/json") public List<SocialLinkRepresentation> getSocialLinks(@PathParam(value="username") String username)
username
- @Path(value="{username}/social-links/{provider}") @POST public javax.ws.rs.core.Response addSocialLink(@PathParam(value="username") String username, @PathParam(value="provider") String provider, SocialLinkRepresentation rep)
@Path(value="{username}/social-links/{provider}") @DELETE public void removeSocialLink(@PathParam(value="username") String username, @PathParam(value="provider") String provider)
@Path(value="{username}/logout") @POST public void logout(@PathParam(value="username") String username)
username
- username (not id!)@Path(value="{username}") @DELETE public javax.ws.rs.core.Response deleteUser(@PathParam(value="username") String username)
username
- username (not id!)@GET @Produces(value="application/json") public List<UserRepresentation> getUsers(@QueryParam(value="search") String search, @QueryParam(value="lastName") String last, @QueryParam(value="firstName") String first, @QueryParam(value="email") String email, @QueryParam(value="username") String username, @QueryParam(value="first") Integer firstResult, @QueryParam(value="max") Integer maxResults)
search
- string contained in username, first or last name, or emaillast
- first
- email
- username
- @Path(value="{username}/role-mappings") @GET @Produces(value="application/json") public MappingsRepresentation getRoleMappings(@PathParam(value="username") String username)
username
- username (not id!)@Path(value="{username}/role-mappings/realm") @GET @Produces(value="application/json") public List<RoleRepresentation> getRealmRoleMappings(@PathParam(value="username") String username)
username
- username (not id!)@Path(value="{username}/role-mappings/realm/composite") @GET @Produces(value="application/json") public List<RoleRepresentation> getCompositeRealmRoleMappings(@PathParam(value="username") String username)
username
- username (not id!)@Path(value="{username}/role-mappings/realm/available") @GET @Produces(value="application/json") public List<RoleRepresentation> getAvailableRealmRoleMappings(@PathParam(value="username") String username)
username
- username (not id!)@Path(value="{username}/role-mappings/realm") @POST @Consumes(value="application/json") public void addRealmRoleMappings(@PathParam(value="username") String username, List<RoleRepresentation> roles)
username
- username (not id!)roles
- @Path(value="{username}/role-mappings/realm") @DELETE @Consumes(value="application/json") public void deleteRealmRoleMappings(@PathParam(value="username") String username, List<RoleRepresentation> roles)
username
- username (not id!)roles
- @Path(value="{username}/role-mappings/applications/{app}") public UserApplicationRoleMappingsResource getUserApplicationRoleMappingsResource(@PathParam(value="username") String username, @PathParam(value="app") String appName)
@Path(value="{username}/role-mappings/applications-by-id/{appId}") public UserApplicationRoleMappingsResource getUserApplicationRoleMappingsResourceById(@PathParam(value="username") String username, @PathParam(value="appId") String appId)
@Path(value="{username}/reset-password") @PUT @Consumes(value="application/json") public void resetPassword(@PathParam(value="username") String username, CredentialRepresentation pass)
username
- username (not id!)pass
- temporary password@Path(value="{username}/remove-totp") @PUT @Consumes(value="application/json") public void removeTotp(@PathParam(value="username") String username)
username
- username (not id!)@Path(value="{username}/reset-password-email") @PUT @Consumes(value="application/json") public javax.ws.rs.core.Response resetPasswordEmail(@PathParam(value="username") String username)
username
- username (not id!)Copyright © 2014. All Rights Reserved.