public class UsersResource extends Object
Modifier and Type | Field and Description |
---|---|
protected ClientConnection |
clientConnection |
protected javax.ws.rs.core.HttpHeaders |
headers |
protected static ServicesLogger |
logger |
protected RealmModel |
realm |
protected KeycloakSession |
session |
protected javax.ws.rs.core.UriInfo |
uriInfo |
Constructor and Description |
---|
UsersResource(RealmModel realm,
RealmAuth auth,
AdminEventBuilder adminEvent) |
Modifier and Type | Method and Description |
---|---|
javax.ws.rs.core.Response |
addFederatedIdentity(String id,
String provider,
FederatedIdentityRepresentation rep)
Add a social login provider to the user
|
javax.ws.rs.core.Response |
createUser(javax.ws.rs.core.UriInfo uriInfo,
UserRepresentation rep)
Create a new user
Username must be unique.
|
javax.ws.rs.core.Response |
deleteUser(String id)
Delete the user
|
javax.ws.rs.core.Response |
executeActionsEmail(String id,
String redirectUri,
String clientId,
List<String> actions)
Send a update account email to the user
An email contains a link the user can click to perform a set of required actions.
|
List<Map<String,Object>> |
getConsents(String id)
Get consents granted by the user
|
List<FederatedIdentityRepresentation> |
getFederatedIdentity(String id)
Get social logins associated with the user
|
RoleMapperResource |
getRoleMappings(String id) |
List<UserSessionRepresentation> |
getSessions(String id)
Get sessions associated with the user
|
List<UserSessionRepresentation> |
getSessions(String id,
String clientId)
Get offline sessions associated with the user and client
|
UserRepresentation |
getUser(String id)
Get represenation of the user
|
List<UserRepresentation> |
getUsers(String search,
String last,
String first,
String email,
String username,
Integer firstResult,
Integer maxResults)
Get users
Returns a list of users, filtered according to query parameters
|
Integer |
getUsersCount() |
List<GroupRepresentation> |
groupMembership(String id) |
Map<String,Object> |
impersonate(String id)
Impersonate the user
|
void |
joinGroup(String id,
String groupId) |
void |
logout(String id)
Remove all user sessions associated with the user
Also send notification to all clients that have an admin URL to invalidate the sessions for the particular user.
|
void |
removeFederatedIdentity(String id,
String provider)
Remove a social login provider from user
|
void |
removeMembership(String id,
String groupId) |
void |
removeTotp(String id)
Remove TOTP from the user
|
void |
resetPassword(String id,
CredentialRepresentation pass)
Set up a temporary password for the user
User will have to reset the temporary password next time they log in.
|
javax.ws.rs.core.Response |
resetPasswordEmail(String id,
String redirectUri,
String clientId)
Deprecated.
|
void |
revokeConsent(String id,
String clientId)
Revoke consent and offline tokens for particular client from user
|
javax.ws.rs.core.Response |
sendVerifyEmail(String id,
String redirectUri,
String clientId)
Send an email-verification email to the user
An email contains a link the user can click to verify their email address.
|
javax.ws.rs.core.Response |
updateUser(String id,
UserRepresentation rep)
Update the user
|
static void |
updateUserFromRep(UserModel user,
UserRepresentation rep,
Set<String> attrsToRemove,
RealmModel realm,
KeycloakSession session,
boolean removeMissingRequiredActions) |
protected static final ServicesLogger logger
protected RealmModel realm
@Context protected ClientConnection clientConnection
@Context protected javax.ws.rs.core.UriInfo uriInfo
@Context protected KeycloakSession session
@Context protected javax.ws.rs.core.HttpHeaders headers
public UsersResource(RealmModel realm, RealmAuth auth, AdminEventBuilder adminEvent)
@Path(value="{id}") @PUT @Consumes(value="application/json") public javax.ws.rs.core.Response updateUser(@PathParam(value="id") String id, UserRepresentation rep)
id
- User idrep
- @POST @Consumes(value="application/json") public javax.ws.rs.core.Response createUser(@Context javax.ws.rs.core.UriInfo uriInfo, UserRepresentation rep)
uriInfo
- rep
- public static void updateUserFromRep(UserModel user, UserRepresentation rep, Set<String> attrsToRemove, RealmModel realm, KeycloakSession session, boolean removeMissingRequiredActions)
@Path(value="{id}") @GET @Produces(value="application/json") public UserRepresentation getUser(@PathParam(value="id") String id)
id
- User id@Path(value="{id}/impersonation") @POST @Produces(value="application/json") public Map<String,Object> impersonate(@PathParam(value="id") String id)
id
- User id@Path(value="{id}/sessions") @GET @Produces(value="application/json") public List<UserSessionRepresentation> getSessions(@PathParam(value="id") String id)
id
- User id@Path(value="{id}/offline-sessions/{clientId}") @GET @Produces(value="application/json") public List<UserSessionRepresentation> getSessions(@PathParam(value="id") String id, @PathParam(value="clientId") String clientId)
id
- User id@Path(value="{id}/federated-identity") @GET @Produces(value="application/json") public List<FederatedIdentityRepresentation> getFederatedIdentity(@PathParam(value="id") String id)
id
- User id@Path(value="{id}/federated-identity/{provider}") @POST public javax.ws.rs.core.Response addFederatedIdentity(@PathParam(value="id") String id, @PathParam(value="provider") String provider, FederatedIdentityRepresentation rep)
id
- User idprovider
- Social login provider idrep
- @Path(value="{id}/federated-identity/{provider}") @DELETE public void removeFederatedIdentity(@PathParam(value="id") String id, @PathParam(value="provider") String provider)
id
- User idprovider
- Social login provider id@Path(value="{id}/consents") @GET @Produces(value="application/json") public List<Map<String,Object>> getConsents(@PathParam(value="id") String id)
id
- User id@Path(value="{id}/consents/{client}") @DELETE public void revokeConsent(@PathParam(value="id") String id, @PathParam(value="client") String clientId)
id
- User idclientId
- Client id@Path(value="{id}/logout") @POST public void logout(@PathParam(value="id") String id)
id
- User id@Path(value="{id}") @DELETE public javax.ws.rs.core.Response deleteUser(@PathParam(value="id") String id)
id
- User 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
- A String contained in username, first or last name, or emaillast
- first
- email
- username
- first
- Pagination offsetmaxResults
- Pagination size@Path(value="count") @GET @Produces(value="application/json") public Integer getUsersCount()
@Path(value="{id}/role-mappings") public RoleMapperResource getRoleMappings(@PathParam(value="id") String id)
@Path(value="{id}/reset-password") @PUT @Consumes(value="application/json") public void resetPassword(@PathParam(value="id") String id, CredentialRepresentation pass)
id
- User idpass
- A Temporary password@Path(value="{id}/remove-totp") @PUT @Consumes(value="application/json") public void removeTotp(@PathParam(value="id") String id)
id
- User id@Deprecated @Path(value="{id}/reset-password-email") @PUT @Consumes(value="application/json") public javax.ws.rs.core.Response resetPasswordEmail(@PathParam(value="id") String id, @QueryParam(value="redirect_uri") String redirectUri, @QueryParam(value="client_id") String clientId)
id
- redirectUri
- redirect uriclientId
- client id@Path(value="{id}/execute-actions-email") @PUT @Consumes(value="application/json") public javax.ws.rs.core.Response executeActionsEmail(@PathParam(value="id") String id, @QueryParam(value="redirect_uri") String redirectUri, @QueryParam(value="client_id") String clientId, List<String> actions)
id
- User isredirectUri
- Redirect uriclientId
- Client idactions
- required actions the user needs to complete@Path(value="{id}/send-verify-email") @PUT @Consumes(value="application/json") public javax.ws.rs.core.Response sendVerifyEmail(@PathParam(value="id") String id, @QueryParam(value="redirect_uri") String redirectUri, @QueryParam(value="client_id") String clientId)
id
- User idredirectUri
- Redirect uriclientId
- Client id@GET @Path(value="{id}/groups") @Produces(value="application/json") public List<GroupRepresentation> groupMembership(@PathParam(value="id") String id)
@DELETE @Path(value="{id}/groups/{groupId}") public void removeMembership(@PathParam(value="id") String id, @PathParam(value="groupId") String groupId)
Copyright © 2016 JBoss by Red Hat. All rights reserved.