AciTestCase.java revision 9aa1482c49865483f798f91ef7d16f03cc3ec811
/*
* 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.
* Portions Copyright 2013-2015 ForgeRock AS
*/
@SuppressWarnings("javadoc")
public abstract class AciTestCase extends DirectoryServerTestCase {
private Attribute globalACIAttribute;
public void aciTestCaseSetup() throws Exception
{
// Save Global ACI.
{
}
}
@AfterClass(alwaysRun = true)
public void aciTestCaseTearDown() throws Exception
{
// Restore Global ACI.
if (globalACIAttribute != null)
{
ModifyOperation op = getRootConnection().processModify(DN.valueOf(ACCESS_HANDLER_DN), newArrayList(mod));
}
}
public static final String ACCESS_HANDLER_DN =
"cn=Access Control Handler,cn=config";
"ldap://kansashost/OU=People,O=Kansas,C=US";
//GLOBAL ACIs
protected static final String G_READ_ACI =
"(targetattr!=\"userPassword||authPassword\")" +
"(version 3.0; acl \"Anonymous read access\";" +
"allow (read,search,compare) userdn=\"ldap:///anyone\";)";
protected static final String G_SELF_MOD =
"(targetattr=\"*\")(version 3.0; acl \"Self entry modification\";" +
"allow (write) userdn=\"ldap:///self\";)";
"(target=\"ldap:///cn=schema\")(targetscope=\"base\")" +
"(targetattr=\"attributeTypes||dITContentRules||dITStructureRules||" +
"ldapSyntaxes||matchingRules||matchingRuleUse||nameForms||" +
"objectClasses\")" +
"(version 3.0; acl \"User-Visible Schema Operational Attributes\";" +
"allow (read,search,compare) userdn=\"ldap:///anyone\";)";
"(target=\"ldap:///\")(targetscope=\"base\")" +
"(targetattr=\"namingContexts||supportedAuthPasswordSchemes||" +
"supportedControl||supportedExtension||supportedFeatures||" +
"supportedSASLMechanisms||vendorName||vendorVersion\")" +
"(version 3.0; acl \"User-Visible Root DSE Operational Attributes\"; " +
"allow (read,search,compare) userdn=\"ldap:///anyone\";)";
protected static final String G_USER_OPS =
"(targetattr=\"createTimestamp||creatorsName||modifiersName||" +
"modifyTimestamp||entryDN||entryUUID||subschemaSubentry\")" +
"(version 3.0; acl \"User-Visible Operational Attributes\"; " +
"allow (read,search,compare) userdn=\"ldap:///anyone\";)";
"(targetcontrol = \"*\")" +
"(version 3.0; acl \"Anonymous control access\"; " +
"allow (read) userdn=\"ldap:///anyone\";)";
protected static final String E_EXTEND_OP =
"(extop = \"*\")" +
"(version 3.0; acl \"Anonymous extend op access\"; " +
"allow (read) userdn=\"ldap:///anyone\";)";
if(noOpControl != null) {
}
if(pwdPolicyControl != null) {
}
}
/**
* Perform a modify operation, and request attributes via a preRead control.
*
* @param bindDn The user to authenticate as.
* @param bindPassword The user's credentials.
* @param ldif The modification to make.
* @param attributes A space-separated list of attributes to return.
*
* @return The output of the command.
*
* @throws Exception If an unexpected problem occurred.
*/
{
if (attributes != null) {
}
}
}
if(controlStr != null) {
}
int retVal =
}
protected String
boolean pwdPolicy, boolean reportAuthzID,
int expectedRc) {
}
}
boolean pwdPolicy, boolean reportAuthzID,
int expectedRc) {
}
}
}
}
if(pwdPolicy) {
}
if(reportAuthzID) {
}
}
}
{
}
{
}
throws Exception {
}
throws Exception {
}
throws Exception {
}
{
}
{
if(controlStr != null) {
}
}
{
}
throws Exception
{
if (useAdminPort) {
} else {
}
if(controlStr != null) {
}
if(add) {
}
}
{
try {
} catch (NoPermissionException npe) {
return;
} catch (NamingException ex) {
+ ex.getMessage());
}
}
throws IOException
{
}
}
{
if (expectedRc != -1)
{
}
}
"dn: " + dn,
"changetype: modify",
"delete: " + attr));
}
throws Exception {
"dn: " + dn,
"changetype: modify",
"delete: " + attr));
}
String newSuperior ) {
if(newSuperior != null)
{
}
}
{
}
}
{
}
}
{
}
}
if (tempFilesForThisThread == null) {
tempFilesForThisThread = new HashMap<>();
}
}
return tempFile;
}
protected void addRootEntry() throws Exception {
"dn: cn=Admin Root,cn=Root DNs,cn=config",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"objectClass: ds-cfg-root-dn-user",
"cn: Admin Root",
"givenName: Administrator",
"sn: Admin",
"uid: admin.root",
"userPassword: password",
"ds-privilege-name: -bypass-acl",
"ds-cfg-alternate-bind-dn: cn=root",
"ds-cfg-alternate-bind-dn: cn=admin",
"ds-cfg-alternate-bind-dn: cn=admin root"
);
}
"dn: ou=People," + suffix,
"objectClass: top",
"objectClass: organizationalUnit",
"ou: People",
"",
"dn: ou=admins," + suffix ,
"objectClass: top",
"objectClass: organizationalUnit",
"ou: admins",
"",
"dn: cn=group,ou=People," + suffix,
"objectclass: top",
"objectclass: groupOfNames",
"cn: group",
"member: uid=user.3,ou=People," + suffix,
"",
"dn: ou=Nested Groups," + suffix,
"objectClass: top",
"objectClass: organizationalUnit",
"ou: Nested Groups",
"",
"dn: cn=group 1,ou=Nested Groups," + suffix,
"objectClass: top",
"objectClass: groupOfNames",
"cn: group 1",
"",
"dn: cn=group 2,ou=Nested Groups," + suffix,
"objectClass: top",
"objectClass: groupOfNames",
"cn: group 2",
"",
"dn: cn=group 3,ou=Nested Groups," + suffix,
"objectClass: top",
"objectClass: groupOfNames",
"cn: group 3",
"",
"dn: cn=group 4,ou=Nested Groups," + suffix,
"objectClass: top",
"objectClass: groupOfURLs",
"cn: group 4",
"memberURL: ldap:///ou=people,o=test??sub?(sn>=5)",
"",
"dn: uid=superuser,ou=admins," + suffix,
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: superuser",
"givenName: superuser",
"sn: 1",
"cn: User 1",
"userPassword: password",
"ds-privilege-name: proxied-auth",
"",
"dn: uid=proxyuser,ou=admins," + suffix,
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: proxyuser",
"givenName: proxyuser",
"sn: 1",
"cn: User 1",
"userPassword: password",
"",
"dn: uid=smart referral admin,uid=proxyuser,ou=admins," + suffix,
"objectClass: top",
"objectClass: extensibleobject",
"objectClass: referral",
"ref:" + refURL,
"",
"dn: uid=smart referral people,ou=people," + suffix,
"objectClass: top",
"objectClass: extensibleobject",
"objectClass: referral",
"ref:" + refURL,
"",
"dn: uid=user.1,ou=People," + suffix,
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.1",
"givenName: User 1",
"sn: 1",
"cn: User1",
"l: Austin",
"manager: cn=group,ou=People," + suffix,
"userPassword: password",
"",
"dn: uid=user.2,ou=People," + suffix,
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.2",
"givenName: User 2",
"sn: 2",
"cn: User 2",
"l: dallas",
"userPassword: password",
"",
"dn: uid=user.3,ou=People," + suffix,
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.3",
"givenName: User 3",
"sn: 3",
"cn: User 3",
"l: Austin",
"userPassword: password",
"ds-privilege-name: proxied-auth",
"",
"dn: uid=user.4,ou=People," + suffix,
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.4",
"givenName: User 4",
"sn: 4",
"cn: User 4",
"l: ft worth",
"userPassword: password",
"",
"dn: uid=user.5,ou=People," + suffix,
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.5",
"givenName: User 5",
"sn: 5",
"mail: user.5@test",
"description: user.5 description",
"cn: User 5",
"l: waco",
"userPassword: password",
"ds-privilege-name: proxied-auth");
}
{
return getAttrMap(resultString, false);
}
/**
* Parse a tool output for an LDIF record, returning the attributes in a Map.
*
* @param resultString The entire output from the operation
* @param stripHeader Set to {@code true} if data before the LDIF needs to be ignored
* @return A map of attribute-values
*/
{
boolean stripping = stripHeader;
try {
while (true) {
if (s == null)
{
break;
}
if (stripping) {
if (s.startsWith("dn:"))
{
stripping = false;
}
continue;
}
if (a.length != 2)
{
break;
}
}
} catch (IOException e) {
}
return attrMap;
}
}