AMSetupServlet.java revision 2feee3bd4482cbe7e4a8cf1a228bf17723b13934
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2006 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: AMSetupServlet.java,v 1.117 2010/01/20 17:01:35 veiming Exp $
*
*/
/*
* Portions Copyrighted 2010-2012 ForgeRock AS
*/
/**
* This class is the first class to get loaded by the Servlet
* container.
* It has helper methods to determine the status of Access Manager
* configuration when deployed as a single web-application. If
* Access Manager is not deployed as single web-application then the
* configured status returned is always true.
*/
public class AMSetupServlet extends HttpServlet {
private static boolean isConfiguredFlag = false;
private static boolean isVersionNewer = false;
private static boolean upgradeCompleted = false;
private static boolean debugEnabled = false;
static {
}
/*
* Initializes the servlet.
*/
if (servletCtx == null ) {
}
// this will sync up bootstrap file will serverconfig,xml
// due startup; and also register the observer.
// Syncup embedded opends replication with current
// server instances.
if (syncServerInfoWithRelication() == false) {
"AMSetupServlet.init: embedded replication sync failed.");
}
}
}
/*
* Flag indicating if OpenAM is configured with the latest valid config
*/
static public boolean isCurrentConfigurationValid() {
if (isConfiguredFlag) {
}
}
static public boolean isConfigured() {
return isConfiguredFlag;
}
try {
new BootstrapData(baseDir), false);
return isConfiguredFlag;
} catch (Exception e) {
//ignore
return false;
}
} else {
return false;
}
}
/**
* Used this method to check if the version is newer; called post upgrade
*/
public static void isVersionNewer() {
if (isConfiguredFlag) {
}
}
public static void upgradeCompleted() {
upgradeCompleted = true;
}
public static boolean isUpgradeCompleted() {
return upgradeCompleted;
}
public static void enableDebug() {
for (Debug d : debugInstances) {
}
debugEnabled = true;
}
public static void disableDebug() {
if (debugEnabled) {
for (Debug d : debugInstances) {
}
}
}
/**
* Checks if the embedded directory (if present) needs to be upgraded
*/
public static void checkOpenDJUpgrade() {
// check for embedded directory
if (!isEmbeddedDS()) {
return;
}
// check if upgrade is required
if (!upgrader.isUpgradeRequired()) {
return;
}
// backup embedded directory
// initiate upgrade
try {
}
}
protected static void createOpenDJBackup() {
try {
} catch (UpgradeException ue) {
return;
}
if (backupFile.exists()) {
Debug.getInstance(SetupConstants.DEBUG_NAME).error("Upgrade cannot continue as backup file exists! " + backupFile.getName());
return;
}
try {
// Compress the files
}
} catch (IOException ioe) {
} finally {
try {
} catch (IOException ioe) {
// do nothing
}
}
}
}
}
try {
}
if (!filename.isDirectory()) {
zOut.putNextEntry(new ZipEntry((dirName + filename.getName()).replace('\\','/').substring(stripLen)));
}
zOut.closeEntry();
} else {
zOut.closeEntry();
}
}
}
}
/**
* Checks if the product is already configured. This is required
* when the container on which WAR is deployed is restarted. If
* product is configured the flag is set true. Also the flag is
* set to true in case of non-single war deployment.
*/
public static void checkConfigProperties() {
try {
if (bootstrapFile != null) {
new BootstrapData(baseDir), false);
} else {
baseDir + "/" +
}
}
} catch (ConfiguratorException e) {
//ignore, WAR may not be configured yet.
} catch (Exception e) {
"AMSetupServlet.checkConfigProperties", e);
}
}
}
throws IOException {
boolean loaded = false;
try {
loaded =true;
}
} finally {
try {
} catch (IOException e) {
//ignore
}
}
}
}
return loaded;
}
/**
* Invoked from the filter to decide which page needs to be
* displayed.
* @param servletctx is the Servlet Context
* @return true if AM is already configured, false otherwise
*/
return isConfiguredFlag;
}
}
if (loadBalancerHost != null) {
// site configuration is passed as a map of the site
// information
}
if (userStoreType != null) {
// site configuration is passed as a map of the site information
"USERSTORE_DOMAINNAME");
try {
if (domainName != null &&
}
} catch (NamingException nex) {
.error("AMSetupServlet:Naming Exception"+
"get host and port from domain name" + nex);
} catch (IOException ioex) {
.error("AMSetupServlet:IO Exception. get"+
" host and port from domain name" + ioex);
}
}
} else {
}
}
} else {
}
}
if (result == false) {
"Configuration failed - check installation logs!" );
} else
}
/**
* The main entry point for configuring Access Manager. The parameters
* are passed from configurator page.
*
* @param request Servlet request.
* @param response Servlet response.
* @return <code>true</code> if the configuration succeeded.
*/
public static boolean processRequest(
) {
response);
}
public static boolean processRequest(
) {
/*
* This logic needs refactoring later. setServiceConfigValues()
* attempts to check if directory is up and makes a call
* back to this class. The implementation'd
* be cleaner if classes&methods are named better and separated than
* intertwined together.
*/
// set debug directory
// used for site configuration later
try {
if (isConfiguredFlag) {
//postInitialize was called at the end of configure????
}
if (isConfiguredFlag) {
if (fileBootstrap != null) {
}
if (!legacy) {
// this will write bootstrap file after configuration is
// done; and also register the observer.
if (fileBootstrap == null) {
} else {
}
// this is to store the bootstrap location
// store the ds admin port if we are running in embedded mode
}
// setup site configuration information
/*
* If primary url is null that means we are adding
* to an existing site. we don't need to create it
* first.
*/
}
}
{
}
}
// Setup Replication port in SMS for each server
}
}
}
} catch (Exception e) {
"AMSetupServlet.processRequest: error", e);
"AMSetupServlet.processRequest: error", e);
throw new ConfiguratorException("configuration.failed",
} finally {
}
} else {
"WebtopNaming.configMonitoring returned error.");
}
return isConfiguredFlag;
}
throws IOException {
} else {
}
} else {
}
}
}
}
}
}
throws IOException {
if (!baseDirectory.exists()) {
} else {
throw new ConfiguratorException(
"Base directory specified :" +
basedir +
" cannot be used - has preexisting config data.");
}
}
}
// (i) install, configure and start an embedded instance.
// or
// (ii) install, configure, and replicate embedded instance
throws ConfigurationException, Exception {
boolean ditLoaded = false;
// wait for at most 10 seconds for OpenDS to come up
int sleepTime = 10;
// sleep one second a time
}
if (!dsConfig.isDServerUp()) {
throw new ConfigurationException(
"OpenDJ cannot be started.");
}
// Determine if DITLoaded flag needs to be set: multi instance
// Replication
// TOFIX: Temporary fix until OpenDS auto-loads schema
// Get the remote host name from the SERVER URL
// entered in the 'Add to existing instance' and place
// it in the map. This is for console configurator.
// For cli configurator, the "DS_EMB_REPL_HOST2" would
// be entered in the config. file itself.
if (existingInstance != null) {
if ((ndx1 != -1) &&
finalStr);
}
}
}
ditLoaded = true;
}
return ditLoaded;
}
throws Exception {
}
if (!isDITLoaded) {
}
return isDITLoaded;
}
private static void configureServerInstance(
boolean isDITLoaded,
"configurator.progress.configure.server.instance", null);
} else {
try {
if (!isDITLoaded) {
}
if (!isDITLoaded ||
}
} catch (UnknownPropertyNameException ex) {
// ignore, property names are valid because they are
// gotten from template.
}
}
}
private static boolean configure(
) throws Exception {
boolean configured = false;
boolean existingConfiguration = false;
try {
// do this here since initializeConfigProperties needs the dir
// Set the install property since reInitConfigProperties
// initializes SMS which inturn initializes EventService
// SystemProperties gets reinitialized and installTime property
// has to set again
if (!isDITLoaded) {
}
// Set installTime to false, to avoid in-memory notification from
// SMS in cases where not needed, and to denote that service
// registration got completed during configuration phase and it
// has passed installtime.
propAMConfig, map);
// Embedded :get our serverid and configure embedded idRepo
// Ensure this service are initialized before continuing
if (embedded) {
try {
":"+
"|"+ serverID;
"EmbeddedDS : failed to setup serverid", ex);
throw ex;
}
}
// Construct the SMSEntry for the node to check to
// see if this is an existing configuration store,
// or new store.
if (entry.isNewEntry()) {
} else {
existingConfiguration = true;
}
}
}
/*
* Requiring the keystore.jks file in OpenSSO workspace.
* The createIdentitiesForWSSecurity is for the
*/
if (!isDITLoaded) {
}
if (!existingConfiguration) {
}
}
isConfiguredFlag = true;
configured = true;
} catch (Exception e) {
// catch all because we want all exception to be logged
"AMSetupServlet.configure: error", e);
errorMessage = e.getMessage();
throw e;
}
return configured;
}
public static String getErrorMessage() {
}
}
}
throws SSOException, SMSException {
svcMgr.clearCache();
}
throws IOException {
if (legacy) {
basedir);
} else {
}
return initMap;
}
{
if (servletCtx == null) {
return;
}
}
}
private static List getConfigPluginClasses()
{
try {
if (strPlugins != null) {
while (st.hasMoreTokens()) {
}
}
} catch (IllegalAccessException e) {
"AMSetupServlet.getConfigPluginClasses: error", e);
throw e;
} catch (InstantiationException e) {
"AMSetupServlet.getConfigPluginClasses: error", e);
throw e;
} catch (ClassNotFoundException e) {
"AMSetupServlet.getConfigPluginClasses: error", e);
throw e;
} catch (MissingResourceException e) {
//ignore if there are no configurator plugins.
}
return plugins;
}
private static void reInitConfigProperties(
{
}
}
public static String getPresetConfigDir()
throws ConfiguratorException {
try {
} catch (MissingResourceException e) {
//ignored because bootstrap properties file maybe absent.
}
}
} else {
throw new ConfiguratorException(
"cannot get configuration path");
}
}
return configDir;
}
/**
* Returns location of the bootstrap file.
*
* @return Location of the bootstrap file. Returns null if the file
* cannot be located
* @throws ConfiguratorException if servlet context is null or deployment
* application real path cannot be determined.
*/
static String getBootStrapFile()
throws ConfiguratorException {
} else {
try {
} catch (IOException e) {
throw new ConfiguratorException(e.getMessage());
} finally {
try {
} catch (IOException e) {
//ignore
}
}
}
}
}
}
return bootstrap;
}
// this is the file which contains the base dir.
// this file is not created if configuration directory is
// preset in bootstrap.properties
private static String getBootstrapLocator()
throws ConfiguratorException {
return null;
}
if (servletCtx != null) {
} else {
throw new ConfiguratorException(
"Cannot read the bootstrap path");
}
} else {
return null;
}
}
public static String getBaseDir()
throws ConfiguratorException {
return configDir;
}
if (servletCtx != null) {
return null;
}
try {
} catch (IOException e) {
throw new ConfiguratorException(e.getMessage());
} finally {
try {
} catch (IOException e) {
//ignore
}
}
}
} else {
throw new ConfiguratorException(
"Cannot read the bootstrap path");
}
} else {
throw new ConfiguratorException("Servlet Context is null");
}
}
if (servletCtx != null) {
} else {
}
if (idx != -1) {
}
}
}
return path;
}
/**
* Returns URL of the default resource.
*
* @return URL of the default resource. Returns null of servlet context is
* null.
*/
if (servletCtx != null) {
try {
} catch (MalformedURLException mue) {
"AMSetupServlet.getAppResource: Cannot access the resource",
mue);
}
} else {
"AMSetupServlet.getAppResource: Context is null");
}
return null;
}
/**
* This method takes the name of XML file, process each
* request object one by one immediately after parsing.
*
* @param xmlBaseDir is the location of request xml files
* @throws SMSException if error occurs in the service management space.
* @throws SSOException if administrator single sign on is not valid.
* @throws IOException if error accessing the configuration files.
* @throws PolicyException if policy cannot be loaded.
*/
{
null);
try {
} catch (SMSException e) {
"AMSetupServlet.processDataRequests", e);
throw e;
} catch (SSOException e) {
"AMSetupServlet.processDataRequests", e);
throw e;
} catch (IOException e) {
"AMSetupServlet.processDataRequests", e);
throw e;
}
}
/**
* Helper method to return Admin token
* @return Admin Token
*/
private static SSOToken getAdminSSOToken() {
if (adminToken == null) {
}
return adminToken;
}
/**
* Initialize AMConfig.propeties with host specific values
*/
private static Map initializeConfigProperties()
throws SecurityException, IOException {
try {
} catch (SecurityException e){
"AMSetupServlet.initializeConfigProperties", e);
throw e;
}
// this is for the servicetag-registry.xml stuff, a bit later
/*
* if the file's not there, just skip it
* usually will be about a file included with OpenSSO,
* so it's informational, rather than a "real" error.
*/
try {
} catch (IOException ioex) {
break;
}
boolean embedded =
boolean dbSunDS = false;
boolean dbMsAD = false;
if (embedded) {
dbSunDS = true;
} else { // Keep old behavior for now.
}
if (idx1 != -1) {
.length(), dataStoreClass);
}
}
}
/*
* if Linux, the default PAM service name is "password",
* rather than "other"
*/
}
) {
} else if (absFile.equalsIgnoreCase(
{
swapped);
} else {
}
}
return mapFileNameToContent;
}
throws IOException {
try {
}
char[] cbuf = new char[1024];
int len;
}
} finally {
try {
//No handling required
}
}
try {
// no handling required
}
}
}
return sbuf;
}
throws IOException {
}
}
throws IOException {
try {
} catch (IOException e) {
"AMSetupServlet.writeToFile", e);
throw e;
} finally {
try {
//No handling requried
}
}
}
}
/**
* Returns secure random string.
*
* @return secure random string.
*/
public static String getRandomString() {
try {
byte [] bytes = new byte[24];
} catch (Exception e) {
"AMSetupServlet.getRandomString:" +
"Exception in generating encryption key.", e);
}
}
/**
* Returns a unused port on a given host.
* @param hostname (eg localhost)
* @param start starting port number to check (eg 389).
* @param incr port number increments to check (eg 1000).
* @return available port num if found. -1 of not found.
*/
{
int defaultPort = -1;
if (canUseAsPort(hostname, i))
{
defaultPort = i;
}
}
return defaultPort;
}
/**
* Checks whether the given host:port is currenly under use.
* @param hostname (eg localhost)
* @param port port number.
* @return true if not in use, false if in use.
*/
{
boolean canUseAsPort = false;
try {
serverSocket = new ServerSocket();
//if (!isWindows()) {
//serverSocket.setReuseAddress(true);
//}
canUseAsPort = true;
try {
s = new Socket();
canUseAsPort = false;
} catch (Throwable t) {
}
finally {
if (s != null) {
try {
s.close();
} catch (Throwable t)
{
}
}
}
} catch (IOException ex) {
canUseAsPort = false;
} catch (NullPointerException ne) {
canUseAsPort = false;
} finally {
try {
if (serverSocket != null) {
}
}
return canUseAsPort;
}
/**
* Obtains misc config data from a remote OpenSSO server :
* opends admin port
* config basedn
* flag to indicate replication is already on or not
* opends replication port or opends sugested port
*
* @param server URL string representing the remote OpenSSO
* server
* @param userid - admin userid on remote server (only amdmin)
* @param pwd - admin password
* @return Map of confif params.
* @throws <code>ConfiguratonException</code>
* errorCodes :
* 401=Unauthorized - invalid credentials
* 405=Method Not Allowed - only POST is honored
* 408=Request Timeout - requested timed out
* 500=Internal Server Error
* 702=Connection Error - failed to connect
*/
public static Map getRemoteServerInfo(
) throws ConfigurationException {
try {
// Construct data
// Send data
return true;
}
});
}
conn.setDoOutput(true);
continue;
}
return info;
"AMSetupServlet.getRemoteServerInfo()", e);
} catch (IllegalArgumentException e) {
"AMSetupServlet.getRemoteServerInfo()", e);
"AMSetupServlet.getRemoteServerInfo()", e);
"AMSetupServlet.getRemoteServerInfo()", e);
} catch (FileNotFoundException e) {
"AMSetupServlet.getRemoteServerInfo()", e);
"AMSetupServlet.getRemoteServerInfo()", e);
} catch (IOException e) {
int status = 0;
try {
}
status == 408 ) {
} else {
}
"AMSetupServlet.getRemoteServerInfo()", e);
throw cex;
} finally {
conn.disconnect();
}
}
}
/**
* Returns schema file names.
*
* @param dataStore Name of data store configuration data.
* @throws MissingResourceException if the bundle cannot be found.
*/
throws MissingResourceException
{
if (embedded) {
} else {
}
while (st.hasMoreTokens()) {
}
return fileNames;
}
private static List getTagSwapConfigFiles()
throws MissingResourceException
{
while (st.hasMoreTokens()) {
}
return fileNames;
}
if (isIPAddr) {
while (st.hasMoreTokens()) {
try {
} catch (NumberFormatException e) {
isIPAddr = false;
}
}
}
return isIPAddr;
}
/**
* Tag swaps strings in schema files.
*
* @param basedir the configuration base directory.
* @param schemaFiles List of schema files to be loaded.
* @throws IOException if data files cannot be written.
*/
private static void writeSchemaFiles(
) throws Exception {
null);
try {
} catch (IOException ioex) {
"AMSetupServlet.writeSchemaFiles: " +
"Exception in writing schema files:" , ioex);
throw ioex;
} finally {
try {
//No handling requried
}
}
}
}
if (ret != 0) {
"AMSetupServlet.writeSchemaFiles: " +
"Unable to rebuild indexes in OpenDJ: " + ret);
}
}
}
}
/**
* Update famsts.wsdl with Keystore location.
*
* @param basedir the configuration base directory.
* @param deployuri the deployment URI.
* @throws IOException if password files cannot be written.
*/
private static void updateSTSwsdl(
) throws IOException {
// Get OpenSSO web application base location.
// TODO: Needs to be Fixed...
// Update famsts.wsdl with Keystore location.
"/WEB-INF/wsdl/famsts.wsdl"));
}
/**
* Create the storepass and keypass files
*
* @param basedir the configuration base directory.
* @param deployuri the deployment URI.
* @throws IOException if password files cannot be written.
*/
private static void createPasswordFiles(
) throws IOException
{
}
/**
* Helper method to create the storepass and keypass files
*
* @param fName is the name of the file to create.
* @param content is the password to write in the file.
*/
throws IOException
{
try {
} catch (IOException ioex) {
"AMSetupServlet.writeContent: " +
"Exception in creating password files:" , ioex);
throw ioex;
} finally {
try {
//No handling requried
}
}
}
}
/**
* Update Embedded Idrepo instance with new embedded opends isntance.
*/
private static void updateEmbeddedIdRepo(
) throws SMSException, SSOException {
"sun-idrepo-ldapv3-config-ldap-server");
}
}
}
/**
* Update platform server list and Organization alias
*/
private static void updatePlatformServerList(
) throws SMSException, SSOException
{
"iPlanetAMPlatformService", token);
"iplanet-am-platform-server-list");
// Update Organization Aliases
"sunOrganizationAliases", values);
}
}
}
int instanceNumber = 1;
int maxNumber = 1;
if (index1 != -1) {
try {
if (n > maxNumber) {
maxNumber = n;
}
} catch (NumberFormatException nfe) {
// Ignore and continue
}
}
}
}
return instanceName;
}
boolean found = false;
if (idx != -1) {
}
}
return found;
}
try {
"AgentService", token);
} catch (SSOException ex) {
return false;
} catch (SMSException ex) {
return false;
}
}
private static void createDemoUser()
throws IdRepoException, SSOException {
null);
try {
getAdminSSOToken(), "/");
} catch (IdRepoException e) {
"AMSetupServlet.createDemoUser", e);
throw e;
} catch (SSOException e) {
"AMSetupServlet.createDemoUser", e);
throw e;
}
}
/**
* Creates Identities for WS Security
*
* @param serverURL URL at which Access Manager is configured.
*/
private static void createIdentitiesForWSSecurity(
) throws IdRepoException, SSOException {
if (!isAgentServiceLoad(token)) {
return;
}
null);
//createUser(idrepo, "jsmith", "John", "Smith");
//createUser(idrepo, "jondoe", "Jon", "Doe");
// Add WSC configuration
"ReplyTo,Action,MessageID");
// Add WSP configuration
"urn:sun:wss:security:null:SAML2Token-HK," +
"urn:sun:wss:security:null:SAML2Token-SV," +
"urn:sun:wss:security:null:X509Token");
// Add STS Client configuration
//createAgent(idrepo, "defaultSTS", "STS", "", config);
// Add Agent Authenticator configuration
"wsc,wsp,SecurityTokenService");
/*
// Add UsernameToken profile
createAgent(idrepo, "UserNameToken", "WSP",
"WS-I BSP UserName Token Profile Configuration", config);
// Add SAML-HolderOfKey
config.remove("SecurityMech");
config.remove("UserCredential");
config.put("SecurityMech","urn:sun:wss:security:null:SAMLToken-HK");
createAgent(idrepo, "SAML-HolderOfKey", "WSP",
"WS-I BSP SAML Holder Of Key Profile Configuration", config);
// Add SAML-SenderVouches
config.remove("SecurityMech");
config.put("SecurityMech","urn:sun:wss:security:null:SAMLToken-SV");
createAgent(idrepo, "SAML-SenderVouches", "WSP",
"WS-I BSP SAML Sender Vouches Token Profile Configuration", config);
// Add X509Token
config.remove("SecurityMech");
config.put("SecurityMech","urn:sun:wss:security:null:X509Token");
createAgent(idrepo, "X509Token", "WSP",
"WS-I BSP X509 Token Profile Configuration", config);
// Add LibertyX509Token
config.put("TrustAuthority","LocalDisco");
config.put("WSPEndpoint","http://wsp.com");
config.remove("SecurityMech");
config.put("SecurityMech","urn:liberty:security:2005-02:null:X509");
createAgent(idrepo, "LibertyX509Token", "WSP",
"Liberty X509 Token Profile Configuration", config);
// Add LibertyBearerToken
config.remove("SecurityMech");
config.put("SecurityMech","urn:liberty:security:2005-02:null:Bearer");
createAgent(idrepo, "LibertyBearerToken", "WSP",
"Liberty SAML Bearer Token Profile Configuration", config);
// Add LibertySAMLToken
config.remove("SecurityMech");
config.put("SecurityMech","urn:liberty:security:2005-02:null:SAML");
createAgent(idrepo, "LibertySAMLToken", "WSP",
"Liberty SAML Token Profile Configuration", config);
// Add local discovery service
config.clear();
config.put("AgentType","DiscoveryAgent");
createAgent(idrepo, "LocalDisco", "Discovery",
"Local Liberty Discovery Service Configuration", config);*/
}
private static void createUser(
) throws IdRepoException, SSOException
{
}
private static void createAgent(
) throws IdRepoException, SSOException {
"/", null);
while (st.hasMoreTokens()) {
}
} else {
}
}
}
}
{
"configurator.progress.setup.monitorauthfile", null);
/*
* make sure the basedir + "/" + deployuri + "/lib/registration"
* directory exists, and then create the monitoring auth file
* there.
*/
try {
}
} catch (IOException ex) {
"AMSetupServlet.createMonitoringAuthFile:" +
"failed to create monitoring authentication file");
}
}
/*
* directory exists.
*/
if (!dataAceDir.mkdirs()) {
"AMSetupServlet.setupSecurIDDirs: " +
"failed to create SecurID data directory");
}
}
/*
* not rsa_api.properties, as it's tagged swapped and
*
* if file isn't copied, it's probably because this is
* an OpenSSO deployment, rather than OpenSSO, so it would
* just be informational, but at the debug error level.
* additionally, before some point, the debug stuff can't
* be invoked.
*/
try {
}
} catch (IOException ioex) {
"AMSetupServlet.copyAuthSecurIDFiles:", ioex);
}
}
{
byte[] b = new byte[2000];
int len;
}
} else {
return false;
}
return true;
}
throws LDAPServiceException {
try {
} finally {
try {
} catch (IOException e) {
//ignore
}
}
}
}
.append("\n");
}
}
private static String determineOS() {
return SetupConstants.WINDOWS;
} else {
return SetupConstants.X86SOLARIS;
} else {
return SetupConstants.LINUX;
}
}
} else {
return SetupConstants.SOLARIS;
}
}
} else {
if ((acceptLangHeader != null) &&
{
} else {
}
}
}
throws IOException {
}
private static boolean isEmbeddedDS() {
}
/**
* Synchronizes embedded replication state with current server list.
* @returns boolean true is sync succeeds else false.
*/
private static boolean syncServerInfoWithRelication() {
// We need to execute syn only if we are in Embedded mode
if (!isEmbeddedDS()) {
return true;
}
try {
if (getAdminSSOToken() == null) {
"AMSetupServlet.syncServerInfoWithRelication: "+
"Could not sync servers with embedded replication:"+
"no admin token");
return false;
}
// Determine which server this is
// See if we need to execute sync
// Check if we are already replication with other servers
(adminToken, myName);
return true;
}
// Get server list
return true;
}
adminToken, sname);
}
"AMSetupServlet.syncServerInfoWithRelication: "+
"Could not sync servers with embedded replication:", ex);
return false;
}
}
/**
* Gets <code>ServerGroup</code> for SMS for specified server
* @param sname servername of groupo to find.
* @returns <code>ServerGroup</code> instance
*/
throws Exception
{
return scc.getSMSServerGroup() ;
}
/**
* Gets clear password of SMS datastore
* @param ssg <code>ServerGroup</code> instance representing SMS
* or Configuration datastore.
* @returns clear password
*/
{
new DecodeAction(epass));
return pass;
}
/**
* Gets port number of SMS datastore
* @param ssg <code>ServerGroup</code> instance representing SMS
* or Configuration datastore.
* @returns port
*/
{
}
{
try {
// Update this instance first...
// Update remote instance
// Update remote instance ...
"AMSetupServlet.updateReplPortInfo: "+
"could not add replication port info to SM", ex);
}
}
if (servletContext == null) {
// remove leading '/'
} else {
}
}
// Method to convert the domain name to the root suffix.
// eg., Domain Name amqa.test.com is converted to root suffix
// DC=amqa,DC=test,DC=com
}
}
// Method to get hostname and port number with the
// provided Domain Name for Active Directory user data store.
throws NamingException, IOException {
domainName+='.';
}
// Check if domain name is a valid one.
// The resource record type A is defined in RFC 1035.
try {
"com.sun.jndi.dns.DnsContextFactory");
throw new NamingException();
}
} catch (NamingException e) {
// Failed to resolve domainName to A record.
// throw exception.
throw e;
}
// then look for the LDAP server
try {
// Attempting to resolve ldapServer to SRV record.
// This is a mechanism defined in MSDN, querying
// SRV records for _ldap._tcp.DOMAINNAME.
// and get host and port from domain.
throw new NamingException();
}
} catch (NamingException e) {
// Failed to resolve ldapServer to SRV record.
// throw exception.
throw e;
}
// try to connect to LDAP port to make sure this machine
// has LDAP service
try {
} catch (IOException e) {
throw e;
}
return hostAndPort;
}
private static void registerListeners() {
if (isConfiguredFlag) {
SetupListener.class);
for (SetupListener p : listeners) {
p.addListener();
}
}
}
}