/*
* 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 2009-2010 Sun Microsystems, Inc.
* Portions Copyright 2011-2015 ForgeRock AS
*/
/**
* This class represents RFC 3672 subentries and RFC 3671
* collective attribute subentries objects.
*/
public class SubEntry {
/**
* Defines the set of permissible values for the conflict behavior.
* Specifies the behavior that the server is to exhibit for entries
* that already contain one or more real values for the associated
* collective attribute.
*/
public static enum CollectiveConflictBehavior {
/**
* Indicates that the virtual attribute provider is to preserve
* any real values contained in the entry and merge them with the
* set of generated virtual values so that both the real and
* virtual values are used.
*/
/**
* Indicates that any real values contained in the entry are
* preserved and used, and virtual values are not generated.
*/
/**
* Indicates that the virtual attribute provider suppresses any
* real values contained in the entry and generates virtual values
* and uses them.
*/
/** String representation of the value. */
/**
* Private constructor.
* @param name for this conflict behavior.
*/
{
}
/** {@inheritDoc} */
{
return name;
}
}
/**
* The name of the "collectiveConflictBehavior" attribute type,
* formatted in all lowercase characters.
*/
"collectiveconflictbehavior";
/**
* The name of the "inheritFromDNAttribute" attribute type,
* formatted in all lowercase characters.
*/
"inheritfromdnattribute";
/**
* The name of the "inheritFromRDNAttribute" attribute type,
* formatted in all lowercase characters.
*/
"inheritfromrdnattribute";
/**
* The name of the "inheritFromRDNType" attribute type,
* formatted in all lowercase characters.
*/
"inheritfromrdntype";
/**
* The name of the "inheritFromBaseRDN" attribute type,
* formatted in all lowercase characters.
*/
"inheritfrombaserdn";
/**
* The name of the "inheritAttribute" attribute type,
* formatted in all lowercase characters.
*/
"inheritattribute";
/** Attribute option to mark attributes collective. */
"collective";
/** Entry object. */
/** Subtree specification. */
/** Collective subentry flag. */
private boolean isCollective;
/** Inherited collective subentry flag. */
private boolean isInheritedCollective;
/** Inherited collective from DN subentry flag. */
private boolean isInheritedFromDNCollective;
/** Inherited collective from RDN subentry flag. */
private boolean isInheritedFromRDNCollective;
/** Inherited collective DN attribute type. */
/** Inherited collective RDN attribute type. */
/** Inherited collective RDN type attribute type. */
/** Inherited collective RDN attribute value. */
/** Inherited collective from DN value. */
/** Inherited collective from base DN. */
/** Collective attributes. */
/** Conflict behavior. */
/**
* Constructs a subentry object from a given entry object.
* @param entry LDAP subentry to construct from.
* @throws DirectoryException if there is a problem with
* constructing a subentry from a given entry.
*/
{
// Process subtree specification.
this.subTreeSpec = null;
boolean isValidSpec = true;
if (specAttrList != null)
{
{
{
try
{
isValidSpec = true;
}
catch (DirectoryException de)
{
isValidSpec = false;
}
if (this.subTreeSpec != null)
{
break;
}
}
if (this.subTreeSpec != null)
{
break;
}
}
}
// Check that the subtree spec is flagged as valid. If it is not
// that means all parsers have failed and it is invalid syntax.
if (!isValidSpec)
{
throw new DirectoryException(
}
// Subentry has to to have a subtree specification.
if (this.subTreeSpec == null)
{
// There is none for some reason eg this could be
// old Draft based ldapSubEntry so create a dummy.
}
// Determine if this subentry is collective attribute subentry.
// Determine if this subentry is inherited collective
// attribute subentry and if so what kind.
this.isInheritedCollective =
if (this.isInheritedCollective)
{
this.isInheritedFromDNCollective =
this.isInheritedFromRDNCollective =
}
// Process collective attributes.
this.collectiveAttributes = new ArrayList<>();
if (this.isCollective)
{
{
if (attrType.isCollective())
{
}
{
}
}
}
// Process inherited collective attributes.
if (this.isInheritedCollective)
{
if (this.isInheritedFromDNCollective)
{
{
{
{
this.inheritFromDNAttrValue = value;
break;
}
}
}
}
if (this.isInheritedFromRDNCollective)
{
{
{
{
this.inheritFromRDNAttrType = DirectoryServer.getAttributeTypeOrDefault(value.toString().toLowerCase());
this.inheritFromRDNAttrValue = value;
break;
}
}
}
{
{
{
this.inheritFromRDNType = DirectoryServer.getAttributeTypeOrDefault(value.toString().toLowerCase());
break;
}
}
}
{
{
{
// Has to have a parent since subentry itself
// cannot be a suffix entry within the server.
break;
}
}
}
}
{
{
{
}
}
}
}
// Establish collective attribute conflict behavior.
if (this.isCollective || this.isInheritedCollective)
{
{
{
{
{
{
this.conflictBehavior = behavior;
break;
}
}
}
}
}
}
}
/**
* Retrieves the distinguished name for this subentry.
* @return The distinguished name for this subentry.
*/
{
}
/**
* Getter to retrieve the actual entry object
* for this subentry.
* @return entry object for this subentry.
*/
{
return this.entry;
}
/**
* Indicates whether or not this subentry is
* a collective attribute subentry.
* @return <code>true</code> if collective,
* <code>false</code> otherwise.
*/
public boolean isCollective()
{
return this.isCollective;
}
/**
* Indicates whether or not this subentry is
* an inherited collective attribute subentry.
* @return <code>true</code> if inherited
* collective, <code>false</code>
* otherwise.
*/
public boolean isInheritedCollective()
{
return this.isInheritedCollective;
}
/**
* Indicates whether or not this subentry is
* an inherited from DN collective attribute
* subentry.
* @return <code>true</code> if inherited
* from DN collective,
* <code>false</code> otherwise.
*/
public boolean isInheritedFromDNCollective()
{
return this.isInheritedFromDNCollective;
}
/**
* Indicates whether or not this subentry is
* an inherited from RDN collective attribute
* subentry.
* @return <code>true</code> if inherited
* from RDN collective,
* <code>false</code> otherwise.
*/
public boolean isInheritedFromRDNCollective()
{
return this.isInheritedFromRDNCollective;
}
/**
* Getter to retrieve inheritFromDNAttribute type
* for inherited collective attribute subentry.
* @return Type of inheritFromDNAttribute or,
* <code>null</code> if there is none.
*/
{
return this.inheritFromDNType;
}
/**
* Getter to retrieve inheritFromRDNAttribute type
* for inherited collective attribute subentry.
* @return Type of inheritFromRDNAttribute or,
* <code>null</code> if there is none.
*/
{
return this.inheritFromRDNAttrType;
}
/**
* Getter to retrieve inheritFromRDNAttribute value
* for inherited collective attribute subentry.
* @return ByteString of inheritFromRDNAttribute
* or, <code>null</code> if there is none.
*/
{
return this.inheritFromRDNAttrValue;
}
/**
* Getter to retrieve RDN type of inheritFromRDNType
* for inherited collective attribute subentry.
* @return RDN Type of inheritFromRDNAttribute or,
* <code>null</code> if there is none.
*/
{
return this.inheritFromRDNType;
}
/**
* Getter to retrieve inheritFromDNAttribute value
* for inherited collective attribute subentry.
* @return ByteString of inheritFromDNAttribute
* or, <code>null</code> if there is none.
*/
{
return this.inheritFromDNAttrValue;
}
/**
* Getter to retrieve inheritFromBaseRDN DN
* for inherited collective attribute subentry.
* @return DN of inheritFromBaseRDN or,
* <code>null</code> if there is none.
*/
{
return this.inheritFromBaseDN;
}
/**
* Getter for subentry subtree specification.
* @return subtree specification for this subentry.
*/
{
return this.subTreeSpec;
}
/**
* Getter for collective attributes contained within this subentry.
* @return collective attributes contained within this subentry.
*/
{
return this.collectiveAttributes;
}
/**
* Getter for collective conflict behavior defined for this
* collective attributes subentry.
* @return conflict behavior for this collective attributes
* subentry.
*/
{
return this.conflictBehavior;
}
}