1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
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  }