use of java.util.ResourceBundle in project OpenAM by OpenRock.
the class Main method main.
public static void main(String[] args) {
ResourceBundle bundle = ResourceBundle.getBundle(System.getProperty(SETUP_PROPERTIES_FILE, DEFAULT_PROPERTIES_FILE));
if ((System.getProperty(PRINT_HELP) != null) && System.getProperty(PRINT_HELP).equals(YES)) {
SetupUtils.printUsage(bundle);
System.exit(0);
}
if (System.getProperty(CHECK_VERSION) != null) {
if (System.getProperty(CHECK_VERSION).equals(YES)) {
System.exit(VersionCheck.isValid());
}
}
boolean acceptLicense = false;
for (String arg : args) {
if (arg.equals(ACCEPT_LICENSE)) {
acceptLicense = true;
break;
}
}
try {
LICENSE_PRESENTER.presentLicenses(acceptLicense);
} catch (LicenseRejectedException e) {
System.out.println(bundle.getString("message.error.license"));
System.exit(0);
}
boolean loadConfig = (System.getProperty(CONFIG_LOAD) != null) && System.getProperty(CONFIG_LOAD).equals(YES);
String currentOS = SetupUtils.determineOS();
Properties configProp = null;
String debugPath = null;
String logPath = null;
if (loadConfig) {
String configPath = System.getProperty(AMCONFIG_PATH);
debugPath = System.getProperty(DEBUG_PATH);
logPath = System.getProperty(LOG_PATH);
String currentDir = System.getProperty("user.dir");
try {
if ((configPath == null) || (configPath.length() == 0)) {
configPath = SetupUtils.getUserInput(bundle.getString(currentOS + QUESTION), System.getProperty("user.home") + File.separator + "openam");
if (!(new File(configPath).isAbsolute())) {
System.out.println(bundle.getString("message.error.dir.absolute"));
System.exit(1);
}
if ((debugPath == null) || (debugPath.length() == 0)) {
debugPath = SetupUtils.getUserInput(bundle.getString(currentOS + ".debug.dir"), currentDir + File.separator + "debug");
}
if (!(new File(debugPath).isAbsolute())) {
System.out.println(bundle.getString("message.error.dir.absolute"));
System.exit(1);
}
if (!isWriteable(debugPath)) {
System.out.println(bundle.getString("message.error.debug.dir.not.writable"));
System.exit(1);
}
if ((logPath == null) || (logPath.length() == 0)) {
logPath = SetupUtils.getUserInput(bundle.getString(currentOS + ".log.dir"), currentDir + File.separator + "log");
}
if (!(new File(logPath).isAbsolute())) {
System.out.println(bundle.getString("message.error.dir.absolute"));
System.exit(1);
}
if (!isWriteable(logPath)) {
System.out.println(bundle.getString("message.error.log.dir.not.writable"));
System.exit(1);
}
} else {
String toolsHome = new File(".").getCanonicalPath();
toolsHome = toolsHome.replaceAll("\\\\", "/");
if ((debugPath == null) || (debugPath.length() == 0)) {
debugPath = toolsHome + "/debug";
}
if ((logPath == null) || (logPath.length() == 0)) {
logPath = toolsHome + "/log";
}
}
configProp = Bootstrap.load(configPath, false);
if (configProp == null) {
System.out.println(bundle.getString("message.error.dir"));
System.exit(1);
}
File path = new File(debugPath);
boolean created = path.exists() || path.mkdirs();
if (!created) {
System.out.println(bundle.getString("message.error.debug.dir.not.writable"));
System.exit(1);
}
path = new File(logPath);
created = path.exists() || path.mkdirs();
if (!created) {
System.out.println(bundle.getString("message.error.log.dir.not.writable"));
System.exit(1);
}
if (!configPath.endsWith(FILE_SEPARATOR)) {
configPath = configPath + FILE_SEPARATOR;
}
configProp.setProperty(USER_INPUT, configPath.substring(0, configPath.length() - 1));
configProp.setProperty("LogDir", logPath);
configProp.setProperty("DebugDir", debugPath);
configProp.setProperty(CURRENT_PLATFORM, currentOS);
} catch (Exception ex) {
System.out.println(ex.getMessage());
System.exit(1);
}
} else {
configProp = new Properties();
}
SetupUtils.evaluateBundleValues(bundle, configProp);
try {
SetupUtils.copyAndFilterScripts(bundle, configProp);
if (loadConfig) {
Object[] p = { debugPath };
System.out.println(MessageFormat.format(bundle.getString("message.info.debug.dir"), p));
p[0] = logPath;
System.out.println(MessageFormat.format(bundle.getString("message.info.log.dir"), p));
System.out.println(bundle.getString("message.info.version.tools") + " " + bundle.getString(TOOLS_VERSION));
System.out.println(bundle.getString("message.info.version.am") + " " + SystemProperties.get("com.iplanet.am.version"));
}
} catch (IOException ex) {
System.out.println(bundle.getString("message.error.copy"));
System.exit(1);
}
System.exit(0);
}
use of java.util.ResourceBundle in project OpenAM by OpenRock.
the class ServerConfiguration method getNewServerDefaults.
public static Map<String, String> getNewServerDefaults(SSOToken ssoToken) throws SMSException, SSOException {
boolean bCreated = false;
ServiceConfig sc = getRootServerConfig(ssoToken);
try {
bCreated = (sc.getSubConfig(DEFAULT_SERVER_CONFIG) != null);
} catch (SMSException smse) {
// ignore, default is not created.
}
if (bCreated) {
ResourceBundle res = ResourceBundle.getBundle(SERVER_DEFAULTS);
Map<String, String> newValues = new HashMap<String, String>();
for (Enumeration<String> i = res.getKeys(); i.hasMoreElements(); ) {
String key = i.nextElement();
String val = res.getString(key);
if (val.equals("@" + SetupConstants.CONFIG_VAR_PLATFORM_LOCALE + "@")) {
val = Locale.getDefault().toString();
}
newValues.put(key, val);
}
newValues.put(Constants.PROPERTY_NAME_LB_COOKIE_VALUE, DEFAULT_SERVER_ID);
return newValues;
} else {
return Collections.EMPTY_MAP;
}
}
use of java.util.ResourceBundle in project OpenAM by OpenRock.
the class AMModelBase method getServiceResourceBundle.
protected ResourceBundle getServiceResourceBundle(String serviceName) {
ResourceBundle rb = null;
try {
ServiceSchemaManager mgr = new ServiceSchemaManager(serviceName, ssoToken);
String rbName = mgr.getI18NFileName();
if ((rbName != null) && (rbName.trim().length() > 0)) {
rb = AMResBundleCacher.getBundle(rbName, locale);
}
} catch (SSOException e) {
debug.warning("AMModelBase.getServiceResourceBundle", e);
} catch (SMSException e) {
debug.warning("AMModelBase.getServiceResourceBundle", e);
}
return rb;
}
use of java.util.ResourceBundle in project OpenAM by OpenRock.
the class PolicyModelImpl method getSvcTypeNameToActionsMap.
private Map getSvcTypeNameToActionsMap(Policy policy, String realmName) {
if (mapSvcTypeNameToActions == null) {
try {
Set serviceTypeNames = getServiceTypeNames().keySet();
int sz = serviceTypeNames.size();
mapSvcTypeNameToActions = new HashMap(sz * 2);
mapSvcTypeNameToResBundle = new HashMap(sz * 2);
ServiceTypeManager mgr = getServiceTypeManager();
for (Iterator i = serviceTypeNames.iterator(); i.hasNext(); ) {
String serviceTypeName = (String) i.next();
ServiceType serviceType = mgr.getServiceType(serviceTypeName);
if (serviceType != null) {
ResourceBundle rb = getResourceBundle(serviceType, getUserLocale());
if (rb != null) {
mapSvcTypeNameToResBundle.put(serviceTypeName, rb);
Set as = getActionSchemas(serviceType);
filterActionSchemaWithI18nKey(as);
if ((as != null) && !as.isEmpty()) {
mapSvcTypeNameToActions.put(serviceTypeName, as);
if (requiresResourceName(policy, realmName, serviceTypeName, as, true)) {
requiredResourceNameService.add(serviceTypeName);
}
if (requiresResourceName(policy, realmName, serviceTypeName, as, false)) {
notRequiredResourceNameService.add(serviceTypeName);
}
}
}
}
}
} catch (AMConsoleException e) {
debug.warning("PolicyModelImppl.getSvcTypeNameToActionsMap", e);
} catch (SSOException e) {
debug.warning("PolicyModelImppl.getSvcTypeNameToActionsMap", e);
} catch (NameNotFoundException e) {
debug.warning("PolicyModelImppl.getSvcTypeNameToActionsMap", e);
}
}
return mapSvcTypeNameToActions;
}
use of java.util.ResourceBundle in project OpenAM by OpenRock.
the class LoginLogoutMapping method init.
/**
* Initializes the servlet.
*
* @param servletCtx servlet config
* @throws ServletException if it fails to get servlet context.
*/
public void init(ServletContext servletCtx) throws ServletException {
if (isProductInitialize) {
boolean initialized = initializeAuth(servletCtx);
if (!initialized) {
Locale locale = java.util.Locale.getDefault();
ResourceBundle rb = ResourceBundle.getBundle(bundleName, locale);
throw new ServletException(rb.getString(CANNOT_INIT_AUTH));
}
}
}
Aggregations