1 package org.apache.struts2.portlet.interceptor;
2
3 import org.apache.struts2.interceptor.PrincipalProxy;
4
5 import javax.portlet.PortletRequest;
6 import javax.servlet.http.HttpServletRequest;
7 import java.security.Principal;
8
9 /***
10 * PrincipalProxy implementation for using PortletRequest Principal related methods.
11 */
12 public class PortletPrincipalProxy implements PrincipalProxy {
13
14 private PortletRequest request;
15
16 /***
17 * Constructs a proxy
18 *
19 * @param request The underlying request
20 */
21 public PortletPrincipalProxy(PortletRequest request) {
22 this.request = request;
23 }
24
25 /***
26 * True if the user is in the given role
27 *
28 * @param role The role
29 * @return True if the user is in that role
30 */
31 public boolean isUserInRole(String role) {
32 return request.isUserInRole(role);
33 }
34
35 /***
36 * Gets the user principal
37 *
38 * @return The principal
39 */
40 public Principal getUserPrincipal() {
41 return request.getUserPrincipal();
42 }
43
44 /***
45 * Gets the user id
46 *
47 * @return The user id
48 */
49 public String getRemoteUser() {
50 return request.getRemoteUser();
51 }
52
53 /***
54 * Is the request using https?
55 *
56 * @return True if using https
57 */
58 public boolean isRequestSecure() {
59 return request.isSecure();
60 }
61
62 /***
63 * Gets the request.
64 *
65 * @return The request
66 * @throws UnsupportedOperationException not supported in this implementation.
67 * @deprecated To obtain the HttpServletRequest in your action, use
68 * {@link org.apache.struts2.servlet.ServletRequestAware}, since this method will be dropped in future.
69 */
70 public HttpServletRequest getRequest() {
71 throw new UnsupportedOperationException("Usage of getRequest() method is deprecadet and not supported for this implementation");
72 }
73 }