AMSetupDSConfig.java revision b0465323d102d12fdad78489cccc5e6a379db9e0
/*
* 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: AMSetupDSConfig.java,v 1.20 2009/11/20 23:52:55 ww203982 Exp $
*
* Portions Copyrighted 2011-2016 ForgeRock AS.
*/
/**
* This class does Directory Server related tasks for
* OpenAM deployed as single web application.
*/
public class AMSetupDSConfig {
private String dsHostName;
private String dsAdminPwd;
private static ConnectionFactory ld;
private static AMSetupDSConfig dsConfigInstance;
/**
* Constructs a new instance.
*/
private AMSetupDSConfig() {
}
/**
* Returns a single instance if not already created.
*
* @return AMSetupDSConfig instance.
*/
public static AMSetupDSConfig getInstance() {
synchronized (AMSetupDSConfig.class) {
if (dsConfigInstance == null) {
dsConfigInstance = new AMSetupDSConfig();
}
}
return dsConfigInstance;
}
}
boolean isDServerUp(boolean ssl) {
}
/**
* Validates if directory server is running and can be
* connected at the specified host and port.
*
* @return <code>true</code> if directory server is running.
*/
boolean isDServerUp() {
return isDServerUp(false);
}
/**
* Validates the directory server port and returns as an int value.
*
* @return port of directory server.
* @throws NumberFormatException if port specified is incorrect.
*/
private int getPort() {
try {
} catch (NumberFormatException e) {
throw new ConfiguratorException("configurator.invalidport",
}
}
/**
* Set the values required for Service Schema files.
*/
public void setDSValues() {
// Get naming rdn
}
}
/**
* Returns the relative DN from the suffix.
*
* @param nSuffix Normalized suffix.
* @return the last component of the suffix.
*/
}
/**
* Returns suffix with specified delimiter.
*
* @param nSuffix Normalized suffix.
* @param replaceWith the replacing delimiter to use.
* @return the suffix with delimiter replaced with the string
* specified as replaceWith.
*/
}
/**
* Check if Directory Server has the suffix.
*
* @param ssl <code>true</code> if directory server is running on LDAPS.
* @return <code>true</code> if specified suffix exists.
*/
public boolean connectDSwithDN(boolean ssl) {
ConnectionEntryReader results = conn.search(LDAPRequests.newSearchRequest(suffix, SearchScope.BASE_OBJECT,
} catch (LdapException e) {
return false;
}
}
/**
* Check if DS is loaded with OpenAM entries
*
* @param ssl <code>true</code> of directory server is running on LDAPS.
* @return <code>true</code> if Service Schema is loaded into
* Directory Server.
*/
ConnectionEntryReader results = conn.search(LDAPRequests.newSearchRequest(baseDN, SearchScope.WHOLE_SUBTREE,
filter, "dn"));
} catch (LdapException e) {
"AMSetupDSConfig.isDITLoaded: LDAP Operation return code: " +
e.getResult().getResultCode());
}
return "false";
}
}
/**
* Loads the schema files into the directory Server.
*
* @param schemaFiles Array of schema files to load.
* @throws ConfiguratorException if unable to load schema.
*/
throws ConfiguratorException {
try {
}
} catch (IOException e) {
"AMSetupDSConfig.loadSchemaFiles:failed", e);
"AMSetupDSConfig.loadSchemaFiles:failed", e);
throw new ConfiguratorException("configurator.ldiferror",
}
}
/**
* Helper method to disconnect from Directory Server.
*/
private void disconnectDServer() {
}
}
/**
* Helper method to return Ldap connection
*
* @param ssl <code>true</code> if directory server is running SSL.
* @return Ldap connection
*/
try {
// All connections will use authentication
if (ssl) {
}
ShutdownListener() {
public void shutdown() {
}
});
}
return ld.getConnection();
} catch (LdapException e) {
} catch (Exception e) {
}
return null;
}
}