View Javadoc

1   /* 
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.jetspeed.security.impl;
18  
19  import org.apache.jetspeed.security.LoginModuleProxy;
20  import org.apache.jetspeed.security.UserManager;
21  
22  /***
23   * @see org.apache.jetspeed.security.LoginModuleProxy
24   * @author <a href="mailto:dlestrat@apache.org">David Le Strat </a>
25   */
26  public class LoginModuleProxyImpl implements LoginModuleProxy
27  {
28      /*** The {@link LoginModuleProxy}instance. */
29      static LoginModuleProxy loginModuleProxy;
30  
31      /*** The {@link UserManager}. */
32      private UserManager userMgr;
33  
34      /*** The portal user role. */
35      private String portalUserRole;
36  
37      /***
38       * <p>
39       * Constructor providing a bridge between the login module and the user
40       * manager.
41       * </p>
42       * 
43       * @param userMgr The user manager.
44       * @param portalUserRole The portal user role shared by all portal users: used
45       *                       in web.xml authorization to detect authenticated portal
46       *                       users.
47       *  
48       */
49      public LoginModuleProxyImpl(UserManager userMgr, String portalUserRole)
50      {
51          // The user manager.
52          this.userMgr = userMgr;
53  
54          // The portal user role
55          this.portalUserRole = (portalUserRole != null ? portalUserRole : DEFAULT_PORTAL_USER_ROLE_NAME);
56  
57          // Hack providing access to the UserManager in the LoginModule.
58          // TODO Can we fix this?
59          LoginModuleProxyImpl.loginModuleProxy = this;
60      }
61      public LoginModuleProxyImpl(UserManager userMgr)
62      {
63          this(userMgr, DEFAULT_PORTAL_USER_ROLE_NAME);
64      }
65  
66      /***
67       * @see org.apache.jetspeed.security.LoginModuleProxy#getUserManager()
68       */
69      public UserManager getUserManager()
70      {
71          return this.userMgr;
72      }
73  
74      /***
75       * @see org.apache.jetspeed.security.LoginModuleProxy#getPortalUserRole()
76       */
77      public String getPortalUserRole()
78      {
79          return this.portalUserRole;
80      }
81  }