001package jmri.configurexml; 002 003import jmri.*; 004 005import org.openide.util.lookup.ServiceProvider; 006 007/** 008 * Owner of permissions for Load and Store classes. 009 * 010 * @author Daniel Bergqist (C) 2024 011 */ 012public class LoadAndStorePermissionOwner implements PermissionOwner { 013 014 public static final LoadAndStorePermissionOwner LOAD_AND_STORE_PERMISSION_OWNER = 015 new LoadAndStorePermissionOwner(); 016 017 public static final LoadXmlFilePermission LOAD_XML_FILE_PERMISSION = 018 new LoadXmlFilePermission(LOAD_AND_STORE_PERMISSION_OWNER); 019 020 public static final StoreXmlFilePermission STORE_XML_FILE_PERMISSION = 021 new StoreXmlFilePermission(LOAD_AND_STORE_PERMISSION_OWNER); 022 023 024 @Override 025 public String getName() { 026 return Bundle.getMessage("LoadAndStorePermissionOwner_Name"); 027 } 028 029 030 @ServiceProvider(service = PermissionFactory.class) 031 public static class Factory implements PermissionFactory { 032 033 @Override 034 public void register(PermissionManager manager) { 035 manager.registerOwner(LOAD_AND_STORE_PERMISSION_OWNER); 036 manager.registerPermission(LOAD_XML_FILE_PERMISSION); 037 manager.registerPermission(STORE_XML_FILE_PERMISSION); 038 } 039 040 } 041 042 043 public static class LoadXmlFilePermission implements BooleanPermission { 044 045 private final PermissionOwner _owner; 046 047 private LoadXmlFilePermission(PermissionOwner owner) { 048 _owner = owner; 049 } 050 051 @Override 052 public PermissionOwner getOwner() { 053 return _owner; 054 } 055 056 @Override 057 public String getName() { 058 return Bundle.getMessage("LoadAndStorePermission_Load"); 059 } 060 061 @Override 062 public BooleanValue getDefaultPermission(Role role) { 063 return BooleanValue.get(role.isAdminRole()); 064 } 065 066 } 067 068 069 public static class StoreXmlFilePermission implements BooleanPermission { 070 071 private final PermissionOwner _owner; 072 073 private StoreXmlFilePermission(PermissionOwner owner) { 074 _owner = owner; 075 } 076 077 @Override 078 public PermissionOwner getOwner() { 079 return _owner; 080 } 081 082 @Override 083 public String getName() { 084 return Bundle.getMessage("LoadAndStorePermission_Store"); 085 } 086 087 @Override 088 public BooleanValue getDefaultPermission(Role role) { 089 return BooleanValue.get(role.isAdminRole()); 090 } 091 092 } 093}