Step3.java revision bd74afd3d3a48aed63cf319b1f7506429e0346c3
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2007 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: Step3.java,v 1.39 2009/12/17 17:43:39 goodearth Exp $
*
*/
/*
* Portions Copyrighted [2010-2012] [ForgeRock AS]
*/
/**
* Step 3 is for selecting the embedded or external configuration store
*/
public class Step3 extends LDAPStoreWizardPage {
public static final String LDAP_STORE_SESSION_KEY =
"wizardCustomConfigStore";
public ActionLink validateSMHostLink =
public ActionLink validateRootSuffixLink =
public ActionLink validateSessionRootSuffixLink =
public ActionLink setSessionStoreType =
public ActionLink setReplicationLink =
public ActionLink validateHostNameLink =
public ActionLink validateConfigStoreHost =
public ActionLink setConfigType =
public ActionLink validateLocalPortLink =
public ActionLink validateLocalAdminPortLink =
public ActionLink validateLocalJmxPortLink =
public ActionLink validateEncKey =
private String localRepPort;
public Step3() {
}
public void onInit() {
val = getAttribute(SessionAttributeNames.CONFIG_STORE_SESSION_STORE_TYPE, Wizard.defaultSessionStoreType);
val = getAttribute(SessionAttributeNames.CONFIG_STORE_SESSION_ROOT_DN, Wizard.defaultSessionRootDN);
} else {
}
// initialize the data store type being used
val = getAttribute(
} else {
}
} else {
}
super.onInit();
}
public boolean setConfigType() {
} else {
}
return true;
}
public boolean setReplication() {
}
return true;
}
public boolean validateRootSuffix() {
} else {
writeToResponse("true");
}
return false;
}
public boolean validateSessionRootSuffix() {
} else {
writeToResponse("true");
}
return false;
}
public boolean setSessionStoreType() {
} else {
}
return false;
}
public boolean validateLocalPort() {
} else {
try {
} else {
boolean ok = false;
"configStoreHost");
host = "localhost";
}
ok = true;
} else {
}
} else {
ok = true;
}
if (ok) {
writeToResponse("ok");
}
}
} catch (NumberFormatException e) {
} catch (NullPointerException ne) {
}
}
return false;
}
public boolean validateLocalAdminPort() {
} else {
try {
} else {
boolean ok = false;
"configStoreHost");
host = "localhost";
}
ok = true;
} else {
}
} else {
ok = true;
}
if (ok) {
writeToResponse("ok");
}
}
} catch (NumberFormatException e) {
} catch (NullPointerException ne) {
}
}
return false;
}
public boolean validateLocalJmxPort() {
} else {
try {
} else {
boolean ok = false;
"configStoreHost");
host = "localhost";
}
ok = true;
} else {
}
} else {
ok = true;
}
if (ok) {
writeToResponse("ok");
}
}
} catch (NumberFormatException e) {
} catch (NullPointerException ne) {
}
}
return false;
}
/**
* Returns <code>false</code> always. Length of encryption key
* must be at least 10 chars.
*/
public boolean validateEncKey() {
} else {
} else {
writeToResponse("true");
}
}
return false;
}
public boolean validateConfigStoreHost() {
getLocalizedString("missing.required.field"));
return false;
} else {
"configStoreHost", host);
}
try {
writeToResponse("ok");
} else {
}
} catch (UnknownHostException uhe) {
} catch (IOException ioe) {
} catch (NullPointerException ne) {
}
return false;
}
/*
* a call is made to the OpenSSO url entered in the browser. If
* the OpenSSO 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() {
getLocalizedString("missing.required.field"));
} else {
// try to retrieve the remote OpenSSO information
try {
// data returned from existing OpenSSO server
// true for embedded, false for sunds
// set the multi embedded flag
// get the existing replication ports if any
if (replAvailable == null) {
replAvailable = "false";
}
"existingserverid");
// dsmgr password is same as amadmin for embedded
} else {
"SSL" : "SIMPLE";
));
}
// set the replication ports pulled from the remote
// server in the session and pass back to the client
// set the configuration store port
// set the configuration store host
// set the configuration store port
}
} catch (ConfigurationException c) {
code = "999";
message = c.getMessage();
}
} catch (ConfiguratorException c) {
code = "999";
message = c.getMessage();
}
}
}
return false;
}
// add first object
} else {
}
}
/*
* the following value have been pulled from an existing OpenAM
* server which was configured to use an external DS. We need to set the DS
* values in the request so they can be used to configure the existing
* OpenAM server.
*/
}
public boolean validateSMHost() {
host = "localhost";
}
}
bindDN = "cn=Directory Manager";
}
if (rootSuffix == null) {
}
if (sessionRootDN == null) {
}
if (sessionStoreType == null) {
}
try {
new LDAPConnection();
attrs, false);
writeToResponse("ok");
} catch (LDAPException lex) {
switch (lex.getLDAPResultCode()) {
case LDAPException.CONNECT_ERROR:
break;
case LDAPException.SERVER_DOWN:
break;
break;
case LDAPException.NO_SUCH_OBJECT:
break;
getLocalizedString("ldap.invalid.credentials"));
break;
break;
break;
break;
default:
getLocalizedString("cannot.connect.to.SM.datastore"));
}
} catch (Exception e) {
getLocalizedString("cannot.connect.to.SM.datastore"));
} finally {
try {
ld.disconnect();
} catch (LDAPException ex) {
//ignore
}
}
}
return false;
}
}