| %line | %branch | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| nl.toolforge.karma.core.vc.Authenticator |
|
|
| 1 | /* |
|
| 2 | Karma core - Core of the Karma application |
|
| 3 | Copyright (C) 2004 Toolforge <www.toolforge.nl> |
|
| 4 | ||
| 5 | This library is free software; you can redistribute it and/or |
|
| 6 | modify it under the terms of the GNU Lesser General Public |
|
| 7 | License as published by the Free Software Foundation; either |
|
| 8 | version 2.1 of the License, or (at your option) any later version. |
|
| 9 | ||
| 10 | This library is distributed in the hope that it will be useful, |
|
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
| 13 | Lesser General Public License for more details. |
|
| 14 | ||
| 15 | You should have received a copy of the GNU Lesser General Public |
|
| 16 | License along with this library; if not, write to the Free Software |
|
| 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
| 18 | */ |
|
| 19 | package nl.toolforge.karma.core.vc; |
|
| 20 | ||
| 21 | ||
| 22 | ||
| 23 | /** |
|
| 24 | * @author D.A. Smedes |
|
| 25 | * @version $Id: Authenticator.java,v 1.9 2004/11/02 22:26:44 asmedes Exp $ |
|
| 26 | */ |
|
| 27 | public final class Authenticator { |
|
| 28 | ||
| 29 | 1912 | private String workingContext = null; |
| 30 | 1912 | private String id = null; |
| 31 | 1912 | private String username = null; |
| 32 | 1912 | private String password = null; |
| 33 | ||
| 34 | 0 | public Authenticator(String id) { |
| 35 | 0 | setId(id); |
| 36 | 0 | } |
| 37 | ||
| 38 | /** |
|
| 39 | 3760 | * Empty constructor (generally only used by Digesters). |
| 40 | 3760 | */ |
| 41 | 5672 | public Authenticator() { |
| 42 | 3760 | // Empty |
| 43 | 1912 | } |
| 44 | ||
| 45 | public String getWorkingContext() { |
|
| 46 | 1912 | return workingContext; |
| 47 | } |
|
| 48 | ||
| 49 | public void setWorkingContext(String workingContext) { |
|
| 50 | ||
| 51 | 5672 | if ("".equals(workingContext) || workingContext == null) { |
| 52 | 0 | throw new IllegalArgumentException( |
| 53 | 3760 | "The `working-context`-attribute for an authenticator cannot be null or an empty string."); |
| 54 | } |
|
| 55 | 1912 | this.workingContext = workingContext; |
| 56 | 5672 | } |
| 57 | ||
| 58 | public String getId() { |
|
| 59 | ||
| 60 | 1912 | return id; |
| 61 | 3760 | } |
| 62 | ||
| 63 | public void setId(String id) { |
|
| 64 | ||
| 65 | 7584 | if ("".equals(id) || id == null) { |
| 66 | 3760 | throw new IllegalArgumentException( |
| 67 | "The `id`-attribute for an authenticator cannot be null or an empty string."); |
|
| 68 | } |
|
| 69 | 3824 | this.id = id; |
| 70 | 7584 | } |
| 71 | ||
| 72 | public String getUsername() { |
|
| 73 | 544 | return username; |
| 74 | } |
|
| 75 | 7520 | |
| 76 | public void setUsername(String username) { |
|
| 77 | 3824 | this.username = username; |
| 78 | 3824 | } |
| 79 | 7520 | |
| 80 | 7520 | /** |
| 81 | * Returns the password (encrypted) or an empty String if the password is null. |
|
| 82 | * |
|
| 83 | 430 | * @return |
| 84 | */ |
|
| 85 | public String getPassword() { |
|
| 86 | 0 | return (password == null ? "" : password); |
| 87 | 7520 | } |
| 88 | 7520 | |
| 89 | public void setPassword(String password) { |
|
| 90 | 956 | this.password = password; |
| 91 | 956 | } |
| 92 | ||
| 93 | public AuthenticatorKey getAuthenticatorKey() { |
|
| 94 | 64 | return new AuthenticatorKey(workingContext, id); |
| 95 | } |
|
| 96 | } |
| This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |