1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.kernel.security.jaas;
16  
17  import com.liferay.portal.kernel.log.Log;
18  import com.liferay.portal.kernel.log.LogFactoryUtil;
19  import com.liferay.portal.kernel.util.PortalClassLoaderUtil;
20  
21  import java.util.Map;
22  
23  import javax.security.auth.Subject;
24  import javax.security.auth.callback.CallbackHandler;
25  import javax.security.auth.login.LoginException;
26  import javax.security.auth.spi.LoginModule;
27  
28  /**
29   * <a href="PortalLoginModule.java.html"><b><i>View Source</i></b></a>
30   *
31   * @author Brian Wing Shun Chan
32   */
33  public class PortalLoginModule implements LoginModule {
34  
35      public PortalLoginModule() {
36          try {
37              Class<?> classObj = Class.forName(
38                  _CLASS_NAME, true, PortalClassLoaderUtil.getClassLoader());
39  
40              _loginModule = (LoginModule)classObj.newInstance();
41          }
42          catch (Exception e) {
43              _log.error(e);
44          }
45      }
46  
47      public boolean abort() throws LoginException {
48          return _loginModule.abort();
49      }
50  
51      public boolean commit() throws LoginException {
52          return _loginModule.commit();
53      }
54  
55      public void initialize(
56          Subject subject, CallbackHandler callbackHandler,
57          Map<String, ?> sharedState, Map<String, ?> options) {
58  
59          _loginModule.initialize(subject, callbackHandler, sharedState, options);
60      }
61  
62      public boolean login() throws LoginException {
63          return _loginModule.login();
64      }
65  
66      public boolean logout() throws LoginException {
67          return _loginModule.logout();
68      }
69  
70      private static final String _CLASS_NAME =
71          "com.liferay.portal.security.jaas.PortalLoginModule";
72  
73      private static Log _log = LogFactoryUtil.getLog(PortalLoginModule.class);
74  
75      private LoginModule _loginModule;
76  
77  }