source: branches/TaskRewrite/src/plugins/acegi-0.5.1/src/java/org/codehaus/groovy/grails/plugins/springsecurity/GrailsUserImpl.java @ 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.8 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.GrantedAuthority;
18import org.springframework.security.providers.dao.DaoAuthenticationProvider;
19import org.springframework.security.userdetails.User;
20
21/**
22 * Extends Spring Security's {@link User} class to set Grails Domain Class at login,
23 * to load auth class from context.
24 *
25 * @author T.Yamamoto
26 * @author <a href='mailto:beckwithb@studentsonly.com'>Burt Beckwith</a>
27 */
28public class GrailsUserImpl extends User implements GrailsUser {
29
30        private static final long serialVersionUID = 6089520028447407158L;
31
32        private final Object domainClass;
33
34        /**
35         * Constructor.
36         * @param username the username presented to the
37         *        {@link DaoAuthenticationProvider}
38         * @param password the password that should be presented to the
39         *        {@link DaoAuthenticationProvider}
40         * @param enabled set to <code>true</code> if the user is enabled
41         * @param accountNonExpired set to <code>true</code> if the account has not
42         *        expired
43         * @param credentialsNonExpired set to <code>true</code> if the credentials
44         *        have not expired
45         * @param accountNonLocked set to <code>true</code> if the account is not
46         *        locked
47         * @param authorities the authorities that should be granted to the caller
48         *        if they presented the correct username and password and the user
49         *        is enabled
50         * @param user  the user domain instance
51         *
52         * @throws IllegalArgumentException if a <code>null</code> value was passed
53         *         either as a parameter or as an element in the
54         *         {@link GrantedAuthority}[] array
55         */
56        public GrailsUserImpl(
57                        final String username, final String password, final boolean enabled,
58                        final boolean accountNonExpired, final boolean credentialsNonExpired,
59                        final boolean accountNonLocked, final GrantedAuthority[] authorities,
60                        final Object user) throws IllegalArgumentException {
61                super(username, password, enabled, accountNonExpired,
62                                credentialsNonExpired, accountNonLocked, authorities);
63                domainClass = user;
64        }
65
66        /**
67         * {@inheritDoc}
68         * @see org.codehaus.groovy.grails.plugins.springsecurity.GrailsUser#getDomainClass()
69         */
70        public Object getDomainClass() {
71                return domainClass;
72        }
73}
Note: See TracBrowser for help on using the repository browser.