Skip to content

Instantly share code, notes, and snippets.

View novoj's full-sized avatar
💻
Hacking on evitaDB

Jan Novotný novoj

💻
Hacking on evitaDB
View GitHub Profile
[
{
"jmhVersion" : "1.27",
"benchmark" : "io.evitadb.spike.ArrayOrHashMap.retrieveValueFromArray",
"mode" : "thrpt",
"threads" : 1,
"forks" : 1,
"jvm" : "/opt/Java/jdk11.0.10/bin/java",
"jvmArgs" : [
],
@novoj
novoj / SpringSecurity.java
Created February 27, 2017 16:05
Spring Security Java Configuration
@Configuration
@EnableWebMvcSecurity
@ComponentScan(basePackageClasses = UserRepositoryUserDetailsService.class)
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
@Autowired
private UserDetailsService userDetailsService;
@Configuration
@EnableGlobalMethodSecurity(prePostEnabled = true)
static class MethodSecurityConfiguration extends GlobalMethodSecurityConfiguration {
@novoj
novoj / spring-security.xml
Created February 27, 2017 16:02
Spring Security XML example
<?xml version="1.0" encoding="utf-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security.xsd">
<http pattern="/css/**" security="none"/>
@novoj
novoj / CsrfTokenUtils.java
Created January 7, 2017 21:48
CSRF Protection against Breach
package com.fg.http.csrf;
import org.apache.commons.codec.binary.Base32;
import org.springframework.web.util.WebUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.security.SecureRandom;
import java.util.Random;
private static class SerializableProxyDescriptor implements Serializable {
private static final long serialVersionUID = 8401525823871149500L;
private final Class mainClass;
private final Class[] interfaces;
private final Object target;
private final DeserializationProxyFactory deserializationProxyFactory;
private final Map<String, Object> pojoFields = new HashMap<String, Object>();
private SerializableProxyDescriptor(Class mainClass, Class[] interfaces, Object target, DeserializationProxyFactory deserializationProxyFactory) {
this.mainClass = mainClass;
/**
* Partial update allows AJAX partial update of the DOM structure by communicating with component background implemented
* in RamJet technology.
*
* Custom settings:
*
* alterHistory - boolean true - if browser history is ought to be altered,
* - boolean false - if browser history should remain untouched
* - (default) not set - only links/forms targeting the same page will alter the history
* historyScope - parameters - keeps only parameter values in history
package com.fg.doxx.gastro.web.user.validator;
import com.fg.doxx.gastro.business.GastroUserManager;
import com.fg.doxx.gastro.model.user.GastroUser;
import com.fg.form.core.context.RequestContext;
import com.fg.form.core.data.state.State;
import com.fg.form.core.lifecycle.validate.impl.AbstractSingleValueWidgetValidator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
@novoj
novoj / HackedDynamicMappingFilter.java
Last active December 23, 2015 06:29
Patch for Stripes framework on WebSphere 8.x
package net.sourceforge.stripes.controller;
import net.sourceforge.stripes.action.ActionBean;
import net.sourceforge.stripes.exception.StripesServletException;
import net.sourceforge.stripes.util.HttpUtil;
import net.sourceforge.stripes.util.Log;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
@novoj
novoj / bootstrapDictionary.xml
Created September 4, 2013 10:12
Bootstrap dictionary
<?xml version="1.0" encoding="utf-8"?>
<dictionary>
<widgets>
<rowFluid extends="widgetContainer" template="inherit">
<metadata>
<htmlClass>row-fluid</htmlClass>
</metadata>
</rowFluid>
<span1 extends="widgetContainer" template="inherit">
<metadata>
@novoj
novoj / ServletFreemarkerRenderer.java
Created August 28, 2013 12:13
ServletFreemarkerRenderer_part
public void render(RequestContext context, WidgetDefinition widgetDefinition, TemplateReference templateReference, ServletContext servletContext, HttpServletRequest request, HttpServletResponse response) throws TemplateNotFoundException, TemplateProcessingException {
try {
//we have to set encoding before writer is fetche
try {
response.setCharacterEncoding(configuration.getDefaultEncoding());
} catch (NoSuchMethodError e) {
// servlet spec 2.3
response.setContentType("text/html; encoding=" + configuration.getDefaultEncoding());
}
PageDefinition pageDefinition = (PageDefinition) context.getRequestable();