/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. package com.google.ie.common.openid;
  16. import com.google.inject.Inject;
  17. import com.google.step2.discovery.UrlHostMetaFetcher;
  18. import com.google.step2.http.HttpFetcher;
  19. import java.net.URI;
  20. import java.net.URISyntaxException;
  21. /**
  22. * Fetches host-meta files from a Google-hosted location.
  23. */
  24. public class GoogleHostedHostMetaFetcher extends UrlHostMetaFetcher {
  25. private static final String SOURCE_PARAM = "step2.hostmeta.google.source";
  26. private static final String DEFAULT_SOURCE = "https://www.google.com";
  27. private static final String HOST_META_PATH = "/accounts/o8/.well-known/host-meta";
  28. private static final String DOMAIN_PARAM = "hd";
  29. @Inject
  30. public GoogleHostedHostMetaFetcher(HttpFetcher fetcher) {
  31. super(fetcher);
  32. }
  33. @Override
  34. protected URI getHostMetaUriForHost(String host) throws URISyntaxException {
  35. String source = System.getProperty(SOURCE_PARAM, DEFAULT_SOURCE);
  36. String uri = source + HOST_META_PATH + "?" + DOMAIN_PARAM + "=" + host;
  37. return new URI(uri);
  38. }
  39. }