use of com.sun.identity.setup.ConfiguratorException in project OpenAM by OpenRock.
the class Wizard method createConfig.
/**
* This is the 'execute' operation for the entire wizard. This method
* aggregates all data submitted across the wizard pages here in one lump
* and hands it off to the back-end for processing.
*/
public boolean createConfig() {
HttpServletRequest req = getContext().getRequest();
HttpServletRequestWrapper request = new HttpServletRequestWrapper(getContext().getRequest());
HttpServletResponseWrapper response = new HttpServletResponseWrapper(getContext().getResponse());
initializeResourceBundle();
// User must have accepted license terms to reach this point
request.addParameter(SetupConstants.ACCEPT_LICENSE_PARAM, "true");
/*
* Get the admin password. use the same value for password and confirm
* value because they were validated in the input screen
*/
String adminPassword = (String) getContext().getSessionAttribute(SessionAttributeNames.CONFIG_VAR_ADMIN_PWD);
request.addParameter(SetupConstants.CONFIG_VAR_ADMIN_PWD, adminPassword);
request.addParameter(SetupConstants.CONFIG_VAR_CONFIRM_ADMIN_PWD, adminPassword);
/*
* Get the agent password. same value used for password and confirm
* because they were validated in the input screen.
*/
String agentPassword = (String) getContext().getSessionAttribute(SessionAttributeNames.CONFIG_VAR_AMLDAPUSERPASSWD);
request.addParameter(SetupConstants.CONFIG_VAR_AMLDAPUSERPASSWD, agentPassword);
request.addParameter(SetupConstants.CONFIG_VAR_AMLDAPUSERPASSWD_CONFIRM, agentPassword);
/*
* Set the data store information
*/
String tmp = getAttribute(SetupConstants.CONFIG_VAR_DATA_STORE, SetupConstants.SMS_EMBED_DATASTORE);
request.addParameter(SetupConstants.CONFIG_VAR_DATA_STORE, tmp);
boolean isEmbedded = false;
if (tmp.equals(SetupConstants.SMS_EMBED_DATASTORE)) {
tmp = getAttribute("configStoreHost", hostName);
request.addParameter(SetupConstants.CONFIG_VAR_DIRECTORY_SERVER_HOST, tmp);
request.addParameter(SetupConstants.CONFIG_VAR_DIRECTORY_SERVER_SSL, "SIMPLE");
tmp = getAttribute(SetupConstants.DS_EMB_REPL_FLAG, "false");
/*
* set the embedded replication information for local host port
* and remote host port
*/
isEmbedded = tmp.equals(SetupConstants.DS_EMP_REPL_FLAG_VAL);
if (isEmbedded) {
request.addParameter(SetupConstants.DS_EMB_REPL_FLAG, SetupConstants.DS_EMP_REPL_FLAG_VAL);
tmp = getAttribute("localRepPort", "");
request.addParameter(SetupConstants.DS_EMB_REPL_REPLPORT1, tmp);
tmp = getAttribute("existingHost", "");
request.addParameter(SetupConstants.DS_EMB_REPL_HOST2, tmp);
tmp = getAttribute("existingPort", "");
request.addParameter(SetupConstants.DS_EMB_REPL_ADMINPORT2, tmp);
tmp = getAttribute("existingRepPort", "");
request.addParameter(SetupConstants.DS_EMB_REPL_REPLPORT2, tmp);
tmp = getAttribute("existingserverid", "");
request.addParameter(SetupConstants.DS_EMB_EXISTING_SERVERID, tmp);
}
}
tmp = getAttribute("configStorePort", defaultPort);
request.addParameter(SetupConstants.CONFIG_VAR_DIRECTORY_SERVER_PORT, tmp);
tmp = getAttribute("configStoreAdminPort", defaultAdminPort);
request.addParameter(SetupConstants.CONFIG_VAR_DIRECTORY_ADMIN_SERVER_PORT, tmp);
tmp = getAttribute("configStoreJmxPort", defaultJmxPort);
request.addParameter(SetupConstants.CONFIG_VAR_DIRECTORY_JMX_SERVER_PORT, tmp);
tmp = getAttribute("rootSuffix", defaultRootSuffix);
request.addParameter(SetupConstants.CONFIG_VAR_ROOT_SUFFIX, tmp);
if (!isEmbedded) {
tmp = getAttribute("configStoreHost", hostName);
request.addParameter(SetupConstants.CONFIG_VAR_DIRECTORY_SERVER_HOST, tmp);
tmp = getAttribute("configStoreSSL", "SIMPLE");
request.addParameter(SetupConstants.CONFIG_VAR_DIRECTORY_SERVER_SSL, tmp);
}
tmp = getAttribute("configStoreLoginId", defaultUserName);
request.addParameter(SetupConstants.CONFIG_VAR_DS_MGR_DN, tmp);
tmp = getAttribute("configStorePassword", "");
request.addParameter(SetupConstants.CONFIG_VAR_DS_MGR_PWD, tmp);
// user store repository
tmp = (String) getContext().getSessionAttribute(SessionAttributeNames.EXT_DATA_STORE);
if ((tmp != null) && tmp.equals("true")) {
Map store = new HashMap(12);
tmp = (String) getContext().getSessionAttribute(SessionAttributeNames.USER_STORE_HOST);
store.put(SetupConstants.USER_STORE_HOST, tmp);
tmp = (String) getContext().getSessionAttribute(SessionAttributeNames.USER_STORE_SSL);
store.put(SetupConstants.USER_STORE_SSL, tmp);
tmp = (String) getContext().getSessionAttribute(SessionAttributeNames.USER_STORE_PORT);
store.put(SetupConstants.USER_STORE_PORT, tmp);
tmp = (String) getContext().getSessionAttribute(SessionAttributeNames.USER_STORE_ROOT_SUFFIX);
store.put(SetupConstants.USER_STORE_ROOT_SUFFIX, tmp);
tmp = (String) getContext().getSessionAttribute(SessionAttributeNames.USER_STORE_LOGIN_ID);
store.put(SetupConstants.USER_STORE_LOGIN_ID, tmp);
tmp = (String) getContext().getSessionAttribute(SessionAttributeNames.USER_STORE_LOGIN_PWD);
store.put(SetupConstants.USER_STORE_LOGIN_PWD, tmp);
tmp = (String) getContext().getSessionAttribute(SessionAttributeNames.USER_STORE_TYPE);
store.put(SetupConstants.USER_STORE_TYPE, tmp);
request.addParameter("UserStore", store);
}
// site configuration is passed as a map of the site information
Map siteConfig = new HashMap(3);
String loadBalancerHost = (String) getContext().getSessionAttribute(SessionAttributeNames.LB_SITE_NAME);
String primaryURL = (String) getContext().getSessionAttribute(SessionAttributeNames.LB_PRIMARY_URL);
// Assume no Session HA Failover.
Boolean isSessionHASFOEnabled = false;
if (getContext().getSessionAttribute(SessionAttributeNames.LB_SESSION_HA_SFO) != null) {
isSessionHASFOEnabled = Boolean.valueOf((Boolean) getContext().getSessionAttribute(SessionAttributeNames.LB_SESSION_HA_SFO));
}
if (loadBalancerHost != null) {
siteConfig.put(SetupConstants.LB_SITE_NAME, loadBalancerHost);
siteConfig.put(SetupConstants.LB_PRIMARY_URL, primaryURL);
siteConfig.put(SetupConstants.LB_SESSION_HA_SFO, isSessionHASFOEnabled.toString());
request.addParameter(SetupConstants.CONFIG_VAR_SITE_CONFIGURATION, siteConfig);
}
// server properties
String serverUrl = (String) getContext().getSessionAttribute(SessionAttributeNames.SERVER_URL);
String serverHost;
int serverPort;
if (serverUrl == null) {
serverUrl = req.getRequestURL().toString();
serverHost = getHostName();
serverPort = req.getServerPort();
} else {
serverHost = getHostName(serverUrl, getHostName());
serverPort = getServerPort(serverUrl, req.getServerPort());
}
request.addParameter(SetupConstants.CONFIG_VAR_SERVER_HOST, serverHost);
request.addParameter(SetupConstants.CONFIG_VAR_SERVER_PORT, serverPort);
request.addParameter(SetupConstants.CONFIG_VAR_SERVER_URI, req.getRequestURL().toString());
request.addParameter(SetupConstants.CONFIG_VAR_SERVER_URL, getAttribute("serverURL", serverUrl));
tmp = (String) getContext().getSessionAttribute(SessionAttributeNames.ENCRYPTION_KEY);
if (tmp == null) {
tmp = AMSetupUtils.getRandomString();
}
request.addParameter(SetupConstants.CONFIG_VAR_ENCRYPTION_KEY, tmp);
tmp = (String) getContext().getSessionAttribute(SessionAttributeNames.ENCLDAPUSERPASSWD);
if (tmp != null) {
request.addParameter(SetupConstants.ENCRYPTED_LDAP_USER_PWD, tmp);
}
String cookie = (String) getContext().getSessionAttribute(SessionAttributeNames.COOKIE_DOMAIN);
if (cookie == null) {
cookie = getCookieDomain();
}
request.addParameter(SetupConstants.CONFIG_VAR_COOKIE_DOMAIN, cookie);
String locale = (String) getContext().getSessionAttribute(SessionAttributeNames.PLATFORM_LOCALE);
if (locale == null) {
locale = SetupConstants.DEFAULT_PLATFORM_LOCALE;
}
request.addParameter(SetupConstants.CONFIG_VAR_PLATFORM_LOCALE, locale);
String base = (String) getContext().getSessionAttribute(SessionAttributeNames.CONFIG_DIR);
if (base == null) {
base = getBaseDir(getContext().getRequest());
}
request.addParameter(SetupConstants.CONFIG_VAR_BASE_DIR, base);
request.addParameter("locale", configLocale.toString());
try {
if (AMSetupServlet.processRequest(request, response)) {
writeToResponse("true");
} else {
writeToResponse(AMSetupServlet.getErrorMessage());
}
} catch (ConfiguratorException cfe) {
writeToResponse(cfe.getMessage());
}
setPath(null);
return false;
}
use of com.sun.identity.setup.ConfiguratorException in project OpenAM by OpenRock.
the class Step3 method validateHostName.
/*
* a call is made to the OpenAM url entered in the browser. If
* the OpenAM server
* exists a <code>Map</code> of data will be returned which contains the
* information about the existing servers data store, including any
* replication ports if its embedded.
* Information to control the UI is returned in a JSON object of the form
* {
* "param1" : "value1",
* "param2" : "value2"
* }
* The JS on the browser will interpret the above and make the necessary
* changes to prompt the user for any more details required.
*/
public boolean validateHostName() {
StringBuffer sb = new StringBuffer();
String hostName = toString("hostName");
if (hostName == null) {
addObject(sb, "code", "100");
addObject(sb, "message", getLocalizedString("missing.required.field"));
} else {
// try to retrieve the remote OpenAM information
String admin = "amadmin";
String password = (String) getContext().getSessionAttribute(SessionAttributeNames.CONFIG_VAR_ADMIN_PWD);
try {
String dsType;
Map data = AMSetupUtils.getRemoteServerInfo(hostName, admin, password);
// data returned from existing OpenAM server
if (data != null && !data.isEmpty()) {
addObject(sb, "code", "100");
addObject(sb, "message", getLocalizedString("ok.string"));
setupDSParams(data);
String key = (String) data.get("enckey");
getContext().setSessionAttribute(SessionAttributeNames.ENCRYPTION_KEY, key);
getContext().setSessionAttribute(SessionAttributeNames.ENCLDAPUSERPASSWD, (String) data.get("ENCLDAPUSERPASSWD"));
// true for embedded, false for ODSEE
String embedded = (String) data.get(BootstrapData.DS_ISEMBEDDED);
addObject(sb, "embedded", embedded);
String host = (String) data.get(BootstrapData.DS_HOST);
if (embedded.equals("true")) {
getContext().setSessionAttribute(SessionAttributeNames.CONFIG_STORE_HOST, getHostName());
addObject(sb, "configStoreHost", getHostName());
// set the multi embedded flag
getContext().setSessionAttribute(SessionAttributeNames.CONFIG_VAR_DATA_STORE, SetupConstants.SMS_EMBED_DATASTORE);
getContext().setSessionAttribute(SessionAttributeNames.DS_EMB_REPL_FLAG, SetupConstants.DS_EMP_REPL_FLAG_VAL);
// get the existing replication ports if any
String replAvailable = (String) data.get(BootstrapData.DS_REPLICATIONPORT_AVAILABLE);
if (replAvailable == null) {
replAvailable = "false";
}
addObject(sb, "replication", replAvailable);
String existingRep = (String) data.get(BootstrapData.DS_REPLICATIONPORT);
getContext().setSessionAttribute(SessionAttributeNames.EXISTING_REPL_PORT, existingRep);
addObject(sb, "replicationPort", existingRep);
String existingServerid = (String) data.get("existingserverid");
getContext().setSessionAttribute(SessionAttributeNames.EXISTING_SERVER_ID, existingServerid);
addObject(sb, "existingserverid", existingServerid);
// dsmgr password is same as amadmin for embedded
getContext().setSessionAttribute(SessionAttributeNames.CONFIG_STORE_PWD, password);
} else {
getContext().setSessionAttribute(SessionAttributeNames.CONFIG_STORE_PORT, (String) data.get(BootstrapData.DS_PORT));
getContext().setSessionAttribute(SessionAttributeNames.CONFIG_STORE_HOST, host);
addObject(sb, "configStoreHost", host);
String dsprot = (String) data.get(BootstrapData.DS_PROTOCOL);
String dsSSL = ("ldaps".equals(dsprot)) ? "SSL" : "SIMPLE";
getContext().setSessionAttribute(SessionAttributeNames.CONFIG_STORE_SSL, dsSSL);
addObject(sb, "configStoreSSL", dsSSL);
String dspwd = (String) data.get(BootstrapData.DS_PWD);
getContext().setSessionAttribute(SessionAttributeNames.CONFIG_STORE_PWD, Crypt.decode(dspwd, Crypt.getHardcodedKeyEncryptor()));
}
// set the replication ports pulled from the remote
// server in the session and pass back to the client
String existing = (String) data.get(SetupConstants.DS_EMB_REPL_ADMINPORT2);
getContext().setSessionAttribute(SessionAttributeNames.EXISTING_PORT, existing);
addObject(sb, "existingPort", existing);
// set the configuration store port
String ds_existingStorePort = (String) data.get(BootstrapData.DS_PORT);
getContext().setSessionAttribute(SessionAttributeNames.EXISTING_STORE_PORT, ds_existingStorePort);
addObject(sb, "existingStorePort", ds_existingStorePort);
getContext().setSessionAttribute(SessionAttributeNames.EXISTING_HOST, host);
// set the configuration store host
getContext().setSessionAttribute(SessionAttributeNames.EXISTING_STORE_HOST, host);
addObject(sb, "existingStoreHost", host);
// set the configuration store port
getContext().setSessionAttribute(SessionAttributeNames.LOCAL_REPL_PORT, localRepPort);
}
} catch (ConfigurationException c) {
String code = c.getErrorCode();
String message = getLocalizedString(code);
if (code == null) {
code = "999";
message = c.getMessage();
}
addObject(sb, "code", code);
addObject(sb, "message", message);
} catch (ConfiguratorException c) {
String code = c.getErrorCode();
String message = getLocalizedString(code);
if (code == null) {
code = "999";
message = c.getMessage();
}
addObject(sb, "code", code);
addObject(sb, "message", message);
}
}
sb.append(" }");
writeToResponse(sb.toString());
setPath(null);
return false;
}
use of com.sun.identity.setup.ConfiguratorException in project OpenAM by OpenRock.
the class ServerConfigMgr method main.
public static void main(String[] args) {
try {
Bootstrap.load();
if (VersionCheck.isVersionValid() == 1) {
System.exit(1);
}
debug = Debug.getInstance(IUMSConstants.UMS_DEBUG);
validateArguments(args);
boolean proceeded = printHelpMessage(args) || encryptPassword(args) || changePassword(args);
} catch (ConfiguratorException ex) {
System.err.println(ex.getL10NMessage(Locale.getDefault()));
System.exit(1);
} catch (Exception ex) {
System.err.println(ex.getMessage());
System.exit(1);
} finally {
ShutdownManager shutdownMan = com.sun.identity.common.ShutdownManager.getInstance();
shutdownMan.shutdown();
}
}
Aggregations