Wiki source code of EROpenID Framework

Last modified by Pascal Robert on 2012/07/19 21:11

Show last authors
1 **Using EROpenID with Google Apps Federated login**
2
3 Sample delegate for talking to Google Apps via Google's openID deferated login. Note Google does not support SRegRequest.
4
5 {{code}}
6
7 public class GoogleAppsDelegate extends EROpenIDManager.DefaultDelegate {
8
9 @Override
10 public List<MessageExtension> createFetchMessageExtensions(String userSuppliedString, WORequest request,
11 WOContext context) throws MessageException {
12 ArrayList<MessageExtension> exts = new ArrayList<MessageExtension>();
13 FetchRequest fetchRequest = FetchRequest.createFetchRequest();
14 fetchRequest.addAttribute("Email", "http://axschema.org/contact/email", true);
15 exts.add(fetchRequest);
16 return exts;
17 }
18
19 }
20
21 {{/code}}
22
23 Then override appendToResponse your standard login page with something like this:
24
25 {{code}}
26
27 public void appendToResponse(WOResponse r, WOContext c) {
28 // Assume client and realm exists.
29 if (client.doesOpenID()) {
30 String url = ((ERXWOContext) c).directActionURLForActionNamed(ERODirectAction.class.getName()
31 + "/openIDRequest?" + "identity=" + client.openIdIdentity() + "&realm="
32 + realm, null);
33 r.setHeader(url, "location");
34 r.setStatus(302);
35 } else {
36 super.appendToResponse(r, c);
37 }
38 }
39
40 {{/code}}
41
42 Notes: the realm needs to be something static and explicit to your app. We use this:
43
44 WOApplication.application().webserverConnectURL().replaceFirst("http", "https")
45
46 client.openIDIdentity() should return something like this:
47
48 clientsdomainname.com/openid
49
50 where openid is an XRDS document. comprehensive instructions on setting up the rest is here:
51
52 [[http:~~/~~/jeremiahlee.com/blog/2009/09/28/how-to-setup-openid-with-google-apps/>>url:http://jeremiahlee.com/blog/2009/09/28/how-to-setup-openid-with-google-apps/||shape="rect"]]