1 13 14 package org.ejbca.core.model.ra.raadmin; 15 16 17 18 import org.ejbca.core.model.UpgradeableDataHashMap; 19 20 21 26 public class GlobalConfiguration extends UpgradeableDataHashMap implements java.io.Serializable { 27 28 public static final float LATEST_VERSION = 1; 30 31 public static final String EJBCA_VERSION = "@ejbca.version@"; 32 33 37 public static final boolean HARDTOKEN_DIPLAYSENSITIVEINFO = "@hardtoken.diplaysensitiveinfo@".equalsIgnoreCase("true"); 38 39 public static final String PREFEREDINTERNALRESOURCES = "@intresources.preferredlanguage@".trim(); 40 public static final String SECONDARYINTERNALRESOURCES = "@intresources.secondarylanguage@".trim(); 41 42 private final String [] DEFAULTPOSSIBLEENTRIESPERPAGE = {"10" , "25" , "50" , "100"}; 44 private final String [] DEFAULTPOSSIBLELOGENTRIESPERPAGE = {"10" , "25" , "50" , "100", "200", "400"}; 46 47 private static final String DEFAULTCRLDISTURIPATH = "publicweb/webdist/certdist?cmd=crl&issuer="; 49 50 private static final String DEFAULTCRLDISTURIPATHDN = "CN=TestCA,O=AnaTom,C=SE"; 52 53 54 private static final String DEFAULTOCSPSERVICELOCATORURIPATH = "publicweb/status/ocsp"; 56 57 private static final String DEFAULTHEADBANNER = "head_banner.jsp"; 59 private static final String DEFAULTFOOTBANNER = "foot_banner.jsp"; 61 62 private static final String DEFAULTEJBCATITLE = "@EJBCA@ Administration"; 64 65 public static final int EN = 0; 67 public static final int SE = 1; 68 69 public static final String HEADERFRAME = "topFrame"; public static final String MENUFRAME = "leftFrame"; public static final String MAINFRAME = "mainFrame"; 74 75 76 public GlobalConfiguration() { 77 super(); 78 79 setEjbcaTitle(DEFAULTEJBCATITLE); 80 setEnableEndEntityProfileLimitations(true); 81 setEnableAuthenticatedUsersOnly(false); 82 setEnableKeyRecovery(false); 83 setIssueHardwareTokens(false); 84 } 85 86 87 88 public void initialize(String adminpath, String availablelanguages, String availablethemes, 89 String publicport, String privateport, String publicprotocol, String privateprotocol){ 90 91 String tempadminpath = adminpath.trim(); 92 93 94 if(tempadminpath == null) 95 tempadminpath = ""; 96 if(!tempadminpath.endsWith("/") && !tempadminpath.equals("")){ 97 tempadminpath = tempadminpath + "/"; } 99 if(tempadminpath.startsWith("/")){ 100 tempadminpath =tempadminpath.substring(1); } 102 103 104 105 data.put(ADMINPATH,tempadminpath); 106 data.put(AVAILABLELANGUAGES,availablelanguages.trim()); 107 data.put(AVAILABLETHEMES,availablethemes.trim()); 108 data.put(PUBLICPORT,publicport.trim()); 109 data.put(PRIVATEPORT,privateport.trim()); 110 data.put(PUBLICPROTOCOL,publicprotocol.trim()); 111 data.put(PRIVATEPROTOCOL,privateprotocol.trim()); 112 113 data.put(AUTHORIZATION_PATH,tempadminpath+"administratorprivileges"); 114 data.put(BANNERS_PATH,"banners"); 115 data.put(CA_PATH, tempadminpath+"ca"); 116 data.put(CONFIG_PATH,tempadminpath+"sysconfig"); 117 data.put(HELP_PATH,"help"); 118 data.put(IMAGES_PATH,"images"); 119 data.put(LANGUAGE_PATH,"languages"); 120 data.put(LOG_PATH,tempadminpath+"log"); 121 data.put(RA_PATH,tempadminpath+"ra"); 122 data.put(THEME_PATH,"themes"); 123 data.put(HARDTOKEN_PATH,tempadminpath+"hardtoken"); 124 125 data.put(LANGUAGEFILENAME,"languagefile"); 126 data.put(MAINFILENAME,"main.jsp"); 127 data.put(INDEXFILENAME,"index.jsp"); 128 data.put(MENUFILENAME,"adminmenu.jsp"); 129 data.put(ERRORPAGE,"errorpage.jsp"); 130 131 setHeadBanner(DEFAULTHEADBANNER); 132 setFootBanner(DEFAULTFOOTBANNER); 133 134 } 135 136 137 public boolean isInitialized(){ 138 return data.get(AVAILABLELANGUAGES)!=null; 139 } 140 141 142 public String getBaseUrl(String requestServerName) { 143 return (String ) data.get(GlobalConfiguration.PRIVATEPROTOCOL) + "://" + 144 requestServerName + "/" + 145 (String ) data.get(GlobalConfiguration.APPLICATIONPATH); 146 } 147 148 public String getBaseUrl() { 149 return (String ) data.get(GlobalConfiguration.PRIVATEPROTOCOL) + "://" + 150 (String ) data.get(GlobalConfiguration.COMPUTERNAME) + ":" + 151 (String ) data.get(GlobalConfiguration.PRIVATEPORT) + "/" + 152 (String ) data.get(GlobalConfiguration.APPLICATIONPATH); 153 } 154 155 156 157 public void setComputerName(String computername){ 158 data.put(COMPUTERNAME, computername); 159 } 160 161 public void setApplicationPath(String applicationpath){ 162 if(!applicationpath.endsWith("/")){ 164 data.put(APPLICATIONPATH,applicationpath + "/"); 165 } 166 else{ 167 data.put(APPLICATIONPATH,applicationpath); 168 } 169 } 170 171 172 173 public String getAdminWebPath(){return (String ) data.get(ADMINPATH);} 174 175 public String getStandardCRLDistributionPointURI(){ 176 String retval = getBaseUrl(); 177 retval =retval.replaceFirst((String ) data.get(PRIVATEPROTOCOL), (String ) data.get(PUBLICPROTOCOL)); 178 retval =retval.replaceFirst((String ) data.get(PRIVATEPORT), (String ) data.get(PUBLICPORT)); 179 retval+= DEFAULTCRLDISTURIPATH + DEFAULTCRLDISTURIPATHDN; 180 return retval; 181 } 182 183 public String getStandardCRLDistributionPointURINoDN(){ 184 String retval = getBaseUrl(); 185 retval =retval.replaceFirst((String ) data.get(PRIVATEPROTOCOL), (String ) data.get(PUBLICPROTOCOL)); 186 retval =retval.replaceFirst((String ) data.get(PRIVATEPORT), (String ) data.get(PUBLICPORT)); 187 retval+= DEFAULTCRLDISTURIPATH; 188 return retval; 189 } 190 191 public String getStandardOCSPServiceLocatorURI(){ 192 String retval = getBaseUrl(); 193 retval =retval.replaceFirst((String ) data.get(PRIVATEPROTOCOL), (String ) data.get(PUBLICPROTOCOL)); 194 retval =retval.replaceFirst((String ) data.get(PRIVATEPORT), (String ) data.get(PUBLICPORT)); 195 retval+= DEFAULTOCSPSERVICELOCATORURIPATH; 196 return retval; 197 } 198 199 201 public String [] getAvailableThemes() { 202 String [] availablethemes; 203 availablethemes = getAvailableThemesAsString().split(","); 204 if(availablethemes != null){ 205 for(int i = 0; i < availablethemes.length; i++){ 206 availablethemes[i] = availablethemes[i].trim(); 207 if(availablethemes[i].endsWith(".css")){ 208 availablethemes[i] = availablethemes[i].substring(0,availablethemes[i].length()-4); 209 } 210 } 211 } 212 return availablethemes; 213 } 214 215 216 public String getDefaultAvailableTheme(){ 217 return getAvailableThemes()[0]; 218 } 219 220 221 222 public String getHeadBanner() {return (String ) data.get(HEADBANNER);} 224 public String getHeadBannerFilename(){ 225 String returnval = (String ) data.get(HEADBANNER); 226 return returnval.substring(returnval.lastIndexOf('/')+1); 227 } 228 public void setHeadBanner(String head){ 229 data.put(HEADBANNER, ((String ) data.get(ADMINPATH)) + ((String ) data.get(BANNERS_PATH)) + "/" + head); 230 } 231 232 233 public String getFootBanner() {return (String ) data.get(FOOTBANNER);} 235 public String getFootBannerFilename(){ 236 String returnval = (String ) data.get(FOOTBANNER); 237 return returnval.substring(returnval.lastIndexOf('/')+1); 238 } 239 public void setFootBanner(String foot){ 240 data.put(FOOTBANNER, "/" + ((String ) data.get(BANNERS_PATH)) + "/" +foot); 241 } 242 243 public String getEjbcaTitle() {return (String ) data.get(TITLE);} 245 public void setEjbcaTitle(String ejbcatitle) {data.put(TITLE,ejbcatitle);} 246 247 248 public String getAuthorizationPath() {return (String ) data.get(AUTHORIZATION_PATH);} 249 public String getBannersPath() {return (String ) data.get(BANNERS_PATH);} 250 public String getCaPath() {return (String ) data.get(CA_PATH);} 251 public String getConfigPath() {return (String ) data.get(CONFIG_PATH);} 252 public String getHelpPath() {return (String ) data.get(HELP_PATH);} 253 public String getImagesPath() {return (String ) data.get(IMAGES_PATH);} 254 public String getLanguagePath() {return (String ) data.get(LANGUAGE_PATH);} 255 public String getLogPath() {return (String ) data.get(LOG_PATH);} 256 public String getRaPath() {return (String ) data.get(RA_PATH);} 257 public String getThemePath() {return (String ) data.get(THEME_PATH);} 258 public String getHardTokenPath() {return (String ) data.get(HARDTOKEN_PATH);} 259 260 public String getLanguageFilename(){return (String ) data.get(LANGUAGEFILENAME);} 261 public String getMainFilename(){return (String ) data.get(MAINFILENAME);} 262 public String getIndexFilename(){return (String ) data.get(INDEXFILENAME);} 263 public String getMenuFilename(){return (String ) data.get(MENUFILENAME);} 264 public String getErrorPage(){return (String ) data.get(ERRORPAGE);} 265 266 public String [] getPossibleEntiresPerPage(){return DEFAULTPOSSIBLEENTRIESPERPAGE;} 267 public String [] getPossibleLogEntiresPerPage(){return DEFAULTPOSSIBLELOGENTRIESPERPAGE;} 268 269 public String getAvailableLanguagesAsString(){return (String ) data.get(AVAILABLELANGUAGES);} 270 public String getAvailableThemesAsString(){return (String ) data.get(AVAILABLETHEMES);} 271 272 public boolean getEnableEndEntityProfileLimitations(){return ((Boolean ) data.get(ENABLEEEPROFILELIMITATIONS)).booleanValue();} 273 public void setEnableEndEntityProfileLimitations(boolean value){ data.put(ENABLEEEPROFILELIMITATIONS, Boolean.valueOf(value));} 274 275 public boolean getEnableAuthenticatedUsersOnly(){return ((Boolean ) data.get(ENABLEAUTHENTICATEDUSERSONLY)).booleanValue();} 276 public void setEnableAuthenticatedUsersOnly(boolean value){ data.put(ENABLEAUTHENTICATEDUSERSONLY, Boolean.valueOf(value));} 277 278 public boolean getEnableKeyRecovery(){return ((Boolean ) data.get(ENABLEKEYRECOVERY)).booleanValue();} 279 public void setEnableKeyRecovery(boolean value){ data.put(ENABLEKEYRECOVERY, Boolean.valueOf(value));} 280 281 public boolean getIssueHardwareTokens(){return ((Boolean ) data.get(ISSUEHARDWARETOKENS)).booleanValue();} 282 public void setIssueHardwareTokens(boolean value){ data.put(ISSUEHARDWARETOKENS, Boolean.valueOf(value));} 283 284 287 public int getNumberOfApprovalsToViewPUK(){ 288 Object num = data.get(NUMBEROFAPPROVALSTOVIEWPUK); 289 if(num == null){ 290 return 0; 291 } 292 293 return ((Integer ) num).intValue(); 294 } 295 296 public void setNumberOfApprovalsToViewPUK(int numberOfHardTokenApprovals){ 297 data.put(NUMBEROFAPPROVALSTOVIEWPUK, new Integer (numberOfHardTokenApprovals)); 298 } 299 300 303 public boolean getUseApprovalNotifications(){ 304 Object value = data.get(USEAPPROVALNOTIFICATIONS); 305 if(value == null){ 306 return false; 307 } 308 309 return ((Boolean ) value).booleanValue(); 310 } 311 312 public void setUseApprovalNotifications(boolean useApprovalNotifications){ 313 data.put(USEAPPROVALNOTIFICATIONS, Boolean.valueOf(useApprovalNotifications)); 314 } 315 316 320 public String getApprovalAdminEmailAddress(){ 321 Object value = data.get(APPROVALADMINEMAILADDRESS); 322 if(value == null){ 323 return ""; 324 } 325 326 return (String ) value; 327 } 328 329 public void setApprovalAdminEmailAddress(String approvalAdminEmailAddress){ 330 data.put(APPROVALADMINEMAILADDRESS, approvalAdminEmailAddress); 331 } 332 333 336 public String getApprovalNotificationFromAddress(){ 337 Object value = data.get(APPROVALNOTIFICATIONFROMADDR); 338 if(value == null){ 339 return ""; 340 } 341 342 return (String ) value; 343 } 344 345 public void setApprovalNotificationFromAddress(String approvalNotificationFromAddress){ 346 data.put(APPROVALNOTIFICATIONFROMADDR, approvalNotificationFromAddress); 347 } 348 349 350 351 public float getLatestVersion(){ 352 return LATEST_VERSION; 353 } 354 355 356 357 public void upgrade(){ 358 if(Float.compare(LATEST_VERSION, getVersion()) != 0) { 359 if(data.get(HARDTOKEN_PATH) == null){ 361 data.put(HARDTOKEN_PATH, ((String ) data.get(ADMINPATH) + "hardtoken")); 362 } 363 364 data.put(VERSION, new Float (LATEST_VERSION)); 365 } 366 } 367 368 370 private static final String COMPUTERNAME = "computername"; 373 private static final String APPLICATIONPATH = "applicationpath"; 374 private static final String ADMINPATH = "raadminpath"; 375 private static final String AVAILABLELANGUAGES = "availablelanguages"; 376 private static final String AVAILABLETHEMES = "availablethemes"; 377 private static final String PUBLICPORT = "publicport"; 378 private static final String PRIVATEPORT = "privateport"; 379 private static final String PUBLICPROTOCOL = "publicprotocol"; 380 private static final String PRIVATEPROTOCOL = "privateprotocol"; 381 382 383 private static final String TITLE = "title"; 385 private static final String HEADBANNER = "headbanner"; 387 private static final String FOOTBANNER = "footbanner"; 388 private static final String ENABLEEEPROFILELIMITATIONS = "endentityprofilelimitations"; 390 private static final String ENABLEAUTHENTICATEDUSERSONLY = "authenticatedusersonly"; 391 private static final String ENABLEKEYRECOVERY = "enablekeyrecovery"; 392 private static final String ISSUEHARDWARETOKENS = "issuehardwaretokens"; 393 394 private static final String NUMBEROFAPPROVALSTOVIEWPUK = "numberofapprovalstoviewpuk"; 395 private static final String USEAPPROVALNOTIFICATIONS = "useapprovalnotifications"; 396 private static final String APPROVALADMINEMAILADDRESS = "approvaladminemailaddress"; 397 private static final String APPROVALNOTIFICATIONFROMADDR = "approvalnotificationfromaddr"; 398 399 400 401 private static final String AUTHORIZATION_PATH = "authorization_path"; 403 private static final String BANNERS_PATH = "banners_path"; 404 private static final String CA_PATH = "ca_path"; 405 private static final String CONFIG_PATH = "data_path"; 406 private static final String HELP_PATH = "help_path"; 407 private static final String IMAGES_PATH = "images_path"; 408 private static final String LANGUAGE_PATH = "language_path"; 409 private static final String LOG_PATH = "log_path"; 410 private static final String RA_PATH = "ra_path"; 411 private static final String THEME_PATH = "theme_path"; 412 private static final String HARDTOKEN_PATH = "hardtoken_path"; 413 414 private static final String LANGUAGEFILENAME = "languagefilename"; 415 private static final String MAINFILENAME = "mainfilename"; 416 private static final String INDEXFILENAME = "indexfilename"; 417 private static final String MENUFILENAME = "menufilename"; 418 private static final String ERRORPAGE = "errorpage"; 419 420 } 421 | Popular Tags |