source: branches/TaskRewrite/src/plugins/acegi-0.5.1/src/groovy/org/codehaus/groovy/grails/plugins/springsecurity/GrailsNtlmProcessingFilterEntryPoint.groovy @ 58

Last change on this file since 58 was 58, checked in by gav, 15 years ago

Configure BootStrap? with latest concepts.
Install and setup Acegi plugin with custom views.
Test Fixture plugin in a test app but couldn't get it to work with Acegi encodePassword() so gave up.

File size: 2.5 KB
Line 
1/* Copyright 2006-2009 the original author or authors.
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *      http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15package org.codehaus.groovy.grails.plugins.springsecurity
16
17import org.springframework.security.AuthenticationException
18import org.springframework.security.BadCredentialsException
19import org.springframework.security.ui.ntlm.NtlmBaseException
20import org.springframework.security.ui.ntlm.NtlmBeginHandshakeException
21import org.springframework.security.ui.ntlm.NtlmProcessingFilter
22import org.springframework.security.ui.ntlm.NtlmProcessingFilterEntryPoint
23
24import javax.servlet.ServletException
25import javax.servlet.ServletRequest
26import javax.servlet.ServletResponse
27import javax.servlet.http.HttpServletRequest
28import javax.servlet.http.HttpServletResponse
29
30/**
31 * @author Martin Vlcek
32 * @author <a href='mailto:beckwithb@studentsonly.com'>Burt Beckwith</a>
33 */
34class GrailsNtlmProcessingFilterEntryPoint extends NtlmProcessingFilterEntryPoint {
35
36        private final String STATE_ATTR = NtlmProcessingFilter.@STATE_ATTR
37        private final Integer BEGIN = NtlmProcessingFilter.@BEGIN
38
39        /**
40         * {@inheritDoc}
41         * @see org.springframework.security.ui.ntlm.NtlmProcessingFilterEntryPoint#commence(
42         *      javax.servlet.ServletRequest, javax.servlet.ServletResponse,
43         *      org.springframework.security.AuthenticationException)
44         */
45        @Override
46        void commence(ServletRequest req, ServletResponse res, AuthenticationException authException) throws IOException, ServletException {
47
48                // start authentication, if necessary and forceIdentification in NtlmProcessingFilter is false
49                if (!(authException instanceof NtlmBaseException
50                                || authException instanceof BadCredentialsException)) {
51
52                        req.session.setAttribute STATE_ATTR, BEGIN
53
54                        HttpServletResponse response = (HttpServletResponse)res
55
56                        response.setHeader 'WWW-Authenticate', new NtlmBeginHandshakeException().message
57                        response.setHeader 'Connection', 'Keep-Alive'
58                        response.status = HttpServletResponse.SC_UNAUTHORIZED
59                        response.contentLength = 0
60                        response.flushBuffer()
61                }
62                else {
63                        super.commence(req, res, authException)
64                }
65        }
66}
Note: See TracBrowser for help on using the repository browser.