SSFTestCase.java revision ea1068c292e9b341af6d6b563cd8988a96be20a9
/*
* 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 2011-2015 ForgeRock AS
*/
/**
* Unit test to test the ssf ACI bind rule keyword.
*/
public class SSFTestCase extends AciTestCase {
private static final String pwdPolicyDN =
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: new.user",
"givenName: New",
"sn: User",
"cn: New User",
"mail: new.user@test.com",
"ds-pwp-password-policy-dn:" + pwdPolicyDN
};
private static final
"(version 3.0; acl \"integrity aci\";" +
"allow(all) (userdn=\"ldap:///self\" and ssf = \"1\");)";
private static final
"(version 3.0; acl \"greater integrity aci\";" +
"allow(all) (userdn=\"ldap:///self\" and ssf > \"1\");)";
private static final
"(version 3.0; acl \"56 bit key aci\";" +
"allow(all) (userdn=\"ldap:///self\" and ssf = \"56\");)";
private static final
"(version 3.0; acl \"NE 56 bit key aci\";" +
"allow(all) (userdn=\"ldap:///self\" and ssf != \"56\");)";
private static final
"(version 3.0; acl \"128 bit key aci\";" +
"allow(all) (userdn=\"ldap:///self\" and ssf = \"128\");)";
private static final
"(version 3.0; acl \"greater 128 bit aci\";" +
"allow(all) (userdn=\"ldap:///self\" and ssf > \"128\");)";
public void setupClass() throws Exception {
"create-password-policy",
"--type", "password-policy",
"--policy-name", pwdPolicy,
"--set", "password-attribute:userPassword",
"--set", "default-password-storage-scheme: Clear"
);
"set-sasl-mechanism-handler-prop",
"--handler-name", "DIGEST-MD5",
"--set", "server-fqdn:localhost");
addEntries("o=test");
}
@AfterClass(alwaysRun = true)
"delete-password-policy",
"--policy-name", pwdPolicy
);
"set-sasl-mechanism-handler-prop",
"--handler-name", "DIGEST-MD5",
"--reset", "server-fqdn",
"--reset", "quality-of-protection");
}
//Valid ssf statements. Not the complete ACI.
return new Object[][] {
{"1"},
{"40"},
{"56"},
{"128"},
{"256"},
{"129"},
};
}
//Invalid ssf statements. Not the complete ACI.
return new Object[][] {
{"-1"},
{"0"},
{"not valid"},
{"1025"},
{"10000"},
};
}
/**
* Test valid ssf statements.
*
* @param statement The ssf statement to attempt to decode.
* @throws AciException If an unexpected result happens.
*/
}
/**
* Test invalid ssf statements.
*
* @param statement The ssf statement to attempt to decode.
* @throws Exception If an unexpected result happens.
*/
dataProvider="invalidStatements")
try {
} catch (AciException e) {
throw e;
} catch (Exception e) {
"Invalid ssf <" + statement +
"> threw wrong exception type.");
throw e;
}
throw new RuntimeException(
"Invalid ssf <" + statement +
"> did not throw an exception.");
}
/**
* Test ssf bind rule using ssf value for integrity.
*
* @throws Exception If a test doesn't pass.
*/
@Test
public void testIntegrity() throws Exception {
//set QOP to integrity.
"set-sasl-mechanism-handler-prop",
"--handler-name", "DIGEST-MD5",
"--set", "quality-of-protection:" + "integrity");
//Configure JNDI props.
//Select integrity QOP.
//Add ACI with ssf > 1, should fail.
//Add ACI with ssf = 1.
//Should succeed.
}
/**
* Test confidentiality settings using DIGEST-MD5.
* @throws Exception
*/
@Test
public void testConfidentiality() throws Exception {
//set QOP to integrity.
"set-sasl-mechanism-handler-prop",
"--handler-name", "DIGEST-MD5",
"--set", "quality-of-protection:" + "confidentiality");
//Select integrity QOP.
//Add ACI with ssf > 1, should succeed.
//Test medium strength.
//Test medium strength "!="
//Test high strength.
// TODO: this hangs sometimes during the JNDIModify (see OPENDJ-256).
//Fail DIGEST-MD5 only goes to 128.
}
}