PageRenderTime 263ms CodeModel.GetById 111ms app.highlight 3ms RepoModel.GetById 147ms app.codeStats 1ms

/src/main/java/com/google/ie/common/openid/GoogleHostedHostMetaFetcher.java

http://thoughtsite.googlecode.com/
Java | 47 lines | 22 code | 8 blank | 17 comment | 0 complexity | ba1db00a3cfee119d99b1646a07422b3 MD5 | raw file
 1/* Copyright 2010 Google Inc.
 2 * 
 3 * Licensed under the Apache License, Version 2.0 (the "License");
 4 * you may not use this file except in compliance with the License.
 5 * You may obtain a copy of the License at
 6 * 
 7 *      http://www.apache.org/licenses/LICENSE-2.0
 8 * 
 9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS.
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License
14 */
15
16package com.google.ie.common.openid;
17
18import com.google.inject.Inject;
19import com.google.step2.discovery.UrlHostMetaFetcher;
20import com.google.step2.http.HttpFetcher;
21
22import java.net.URI;
23import java.net.URISyntaxException;
24
25/**
26 * Fetches host-meta files from a Google-hosted location.
27 */
28public class GoogleHostedHostMetaFetcher extends UrlHostMetaFetcher {
29
30    private static final String SOURCE_PARAM = "step2.hostmeta.google.source";
31    private static final String DEFAULT_SOURCE = "https://www.google.com";
32    private static final String HOST_META_PATH = "/accounts/o8/.well-known/host-meta";
33    private static final String DOMAIN_PARAM = "hd";
34
35    @Inject
36    public GoogleHostedHostMetaFetcher(HttpFetcher fetcher) {
37        super(fetcher);
38    }
39
40    @Override
41    protected URI getHostMetaUriForHost(String host) throws URISyntaxException {
42        String source = System.getProperty(SOURCE_PARAM, DEFAULT_SOURCE);
43        String uri = source + HOST_META_PATH + "?" + DOMAIN_PARAM + "=" + host;
44        return new URI(uri);
45    }
46}
47