1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.opensaml.ws.transport.http;
18
19 import java.io.IOException;
20 import java.io.OutputStream;
21 import java.util.List;
22
23 import javax.servlet.http.HttpServletResponse;
24
25 import org.opensaml.xml.security.credential.Credential;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
28
29
30
31
32 public class HttpServletResponseAdapter implements HTTPOutTransport {
33
34
35 private HttpServletResponse httpServletResponse;
36
37
38 private final Logger log = LoggerFactory.getLogger(HttpServletResponseAdapter.class);
39
40
41 private boolean peerAuthenticated;
42
43
44 private boolean secure;
45
46
47
48
49
50
51
52 public HttpServletResponseAdapter(HttpServletResponse response, boolean isSecure) {
53 httpServletResponse = response;
54 secure = isSecure;
55 }
56
57
58
59
60
61
62 public Object getAttribute(String name) {
63 return null;
64 }
65
66
67 public String getCharacterEncoding() {
68 return httpServletResponse.getCharacterEncoding();
69 }
70
71
72
73
74
75
76
77 public String getHeaderValue(String name) {
78 return null;
79 }
80
81
82
83
84
85
86 public String getHTTPMethod() {
87 return null;
88 }
89
90
91 public Credential getLocalCredential() {
92
93 return null;
94 }
95
96
97 public OutputStream getOutgoingStream() {
98 try {
99 return httpServletResponse.getOutputStream();
100 } catch (IOException e) {
101 log.error("Unable to recover input stream from adapted HttpServletResponse", e);
102 return null;
103 }
104 }
105
106
107
108
109
110
111 public String getParameterValue(String name) {
112 return null;
113 }
114
115
116 public List<String> getParameterValues(String name) {
117 return null;
118 }
119
120
121 public Credential getPeerCredential() {
122 return null;
123 }
124
125
126
127
128
129
130 public int getStatusCode() {
131 return -1;
132 }
133
134
135
136
137
138
139 public HTTP_VERSION getVersion() {
140 return null;
141 }
142
143
144
145
146
147
148 public HttpServletResponse getWrappedResponse() {
149 return httpServletResponse;
150 }
151
152
153 public boolean isAuthenticated() {
154 return peerAuthenticated;
155 }
156
157
158
159
160
161
162 public boolean isConfidential() {
163 return secure;
164 }
165
166
167 public void sendRedirect(String location) {
168 try {
169 httpServletResponse.sendRedirect(location);
170 } catch (IOException e) {
171 log.error("Unable to send redirect message", e);
172 }
173 }
174
175
176
177
178
179
180 public void setAttribute(String name, Object value) {
181 }
182
183
184
185
186 public void setAuthenticated(boolean isAuthenticated) {
187 peerAuthenticated = isAuthenticated;
188 }
189
190
191 public void setCharacterEncoding(String encoding) {
192 httpServletResponse.setCharacterEncoding(encoding);
193 }
194
195
196
197
198
199
200 public void setConfidential(boolean isConfidential) {
201 }
202
203
204 public void setHeader(String name, String value) {
205 if (name == null) {
206 return;
207 }
208
209
210 if (name.equalsIgnoreCase("Content-Type")) {
211 httpServletResponse.setContentType(value);
212 } else if (name.equalsIgnoreCase("Content-Length")) {
213 httpServletResponse.setContentLength(Integer.parseInt(value));
214 }
215
216 httpServletResponse.setHeader(name, value);
217 }
218
219
220
221
222
223
224 public void addParameter(String name, String value) {
225 }
226
227
228 public void setStatusCode(int code) {
229 httpServletResponse.setStatus(code);
230 }
231
232
233
234
235
236
237 public void setVersion(HTTP_VERSION version) {
238 }
239
240
241 public boolean isIntegrityProtected() {
242 return secure;
243 }
244
245
246 public void setIntegrityProtected(boolean isIntegrityProtected) {
247
248 }
249 }