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    boolean changePassword(String oldPassword, String newPassword);
021
022    String getName();
023
024    void setName(String name);
025
026    String getComment();
027
028    void setComment(String comment);
029
030    Set<Role> getRoles();
031
032    void addRole(Role role);
033
034    void removeRole(Role role);
035
036    boolean hasPermission(Permission permission);
037
038    /**
039     * Checks if the current user has the permission.
040     * If not, show a message dialog if not headless. Otherwise log a message.
041     * @param permission the permission to check
042     * @return true if the user has the permission, false otherwise
043     */
044    boolean checkPermission(Permission permission);
045
046}