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.security.auth;
16  
17  import com.liferay.portal.PwdEncryptorException;
18  import com.liferay.portal.kernel.log.Log;
19  import com.liferay.portal.kernel.log.LogFactoryUtil;
20  import com.liferay.portal.security.pwd.PwdEncryptor;
21  
22  import java.io.Serializable;
23  
24  /**
25   * <a href="HttpPrincipal.java.html"><b><i>View Source</i></b></a>
26   *
27   * @author Brian Wing Shun Chan
28   */
29  public class HttpPrincipal implements Serializable {
30  
31      public HttpPrincipal(String url) {
32          _url = url;
33      }
34  
35      public HttpPrincipal(String url, String login, String password) {
36          this(url, login, password, false);
37      }
38  
39      public HttpPrincipal(
40          String url, String login, String password, boolean digested) {
41  
42          _url = url;
43          _login = login;
44  
45          if (digested) {
46              _password = password;
47          }
48          else {
49              try {
50                  _password = PwdEncryptor.encrypt(password);
51              }
52              catch (PwdEncryptorException pee) {
53                  _log.error(pee, pee);
54              }
55          }
56      }
57  
58      public String getUrl() {
59          return _url;
60      }
61  
62      public long getCompanyId() {
63          return _companyId;
64      }
65  
66      public void setCompanyId(long companyId) {
67          _companyId = companyId;
68      }
69  
70      public String getLogin() {
71          return _login;
72      }
73  
74      public String getPassword() {
75          return _password;
76      }
77  
78      private static Log _log = LogFactoryUtil.getLog(HttpPrincipal.class);
79  
80      private String _url;
81      private long _companyId;
82      private String _login;
83      private String _password;
84  
85  }