001
014
015 package com.liferay.portal.kernel.util;
016
017 import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
018 import com.liferay.portal.kernel.security.pacl.permission.PortalSocketPermission;
019
020 import java.io.IOException;
021
022 import java.net.URL;
023
024 import java.util.Map;
025
026 import javax.portlet.ActionRequest;
027 import javax.portlet.RenderRequest;
028
029 import javax.servlet.http.Cookie;
030 import javax.servlet.http.HttpServletRequest;
031
032
035 public class HttpUtil {
036
037 public static String addParameter(String url, String name, boolean value) {
038 return getHttp().addParameter(url, name, value);
039 }
040
041 public static String addParameter(String url, String name, double value) {
042 return getHttp().addParameter(url, name, value);
043 }
044
045 public static String addParameter(String url, String name, int value) {
046 return getHttp().addParameter(url, name, value);
047 }
048
049 public static String addParameter(String url, String name, long value) {
050 return getHttp().addParameter(url, name, value);
051 }
052
053 public static String addParameter(String url, String name, short value) {
054 return getHttp().addParameter(url, name, value);
055 }
056
057 public static String addParameter(String url, String name, String value) {
058 return getHttp().addParameter(url, name, value);
059 }
060
061 public static String decodePath(String path) {
062 return getHttp().decodePath(path);
063 }
064
065 public static String decodeURL(String url) {
066 return getHttp().decodeURL(url);
067 }
068
069
072 @Deprecated
073 public static String decodeURL(String url, boolean unescapeSpaces) {
074 return getHttp().decodeURL(url, unescapeSpaces);
075 }
076
077 public static String encodeParameters(String url) {
078 return getHttp().encodeParameters(url);
079 }
080
081 public static String encodePath(String path) {
082 return getHttp().encodePath(path);
083 }
084
085 public static String encodeURL(String url) {
086 return getHttp().encodeURL(url);
087 }
088
089 public static String encodeURL(String url, boolean escapeSpaces) {
090 return getHttp().encodeURL(url, escapeSpaces);
091 }
092
093 public static String fixPath(String path) {
094 return getHttp().fixPath(path);
095 }
096
097 public static String fixPath(
098 String path, boolean leading, boolean trailing) {
099
100 return getHttp().fixPath(path, leading, trailing);
101 }
102
103 public static String getCompleteURL(HttpServletRequest request) {
104 return getHttp().getCompleteURL(request);
105 }
106
107 public static Cookie[] getCookies() {
108 return getHttp().getCookies();
109 }
110
111 public static String getDomain(String url) {
112 return getHttp().getDomain(url);
113 }
114
115 public static Http getHttp() {
116 PortalRuntimePermission.checkGetBeanProperty(HttpUtil.class);
117
118 return _http;
119 }
120
121 public static String getIpAddress(String url) {
122 return getHttp().getIpAddress(url);
123 }
124
125 public static String getParameter(String url, String name) {
126 return getHttp().getParameter(url, name);
127 }
128
129 public static String getParameter(
130 String url, String name, boolean escaped) {
131
132 return getHttp().getParameter(url, name, escaped);
133 }
134
135 public static Map<String, String[]> getParameterMap(String queryString) {
136 return getHttp().getParameterMap(queryString);
137 }
138
139 public static String getPath(String url) {
140 return getHttp().getPath(url);
141 }
142
143 public static String getProtocol(ActionRequest actionRequest) {
144 return getHttp().getProtocol(actionRequest);
145 }
146
147 public static String getProtocol(boolean secure) {
148 return getHttp().getProtocol(secure);
149 }
150
151 public static String getProtocol(HttpServletRequest request) {
152 return getHttp().getProtocol(request);
153 }
154
155 public static String getProtocol(RenderRequest renderRequest) {
156 return getHttp().getProtocol(renderRequest);
157 }
158
159 public static String getProtocol(String url) {
160 return getHttp().getProtocol(url);
161 }
162
163 public static String getQueryString(String url) {
164 return getHttp().getQueryString(url);
165 }
166
167 public static String getRequestURL(HttpServletRequest request) {
168 return getHttp().getRequestURL(request);
169 }
170
171 public static boolean hasDomain(String url) {
172 return getHttp().hasDomain(url);
173 }
174
175 public static boolean hasProtocol(String url) {
176 return getHttp().hasProtocol(url);
177 }
178
179 public static boolean hasProxyConfig() {
180 return getHttp().hasProxyConfig();
181 }
182
183 public static boolean isNonProxyHost(String host) {
184 return getHttp().isNonProxyHost(host);
185 }
186
187 public static boolean isProxyHost(String host) {
188 return getHttp().isProxyHost(host);
189 }
190
191 public static boolean isSecure(String url) {
192 return getHttp().isSecure(url);
193 }
194
195 public static Map<String, String[]> parameterMapFromString(
196 String queryString) {
197
198 return getHttp().parameterMapFromString(queryString);
199 }
200
201 public static String parameterMapToString(
202 Map<String, String[]> parameterMap) {
203
204 return getHttp().parameterMapToString(parameterMap);
205 }
206
207 public static String parameterMapToString(
208 Map<String, String[]> parameterMap, boolean addQuestion) {
209
210 return getHttp().parameterMapToString(parameterMap, addQuestion);
211 }
212
213 public static String protocolize(String url, ActionRequest actionRequest) {
214 return getHttp().protocolize(url, actionRequest);
215 }
216
217 public static String protocolize(String url, boolean secure) {
218 return getHttp().protocolize(url, secure);
219 }
220
221 public static String protocolize(String url, HttpServletRequest request) {
222 return getHttp().protocolize(url, request);
223 }
224
225 public static String protocolize(String url, int port, boolean secure) {
226 return getHttp().protocolize(url, port, secure);
227 }
228
229 public static String protocolize(String url, RenderRequest renderRequest) {
230 return getHttp().protocolize(url, renderRequest);
231 }
232
233 public static String removeDomain(String url) {
234 return getHttp().removeDomain(url);
235 }
236
237 public static String removeParameter(String url, String name) {
238 return getHttp().removeParameter(url, name);
239 }
240
241 public static String removePathParameters(String uri) {
242 return getHttp().removePathParameters(uri);
243 }
244
245 public static String removeProtocol(String url) {
246 return getHttp().removeProtocol(url);
247 }
248
249 public static String sanitizeHeader(String header) {
250 return getHttp().sanitizeHeader(header);
251 }
252
253 public static String setParameter(String url, String name, boolean value) {
254 return getHttp().setParameter(url, name, value);
255 }
256
257 public static String setParameter(String url, String name, double value) {
258 return getHttp().setParameter(url, name, value);
259 }
260
261 public static String setParameter(String url, String name, int value) {
262 return getHttp().setParameter(url, name, value);
263 }
264
265 public static String setParameter(String url, String name, long value) {
266 return getHttp().setParameter(url, name, value);
267 }
268
269 public static String setParameter(String url, String name, short value) {
270 return getHttp().setParameter(url, name, value);
271 }
272
273 public static String setParameter(String url, String name, String value) {
274 return getHttp().setParameter(url, name, value);
275 }
276
277 public static String shortenURL(String url, int count) {
278 return getHttp().shortenURL(url, count);
279 }
280
281 public static byte[] URLtoByteArray(Http.Options options)
282 throws IOException {
283
284 PortalSocketPermission.checkConnect(options);
285
286 return getHttp().URLtoByteArray(options);
287 }
288
289 public static byte[] URLtoByteArray(String location) throws IOException {
290 PortalSocketPermission.checkConnect(location);
291
292 return getHttp().URLtoByteArray(location);
293 }
294
295 public static byte[] URLtoByteArray(String location, boolean post)
296 throws IOException {
297
298 PortalSocketPermission.checkConnect(location);
299
300 return getHttp().URLtoByteArray(location, post);
301 }
302
303 public static String URLtoString(Http.Options options) throws IOException {
304 PortalSocketPermission.checkConnect(options);
305
306 return getHttp().URLtoString(options);
307 }
308
309 public static String URLtoString(String location) throws IOException {
310 PortalSocketPermission.checkConnect(location);
311
312 return getHttp().URLtoString(location);
313 }
314
315 public static String URLtoString(String location, boolean post)
316 throws IOException {
317
318 PortalSocketPermission.checkConnect(location);
319
320 return getHttp().URLtoString(location, post);
321 }
322
323
334 public static String URLtoString(URL url) throws IOException {
335 PortalSocketPermission.checkConnect(url);
336
337 return getHttp().URLtoString(url);
338 }
339
340 public void setHttp(Http http) {
341 PortalRuntimePermission.checkSetBeanProperty(getClass());
342
343 _http = http;
344 }
345
346 private static Http _http;
347
348 }