Skip to content

Instantly share code, notes, and snippets.

View sergiomichels's full-sized avatar

Sérgio Michels sergiomichels

View GitHub Profile
@sergiomichels
sergiomichels / Config.groovy
Created November 9, 2012 22:56
How to make spring security ldap optional, and not validate in the database when activated.
//activate or deactivate the plugin
grails.plugins.springsecurity.ldap.active=true
if(grails.plugins.springsecurity.ldap.active) {
// specify this when you want to skip attempting to load from db and only use LDAP
grails.plugins.springsecurity.providerNames = ['ldapAuthProvider', 'anonymousAuthenticationProvider']
}
@sergiomichels
sergiomichels / CustomUserDetailsService.groovy
Created November 9, 2012 23:21
Grails - Custom UserDetailsService
import org.codehaus.groovy.grails.plugins.springsecurity.GrailsUserDetailsService
import org.springframework.security.core.userdetails.UserDetails
import org.springframework.security.core.userdetails.UsernameNotFoundException
import User
class CustomUserDetailsService implements GrailsUserDetailsService {
//this creates a List of GrantedAuthorityImpl
MyAuthoritiesBuilder myAuthoritiesBuilder
@sergiomichels
sergiomichels / Config.groovy
Created November 15, 2012 12:51
Joda Time Plugin, user types
'user-type' type: org.jadira.usertype.dateandtime.joda.PersistentDateMidnight, class: org.joda.time.DateMidnight
'user-type' type: org.jadira.usertype.dateandtime.joda.PersistentDateTime, class: org.joda.time.DateTime
'user-type' type: org.jadira.usertype.dateandtime.joda.PersistentDateTimeZoneAsString, class: org.joda.time.DateTimeZone
'user-type' type: org.jadira.usertype.dateandtime.joda.PersistentDurationAsString, class: org.joda.time.Duration
'user-type' type: org.jadira.usertype.dateandtime.joda.PersistentInstantAsMillisLong, class: org.joda.time.Instant
'user-type' type: org.jadira.usertype.dateandtime.joda.PersistentInterval, class: org.joda.time.Interval
'user-type' type: org.jadira.usertype.dateandtime.joda.PersistentLocalDate, class: org.joda.time.LocalDate
'user-type' type: org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime, class: org.joda.time.LocalDateTime
'user-type' type: org.jadira.usertype.dateandtime.joda.PersistentLocalTime, class: org.joda.time.LocalTime
'user-type' type: org.j
@sergiomichels
sergiomichels / test.gsp
Created November 22, 2012 12:58
Layout test, resources script
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><g:layoutTitle default="Insoft4 UI Plugin"/></title>
<g:layoutHead/>
<r:layoutResources />
</head>
<body>
@sergiomichels
sergiomichels / index.gsp
Created November 22, 2012 12:59
Index test for plugin
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Teste</title>
<meta name="layout" content="teste" />
<r:script disposition="defer">
alert('index!');
</r:script>
<r:layoutResources />
@sergiomichels
sergiomichels / gist:4626265
Created January 24, 2013 18:41
Trying to run spok tests
| Packaging Grails application.....
| Packaging Grails application.....
Configuring Spring Security Core ...
... finished configuring Spring Security Core
======================================================================
Application: insoft-security
@sergiomichels
sergiomichels / ConstraintRegistrar.groovy
Last active December 13, 2015 19:08
Try to register custom constraints based on the type of the field. Uses the GrailsDomainClass.
package br.com.insoft4.core.constraints
import org.codehaus.groovy.grails.commons.DefaultGrailsDomainClassProperty
import org.codehaus.groovy.grails.commons.GrailsDomainClass
import org.codehaus.groovy.grails.validation.ConstrainedProperty;
import br.com.insoft4.core.types.EmpresaIdentity;
import br.com.insoft4.core.types.SimNao
@sergiomichels
sergiomichels / Example.groovy
Created March 7, 2013 21:04
Example of overriding tags - not working as expected on Grails 2.2.1
PluginATagLib {
static namespace = "my"
def input = { attrs, body ->
out << attrs
}
}
PluginBTagLib {
static namespace = "my"
static final String INPUT_CLASS = PluginATagLib.class.canonicalName
@sergiomichels
sergiomichels / DataSource.groovy
Last active December 14, 2015 22:19
Delayed Session Factory for Oracle
dataSource {
pooled = false
driverClassName = "oracle.jdbc.OracleDriver"
//Add the Dialect for your database
dialect = org.hibernate.dialect.Oracle10gDialect
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
@sergiomichels
sergiomichels / resources.groovy
Created March 13, 2013 23:50
Delayed Session Factory for Oracle - Spring Beans
beans = {
lobHandlerDetector(OracleLobHandler) { nativeJdbcExtractor = new CommonsDbcpNativeJdbcExtractor() }
}