/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
* Portions Copyright 2012 ForgeRock AS
*/
/**
* Check if information found in "cn=admin data" is coherent with
* cn=config. If and inconsistency is detected, we log a warning
* message and update "cn=admin data"
*/
public final class AdministrationDataSync
{
/**
* The root connection.
*/
/**
* The attribute name used to store the port. TODO Use the default
* one.
*/
/**
* Create an object that will syncrhonize configuration and the
* admin data.
*
* @param internalConnection
* The root connection.
*/
{
this.internalConnection = internalConnection;
}
/**
* Check if information found in "cn=admin data" is coherent with
* cn=config. If and inconsistancy is detected, we log a warning
* message and update "cn=admin data"
*/
public void synchronize()
{
// Check if the admin connector is in sync
}
/**
* Check if the admin connector is in sync. The desynchronization
* could occurs after the upgrade from 1.0.
*/
private void checkAdminConnector()
{
// Look for the server registration in "cn=admin data"
if (serverEntryDN == null)
{
// Nothing to do
return;
}
// Get the admin port
{
// best effort.
return;
}
// adminport
.toLowerCase());
{
}
// adminEnabled
attName = "adminEnabled";
{
}
attrType, "true")));
// Process modification
}
/**
* Look for the DN of the local register server. Assumption: default
* Connection Handler naming is used.
*
* @return The DN of the local register server or null.
*/
{
// Get the LDAP and LDAPS port
"cn=LDAP Connection Handler,cn=Connection Handlers,cn=config",
"cn=LDAPS Connection Handler,cn=Connection Handlers,cn=config",
boolean ldapsPortEnable = false;
"cn=LDAPS Connection Handler,cn=Connection Handlers,cn=config",
"ds-cfg-enabled");
{
}
{
// best effort (see assumption)
return null;
}
// Get the IP address of the local host.
try
{
}
catch (Throwable t)
{
// best effort.
return null;
}
// Look for a local server with the Ldap Port.
if (hostnameType == null)
{
}
try
{
"cn=Servers,cn=admin data",
{
{
try
{
{
// Check if one of the port match
attrName = "ldapport";
{
}
{
break;
}
if (ldapsPortEnable)
{
attrName = "ldapsport";
{
}
{
break;
}
}
}
}
catch (Exception e)
{
// best effort.
continue;
}
}
{
}
}
}
catch (DirectoryException e)
{
// never happens because the filter is always valid.
return null;
}
return returnDN;
}
/**
* Gets an attribute value from an entry.
*
* @param DN
* The DN of the entry.
* @param attrName
* The attribute name.
* @return The attribute value or {@code null} if the value could
* not be retrieved.
*/
{
// Prepare the ldap search
try
{
}
catch (LDAPException e)
{
// can not happen
// best effort.
// TODO Log an Error.
return null;
}
{
// can not happen
// best effort.
// TODO Log an Error.
return null;
}
/*
* Read the port from the PORT attribute
*/
{
}
{
}
{
// can not happen
// best effort.
// TODO Log an Error.
return null;
}
// Get the attribute value
}
}