Save my name, email, and website in this browser for the next time I comment. Get Authenticated Principal Details. Get Principal In the Controller Class Once you have Spring Security configured and working, here is how you can get the currently authenticated principal user object in the Controller class. Leave a Reply Cancel reply Your email address will not be published. Secure RestController Methods. I saw the same behaviour on the first go, and I didn't have too much time to waste on that, so I'm back to using 3.
It was a bit of a pain retrieving all the roles from the Subject, but I need to do it just once so that's ok. I found the following link in one of the threads here, but I did not try it out. I'm a little confused. I thought JBoss 3. Does it use all or some of J2EE 1. I checked the API docs for 1. I was thinking request, but typed response. Creating and configuring custom JAAS login module solves problem.
See Listing 4 here. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Asked 10 years, 3 months ago.
Active 9 years ago. Viewed 23k times. Improve this question. Muhammad Imran Tariq Muhammad Imran Tariq 21k 42 42 gold badges silver badges bronze badges. Add a comment. Some servlet containers do not allow servlets to access headers using this method, in which case this method returns null Returns: an enumeration of all the header names sent with this request; if the request has no headers, an empty enumeration; if the servlet container does not allow servlets to use this method, null getIntHeader int getIntHeader java.
If the request does not have a header of the specified name, this method returns If the header cannot be converted to an integer, this method throws a NumberFormatException. Parameters: name - a String specifying the name of a request header Returns: an integer expressing the value of the request header or -1 if the request doesn't have a header of this name Throws: java.
NumberFormatException - If the header value can't be converted to an int getMethod java. Returns: a String specifying the name of the method with which this request was made getPathInfo java. This method returns null if there was no extra path information. Returns: a String , decoded by the web container, specifying extra path information that comes after the servlet path but before the query string in the request URL; or null if the URL does not have any extra path information getPathTranslated java.
If the URL does not have any extra path information, this method returns null or the servlet container cannot translate the virtual path to a real path for any reason such as when the web application is executed from an archive. The web container does not decode this string.
Returns: a String specifying the real path, or null if the URL does not have any extra path information getContextPath java. The context path always comes first in a request URI. For servlets in the default root context, this method returns "". The container does not decode this string. It is possible that a servlet container may match a context by more than one context path. In such cases this method will return the actual context path used by the request and it may differ from the path returned by the ServletContext.
The context path returned by ServletContext. This method returns null if the URL does not have a query string. Returns: a String containing the query string or null if the URL contains no query string. The value is not decoded by the container. Whether the user name is sent with each subsequent request depends on the browser and type of authentication. Returns: a String specifying the login of the user making this request, or null if the user login is not known isUserInRole boolean isUserInRole java.
Roles and role membership can be defined using deployment descriptors. If the user has not been authenticated, the method returns false. Parameters: role - a String specifying the name of the role Returns: a boolean indicating whether the user making this request belongs to a given role; false if the user has not been authenticated getUserPrincipal java. If the user has not been authenticated, the method returns null.
0コメント