Posted By:
me4tatel_me4tatel
Posted On:
Friday, December 12, 2008 02:32 PM
Hi, I'm using Eclipse 3.4.0 ganymede with JSF 1.2, Dynamic Web Module 2.5 and Facelets and RichFaces 3.2.2, Tomcat 6.0. I'm developing a Facebook app. Iôm implementing the Authentication layer in custom filter: public class FaceBookAuthFilter implements Filter { private String _apiKey; private String _secretKey; public void init(final FilterConfig filterConfig){ _apiKey = filterConfig.getInitParameter("api_key"); _secretKey = filterConfig.getInitParameter("secret_key"); } /** * Verifies whether user is logged in. If not, sends user to the login page. */ public void doFilter(final ServletRequest
More>>
Hi,
I'm using Eclipse 3.4.0 ganymede with JSF 1.2, Dynamic Web Module 2.5 and Facelets and RichFaces 3.2.2, Tomcat 6.0.
I'm developing a Facebook app. Iôm implementing the Authentication layer in custom filter:
public class FaceBookAuthFilter implements Filter {
private String _apiKey;
private String _secretKey;
public void init(final FilterConfig filterConfig){
_apiKey = filterConfig.getInitParameter("api_key");
_secretKey = filterConfig.getInitParameter("secret_key");
}
/**
* Verifies whether user is logged in. If not, sends user to the login page.
*/
public void doFilter(final ServletRequest request, final ServletResponse response, FilterChain chai
n) throws IOException, ServletException {
HttpServletRequest httpReq = (HttpServletRequest) request;
HttpServletResponse httpRes = (HttpServletResponse) response;
try {
FacebookXmlRestClient authClient = FaceBookAuthHandler.getAuthenticatedClient(httpReq, _apiKey, _
secretKey);
request.setAttribute("auth.client", authClient);
chain.doFilter(request, response);
} catch (FailedLoginException fle) {
//user not logged in
forceLogin(httpRes);
} catch (Exception e) {
//handle exception
System.out.println(e.toString());
}
}
/**
* Sends user to login page
* @param response
*/
private void forceLogin(HttpServletResponse response) {
try {
response.sendRedirect ("http://www.facebook.com/login.php?api_key=" + _apiKey + "&v=1.0");
} catch (IOException ioe) {
//handle exception
}
}
public void destroy() {
}
}
This is what I have in web.xml
<?xml version="1.0" encoding="UTF-8"?>
AskAvila
javax.faces.DEFAULT_SUFFIX
.xhtml
index.xhtml
index.html
org.richfaces.SKIN
classic
org.ajax4jsf.VIEW_HANDLERS
com.sun.facelets.FaceletViewHandler
Faces Servlet
javax.faces.webapp.FacesServlet
1
Faces Servlet
/faces/*
FaceBookAuthFilter
util.FaceBookAuthFilter
api_key
[the api key]
secret_key
[the secret_key]
FaceBookAuthFilter
/faces/*
RichFaces Filter
richfaces
org.ajax4jsf.Filter
richfaces
Faces Servlet
REQUEST
FORWARD
INCLUDE
Adding the custom filter I receive a blank page, richfaces donôt work propertly. How can I integrate propertly the custom filter, without having conflict with RichFaces filter?