Skip to content

Instantly share code, notes, and snippets.

@mente
Created September 7, 2011 18:02
Show Gist options
  • Save mente/1201270 to your computer and use it in GitHub Desktop.
Save mente/1201270 to your computer and use it in GitHub Desktop.
Smartfox Filter
public class AuthenticationFilter extends SFSExtensionFilter {
@Override
public void destroy() {}
@Override
public FilterAction handleClientRequest(String s, User user, ISFSObject object) throws SFSException {
ThreadState state = new SubjectThreadState(ShiroUtils.getSubject(user.getSession()));
//how to unbind it later?
state.bind();
return FilterAction.CONTINUE;
}
@Override
public FilterAction handleServerEvent(ISFSEvent isfsEvent) throws SFSException {
User user = (User) isfsEvent.getParameter(SFSEventParam.USER);
ThreadState state;
if (user != null) {
state = new SubjectThreadState(ShiroUtils.getSubject(user.getSession()));
} else {
state = new SubjectThreadState(ShiroUtils.newSubject());
}
//how to unbind it later?
state.bind();
return FilterAction.CONTINUE;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment