View Javadoc

1   /*
2    * $Id: PrincipalProxy.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.interceptor;
23  
24  import java.security.Principal;
25  
26  import javax.servlet.http.HttpServletRequest;
27  
28  /***
29   * Proxy interface used together with PrincipalAware interface. It allows indirect
30   * access to HttpServletRequest or PortletRequest Principal related methods.
31   */
32  public interface PrincipalProxy {
33  
34      /***
35       * True if the user is in the given role
36       *
37       * @param role The role
38       * @return True if the user is in that role
39       */
40      boolean isUserInRole(String role);
41  
42      /***
43       * Gets the user principal
44       *
45       * @return The principal
46       */
47      Principal getUserPrincipal();
48  
49      /***
50       * Gets the user id
51       *
52       * @return The user id
53       */
54      String getRemoteUser();
55  
56      /***
57       * Is the request using https?
58       *
59       * @return True if using https
60       */
61      boolean isRequestSecure();
62  
63      /***
64       * Gets the request.
65       *
66       * @return The request
67       * @deprecated To obtain the HttpServletRequest in your action, use
68       *             {@link org.apache.struts2.servlet.ServletRequestAware}, since this method will be dropped in future.
69       */
70      HttpServletRequest getRequest();
71  }