*/
@Action(value = "/socialAuth")
public String execute() throws Exception {
LOG.info("Given provider id :: " + id);
SocialAuthManager manager;
if (userSession.get("socialAuthManager") != null) {
manager = (SocialAuthManager) userSession.get("socialAuthManager");
if ("signout".equals(mode)) {
manager.disconnectProvider(id);
return "home";
}
} else {
InputStream in = SocialAuthenticationAction.class.getClassLoader()
.getResourceAsStream("oauth_consumer.properties");
SocialAuthConfig conf = SocialAuthConfig.getDefault();
conf.load(in);
manager = new SocialAuthManager();
manager.setSocialAuthConfig(conf);
userSession.put("socialAuthManager", manager);
}
String returnToUrl = RequestUtils.getServletPath(request);
System.out.println(returnToUrl);
// returnToUrl =
// "http://opensource.brickred.com/socialauth-struts-demo/socialAuthSuccessAction.do";
returnToUrl = UrlHelper.buildUrl("socialAuthSuccessAction.do", request,
response, null, null, true, true, true);
url = manager.getAuthenticationUrl(id, returnToUrl);
LOG.info("Redirecting to: " + url);
if (url != null) {
return "redirect";
}
return "failure";