Skip to content

Instantly share code, notes, and snippets.

View mente's full-sized avatar

Alex Vasilenko mente

View GitHub Profile
{
"shop" : {
"_routing" : {
"required" : true
},
"properties" : {
"id" : {
"type" : "long"
},
"created_date" : {
{
"query": {
"bool": {
"must": [
{
"top_children": {
"type": "shop",
"query": {
"term": {
"price": 25.23
{
"query": {
"bool": {
"must": [
{
"top_children": {
"type": "shop",
"query": {
"term": {
"price": 25.23
@mente
mente / gist:1200069
Created September 7, 2011 08:38
mmo definition
<bean id="securityManager" class="org.apache.shiro.mgt.DefaultSecurityManager"
p:realm-ref="onyxRealm">
<property name="cacheManager">
<bean class="org.apache.shiro.cache.MemoryConstrainedCacheManager" />
</property>
<property name="sessionManager">
<bean class="org.apache.shiro.session.mgt.DefaultSessionManager"
p:sessionDAO-ref="coreSessionDAO" />
</property>
</bean>
@mente
mente / gist:1200071
Created September 7, 2011 08:40
web application definition
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean"
p:securityManager-ref="webSecurityManager"
p:loginUrl="/login"
p:successUrl="/accounts/profile">
@mente
mente / gist:1200074
Created September 7, 2011 08:43
web application addition
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="staticMethod" value="org.apache.shiro.SecurityUtils.setSecurityManager"/>
<property name="arguments" ref="webSecurityManager"/>
</bean>
@mente
mente / gist:1201270
Created September 7, 2011 18:02
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;
/*
Incorrect initialization
*/
public class MyContextLoaderListener extends ContextLoaderListener {
@Override
protected void customizeContext(ServletContext servletContext, ConfigurableWebApplicationContext applicationContext) {
applicationContext.setParent(MySingleton.getContext());
}
}
public void setSessionMode(String sessionMode) {
String mode = sessionMode;
if (mode == null) {
throw new IllegalArgumentException("sessionMode argument cannot be null.");
}
mode = sessionMode.toLowerCase();
if (!HTTP_SESSION_MODE.equals(mode) && !NATIVE_SESSION_MODE.equals(mode)) {
String msg = "Invalid sessionMode [" + sessionMode + "]. Allowed values are " +
"public static final String constants in the " + getClass().getName() + " class: '"
+ HTTP_SESSION_MODE + "' or '" + NATIVE_SESSION_MODE + "', with '" +
//True hardcode to allow to define manager in spring
public class MyWebSecurityManager extends DefaultWebSecurityManager {
private SessionManager savedSessionManager;
@Override
protected SessionManager createSessionManager(String sessionMode) {
return savedSessionManager;
}