1 import java.io.UnsupportedEncodingException;
2 import java.net.URLEncoder;
3
4
5
6 protected URI createLocationURI(final String location) throws ProtocolException {
7 try {
8 String url = URLEncoder.encode(location,"utf-8");
9 final URIBuilder b = new URIBuilder(new URI(url).normalize());
10 //final URIBuilder b = new URIBuilder(new URI(location).normalize());
11 final String host = b.getHost();
12 if (host != null) {
13 b.setHost(host.toLowerCase(Locale.ENGLISH));
14 }
15 final String path = b.getPath();
16 if (TextUtils.isEmpty(path)) {
17 b.setPath("/");
18 }
19 return b.build();
20 } catch (final URISyntaxException ex) {
21 throw new ProtocolException("Invalid redirect URI: " + location, ex);
22 }catch(UnsupportedEncodingException ex){
23 throw new ProtocolException("Invalid redirect URI: " + location, ex);
24 }
25 }