| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 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 | |
} |