01: /**
02: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
03: *
04: * Permission is hereby granted, free of charge, to any person obtaining a copy
05: * of this software and associated documentation files (the "Software"), to deal
06: * in the Software without restriction, including without limitation the rights
07: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
08: * copies of the Software, and to permit persons to whom the Software is
09: * furnished to do so, subject to the following conditions:
10: *
11: * The above copyright notice and this permission notice shall be included in
12: * all copies or substantial portions of the Software.
13: *
14: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20: * SOFTWARE.
21: */package com.liferay.portal.security.auth;
22:
23: import com.liferay.portal.PwdEncryptorException;
24: import com.liferay.portal.security.pwd.PwdEncryptor;
25:
26: import java.io.Serializable;
27:
28: import org.apache.commons.logging.Log;
29: import org.apache.commons.logging.LogFactory;
30:
31: /**
32: * <a href="HttpPrincipal.java.html"><b><i>View Source</i></b></a>
33: *
34: * @author Brian Wing Shun Chan
35: *
36: */
37: public class HttpPrincipal implements Serializable {
38:
39: public HttpPrincipal(String url) {
40: _url = url;
41: }
42:
43: public HttpPrincipal(String url, long userId, String password) {
44: this (url, userId, password, false);
45: }
46:
47: public HttpPrincipal(String url, long userId, String password,
48: boolean digested) {
49:
50: _url = url;
51: _userId = userId;
52:
53: if (digested) {
54: _password = password;
55: } else {
56: try {
57: _password = PwdEncryptor.encrypt(password);
58: } catch (PwdEncryptorException pee) {
59: _log.error(pee, pee);
60: }
61: }
62: }
63:
64: public String getUrl() {
65: return _url;
66: }
67:
68: public long getCompanyId() {
69: return _companyId;
70: }
71:
72: public void setCompanyId(long companyId) {
73: _companyId = companyId;
74: }
75:
76: public long getUserId() {
77: return _userId;
78: }
79:
80: public String getPassword() {
81: return _password;
82: }
83:
84: private static Log _log = LogFactory.getLog(HttpPrincipal.class);
85:
86: private String _url;
87: private long _companyId;
88: private long _userId;
89: private String _password;
90:
91: }
|