01: /*
02: * $Id: PortletPrincipalProxy.java 560697 2007-07-29 08:58:03Z apetrelli $
03: *
04: * Licensed to the Apache Software Foundation (ASF) under one
05: * or more contributor license agreements. See the NOTICE file
06: * distributed with this work for additional information
07: * regarding copyright ownership. The ASF licenses this file
08: * to you under the Apache License, Version 2.0 (the
09: * "License"); you may not use this file except in compliance
10: * with the License. You may obtain a copy of the License at
11: *
12: * http://www.apache.org/licenses/LICENSE-2.0
13: *
14: * Unless required by applicable law or agreed to in writing,
15: * software distributed under the License is distributed on an
16: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17: * KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations
19: * under the License.
20: */
21: package org.apache.struts2.portlet.interceptor;
22:
23: import org.apache.struts2.interceptor.PrincipalProxy;
24:
25: import javax.portlet.PortletRequest;
26: import javax.servlet.http.HttpServletRequest;
27: import java.security.Principal;
28:
29: /**
30: * PrincipalProxy implementation for using PortletRequest Principal related methods.
31: */
32: public class PortletPrincipalProxy implements PrincipalProxy {
33:
34: private PortletRequest request;
35:
36: /**
37: * Constructs a proxy
38: *
39: * @param request The underlying request
40: */
41: public PortletPrincipalProxy(PortletRequest request) {
42: this .request = request;
43: }
44:
45: /**
46: * True if the user is in the given role
47: *
48: * @param role The role
49: * @return True if the user is in that role
50: */
51: public boolean isUserInRole(String role) {
52: return request.isUserInRole(role);
53: }
54:
55: /**
56: * Gets the user principal
57: *
58: * @return The principal
59: */
60: public Principal getUserPrincipal() {
61: return request.getUserPrincipal();
62: }
63:
64: /**
65: * Gets the user id
66: *
67: * @return The user id
68: */
69: public String getRemoteUser() {
70: return request.getRemoteUser();
71: }
72:
73: /**
74: * Is the request using https?
75: *
76: * @return True if using https
77: */
78: public boolean isRequestSecure() {
79: return request.isSecure();
80: }
81:
82: /**
83: * Gets the request.
84: *
85: * @return The request
86: * @throws UnsupportedOperationException not supported in this implementation.
87: * @deprecated To obtain the HttpServletRequest in your action, use
88: * {@link org.apache.struts2.servlet.ServletRequestAware}, since this method will be dropped in future.
89: */
90: public HttpServletRequest getRequest() {
91: throw new UnsupportedOperationException(
92: "Usage of getRequest() method is deprecadet and not supported for this implementation");
93: }
94: }
|