Skip to content

Instantly share code, notes, and snippets.

<script type="text/javascript">
$(document).ready(function() {
//collapsible management
$('.collapsible').collapsible({
defaultOpen: 'section1,section3'
});
});
</script>
import org.grails.plugin.resource.mapper.MapperPhase
class WoffResourceMapper {
static phase = MapperPhase.ALTERNATEREPRESENTATION
static defaultIncludes = [ '**/*.woff' ]
def map(resource, config) {
resource.requestProcessors << { req, resp ->
resp.setHeader('Content-Type', 'font/opentype')
@Kallin
Kallin / ProxySession.groovy
Created June 19, 2012 22:38
grails dbsession proxySession
protected HttpSession proxySession(final boolean create, final HttpServletRequest request,
final HttpServletResponse response) {
if (log.isDebugEnabled()) {
log.debug("Proxying request for {}", request.getRequestURL());
}
String sessionId = getCookieValue(request);
if (sessionId == null) {
if (!create) {
@Kallin
Kallin / dbsessionpk.groovy
Created June 19, 2012 22:58
dbsession pk gen
column(autoIncrement: "true", name: "id", type: "int8") {
constraints(nullable: "false", primaryKey: "true", primaryKeyName: "persistent_sePK")
}
@Kallin
Kallin / persistent_session_attribute_value.groovy
Created June 19, 2012 23:02
persistent_session_attribute_value serialized column
column(name: "serialized", type: "bytea(20000)") {
constraints(nullable: "false")
}
@Kallin
Kallin / SamlAuthenticationFilter.groovy
Created June 22, 2012 17:52
SamlAuthenticationFilter.groovy
class SamlAuthenticationFilter extends AbstractAuthenticationProcessingFilter {
public SamlAuthenticationFilter() {
super("/somecustomauth")
}
@Override
Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) {
if (!request.getMethod().equals("POST")) {
throw new AuthenticationServiceException("Authentication method not supported: " + request.getMethod())
@Kallin
Kallin / resources.groovy
Created June 22, 2012 17:57
resources.groovy
import SamlAuthenticationFilter
import SamlAuthenticationProvider
beans = {
samlAuthenticationFilter(SamlAuthenticationFilter) {
authenticationManager = ref('authenticationManager')
sessionAuthenticationStrategy = ref('sessionAuthenticationStrategy')
authenticationSuccessHandler = ref('authenticationSuccessHandler')
authenticationFailureHandler = ref('authenticationFailureHandler')
rememberMeServices = ref('rememberMeServices')
@Kallin
Kallin / bootstrap.groovy
Created June 22, 2012 17:59
bootstrap.groovy
import org.codehaus.groovy.grails.plugins.springsecurity.SecurityFilterPosition
import org.codehaus.groovy.grails.plugins.springsecurity.SpringSecurityUtils
class BootStrap {
def init = { servletContext ->
SpringSecurityUtils.clientRegisterFilter('samlAuthenticationFilter', SecurityFilterPosition.SECURITY_CONTEXT_FILTER.order + 10)
}
def destroy = {
@Kallin
Kallin / SamlAuthenticationToken.groovy
Created June 22, 2012 18:01
SamlAuthenticationToken.groovy
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken
import org.springframework.security.core.userdetails.UserDetails
class SamlAuthenticationToken extends UsernamePasswordAuthenticationToken {
String token
public SamlAuthenticationToken(String token) {
super(null, null);
this.token = token;
@Kallin
Kallin / SamlAuthenticationProvider.groovy
Created June 22, 2012 18:05
SamlAuthenticationProvider.groovy
import org.springframework.security.authentication.dao.DaoAuthenticationProvider
import org.springframework.security.core.Authentication
import sonicg.authentication.SAMLAuthenticationService
class SamlAuthenticationProvider extends DaoAuthenticationProvider {
@Override
Authentication authenticate(Authentication authentication) {
def token = (SamlAuthenticationToken) authentication