use of com.sun.identity.setup.HttpServletRequestWrapper 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.HttpServletRequestWrapper in project OpenAM by OpenRock.
the class DefaultSummary method createDefaultConfig.
public boolean createDefaultConfig() {
HttpServletRequest req = getContext().getRequest();
HttpServletRequestWrapper request = new HttpServletRequestWrapper(getContext().getRequest());
HttpServletResponseWrapper response = new HttpServletResponseWrapper(getContext().getResponse());
// License terms must have been accepted to reach this point
request.addParameter(SetupConstants.ACCEPT_LICENSE_PARAM, "true");
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);
String agentPassword = (String) getContext().getSessionAttribute(SessionAttributeNames.CONFIG_VAR_AMLDAPUSERPASSWD);
request.addParameter(SetupConstants.CONFIG_VAR_AMLDAPUSERPASSWD, agentPassword);
request.addParameter(SetupConstants.CONFIG_VAR_AMLDAPUSERPASSWD_CONFIRM, agentPassword);
request.addParameter(SetupConstants.CONFIG_VAR_DIRECTORY_SERVER_SSL, "SIMPLE");
request.addParameter(SetupConstants.CONFIG_VAR_DIRECTORY_SERVER_HOST, getHostName());
request.addParameter(SetupConstants.CONFIG_VAR_DIRECTORY_SERVER_PORT, "" + AMSetupUtils.getFirstUnusedPort(getHostName(), 50389, 1000));
request.addParameter(SetupConstants.CONFIG_VAR_DIRECTORY_ADMIN_SERVER_PORT, Integer.toString(AMSetupUtils.getFirstUnusedPort(getHostName(), 4444, 1000)));
request.addParameter(SetupConstants.CONFIG_VAR_DIRECTORY_JMX_SERVER_PORT, Integer.toString(AMSetupUtils.getFirstUnusedPort(getHostName(), 1689, 1000)));
request.addParameter(SetupConstants.CONFIG_VAR_SERVER_HOST, getHostName());
request.addParameter(SetupConstants.CONFIG_VAR_SERVER_PORT, "" + req.getServerPort());
request.addParameter(SetupConstants.CONFIG_VAR_SERVER_URI, req.getRequestURI());
request.addParameter(SetupConstants.CONFIG_VAR_SERVER_URL, req.getRequestURL().toString());
request.addParameter(SetupConstants.CONFIG_VAR_BASE_DIR, getBaseDir(getContext().getRequest()));
request.addParameter(SetupConstants.CONFIG_VAR_ENCRYPTION_KEY, AMSetupUtils.getRandomString());
request.addParameter(SetupConstants.CONFIG_VAR_COOKIE_DOMAIN, getCookieDomain());
request.addParameter(SetupConstants.CONFIG_VAR_DS_MGR_PWD, "");
request.addParameter(SetupConstants.CONFIG_VAR_DATA_STORE, SetupConstants.SMS_EMBED_DATASTORE);
request.addParameter(SetupConstants.CONFIG_VAR_PLATFORM_LOCALE, SetupConstants.DEFAULT_PLATFORM_LOCALE);
request.addParameter("locale", configLocale.toString());
request.addParameter(SetupConstants.CONFIG_VAR_SESSION_ROOT_SUFFIX, Constants.DEFAULT_SESSION_HA_ROOT_SUFFIX);
request.addParameter(SetupConstants.CONFIG_VAR_SESSION_STORE_TYPE, Constants.DEFAULT_SESSION_HA_STORE_TYPE);
try {
if (!AMSetupServlet.processRequest(request, response)) {
responseString = AMSetupServlet.getErrorMessage();
}
} catch (Exception e) {
responseString = e.getMessage();
debug.error("DefaultSummary.createDefaultConfig()", e);
}
writeToResponse(((responseString != null) ? responseString : ""));
setPath(null);
return false;
}
Aggregations