/*
 * Copyright
 *   2007 axYus - www.axyus.com
 *   2005 C.Marchand - christophe.marchand@axyus.com
 *
 * This file is part of XEMELIOS.
 *
 * XEMELIOS is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * XEMELIOS is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with XEMELIOS; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package fr.gouv.finances.cp.xemelios.auth;

/**
 * Carries user's properties.
 * If an implementation carries user's password, it must be encrypted,
 * but its better not to keep password in instance.
 * @author chm
 *
 */
public interface XemeliosUser {
	public final int ROLE_CONNECT =	0x0001; // 00000001
	public final int ROLE_IMPORT = 	0x0002; // 00000010
	public final int ROLE_CLEAN =	0x0004; // 00000100
	public final int ROLE_SEARCH =	0x0010; // 00001000
	public final int ROLE_BROWSE =	0x0020; // 00010000
	public final int ROLE_EXPORT =	0x0040; // 00100000
	// left-most bits are reserved for implementations
	
	/**
	 * Returns this user's ID
	 * @return ID
	 */
	public String getId();
	/**
	 * Returns the description for this user (you can decide to put anything in)
	 * @return The description
	 */
	public String getDescription();
	/**
	 * Returns the authority of this user for a particular <tt>collectivite</tt>.
	 * You may ignore the collectivite to give the same rules on all collectivites
	 * (this is the default behavior for basic and DGCP implementations). 
	 * @param collectivite
	 * @return the authority
	 */
	public int getAuth(String collectivite);
	/**
	 * Returns <tt>true</tt> if this user can play tyhis <tt>role</tt> on this
	 * <tt>collectivite</tt>, <tt>false</tt> otherwise. <tt>collectivite</tt> should be
	 * ignored for {@link XemeliosUser.ROLE_CONNECT}.
	 * @param collectivite
	 * @param role
	 * @return <tt>true</tt> or <tt>false</tt>, depending on user's authority.
	 */
	public boolean isAllowedTo(String collectivite, int role);
}
