tempUser.setOpenIDDiscoveryInformationMemento(memento);
tempUser.setSessionToken(sessionToken);
userDao.saveOrUpdate(tempUser);
// Build the AuthRequest message to be sent to the OpenID provider
AuthRequest authReq = manager.authenticate(discovered, returnToUrl);
// Build the FetchRequest containing the information to be copied
// from the OpenID provider
FetchRequest fetch = FetchRequest.createFetchRequest();
// Attempt to decode each entry
if (identifier.startsWith(GOOGLE_ENDPOINT)) {
fetch.addAttribute("email", "http://axschema.org/contact/email", true);
fetch.addAttribute("firstName", "http://axschema.org/namePerson/first", true);
fetch.addAttribute("lastName", "http://axschema.org/namePerson/last", true);
} else if (identifier.startsWith(YAHOO_ENDPOINT)) {
fetch.addAttribute("email", "http://axschema.org/contact/email", true);
fetch.addAttribute("fullname", "http://axschema.org/namePerson", true);
} else { // works for myOpenID
fetch.addAttribute("fullname", "http://schema.openid.net/namePerson", true);
fetch.addAttribute("email", "http://schema.openid.net/contact/email", true);
}
// Attach the extension to the authentication request
authReq.addExtension(fetch);
// Redirect the user to their OpenId server authentication process
return Response
.seeOther(URI.create(authReq.getDestinationUrl(true)))
.build();
} catch (MessageException e1) {
log.error("MessageException:", e1);
} catch (DiscoveryException e1) {