ParentInheritance.java revision 040cba63ba4af5bed76846f0edb63c853b009da9
/*
* 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 Sun Microsystems, Inc.
* Portions Copyright 2014 ForgeRock AS
*/
/**
* This class is used by USERDN and GROUPDN userattr types
* to determine what parent inheritance checks to make.
*/
public class ParentInheritance {
/*
* The maximum number of parent inheritance levels supported.
*/
private static final int MAX_LEVELS=10;
/*
* Pattern to match for parent inheritance.
*/
/*
* Array used to hold the level information. Each slot corresponds to a
* level parsed from the rule.
*/
private final int[] levels=new int[MAX_LEVELS];
/*
* The number of levels parsed.
*/
private int numLevels;
/*
* The attribute type string parsed from the rule. Only used in
* inheritance search.
*/
private String attrTypeStr;
/*
* The base DN of a URL parsed from the rule. Used to make sure groupdn
* are under this suffix. Originally a way to search all nested groups
* under this suffix, so the behavior is slightly different.
*/
/**
* Construct a class from the inheritance pattern. The skipParsing boolean
* specifies that parent parsing should be skipped and sets up the class:
* with numLevels=1, level[0]=0 and an attribute type from the
* specified pattern.
*
* @param pattern The string pattern containing the inheritance
* information.
* @param skipParse Specify if the parent inheritance parsing should be
* skipped or not.
* @throws AciException If the pattern is invalid.
*/
if (skipParse) {
//The "parent[" pattern is invalid for ROLEDN user attr keyword.
throw new AciException(message);
} else {
//Check if valid attribute type name.
throw new AciException(message);
}
numLevels=1;
}
}
/**
* Performs all parsing of the specified pattern string.
* @param pattern The string pattern containing the inheritance
* information.
* @throws AciException If the pattern is invalid.
*/
/**
* Check if we have a "parent[" string.
*/
numLevels=0;
/**
* Format needs to be parent[XX].attribute -- everything after the
* '.' is the attribute type.
*/
throw new AciException(message);
}
//Check if valid attribute type name.
throw new AciException(message);
}
while(tok.hasMoreTokens()) {
/**
* Everything between the brackets must be an integer or it's
* an error.
*/
try {
if(numLevels < MAX_LEVELS) {
} else {
throw new AciException(message);
}
} catch (NumberFormatException ex) {
throw new AciException(message);
}
}
} else {
try {
throw new AciException(message);
}
throw new AciException(message);
}
} catch (DirectoryException ex) {
ex.getMessageObject());
throw new AciException(message);
}
}
numLevels=1;
}
}
/**
* Returns the number of levels counted.
* @return The number of levels.
*/
public int getNumLevels() {
return numLevels;
}
/**
* Returns an array of levels, where levels are integers.
* @return Return an array of levels.
*/
public int[] getLevels() {
return levelsCopy;
}
/**
* Return the attribute type.
* @return The attribute type.
*/
public AttributeType getAttributeType() {
{
}
return attrType;
}
/**
* Return the string representation of the attribute type.
* @return The attribute type string.
*/
public String getAttrTypeStr() {
return attrTypeStr;
}
/**
* Return the DN that groupdn must be under.
*
* @return DN that groupdn must be under.
*/
return baseDN;
}
}