| | |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012 ForgeRock AS |
| | | * Portions Copyright 2013 Manuel Gaupp |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | "SubjectAttributeToUserAttributeCertificateMapper", |
| | | "ds-cfg-enabled: true", |
| | | "ds-cfg-subject-attribute-mapping: cn:cn", |
| | | "ds-cfg-user-base-dn: invalid"); |
| | | "ds-cfg-user-base-dn: invalid", |
| | | "", |
| | | "dn: cn=Duplicate Cert Attr OID and Name,cn=Certificate Mappers,cn=config", |
| | | "objectClass: top", |
| | | "objectClass: ds-cfg-certificate-mapper", |
| | | "objectClass: " + |
| | | "ds-cfg-subject-attribute-to-user-attribute-certificate-mapper", |
| | | "cn: Duplicate Cert Attr OID and Name", |
| | | "ds-cfg-java-class: org.opends.server.extensions." + |
| | | "SubjectAttributeToUserAttributeCertificateMapper", |
| | | "ds-cfg-enabled: true", |
| | | "ds-cfg-subject-attribute-mapping: cn:cn", |
| | | "ds-cfg-subject-attribute-mapping: 2.5.4.3:displayName"); |
| | | |
| | | |
| | | Object[][] configEntries = new Object[entries.size()][1]; |
| | |
| | | |
| | | |
| | | /** |
| | | * Tests a successful mapping using an OID for the mapping. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testSuccessfulMappingUsingAnOID() |
| | | throws Exception |
| | | { |
| | | enableMapper(); |
| | | |
| | | try |
| | | { |
| | | setAttributeMappings(new String[] { "cn:cn", "1.2.840.113549.1.9.1:mail" }); |
| | | |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | TestCaseUtils.addEntry( |
| | | "dn: uid=test.user,o=test", |
| | | "objectClass: top", |
| | | "objectClass: person", |
| | | "objectClass: organizationalPerson", |
| | | "objectClass: inetOrgPerson", |
| | | "objectClass: ds-certificate-user", |
| | | "uid: test.user", |
| | | "givenName: Test", |
| | | "sn: User", |
| | | "cn: Test User", |
| | | "mail: test@example.com"); |
| | | |
| | | |
| | | |
| | | String keyStorePath = DirectoryServer.getInstanceRoot() + File.separator + |
| | | "config" + File.separator + "client-emailAddress.keystore"; |
| | | String trustStorePath = DirectoryServer.getInstanceRoot() + File.separator + |
| | | "config" + File.separator + "client.truststore"; |
| | | |
| | | String[] args = |
| | | { |
| | | "--noPropertiesFile", |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapsPort()), |
| | | "-Z", |
| | | "-K", keyStorePath, |
| | | "-W", "password", |
| | | "-P", trustStorePath, |
| | | "-r", |
| | | "-b", "", |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | } |
| | | finally |
| | | { |
| | | disableMapper(); |
| | | setAttributeMappings(new String[] { "cn:cn", "emailAddress:mail" }); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests a successful mapping using the default configuration and a |
| | | * certificate containing a subject with an emailAddress. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testSuccessfulMappingDefaultConfigEmailAddress() |
| | | throws Exception |
| | | { |
| | | enableMapper(); |
| | | |
| | | try |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | TestCaseUtils.addEntry( |
| | | "dn: uid=test.user,o=test", |
| | | "objectClass: top", |
| | | "objectClass: person", |
| | | "objectClass: organizationalPerson", |
| | | "objectClass: inetOrgPerson", |
| | | "objectClass: ds-certificate-user", |
| | | "uid: test.user", |
| | | "givenName: Test", |
| | | "sn: User", |
| | | "cn: Test User", |
| | | "mail: test@example.com"); |
| | | |
| | | |
| | | |
| | | String keyStorePath = DirectoryServer.getInstanceRoot() + File.separator + |
| | | "config" + File.separator + "client-emailAddress.keystore"; |
| | | String trustStorePath = DirectoryServer.getInstanceRoot() + File.separator + |
| | | "config" + File.separator + "client.truststore"; |
| | | |
| | | String[] args = |
| | | { |
| | | "--noPropertiesFile", |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapsPort()), |
| | | "-Z", |
| | | "-K", keyStorePath, |
| | | "-W", "password", |
| | | "-P", trustStorePath, |
| | | "-r", |
| | | "-b", "", |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | } |
| | | finally |
| | | { |
| | | disableMapper(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests a successful mapping with multiple attributes. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | |
| | | finally |
| | | { |
| | | disableMapper(); |
| | | setAttributeMappings(new String[] { "cn:cn", "e:mail" }); |
| | | setAttributeMappings(new String[] { "cn:cn", "emailAddress:mail" }); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | try |
| | | { |
| | | setAttributeMappings(new String[] { "e:mail" }); |
| | | setAttributeMappings(new String[] { "emailAddress:mail" }); |
| | | |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | TestCaseUtils.addEntry( |
| | |
| | | finally |
| | | { |
| | | disableMapper(); |
| | | setAttributeMappings(new String[] { "cn:cn", "e:mail" }); |
| | | setAttributeMappings(new String[] { "cn:cn", "emailAddress:mail" }); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | /** |
| | | * Tests to ensure that an attmept to remove the subject attribute will fail. |
| | | * Tests to ensure that an attempt to remove the subject attribute will fail. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | |
| | | |
| | | |
| | | /** |
| | | * Tests to ensure that an attmept to set an attribute mapping with no colon |
| | | * Tests to ensure that an attempt to set an attribute mapping with no colon |
| | | * will fail. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | |
| | | |
| | | |
| | | /** |
| | | * Tests to ensure that an attmept to set an attribute mapping with no cert |
| | | * Tests to ensure that an attempt to set an attribute mapping with no cert |
| | | * attribute will fail. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | |
| | | |
| | | |
| | | /** |
| | | * Tests to ensure that an attmept to set an attribute mapping with no user |
| | | * Tests to ensure that an attempt to set an attribute mapping with no user |
| | | * attribute will fail. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | |
| | | |
| | | |
| | | /** |
| | | * Tests to ensure that an attmept to set an attribute mapping with an |
| | | * Tests to ensure that an attempt to set an attribute mapping with an |
| | | * undefined user attribute will fail. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | |
| | | |
| | | |
| | | /** |
| | | * Tests to ensure that an attmept to set an attribute mapping with a |
| | | * Tests to ensure that an attempt to set an attribute mapping with a |
| | | * duplicate cert attribute mapping will fail. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | |
| | | |
| | | |
| | | /** |
| | | * Tests to ensure that an attmept to set an attribute mapping with a |
| | | * Tests to ensure that an attempt to set an attribute mapping with a |
| | | * duplicate user attribute mapping will fail. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | |
| | | |
| | | |
| | | /** |
| | | * Tests to ensure that an attmept to set an invalid base DN will fail. |
| | | * Tests to ensure that an attempt to set an invalid base DN will fail. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |