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.subject;
20
21 import org.apache.shiro.subject.SubjectContext;
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 SubjectContext} that additionally provides for type-safe
29 * methods to set and retrieve a {@link ServletRequest} and {@link ServletResponse}.
30 *
31 * @since 1.0
32 */
33 public interface WebSubjectContext extends SubjectContext, RequestPairSource {
34
35 /**
36 * Returns the {@code ServletRequest} received by the servlet container triggering the creation of the
37 * {@code Subject} instance.
38 *
39 * @return the {@code ServletRequest} received by the servlet container triggering the creation of the
40 * {@code Subject} instance.
41 */
42 ServletRequest getServletRequest();
43
44 /**
45 * Sets the {@code ServletRequest} received by the servlet container triggering the creation of the
46 * {@code Subject} instance.
47 *
48 * @param request the {@code ServletRequest} received by the servlet container triggering the creation of the
49 * {@code Subject} instance.
50 */
51 void setServletRequest(ServletRequest request);
52
53 ServletRequest resolveServletRequest();
54
55 /**
56 * The paired {@code ServletResponse} corresponding to the associated {@link #getServletRequest servletRequest}.
57 *
58 * @return the paired {@code ServletResponse} corresponding to the associated
59 * {@link #getServletRequest servletRequest}.
60 */
61 ServletResponse getServletResponse();
62
63 /**
64 * Sets the paired {@code ServletResponse} corresponding to the associated {@link #getServletRequest servletRequest}.
65 *
66 * @param response The paired {@code ServletResponse} corresponding to the associated
67 * {@link #getServletRequest servletRequest}.
68 */
69 void setServletResponse(ServletResponse response);
70
71 ServletResponse resolveServletResponse();
72 }