| ProtectedActionRequest.java |
1 /**
2 * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License as published by the Free
6 * Software Foundation; either version 2.1 of the License, or (at your option)
7 * any later version.
8 *
9 * This library is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 * details.
13 */
14
15 package com.liferay.portal.kernel.portlet;
16
17 import com.liferay.portal.kernel.servlet.ProtectedPrincipal;
18
19 import java.security.Principal;
20
21 import javax.portlet.ActionRequest;
22 import javax.portlet.filter.ActionRequestWrapper;
23
24 /**
25 * <a href="ProtectedActionRequest.java.html"><b><i>View Source</i></b></a>
26 *
27 * @author Brian Wing Shun Chan
28 */
29 public class ProtectedActionRequest extends ActionRequestWrapper {
30
31 public ProtectedActionRequest(
32 ActionRequest actionRequest, String remoteUser) {
33
34 super(actionRequest);
35
36 _remoteUser = remoteUser;
37
38 if (remoteUser != null) {
39 _userPrincipal = new ProtectedPrincipal(remoteUser);
40 }
41 }
42
43 public String getRemoteUser() {
44 if (_remoteUser != null) {
45 return _remoteUser;
46 }
47 else {
48 return super.getRemoteUser();
49 }
50 }
51
52 public Principal getUserPrincipal() {
53 if (_userPrincipal != null) {
54 return _userPrincipal;
55 }
56 else {
57 return super.getUserPrincipal();
58 }
59 }
60
61 private String _remoteUser;
62 private Principal _userPrincipal;
63
64 }