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