Skip to content

Instantly share code, notes, and snippets.

View sergiomichels's full-sized avatar

Sérgio Michels sergiomichels

View GitHub Profile
@sergiomichels
sergiomichels / UserDatabaseAuthenticationProvider.groovy
Last active December 14, 2015 22:19
Class that get's the username and password and try to open a database connection with this information
class UserDatabaseAuthenticationProvider extends AbstractUserDetailsAuthenticationProvider {
def dataSource
@Override
protected void additionalAuthenticationChecks(UserDetails userDetails,
UsernamePasswordAuthenticationToken token) throws AuthenticationException {
}
@Override
@sergiomichels
sergiomichels / MyController.groovy
Created March 14, 2013 00:03
Controller that uses the UserCredentialsDataSourceAdapter
class MyController {
def dataSource //instance of UserCredentialsDataSourceAdapter
def index() {
dataSource.setCredentialsForCurrentThread("user", "password")
//this will call getConnection("user","password")
//If we have a service, it will use the same username and password also
Connection conn = dataSource.getConnection()
}
@sergiomichels
sergiomichels / resources.groovy
Last active December 14, 2015 22:19
Beans defined for set the username and password for the database login
dataSource(UserCredentialsDataSourceAdapter){
targetDataSource= ref("dataSourceUnproxied")
}
@sergiomichels
sergiomichels / resources.groovy
Created March 13, 2013 23:50
Delayed Session Factory for Oracle - Spring Beans
beans = {
lobHandlerDetector(OracleLobHandler) { nativeJdbcExtractor = new CommonsDbcpNativeJdbcExtractor() }
}
@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 / 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 / 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 / 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 / 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 / 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>