A
A
Alexey22222019-07-11 10:04:16
Java
Alexey2222, 2019-07-11 10:04:16

How to set a role to a user in Java EE?

When a user logs in, I want to set his role for the duration of the session. How can I do that?

For example, one of the tutorials says that "you can set roles via REALM database, via LDAP, or create them on the fly". I'm interested in creating a role on the fly, is there something like this? And then if there is a REST method, then the user will not be able to call this method. If not, what alternative [easy] ways to create roles are there? UPD: I have read that roles can be installed on the server. But as I understand it, these are the roles for server users? At least for me:

session.getUser.setRole("usual-user")

@RolesAllowed("other-user")


jUFUk.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question