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 public static String decodeURL(String url, boolean unescapeSpaces) {
070 return getHttp().decodeURL(url, unescapeSpaces);
071 }
072
073 public static String encodeParameters(String url) {
074 return getHttp().encodeParameters(url);
075 }
076
077 public static String encodePath(String path) {
078 return getHttp().encodePath(path);
079 }
080
081 public static String encodeURL(String url) {
082 return getHttp().encodeURL(url);
083 }
084
085 public static String encodeURL(String url, boolean escapeSpaces) {
086 return getHttp().encodeURL(url, escapeSpaces);
087 }
088
089 public static String fixPath(String path) {
090 return getHttp().fixPath(path);
091 }
092
093 public static String fixPath(
094 String path, boolean leading, boolean trailing) {
095
096 return getHttp().fixPath(path, leading, trailing);
097 }
098
099 public static String getCompleteURL(HttpServletRequest request) {
100 return getHttp().getCompleteURL(request);
101 }
102
103 public static Cookie[] getCookies() {
104 return getHttp().getCookies();
105 }
106
107 public static String getDomain(String url) {
108 return getHttp().getDomain(url);
109 }
110
111 public static Http getHttp() {
112 PortalRuntimePermission.checkGetBeanProperty(HttpUtil.class);
113
114 return _http;
115 }
116
117 public static String getIpAddress(String url) {
118 return getHttp().getIpAddress(url);
119 }
120
121 public static String getParameter(String url, String name) {
122 return getHttp().getParameter(url, name);
123 }
124
125 public static String getParameter(
126 String url, String name, boolean escaped) {
127
128 return getHttp().getParameter(url, name, escaped);
129 }
130
131 public static Map<String, String[]> getParameterMap(String queryString) {
132 return getHttp().getParameterMap(queryString);
133 }
134
135 public static String getPath(String url) {
136 return getHttp().getPath(url);
137 }
138
139 public static String getProtocol(ActionRequest actionRequest) {
140 return getHttp().getProtocol(actionRequest);
141 }
142
143 public static String getProtocol(boolean secure) {
144 return getHttp().getProtocol(secure);
145 }
146
147 public static String getProtocol(HttpServletRequest request) {
148 return getHttp().getProtocol(request);
149 }
150
151 public static String getProtocol(RenderRequest renderRequest) {
152 return getHttp().getProtocol(renderRequest);
153 }
154
155 public static String getProtocol(String url) {
156 return getHttp().getProtocol(url);
157 }
158
159 public static String getQueryString(String url) {
160 return getHttp().getQueryString(url);
161 }
162
163 public static String getRequestURL(HttpServletRequest request) {
164 return getHttp().getRequestURL(request);
165 }
166
167 public static boolean hasDomain(String url) {
168 return getHttp().hasDomain(url);
169 }
170
171 public static boolean hasProtocol(String url) {
172 return getHttp().hasProtocol(url);
173 }
174
175 public static boolean hasProxyConfig() {
176 return getHttp().hasProxyConfig();
177 }
178
179 public static boolean isNonProxyHost(String host) {
180 return getHttp().isNonProxyHost(host);
181 }
182
183 public static boolean isProxyHost(String host) {
184 return getHttp().isProxyHost(host);
185 }
186
187 public static boolean isSecure(String url) {
188 return getHttp().isSecure(url);
189 }
190
191 public static Map<String, String[]> parameterMapFromString(
192 String queryString) {
193
194 return getHttp().parameterMapFromString(queryString);
195 }
196
197 public static String parameterMapToString(
198 Map<String, String[]> parameterMap) {
199
200 return getHttp().parameterMapToString(parameterMap);
201 }
202
203 public static String parameterMapToString(
204 Map<String, String[]> parameterMap, boolean addQuestion) {
205
206 return getHttp().parameterMapToString(parameterMap, addQuestion);
207 }
208
209 public static String protocolize(String url, ActionRequest actionRequest) {
210 return getHttp().protocolize(url, actionRequest);
211 }
212
213 public static String protocolize(String url, boolean secure) {
214 return getHttp().protocolize(url, secure);
215 }
216
217 public static String protocolize(String url, HttpServletRequest request) {
218 return getHttp().protocolize(url, request);
219 }
220
221 public static String protocolize(String url, RenderRequest renderRequest) {
222 return getHttp().protocolize(url, renderRequest);
223 }
224
225 public static String removeDomain(String url) {
226 return getHttp().removeDomain(url);
227 }
228
229 public static String removeParameter(String url, String name) {
230 return getHttp().removeParameter(url, name);
231 }
232
233 public static String removeProtocol(String url) {
234 return getHttp().removeProtocol(url);
235 }
236
237 public static String sanitizeHeader(String header) {
238 return getHttp().sanitizeHeader(header);
239 }
240
241 public static String setParameter(String url, String name, boolean value) {
242 return getHttp().setParameter(url, name, value);
243 }
244
245 public static String setParameter(String url, String name, double value) {
246 return getHttp().setParameter(url, name, value);
247 }
248
249 public static String setParameter(String url, String name, int value) {
250 return getHttp().setParameter(url, name, value);
251 }
252
253 public static String setParameter(String url, String name, long value) {
254 return getHttp().setParameter(url, name, value);
255 }
256
257 public static String setParameter(String url, String name, short value) {
258 return getHttp().setParameter(url, name, value);
259 }
260
261 public static String setParameter(String url, String name, String value) {
262 return getHttp().setParameter(url, name, value);
263 }
264
265 public static byte[] URLtoByteArray(Http.Options options)
266 throws IOException {
267
268 PortalSocketPermission.checkConnect(options);
269
270 return getHttp().URLtoByteArray(options);
271 }
272
273 public static byte[] URLtoByteArray(String location) throws IOException {
274 PortalSocketPermission.checkConnect(location);
275
276 return getHttp().URLtoByteArray(location);
277 }
278
279 public static byte[] URLtoByteArray(String location, boolean post)
280 throws IOException {
281
282 PortalSocketPermission.checkConnect(location);
283
284 return getHttp().URLtoByteArray(location, post);
285 }
286
287 public static String URLtoString(Http.Options options) throws IOException {
288 PortalSocketPermission.checkConnect(options);
289
290 return getHttp().URLtoString(options);
291 }
292
293 public static String URLtoString(String location) throws IOException {
294 PortalSocketPermission.checkConnect(location);
295
296 return getHttp().URLtoString(location);
297 }
298
299 public static String URLtoString(String location, boolean post)
300 throws IOException {
301
302 PortalSocketPermission.checkConnect(location);
303
304 return getHttp().URLtoString(location, post);
305 }
306
307
318 public static String URLtoString(URL url) throws IOException {
319 PortalSocketPermission.checkConnect(url);
320
321 return getHttp().URLtoString(url);
322 }
323
324 public void setHttp(Http http) {
325 PortalRuntimePermission.checkSetBeanProperty(getClass());
326
327 _http = http;
328 }
329
330 private static Http _http;
331
332 }