Home » struts-2.1.8.1-src » org.apache » struts2 » portlet » interceptor » [javadoc | source]

    1   /*
    2    * $Id: PortletPrincipalProxy.java 651946 2008-04-27 13:41:38Z apetrelli $
    3    *
    4    * Licensed to the Apache Software Foundation (ASF) under one
    5    * or more contributor license agreements.  See the NOTICE file
    6    * distributed with this work for additional information
    7    * regarding copyright ownership.  The ASF licenses this file
    8    * to you under the Apache License, Version 2.0 (the
    9    * "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   
   22   package org.apache.struts2.portlet.interceptor;
   23   
   24   import org.apache.struts2.interceptor.PrincipalProxy;
   25   
   26   import javax.portlet.PortletRequest;
   27   import javax.servlet.http.HttpServletRequest;
   28   import java.security.Principal;
   29   
   30   /**
   31    * PrincipalProxy implementation for using PortletRequest Principal related methods.
   32    */
   33   public class PortletPrincipalProxy implements PrincipalProxy {
   34   
   35       private PortletRequest request;
   36   
   37       /**
   38        * Constructs a proxy
   39        *
   40        * @param request The underlying request
   41        */
   42       public PortletPrincipalProxy(PortletRequest request) {
   43           this.request = request;
   44       }
   45   
   46       /**
   47        * True if the user is in the given role
   48        *
   49        * @param role The role
   50        * @return True if the user is in that role
   51        */
   52       public boolean isUserInRole(String role) {
   53           return request.isUserInRole(role);
   54       }
   55   
   56       /**
   57        * Gets the user principal
   58        *
   59        * @return The principal
   60        */
   61       public Principal getUserPrincipal() {
   62           return request.getUserPrincipal();
   63       }
   64   
   65       /**
   66        * Gets the user id
   67        *
   68        * @return The user id
   69        */
   70       public String getRemoteUser() {
   71           return request.getRemoteUser();
   72       }
   73   
   74       /**
   75        * Is the request using https?
   76        *
   77        * @return True if using https
   78        */
   79       public boolean isRequestSecure() {
   80           return request.isSecure();
   81       }
   82   
   83       /**
   84        * Gets the request.
   85        *
   86        * @return The request
   87        * @throws UnsupportedOperationException not supported in this implementation.
   88        * @deprecated To obtain the HttpServletRequest in your action, use
   89        *             {@link org.apache.struts2.servlet.ServletRequestAware}, since this method will be dropped in future.
   90        */
   91       public HttpServletRequest getRequest() {
   92           throw new UnsupportedOperationException("Usage of getRequest() method is deprecadet and not supported for this implementation");
   93       }
   94   }

Home » struts-2.1.8.1-src » org.apache » struts2 » portlet » interceptor » [javadoc | source]