PageRenderTime 34ms CodeModel.GetById 28ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/AuthenticRoast/AuthenticRoast-Impl/src/main/java/name/aikesommer/authenticator/DelegatingAuthenticator.java

http://authenticroast.googlecode.com/
Java | 60 lines | 26 code | 11 blank | 23 comment | 0 complexity | 047107f35efd8aee09a4dbaf044b57e6 MD5 | raw file
 1/**
 2 *    Copyright (C) 2007-2010 Aike J Sommer (http://aikesommer.name/)
 3 *
 4 *    This file is part of AuthenticRoast.
 5 *
 6 *    This library is free software; you can redistribute it and/or
 7 *    modify it under the terms of the GNU Lesser General Public
 8 *    License as published by the Free Software Foundation; either
 9 *    version 3 of the License, or (at your option) any later version.
10 *
11 *    This library is distributed in the hope that it will be useful,
12 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
13 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 *    Lesser General Public License for more details.
15 *
16 *    You should have received a copy of the GNU Lesser General
17 *    Public License along with this library; if not, write to the
18 *    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 *    Boston, MA 02110-1301 USA
20 *
21 *    You can reach the author and get more information about this
22 *    project at: http://aikesommer.name/
23 */
24package name.aikesommer.authenticator;
25
26import javax.servlet.ServletContext;
27
28
29public class DelegatingAuthenticator extends PluggableAuthenticator {
30
31    private PluggableAuthenticator delegateAuthenticator;
32
33    private ServletContext delegateContext;
34
35    public DelegatingAuthenticator(PluggableAuthenticator delegateAuthenticator,
36            ServletContext delegateContext) {
37        this.delegateAuthenticator = delegateAuthenticator;
38        this.delegateContext = delegateContext;
39    }
40
41    private AuthenticationRequest wrapRequest(AuthenticationRequest request) {
42        return ((AuthenticationRequestImpl) request).delegate(delegateContext);
43    }
44
45    @Override
46    public AuthenticationRequest.Status tryAuthenticate(AuthenticationManager manager, AuthenticationRequest request) {
47        return delegateAuthenticator.tryAuthenticate(manager, wrapRequest(request));
48    }
49
50    @Override
51    public AuthenticationRequest.Status authenticate(AuthenticationManager manager, AuthenticationRequest request) {
52        return delegateAuthenticator.authenticate(manager, wrapRequest(request));
53    }
54
55    @Override
56    public AuthenticationRequest.ManageAction manage(AuthenticationManager manager, AuthenticationRequest request) {
57        return delegateAuthenticator.manage(manager, wrapRequest(request));
58    }
59
60}