1 31 32 package org.opencms.db; 33 34 import org.opencms.main.CmsLog; 35 import org.opencms.main.CmsRuntimeException; 36 import org.opencms.util.CmsStringUtil; 37 38 48 public class CmsDefaultUsers { 49 50 51 protected static final String DEFAULT_GROUP_ADMINISTRATORS = "Administrators"; 52 53 54 protected static final String DEFAULT_GROUP_GUESTS = "Guests"; 55 56 57 protected static final String DEFAULT_GROUP_PROJECTMANAGERS = "Projectmanagers"; 58 59 60 protected static final String DEFAULT_GROUP_USERS = "Users"; 61 62 63 protected static final String DEFAULT_USER_ADMIN = "Admin"; 64 65 66 public static final String DEFAULT_USER_DELETED_RESOURCE = "Admin"; 67 68 69 protected static final String DEFAULT_USER_EXPORT = "Export"; 70 71 72 protected static final String DEFAULT_USER_GUEST = "Guest"; 73 74 75 private String m_groupAdministrators; 76 77 78 private String m_groupGuests; 79 80 81 private String m_groupProjectmanagers; 82 83 84 private String m_groupUsers; 85 86 87 private String m_userAdmin; 88 89 90 private String m_userExport; 91 92 93 private String m_userGuest; 94 95 96 private String m_userDeletedResource; 97 98 103 public CmsDefaultUsers() { 104 105 m_userAdmin = DEFAULT_USER_ADMIN; 106 m_userGuest = DEFAULT_USER_GUEST; 107 m_userExport = DEFAULT_USER_EXPORT; 108 m_userDeletedResource = DEFAULT_USER_DELETED_RESOURCE; 109 m_groupAdministrators = DEFAULT_GROUP_ADMINISTRATORS; 110 m_groupProjectmanagers = DEFAULT_GROUP_PROJECTMANAGERS; 111 m_groupUsers = DEFAULT_GROUP_USERS; 112 m_groupGuests = DEFAULT_GROUP_GUESTS; 113 } 114 115 127 public CmsDefaultUsers( 128 String userAdmin, 129 String userGuest, 130 String userExport, 131 String userDeletedResource, 132 String groupAdministrators, 133 String groupProjectmanagers, 134 String groupUsers, 135 String groupGuests) { 136 137 if (CmsLog.INIT.isInfoEnabled()) { 139 CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_CHECKING_DEFAULT_USER_NAMES_0)); 140 } 141 if (CmsStringUtil.isEmptyOrWhitespaceOnly(userAdmin) 142 || CmsStringUtil.isEmptyOrWhitespaceOnly(userGuest) 143 || CmsStringUtil.isEmptyOrWhitespaceOnly(userExport) 144 || CmsStringUtil.isEmptyOrWhitespaceOnly(groupAdministrators) 145 || CmsStringUtil.isEmptyOrWhitespaceOnly(groupProjectmanagers) 146 || CmsStringUtil.isEmptyOrWhitespaceOnly(groupUsers) 147 || CmsStringUtil.isEmptyOrWhitespaceOnly(groupGuests)) { 148 throw new CmsRuntimeException(Messages.get().container(Messages.ERR_USER_GROUP_NAMES_EMPTY_0)); 149 } 150 m_userAdmin = userAdmin.trim(); 152 m_userGuest = userGuest.trim(); 153 m_userExport = userExport.trim(); 154 if (CmsStringUtil.isEmptyOrWhitespaceOnly(userDeletedResource)) { 155 m_userDeletedResource = userAdmin; 156 } else { 157 m_userDeletedResource = userDeletedResource.trim(); 158 } 159 m_groupAdministrators = groupAdministrators.trim(); 160 m_groupProjectmanagers = groupProjectmanagers.trim(); 161 m_groupUsers = groupUsers.trim(); 162 m_groupGuests = groupGuests.trim(); 163 164 if (CmsLog.INIT.isInfoEnabled()) { 165 CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_ADMIN_USER_1, getUserAdmin())); 166 CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_GUEST_USER_1, getUserGuest())); 167 CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_EXPORT_USER_1, getUserExport())); 168 CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_DELETED_RESOURCE_USER_1, getUserDeletedResource())); 169 CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_ADMIN_GROUP_1, getGroupAdministrators())); 170 CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_PROJECT_MANAGERS_GROUP_1, getGroupProjectmanagers())); 171 CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_USERS_GROUP_1, getGroupUsers())); 172 CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_GUESTS_GROUP_1, getGroupGuests())); 173 CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_DEFAULT_USER_NAMES_INITIALIZED_0)); 174 } 175 } 176 177 182 public String getGroupAdministrators() { 183 184 return m_groupAdministrators; 185 } 186 187 192 public String getGroupGuests() { 193 194 return m_groupGuests; 195 } 196 197 202 public String getGroupProjectmanagers() { 203 204 return m_groupProjectmanagers; 205 } 206 207 212 public String getGroupUsers() { 213 214 return m_groupUsers; 215 } 216 217 222 public String getUserAdmin() { 223 224 return m_userAdmin; 225 } 226 227 232 public String getUserExport() { 233 234 return m_userExport; 235 } 236 237 242 public String getUserGuest() { 243 244 return m_userGuest; 245 } 246 247 252 public String getUserDeletedResource() { 253 254 return m_userDeletedResource; 255 } 256 257 269 public boolean isDefaultGroup(String groupName) { 270 271 if (CmsStringUtil.isEmptyOrWhitespaceOnly(groupName)) { 272 return false; 273 } 274 275 return m_groupAdministrators.equals(groupName) 276 || m_groupProjectmanagers.equals(groupName) 277 || m_groupUsers.equals(groupName) 278 || m_groupGuests.equals(groupName); 279 } 280 281 294 public boolean isDefaultUser(String userName) { 295 296 if (CmsStringUtil.isEmptyOrWhitespaceOnly(userName)) { 297 return false; 298 } 299 300 return m_userAdmin.equals(userName) 301 || m_userGuest.equals(userName) 302 || m_userExport.equals(userName) 303 || m_userDeletedResource.equals(userName); 304 } 305 } | Popular Tags |