Return-Path: Delivered-To: apmail-wicket-users-archive@minotaur.apache.org Received: (qmail 8520 invoked from network); 26 Mar 2010 12:43:43 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 26 Mar 2010 12:43:43 -0000 Received: (qmail 76026 invoked by uid 500); 26 Mar 2010 12:43:42 -0000 Delivered-To: apmail-wicket-users-archive@wicket.apache.org Received: (qmail 76006 invoked by uid 500); 26 Mar 2010 12:43:42 -0000 Mailing-List: contact users-help@wicket.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@wicket.apache.org Delivered-To: mailing list users@wicket.apache.org Received: (qmail 75998 invoked by uid 99); 26 Mar 2010 12:43:42 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Mar 2010 12:43:42 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of mail.kaffeeserver@googlemail.com designates 209.85.218.166 as permitted sender) Received: from [209.85.218.166] (HELO mail-bw0-f166.google.com) (209.85.218.166) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Mar 2010 12:43:35 +0000 Received: by bwz6 with SMTP id 6so1072528bwz.12 for ; Fri, 26 Mar 2010 05:43:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:content-type :date:message-id:mime-version:x-mailer:content-transfer-encoding; bh=WxE+6gRrMe8UjtsRvE8R+FGANfj8/J8kuz/9alpDwaI=; b=hvXCVVTl2iDrJqDqvthbdi4s+O/C63OzNwzladG4ORpllizgyItuPgEhLr05pIAXy8 zyqd5ii490lRBRzXAk3iF3/XzYz8u4gOxnhMjFBGH3XAwCcz+6+MpSCf26ZxcdVflSg8 xcy47GLkzRPciYygTOLD5OvC+9WMDVOIhrI4g= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=subject:from:to:content-type:date:message-id:mime-version:x-mailer :content-transfer-encoding; b=v32a4kQd2/WpXfuOd8vGbHD0T8+L5FSoQ3agSvEaoUZbnq2itpgkflh8IZ2Yqnvsng +sG5eJy+HunIqGhJoPMDR1TyXyBWXarXExwSSHvwZFXKY9H/vaJksXaLt1jrJnTpHFql xLcEnfgcRfWSuuUIWgQCORyYcvCIB8EBZ5STU= Received: by 10.204.174.205 with SMTP id u13mr968564bkz.169.1269607394169; Fri, 26 Mar 2010 05:43:14 -0700 (PDT) Received: from [192.168.178.25] (p57BC0C22.dip0.t-ipconnect.de [87.188.12.34]) by mx.google.com with ESMTPS id 13sm490608bwz.15.2010.03.26.05.43.03 (version=SSLv3 cipher=RC4-MD5); Fri, 26 Mar 2010 05:43:13 -0700 (PDT) Subject: Wicket on GAE with Facebook Connect - doesnt work after deploying / HTTP 500 error From: christoph glass To: users@wicket.apache.org Content-Type: text/plain; charset="UTF-8" Date: Fri, 26 Mar 2010 13:43:02 +0100 Message-ID: <1269607382.11633.11.camel@kaffeeserver> Mime-Version: 1.0 X-Mailer: Evolution 2.28.1 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Hi everyone, I'm trying to run a simple Wicket Application with Facebook Connect on Google App Engine. So far it runs local, but when I deploy to Google Facebook Connect wont work. I cant find any examples for using wicket with gae and facebook on the web. Is anyone here who successfully made it? Here is the output from ajax debug window: --- INFO: Using XMLHttpRequest transport INFO: INFO: Initiating Ajax GET request on ?wicket:interface=wicket-9:36:fbconnectpanel::IActivePageBehaviorListener:0:&wicket:ignoreIfNotActive=true&random=0.6834228196057528 INFO: Invoking pre-call handler(s)... ERROR: Received Ajax response with code: 500 ERROR: 500 error had text: 500 Server Error

Error: Server Error

The server encountered an error and could not complete your request.

If the problem persists, please report your problem and mention this error message and the query that caused it.

INFO: Invoking post-call handler(s)... INFO: Invoking failure handler(s)... --- FacebookConnectPanel.java -> took the most from http://cwiki.apache.org/WICKET/adding-facebook-connect.html --- package polizeiwache.sites.auth.facebookconnect; import java.io.IOException; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.wicket.Page; import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.behavior.SimpleAttributeModifier; import org.apache.wicket.markup.html.WebMarkupContainer; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.panel.Panel; import org.apache.wicket.protocol.http.WebResponse; import org.apache.wicket.protocol.http.servlet.ServletWebRequest; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.GrantedAuthorityImpl; import org.springframework.security.core.context.SecurityContext; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.context.SecurityContextImpl; import pojos.FacebookUser; //import com.facebook.api.FacebookException; //import com.facebook.api.FacebookJsonRestClient; //import com.facebook.api.FacebookWebappHelper; //import com.facebook.api.ProfileField; import com.google.code.facebookapi.FacebookException; import com.google.code.facebookapi.FacebookJsonRestClient; import com.google.code.facebookapi.FacebookWebappHelper; import com.google.code.facebookapi.ProfileField; //import com.google.appengine.repackaged.org.apache.commons.logging.impl.LogFactoryImpl; /** * @see http://cwiki.apache.org/WICKET/adding-facebook-connect.html * @author christoph * */ @SuppressWarnings("deprecation") public class FacebookConnectPanel extends Panel { /** * */ private static final long serialVersionUID = -5912681574741410118L; //private static final com.google.appengine.repackaged.org.apache.commons.logging.Log log = LogFactoryImpl.getLog(FacebookConnectPanel.class); private WebMarkupContainer fbloginDiv; private Label fblogin; /** * * @param id */ public FacebookConnectPanel(String id) { super(id); } /** * This method will the panel */ public void createPanel() { fbloginDiv = new WebMarkupContainer("fbloginDiv"); fbloginDiv.setOutputMarkupId(true).setMarkupId("fbloginDiv"); fblogin = new Label("fblogin", ""); fblogin.setEscapeModelStrings(false); fblogin.setOutputMarkupId(true); if (isAuthenticated()) { fbloginDiv.add(new SimpleAttributeModifier("style", "display:none;")); } fbloginDiv.add(fblogin); addOrReplace(fbloginDiv); /** * This will only be called after they're logged in via facebook */ final AbstractDefaultAjaxBehavior behave = new AbstractDefaultAjaxBehavior() { /** * */ private static final long serialVersionUID = -486358491644699655L; protected void respond(final AjaxRequestTarget target) { // deal with facebook try { handleFacebookCallback(target.getPage()); } catch (IOException e) { e.printStackTrace(); } fbloginDiv.add(new SimpleAttributeModifier("style", "display:none;")); target.addComponent(fbloginDiv); } }; add(behave); CharSequence url = behave.getCallbackUrl(); StringBuffer sb = new StringBuffer(); sb.append("function callWicket() { \n"); sb.append(" var wcall = wicketAjaxGet('"); sb.append(url); sb.append("', function() { }, function() { });"); sb.append(" }"); Label fbcallback = new Label("fbcallback", sb.toString()); fbcallback.setOutputMarkupId(true); fbcallback.setEscapeModelStrings(false); add(fbcallback); } /** * All that we do to log you in from facebook. I put my fbook.key and fbook.secret in the * properties file. * @param thePage * @throws IOException */ public void handleFacebookCallback(Page thePage) throws IOException { HttpServletRequest req = ((ServletWebRequest) thePage.getRequest()).getHttpServletRequest(); HttpServletResponse res = ((WebResponse) thePage.getResponse()).getHttpServletResponse(); String api = getLocalizer().getString("fbook.key", this); String secret = getLocalizer().getString("fbook.secret", this); FacebookWebappHelper helper = FacebookWebappHelper.newInstanceJson(req, res, api, secret); // make sure the login worked if (helper.isLogin()) { FacebookJsonRestClient facebookClient = (FacebookJsonRestClient) helper.getFacebookRestClient(); long id; try { // grab the logged in user's id id = facebookClient.users_getLoggedInUser(); // you can bundle ajax calls... facebookClient.beginBatch(); // i'm going to call the users.getInfo fb api call, just to make sure it works ArrayList ids = new ArrayList(); ids.add(new Long(id)); // put together a set of fields for fb to return HashSet fields = new HashSet(); fields.add(ProfileField.FIRST_NAME); fields.add(ProfileField.LAST_NAME); // get the user data facebookClient.users_getInfo(ids, fields); // execute the batch (which also terminates batch mode until beginBatch is called again) List batchResponse = facebookClient.executeBatch(false); JSONArray userInfo = (JSONArray) batchResponse.get(0); JSONObject user = userInfo.getJSONObject(0); // a pojo user object // User theUser = new User(); FacebookUser theUser = new FacebookUser(); String username = user.getString("facebookVorname"); theUser.setVorname(username); // fb emails are proxy, my app needs some kind of holder theUser.setEmail("noreply@facebook.com"); theUser.setUserId(new Integer(0)); theUser.setFacebook(true); theUser.setFacebookId(id); // we use spring, so here we give basic access to the facebook user. List gaList = new ArrayList(); gaList.add(new GrantedAuthorityImpl("STANDARD")); theUser.setAuthorities(gaList.toArray(new GrantedAuthority[] {})); GrantedAuthority[] ga = theUser.getAuthorities(); UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(theUser, theUser, ga); SecurityContext context = new SecurityContextImpl(); context.setAuthentication(authentication); SecurityContextHolder.setContext(context); } catch (FacebookException e) { //log.error("facebook issues: " + e); } catch (JSONException e) { //log.error("facebook json issues: " + e); } } } /** * Do your own kind of auth check * @return */ public boolean isAuthenticated() { return SecurityContextHolder.getContext().getAuthentication() != null; } } --- FacebookConnectPanel.html ---
--- Any help would be most welcome. Thanks and best regards Christoph --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org For additional commands, e-mail: users-help@wicket.apache.org