1 /* 2 * PCUServeur for the PCU project. 3 * Copyright (C) 2010 PLU Julien 4 * 5 * This program is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * This program 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 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 * 18 * For questions: julien.plu@redaction-developpez.com 19 */ 20 package pcuserveur.lib; 21 22 /** 23 * @author PLU Julien 24 * @version 1.0 25 * 26 * <b> 27 * Représente un utilisateur. Un utilisateur est identifié par 28 * son login. Il peut être simple utilisateur ou administrateur. 29 * </b> 30 * <p> 31 * Un Utilisateur est caractérisé par les informations suivantes: 32 * <ul> 33 * <li>Un boolean désignant si l'utilisateur est un administrateur.</li> 34 * <li>Un String représentant le login de l'utilisateur.</li> 35 * </ul> 36 * </p> 37 * 38 * @see GestionnaireConnexion 39 * @see Vide 40 */ 41 public class Utilisateur implements Vide { 42 /** 43 * <p> 44 * Désigne si l'utilisateur est un administrateur ou non. 45 * </p> 46 * 47 * @see Utilisateur#Utilisateur (String, boolean) 48 * @see Utilisateur#estAdministrateur () 49 * @see Utilisateur#estVide () 50 * @see Utilisateur#setAdministrateur (boolean) 51 * @see Utilisateur#vider () 52 */ 53 boolean administrateur; 54 /** 55 * <p> 56 * Login de l'utilisateur. 57 * </p> 58 * 59 * @see Utilisateur#Utilisateur (String, boolean) 60 * @see Utilisateur#estVide () 61 * @see Utilisateur#getLogin () 62 * @see Utilisateur#setLogin (String) 63 * @see Utilisateur#vider () 64 */ 65 private String login; 66 67 /** 68 * <p> 69 * Constructeur par défaut. 70 * </p> 71 */ 72 public Utilisateur () { 73 // Constructeur par defaut. 74 } 75 76 /** 77 * <p> 78 * Constructeur paramétré 79 * </p> 80 * 81 * @param login1 82 * Le login. 83 * @param administrateur1 84 * Un boolean, <code>true</code> si l'utilisateur est 85 * administrateur <code>false</code> sinon. 86 */ 87 public Utilisateur (final String login1, final boolean administrateur1) { 88 this.login = login1; 89 this.administrateur = administrateur1; 90 } 91 92 /** 93 * <p> 94 * Savoir si l'utilisateur est administrateur. Si l'utilisateur est vide, le 95 * résultat est indéterminé. 96 * </p> 97 * 98 * @return <code>true</code> si l'utilisateur est administrateur, 99 * <code>false</code> sinon 100 */ 101 public boolean estAdministrateur () { 102 return this.administrateur; 103 } 104 105 /** 106 * <p> 107 * Savoir si l'utilisateur est vide. 108 * </p> 109 * 110 * @return <code>true</code> si l'utilisateur est vide, <code>false</code> 111 * sinon. 112 * @see Vide 113 */ 114 public boolean estVide () { 115 return this.login == null; 116 } 117 118 /** 119 * <p> 120 * Obtenir le login, si il existe. 121 * </p> 122 * 123 * @return Le login, ou <code>null</code> si l'utilisateur est vide. 124 */ 125 public String getLogin () { 126 return this.login; 127 } 128 129 /** 130 * <p> 131 * Définir si l'utilisateur est, ou pas, un administrateur. 132 * </p> 133 * 134 * @param administrateur1 135 * Un booléen de valeur <code>true</code> si l'utilisateur est 136 * administrateur <code>false</code> sinon. 137 */ 138 public void setAdministrateur (final boolean administrateur1) { 139 this.administrateur = administrateur1; 140 } 141 142 /** 143 * <p> 144 * Définir le login. 145 * </p> 146 * 147 * @param login1 148 * Le login. 149 */ 150 public void setLogin (final String login1) { 151 this.login = login1; 152 } 153 154 /** 155 * <p> 156 * Vider l'utilisateur. A utiliser avec beaucoup de précaution. 157 * </p> 158 */ 159 public void vider () { 160 this.login = null; 161 this.administrateur = false; 162 } 163 }