View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.shiro.web.session.mgt;
20  
21  import org.apache.shiro.session.mgt.SessionContext;
22  import org.apache.shiro.web.util.RequestPairSource;
23  
24  import javax.servlet.ServletRequest;
25  import javax.servlet.ServletResponse;
26  
27  /**
28   * A {@code WebSubjectContext} is a {@link SessionContext} that additionally provides for type-safe
29   * methods to set and retrieve a {@link ServletRequest} and {@link ServletResponse}, as the request/response pair will
30   * often need to be referenced during construction of web-initiated {@code Session} instances.
31   *
32   * @since 1.0
33   */
34  public interface WebSessionContext extends SessionContext, RequestPairSource {
35  
36      /**
37       * Returns the {@code ServletRequest} received by the servlet container triggering the creation of the
38       * {@code Session} instance.
39       *
40       * @return the {@code ServletRequest} received by the servlet container triggering the creation of the
41       *         {@code Session} instance.
42       */
43      ServletRequest getServletRequest();
44  
45      /**
46       * Sets the {@code ServletRequest} received by the servlet container triggering the creation of the
47       * {@code Session} instance.
48       *
49       * @param request the {@code ServletRequest} received by the servlet container triggering the creation of the
50       *                {@code Session} instance.
51       */
52      void setServletRequest(ServletRequest request);
53  
54      /**
55       * The paired {@code ServletResponse} corresponding to the associated {@link #getServletRequest servletRequest}.
56       *
57       * @return the paired {@code ServletResponse} corresponding to the associated
58       *         {@link #getServletRequest servletRequest}.
59       */
60      ServletResponse getServletResponse();
61  
62      /**
63       * Sets the paired {@code ServletResponse} corresponding to the associated {@link #getServletRequest servletRequest}.
64       *
65       * @param response The paired {@code ServletResponse} corresponding to the associated
66       *                 {@link #getServletRequest servletRequest}.
67       */
68      void setServletResponse(ServletResponse response);
69  }