LDAPProfile.java revision d70586b00b9530ab99ab4b8f003e9a54793e419f
/*
* 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 2008-2009 Sun Microsystems, Inc.
*/
/**
* This class is used to map configuration elements to their LDAP schema names.
* <p>
* It is possible to augment the core LDAP profile with additional profile
* mappings at run-time using instances of {@link Wrapper}. This is useful for
* unit tests which need to add and remove mock components.
*/
public final class LDAPProfile {
/**
* LDAP profile wrappers can be used to provide temporary LDAP profile
* information for components which do not have LDAP profile property files.
* These components are typically "mock" components used in unit-tests.
*/
public static abstract class Wrapper {
/**
* Default constructor.
*/
protected Wrapper() {
// No implementation required.
}
/**
* Get the name of the LDAP attribute associated with the specified
* property definition.
* <p>
* The default implementation of this method is to return
* <code>null</code>.
*
* @param d
* The managed object definition.
* @param pd
* The property definition.
* @return Returns the name of the LDAP attribute associated with the
* specified property definition, or <code>null</code> if the
* property definition is not handled by this LDAP profile
* wrapper.
*/
return null;
}
/**
* Gets the LDAP RDN attribute type for child entries of an instantiable
* relation.
* <p>
* The default implementation of this method is to return
* <code>null</code>.
*
* @param r
* The instantiable relation.
* @return Returns the LDAP RDN attribute type for child entries of an
* instantiable relation, or <code>null</code> if the
* instantiable relation is not handled by this LDAP profile
* wrapper.
*/
return null;
}
/**
* Gets the LDAP RDN attribute type for child entries of an set
* relation.
* <p>
* The default implementation of this method is to return
* <code>null</code>.
*
* @param r
* The set relation.
* @return Returns the LDAP RDN attribute type for child entries of an
* set relation, or <code>null</code> if the set relation is not
* handled by this LDAP profile wrapper.
*/
return null;
}
/**
* Get the principle object class associated with the specified
* definition.
* <p>
* The default implementation of this method is to return
* <code>null</code>.
*
* @param d
* The managed object definition.
* @return Returns the principle object class associated with the
* specified definition, or <code>null</code> if the managed
* object definition is not handled by this LDAP profile
* wrapper.
*/
return null;
}
/**
* Get an LDAP RDN sequence associatied with a relation.
* <p>
* The default implementation of this method is to return
* <code>null</code>.
*
* @param r
* The relation.
* @return Returns the LDAP RDN sequence associatied with a relation, or
* <code>null</code> if the relation is not handled by this LDAP
* profile wrapper.
*/
return null;
}
}
// The singleton instance.
/**
* Get the global LDAP profile instance.
*
* @return Returns the global LDAP profile instance.
*/
public static LDAPProfile getInstance() {
return INSTANCE;
}
// The list of profile wrappers.
// The LDAP profile property table.
private final ManagedObjectDefinitionResource resource = ManagedObjectDefinitionResource.createForProfile("ldap");
// Prevent construction.
private LDAPProfile() {
// No implementation required.
}
/**
* Get the name of the LDAP attribute associated with the specified property
* definition.
*
* @param d
* The managed object definition.
* @param pd
* The property definition.
* @return Returns the name of the LDAP attribute associated with the
* specified property definition.
* @throws MissingResourceException
* If the LDAP profile properties file associated with the
* provided managed object definition could not be loaded.
*/
if (attributeName != null) {
return attributeName;
}
}
}
/**
* Gets the LDAP RDN attribute type for child entries of an instantiable
* relation.
*
* @param r
* The instantiable relation.
* @return Returns the LDAP RDN attribute type for child entries of an
* instantiable relation.
* @throws MissingResourceException
* If the LDAP profile properties file associated with the
* provided managed object definition could not be loaded.
*/
if (r.getNamingPropertyDefinition() != null) {
// Use the attribute associated with the naming property.
} else {
return rdnType;
}
}
}
}
/**
* Gets the LDAP object classes associated with an instantiable or set
* relation branch. The branch is the parent entry of child managed objects.
*
* @param r
* The instantiable or set relation.
* @return Returns the LDAP object classes associated with an instantiable
* or set relation branch.
*/
}
/**
* Gets the LDAP RDN attribute type for child entries of an set relation.
*
* @param r
* The set relation.
* @return Returns the LDAP RDN attribute type for child entries of an set
* relation.
* @throws MissingResourceException
* If the LDAP profile properties file associated with the
* provided managed object definition could not be loaded.
*/
return rdnType;
}
}
}
/**
* Get the principle object class associated with the specified definition.
*
* @param d
* The managed object definition.
* @return Returns the principle object class associated with the specified
* definition.
* @throws MissingResourceException
* If the LDAP profile properties file associated with the
* provided managed object definition could not be loaded.
*/
if (d.isTop()) {
return "top";
}
if (objectClass != null) {
return objectClass;
}
}
}
/**
* Get all the object classes associated with the specified definition.
* <p>
* The returned list is ordered such that the uppermost object classes
* appear first (e.g. top).
*
* @param d
* The managed object definition.
* @return Returns all the object classes associated with the specified
* definition.
* @throws MissingResourceException
* If the LDAP profile properties file associated with the
* provided managed object definition could not be loaded.
*/
// Add the object classes from the parent hierarchy.
while (d != null) {
}
d = d.getParent();
}
if (!s.contains("top")) {
}
return objectClasses;
}
/**
* Get an LDAP RDN sequence associatied with a relation.
*
* @param r
* The relation.
* @return Returns the LDAP RDN sequence associatied with a relation.
* @throws MissingResourceException
* If the LDAP profile properties file associated with the
* provided managed object definition could not be loaded.
*/
if (rdnSequence != null) {
return rdnSequence;
}
}
}
/**
* Removes the last LDAP profile wrapper added using
* {@link #pushWrapper(org.forgerock.opendj.config.LDAPProfile.Wrapper)}.
*
* @throws NoSuchElementException
* If there are no LDAP profile wrappers.
*/
public void popWrapper() {
}
/**
* Decorates the core LDAP profile with the provided LDAP profile wrapper.
* All profile requests will be directed to the provided wrapper before
* being forwarded onto the core profile if the request could not be
* satisfied.
*
* @param wrapper
* The LDAP profile wrapper.
*/
}
}