Wiki source code of Project WONDER-Frameworks-EROpenID
Version 9.1 by simon on 2009/10/20 16:05
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | Sample delegate for talking to Google Apps via Google's openID deferated login. Note Google does not support SRegRequest. | ||
2 | |||
3 | public class GoogleAppsDelegate extends EROpenIDManager.DefaultDelegate { | ||
4 | |||
5 | @Override | ||
6 | public List<MessageExtension> createFetchMessageExtensions(String userSuppliedString, WORequest request, | ||
7 | WOContext context) throws MessageException { | ||
8 | ArrayList<MessageExtension> exts = new ArrayList<MessageExtension>(); | ||
9 | FetchRequest fetchRequest = FetchRequest.createFetchRequest(); | ||
10 | fetchRequest.addAttribute("Email", "http:~/~/axschema.org/contact/email", true); | ||
11 | exts.add(fetchRequest); | ||
12 | return exts; | ||
13 | } | ||
14 | |||
15 | } | ||
16 | |||
17 | You'll also need to patch wonder (unless it's been committed) to get Google to remember approved sites. | ||
18 | |||
19 | http:~/~/issues.objectstyle.org/jira/browse/WONDER-374?page=all | ||
20 | |||
21 | Then override appendToResponse your standard login page with something like this: | ||
22 | |||
23 | public void appendToResponse(WOResponse r, WOContext c) { | ||
24 | ~/~/ Assume client and realm exists. | ||
25 | if (client.doesOpenID()) { | ||
26 | String url = ((ERXWOContext) c).directActionURLForActionNamed(ERODirectAction.class.getName() | ||
27 | __ "/openIDRequest?" + "identity=" + client.openIdIdentity() + "&realm=" | ||
28 | __ realm, null); | ||
29 | r.setHeader(url, "location"); | ||
30 | r.setStatus(302); | ||
31 | } else { | ||
32 | super.appendToResponse(r, c); | ||
33 | } | ||
34 | } | ||
35 | |||
36 | Notes: the realm needs to be something static and explicit to your app. We use this: | ||
37 | |||
38 | WOApplication.application().webserverConnectURL().replaceFirst("http", "https") |