use of org.apache.click.Context in project OpenAM by OpenRock.
the class Step3 method validateSMHost.
/**
* Validate an Existing SM Host for Configuration Backend.
* @return
*/
public boolean validateSMHost() {
Context ctx = getContext();
String strSSL = (String) ctx.getSessionAttribute(SessionAttributeNames.CONFIG_STORE_SSL);
boolean ssl = (strSSL != null) && (strSSL.equals("SSL"));
String host = (String) ctx.getSessionAttribute(SessionAttributeNames.CONFIG_STORE_HOST);
if (host == null) {
host = "localhost";
}
String strPort = (String) ctx.getSessionAttribute(SessionAttributeNames.CONFIG_STORE_PORT);
if (strPort == null) {
strPort = getAvailablePort(50389);
}
int port = Integer.parseInt(strPort);
String bindDN = (String) ctx.getSessionAttribute(SessionAttributeNames.CONFIG_STORE_LOGIN_ID);
String rootSuffix = (String) ctx.getSessionAttribute(SessionAttributeNames.CONFIG_STORE_ROOT_SUFFIX);
String bindPwd = (String) ctx.getSessionAttribute(SessionAttributeNames.CONFIG_STORE_PWD);
if (bindDN == null) {
bindDN = "cn=Directory Manager";
}
if (rootSuffix == null) {
rootSuffix = Constants.DEFAULT_ROOT_SUFFIX;
}
try (Connection conn = getConnection(host, port, bindDN, bindPwd.toCharArray(), 5, ssl)) {
String filter = "cn=" + "\"" + rootSuffix + "\"";
String[] attrs = { "" };
conn.search(LDAPRequests.newSearchRequest(rootSuffix, SearchScope.BASE_OBJECT, filter, attrs));
writeToResponse("ok");
} catch (LdapException lex) {
if (!writeErrorToResponse(lex.getResult().getResultCode())) {
writeToResponse(getLocalizedString("cannot.connect.to.SM.datastore"));
}
} catch (Exception e) {
writeToResponse(getLocalizedString("cannot.connect.to.SM.datastore"));
}
setPath(null);
return false;
}
use of org.apache.click.Context in project OpenAM by OpenRock.
the class Step7 method onInit.
public void onInit() {
Context ctx = getContext();
String tmp = getAttribute(SetupConstants.CONFIG_VAR_DATA_STORE, SetupConstants.SMS_EMBED_DATASTORE);
boolean isEmbedded = tmp.equals(SetupConstants.SMS_EMBED_DATASTORE);
// Config Store Properties
tmp = (String) ctx.getSessionAttribute(SessionAttributeNames.CONFIG_DIR);
add("configDirectory", tmp);
if (isEmbedded) {
add("isEmbedded", "1");
add("configStoreHost", "localhost");
} else {
tmp = getAttribute("configStoreHost", getHostName());
add("configStoreHost", tmp);
}
tmp = getAttribute("configStoreSSL", "");
add("displayConfigStoreSSL", tmp.equals("SSL") ? getLocalizedString("yes.label") : getLocalizedString("no.label"));
tmp = getAttribute("rootSuffix", Wizard.defaultRootSuffix);
add("rootSuffix", tmp);
// Provide Port Settings
tmp = getAttribute("configStorePort", getAvailablePort(50389));
add("configStorePort", tmp);
tmp = getAttribute("configStoreAdminPort", getAvailablePort(4444));
add("configStoreAdminPort", tmp);
tmp = getAttribute("configStoreJmxPort", getAvailablePort(1689));
add("configStoreJmxPort", tmp);
tmp = getAttribute("configStoreLoginId", Wizard.defaultUserName);
add("configStoreLoginId", tmp);
// Provide User Store Properties.
tmp = getAttribute(SetupConstants.DS_EMB_REPL_FLAG, "");
if (!tmp.equals(SetupConstants.DS_EMP_REPL_FLAG_VAL)) {
// User Config Store Properties
tmp = (String) ctx.getSessionAttribute(SessionAttributeNames.EXT_DATA_STORE);
if (tmp.equals("true")) {
tmp = (String) ctx.getSessionAttribute(SessionAttributeNames.USER_STORE_HOST);
add("displayUserHostName", tmp);
tmp = (String) ctx.getSessionAttribute(SessionAttributeNames.USER_STORE_SSL);
add("xuserHostSSL", tmp.equals("SSL") ? getLocalizedString("yes.label") : getLocalizedString("no.label"));
tmp = (String) ctx.getSessionAttribute(SessionAttributeNames.USER_STORE_PORT);
add("userHostPort", tmp);
tmp = (String) ctx.getSessionAttribute(SessionAttributeNames.USER_STORE_ROOT_SUFFIX);
add("userRootSuffix", tmp);
tmp = (String) ctx.getSessionAttribute(SessionAttributeNames.USER_STORE_LOGIN_ID);
add("userLoginID", tmp);
tmp = (String) ctx.getSessionAttribute(SessionAttributeNames.USER_STORE_TYPE);
if (tmp.equals("LDAPv3ForODSEE")) {
add("userStoreType", getLocalizedString("odsee.ldap.schema"));
} else if (tmp.equals("LDAPv3ForAD")) {
add("userStoreType", getLocalizedString("activedirectory.ldap.schema"));
} else if (tmp.equals("LDAPv3ForADDC")) {
add("userStoreType", getLocalizedString("activedirectoryfordomainname.ldap.schema"));
} else if (tmp.equals("LDAPv3ForADAM")) {
add("userStoreType", getLocalizedString("adam.ldap.schema"));
} else if (tmp.equals("LDAPv3ForOpenDS")) {
add("userStoreType", getLocalizedString("opends.ldap.schema"));
} else {
add("userStoreType", getLocalizedString("tivoli.ldap.schema"));
}
}
add("firstInstance", "1");
}
// Load Balancer Properties
add("loadBalancerHost", (String) ctx.getSessionAttribute(SessionAttributeNames.LB_SITE_NAME));
add("loadBalancerPort", (String) ctx.getSessionAttribute(SessionAttributeNames.LB_PRIMARY_URL));
// Normalize the information for Summary.
Boolean sessionAttribute = (Boolean) ctx.getSessionAttribute(SessionAttributeNames.LB_SESSION_HA_SFO);
if (sessionAttribute == null) {
tmp = DISABLED;
} else if (sessionAttribute) {
tmp = ENABLED;
} else {
tmp = DISABLED;
}
add(SessionAttributeNames.LB_SESSION_HA_SFO, tmp);
// Initialize our Parent Object.
super.onInit();
}
use of org.apache.click.Context in project OpenAM by OpenRock.
the class Step4 method validateUMDomainName.
public boolean validateUMDomainName() {
setPath(null);
Context ctx = getContext();
String strSSL = (String) ctx.getSessionAttribute(SessionAttributeNames.USER_STORE_SSL);
boolean ssl = (strSSL != null) && (strSSL.equals("SSL"));
String domainName = (String) ctx.getSessionAttribute(SessionAttributeNames.USER_STORE_DOMAINNAME);
String rootSuffixAD = dnsDomainToDN(domainName);
getContext().setSessionAttribute(SessionAttributeNames.USER_STORE_ROOT_SUFFIX, rootSuffixAD);
String[] hostAndPort = { "" };
try {
hostAndPort = getLdapHostAndPort(domainName);
} catch (NamingException nex) {
writeToResponse(getLocalizedString("cannot.connect.to.UM.datastore"));
return false;
} catch (IOException ioex) {
writeToResponse(getLocalizedString("cannot.connect.to.UM.datastore"));
return false;
}
String host = hostAndPort[0];
int port = Integer.parseInt(hostAndPort[1]);
String bindDN = (String) ctx.getSessionAttribute(SessionAttributeNames.USER_STORE_LOGIN_ID);
String rootSuffix = (String) ctx.getSessionAttribute(SessionAttributeNames.USER_STORE_ROOT_SUFFIX);
String bindPwd = (String) ctx.getSessionAttribute(SessionAttributeNames.USER_STORE_LOGIN_PWD);
try (Connection conn = getConnection(host, port, bindDN, bindPwd.toCharArray(), 3, ssl)) {
//String filter = "cn=" + "\"" + rootSuffix + "\"";
String[] attrs = { "" };
conn.search(LDAPRequests.newSearchRequest(rootSuffix, SearchScope.BASE_OBJECT, ObjectClassFilter, attrs));
writeToResponse("ok");
} catch (LdapException lex) {
ResultCode resultCode = lex.getResult().getResultCode();
if (!writeErrorToResponse(resultCode)) {
writeToResponse(getLocalizedString("cannot.connect.to.UM.datastore"));
}
} catch (Exception e) {
writeToResponse(getLocalizedString("cannot.connect.to.UM.datastore"));
}
return false;
}
use of org.apache.click.Context in project OpenAM by OpenRock.
the class Step4 method onInit.
public void onInit() {
super.onInit();
Context ctx = getContext();
if (ctx.getSessionAttribute(SessionAttributeNames.USER_STORE_HOST) == null) {
String val = getAttribute(SetupConstants.CONFIG_VAR_DATA_STORE, SetupConstants.SMS_EMBED_DATASTORE);
if (!val.equals(SetupConstants.SMS_EMBED_DATASTORE)) {
val = getAttribute("configStoreSSL", "SIMPLE");
ctx.setSessionAttribute(SessionAttributeNames.USER_STORE_SSL, val);
val = getAttribute("configStoreHost", getHostName());
ctx.setSessionAttribute(SessionAttributeNames.USER_STORE_HOST, val);
val = getAttribute("configStorePort", "389");
ctx.setSessionAttribute(SessionAttributeNames.USER_STORE_PORT, val);
val = getAttribute("configStoreLoginId", Wizard.defaultUserName);
ctx.setSessionAttribute(SessionAttributeNames.USER_STORE_LOGIN_ID, val);
val = getAttribute("rootSuffix", Wizard.defaultRootSuffix);
ctx.setSessionAttribute(SessionAttributeNames.USER_STORE_ROOT_SUFFIX, val);
}
ctx.setSessionAttribute(SessionAttributeNames.EXT_DATA_STORE, "true");
ctx.setSessionAttribute(SessionAttributeNames.USER_STORE_TYPE, "LDAPv3ForOpenDS");
}
String smsType = getAttribute(SetupConstants.CONFIG_VAR_DATA_STORE, "embedded");
if (!smsType.equals("embedded")) {
ctx.setSessionAttribute(SessionAttributeNames.EXT_DATA_STORE, "true");
addModel("radioDataTypeDisabled", "disabled");
} else {
addModel("radioDataTypeDisabled", "");
}
String val = getAttribute(SetupConstants.USER_STORE_HOST, getHostName());
ctx.setSessionAttribute(SessionAttributeNames.USER_STORE_HOST, val);
addModel("userStoreHost", val);
val = getAttribute(SetupConstants.USER_STORE_SSL, "SIMPLE");
ctx.setSessionAttribute(SessionAttributeNames.USER_STORE_SSL, val);
if (val.equals("SSL")) {
addModel("selectUserStoreSSL", "checked=\"checked\"");
} else {
addModel("selectUserStoreSSL", "");
}
val = getAttribute(SetupConstants.USER_STORE_PORT, "389");
ctx.setSessionAttribute(SessionAttributeNames.USER_STORE_PORT, val);
addModel("userStorePort", val);
val = getAttribute(SetupConstants.USER_STORE_LOGIN_ID, Wizard.defaultUserName);
ctx.setSessionAttribute(SessionAttributeNames.USER_STORE_LOGIN_ID, val);
addModel("userStoreLoginId", val);
val = getAttribute(SetupConstants.USER_STORE_ROOT_SUFFIX, Wizard.defaultRootSuffix);
ctx.setSessionAttribute(SessionAttributeNames.USER_STORE_ROOT_SUFFIX, val);
addModel("userStoreRootSuffix", val);
val = getAttribute(SetupConstants.USER_STORE_TYPE, "LDAPv3ForOpenDS");
if (val.equals("LDAPv3ForAD")) {
addModel("selectLDAPv3ad", "checked=\"checked\"");
addModel("selectLDAPv3addc", "");
addModel("selectLDAPv3adam", "");
addModel("selectLDAPv3odsee", "");
addModel("selectLDAPv3opends", "");
addModel("selectLDAPv3tivoli", "");
} else if (val.equals("LDAPv3ForADDC")) {
addModel("selectLDAPv3addc", "checked=\"checked\"");
addModel("selectLDAPv3ad", "");
addModel("selectLDAPv3adam", "");
addModel("selectLDAPv3odsee", "");
addModel("selectLDAPv3opends", "");
addModel("selectLDAPv3tivoli", "");
} else if (val.equals("LDAPv3ForADAM")) {
addModel("selectLDAPv3adam", "checked=\"checked\"");
addModel("selectLDAPv3ad", "");
addModel("selectLDAPv3addc", "");
addModel("selectLDAPv3odsee", "");
addModel("selectLDAPv3opends", "");
addModel("selectLDAPv3tivoli", "");
} else if (val.equals("LDAPv3ForODSEE")) {
addModel("selectLDAPv3odsee", "checked=\"checked\"");
addModel("selectLDAPv3ad", "");
addModel("selectLDAPv3addc", "");
addModel("selectLDAPv3adam", "");
addModel("selectLDAPv3odsee", "");
addModel("selectLDAPv3tivoli", "");
} else if (val.equals("LDAPv3ForOpenDS")) {
addModel("selectLDAPv3opends", "checked=\"checked\"");
addModel("selectLDAPv3ad", "");
addModel("selectLDAPv3addc", "");
addModel("selectLDAPv3adam", "");
addModel("selectLDAPv3odsee", "");
addModel("selectLDAPv3tivoli", "");
} else {
addModel("selectLDAPv3tivoli", "checked=\"checked\"");
addModel("selectLDAPv3ad", "");
addModel("selectLDAPv3addc", "");
addModel("selectLDAPv3adam", "");
addModel("selectLDAPv3odsee", "");
addModel("selectLDAPv3opends", "");
}
val = getAttribute("EXT_DATA_STORE", "true");
addModel("EXT_DATA_STORE", val);
if (val.equals("true")) {
addModel("selectEmbeddedUM", "");
addModel("selectExternalUM", "checked=\"checked\"");
} else {
addModel("selectEmbeddedUM", "checked=\"checked\"");
addModel("selectExternalUM", "");
}
}
use of org.apache.click.Context in project OpenAM by OpenRock.
the class Step4 method validateUMHost.
public boolean validateUMHost() {
Context ctx = getContext();
String strSSL = (String) ctx.getSessionAttribute(SessionAttributeNames.USER_STORE_SSL);
boolean ssl = (strSSL != null) && (strSSL.equals("SSL"));
String host = (String) ctx.getSessionAttribute(SessionAttributeNames.USER_STORE_HOST);
String strPort = (String) ctx.getSessionAttribute(SessionAttributeNames.USER_STORE_PORT);
int port = Integer.parseInt(strPort);
String bindDN = (String) ctx.getSessionAttribute(SessionAttributeNames.USER_STORE_LOGIN_ID);
String rootSuffix = (String) ctx.getSessionAttribute(SessionAttributeNames.USER_STORE_ROOT_SUFFIX);
String bindPwd = (String) ctx.getSessionAttribute(SessionAttributeNames.USER_STORE_LOGIN_PWD);
try (Connection conn = getConnection(host, port, bindDN, bindPwd.toCharArray(), 5, ssl)) {
//String filter = "cn=" + "\"" + rootSuffix + "\""; // NOT SURE Why "cn" is specified. would never work.
String[] attrs = { "" };
conn.search(LDAPRequests.newSearchRequest(rootSuffix, SearchScope.BASE_OBJECT, ObjectClassFilter, attrs));
writeToResponse("ok");
} catch (LdapException lex) {
ResultCode resultCode = lex.getResult().getResultCode();
if (!writeErrorToResponse(resultCode)) {
writeToResponse(getLocalizedString("cannot.connect.to.SM.datastore"));
}
} catch (Exception e) {
writeToResponse(getLocalizedString("cannot.connect.to.SM.datastore"));
}
setPath(null);
return false;
}
Aggregations