001package jmri;
002
003import java.util.Set;
004
005/**
006 * An user in the permission system.
007 *
008 * @author Daniel Bergqvist (C) 2024
009 */
010public interface User {
011
012    String getUserName();
013
014    boolean isSystemUser();
015
016    int getPriority();
017
018    void setPassword(String newPassword);
019
020    /**
021     * Is the user allowed to change his password?
022     * @return true if the user is allowed to change his password, false otherwise.
023     */
024    boolean isPermittedToChangePassword();
025
026    boolean changePassword(String oldPassword, String newPassword);
027
028    String getName();
029
030    void setName(String name);
031
032    String getComment();
033
034    void setComment(String comment);
035
036    Set<Role> getRoles();
037
038    void addRole(Role role);
039
040    void removeRole(Role role);
041
042    boolean hasAtLeastPermission(Permission permission, PermissionValue minValue);
043
044    /**
045     * Checks if the current user has the permission.
046     * If not, show a message dialog if not headless. Otherwise log a message.
047     * @param permission  the permission to check
048     * @param minValue    the minimum value
049     * @return true if the user has the permission, false otherwise
050     */
051    boolean ensureAtLeastPermission(Permission permission, PermissionValue minValue);
052
053}