Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
HttpUtil |
|
| 3.6666666666666665;3.667 |
1 | /** | |
2 | * Copyright 2011 The Kuali Foundation Licensed under the | |
3 | * Educational Community License, Version 2.0 (the "License"); you may | |
4 | * not use this file except in compliance with the License. You may | |
5 | * obtain a copy of the License at | |
6 | * | |
7 | * http://www.osedu.org/licenses/ECL-2.0 | |
8 | * | |
9 | * Unless required by applicable law or agreed to in writing, | |
10 | * software distributed under the License is distributed on an "AS IS" | |
11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | |
12 | * or implied. See the License for the specific language governing | |
13 | * permissions and limitations under the License. | |
14 | */ | |
15 | package org.kuali.mobility.util; | |
16 | ||
17 | import java.io.BufferedReader; | |
18 | import java.io.InputStreamReader; | |
19 | import java.net.URL; | |
20 | ||
21 | 0 | public class HttpUtil { |
22 | ||
23 | 0 | private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(HttpUtil.class); |
24 | ||
25 | public static String stringFromUrl(String url) { | |
26 | 0 | String response = ""; |
27 | ||
28 | 0 | BufferedReader in = null; |
29 | try { | |
30 | 0 | URL feed = new URL(url); |
31 | 0 | in = new BufferedReader(new InputStreamReader(feed.openStream())); |
32 | ||
33 | String inputLine; | |
34 | 0 | while ((inputLine = in.readLine()) != null) { |
35 | 0 | response += inputLine; |
36 | } | |
37 | 0 | } catch (Exception e) { |
38 | 0 | LOG.error(e.getMessage(), e); |
39 | } finally { | |
40 | 0 | try { |
41 | 0 | in.close(); |
42 | 0 | } catch (Exception e) {} |
43 | 0 | } |
44 | ||
45 | 0 | return response; |
46 | } | |
47 | ||
48 | public static boolean needsAuthenticated(String path) { | |
49 | 0 | if (path.startsWith("/oauth") |
50 | || path.startsWith("/backdoor") | |
51 | || path.startsWith("/admin") | |
52 | || path.startsWith("/publishing")) { | |
53 | 0 | return true; |
54 | } | |
55 | 0 | return false; |
56 | } | |
57 | ||
58 | public static boolean backdoorRestricted(String path) { | |
59 | ||
60 | 0 | return false; |
61 | } | |
62 | ||
63 | } |