public class UsersResource extends Object
Modifier and Type | Field and Description |
---|---|
protected static org.jboss.logging.Logger |
logger |
protected RealmModel |
realm |
protected KeycloakSession |
session |
protected javax.ws.rs.core.UriInfo |
uriInfo |
Constructor and Description |
---|
UsersResource(ProviderSession providerSession,
RealmModel realm,
RealmAuth auth,
TokenManager tokenManager) |
Modifier and Type | Method and Description |
---|---|
void |
addApplicationRoleMapping(String username,
String appName,
List<RoleRepresentation> roles)
Add applicaiton-level roles to the user role mapping.
|
void |
addRealmRoleMappings(String username,
List<RoleRepresentation> roles)
Add realm-level role mappings
|
javax.ws.rs.core.Response |
createUser(javax.ws.rs.core.UriInfo uriInfo,
UserRepresentation rep)
Create a new user.
|
void |
deleteApplicationRoleMapping(String username,
String appName,
List<RoleRepresentation> roles)
Delete application-level roles from user role mapping.
|
void |
deleteRealmRoleMappings(String username,
List<RoleRepresentation> roles)
Delete realm-level role mappings
|
void |
deleteUser(String username)
delete this user
|
List<RoleRepresentation> |
getApplicationRoleMappings(String username,
String appName)
Get application-level role mappings for this user for a specific app
|
List<RoleRepresentation> |
getAvailableApplicationRoleMappings(String username,
String appName)
Get available application-level roles that can be mapped to the user
|
List<RoleRepresentation> |
getAvailableRealmRoleMappings(String username)
Realm-level roles that can be mapped to this user
|
protected List<RoleRepresentation> |
getAvailableRoles(UserModel user,
Set<RoleModel> available) |
List<RoleRepresentation> |
getCompositeApplicationRoleMappings(String username,
String appName)
Get effective application-level role mappings.
|
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.
|
Map<String,UserStats> |
getSessionStats(String username)
For each application with an admin URL, query them for the set of users logged in.
|
List<SocialLinkRepresentation> |
getSocialLinks(String username)
List set of social logins associated with this user.
|
UserRepresentation |
getUser(String username)
Get represenation of the user
|
List<UserRepresentation> |
getUsers(String search,
String last,
String first,
String email,
String username)
Query list of users.
|
void |
logout(String username)
Remove all user sessions associated with this user.
|
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 javax.ws.rs.core.UriInfo uriInfo
@Context protected KeycloakSession session
public UsersResource(ProviderSession providerSession, 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}/session-stats") @GET @Produces(value="application/json") public Map<String,UserStats> getSessionStats(@PathParam(value="username") String username)
username
- @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}/logout") @POST public void logout(@PathParam(value="username") String username)
username
- username (not id!)@Path(value="{username}") @DELETE public void 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)
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}") @GET @Produces(value="application/json") public List<RoleRepresentation> getApplicationRoleMappings(@PathParam(value="username") String username, @PathParam(value="app") String appName)
username
- username (not id!)appName
- app name (not id!)@Path(value="{username}/role-mappings/applications/{app}/composite") @GET @Produces(value="application/json") public List<RoleRepresentation> getCompositeApplicationRoleMappings(@PathParam(value="username") String username, @PathParam(value="app") String appName)
username
- username (not id!)appName
- app name (not id!)@Path(value="{username}/role-mappings/applications/{app}/available") @GET @Produces(value="application/json") public List<RoleRepresentation> getAvailableApplicationRoleMappings(@PathParam(value="username") String username, @PathParam(value="app") String appName)
username
- username (not id!)appName
- app name (not id!)protected List<RoleRepresentation> getAvailableRoles(UserModel user, Set<RoleModel> available)
@Path(value="{username}/role-mappings/applications/{app}") @POST @Consumes(value="application/json") public void addApplicationRoleMapping(@PathParam(value="username") String username, @PathParam(value="app") String appName, List<RoleRepresentation> roles)
username
- username (not id!)appName
- app name (not id!)roles
- @Path(value="{username}/role-mappings/applications/{app}") @DELETE @Consumes(value="application/json") public void deleteApplicationRoleMapping(@PathParam(value="username") String username, @PathParam(value="app") String appName, List<RoleRepresentation> roles)
username
- username (not id!)appName
- app name (not id!)roles
- @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.