001
014
015 package com.liferay.portal.kernel.servlet;
016
017 import java.security.Principal;
018
019 import javax.servlet.http.HttpServletRequest;
020 import javax.servlet.http.HttpServletRequestWrapper;
021
022
025 public class ProtectedServletRequest extends HttpServletRequestWrapper {
026
027 public ProtectedServletRequest(
028 HttpServletRequest request, String remoteUser) {
029
030 this(request, remoteUser, null);
031 }
032
033 public ProtectedServletRequest(
034 HttpServletRequest request, String remoteUser, String authType) {
035
036 super(request);
037
038 if (request instanceof ProtectedServletRequest) {
039 ProtectedServletRequest parentRequest =
040 (ProtectedServletRequest)request;
041
042 setRequest(parentRequest.getRequest());
043 }
044
045 _remoteUser = remoteUser;
046
047 if (remoteUser != null) {
048 _userPrincipal = new ProtectedPrincipal(remoteUser);
049 }
050
051 _authType = authType;
052 }
053
054 @Override
055 public String getAuthType() {
056 if (_authType == null) {
057 return super.getAuthType();
058 }
059
060 return _authType;
061 }
062
063 @Override
064 public String getRemoteUser() {
065 if (_remoteUser != null) {
066 return _remoteUser;
067 }
068 else {
069 return super.getRemoteUser();
070 }
071 }
072
073 @Override
074 public Principal getUserPrincipal() {
075 if (_userPrincipal != null) {
076 return _userPrincipal;
077 }
078 else {
079 return super.getUserPrincipal();
080 }
081 }
082
083 private String _authType;
084 private String _remoteUser;
085 private Principal _userPrincipal;
086
087 }