Sorted predictive attributes name order for LDIF (version control)
| | |
| | | import java.io.OutputStream; |
| | | import java.io.StringWriter; |
| | | import java.io.Writer; |
| | | import java.util.AbstractMap; |
| | | import java.util.List; |
| | | import java.util.TreeMap; |
| | | |
| | | import org.forgerock.opendj.ldap.Attribute; |
| | | import org.forgerock.opendj.ldap.AttributeDescription; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.Entry; |
| | |
| | | } |
| | | |
| | | writeKeyAndValue("dn", entry.getName().toString()); |
| | | |
| | | final TreeMap<String,AbstractMap.SimpleEntry<String,ByteSequence>> attr=new TreeMap<>(); //sort by key:value |
| | | for (final Attribute attribute : entry.getAllAttributes()) { |
| | | // Filter the attribute if required. |
| | | if (isAttributeExcluded(attribute.getAttributeDescription())) { |
| | |
| | | |
| | | final String attributeDescription = attribute.getAttributeDescriptionAsString(); |
| | | if (attribute.isEmpty()) { |
| | | writeKeyAndValue(attributeDescription, ByteString.empty()); |
| | | attr.put(attributeDescription+attr.size(), new AbstractMap.SimpleEntry<String,ByteSequence>(attributeDescription,ByteString.empty()) ); |
| | | } else { |
| | | for (final ByteString value : attribute) { |
| | | writeKeyAndValue(attributeDescription, value); |
| | | attr.put(attributeDescription+attr.size(), new AbstractMap.SimpleEntry<String,ByteSequence>(attributeDescription,value)); |
| | | } |
| | | } |
| | | } |
| | | for (AbstractMap.SimpleEntry<String,ByteSequence> kv : attr.values()) { |
| | | writeKeyAndValue(kv.getKey(), kv.getValue()); |
| | | } |
| | | |
| | | // Make sure there is a blank line after the entry. |
| | | impl.println(); |
| | |
| | | writer.close(); |
| | | |
| | | final String[] expected = |
| | | new String[] { "dn: cn=John Doe,ou=people,dc=example,dc=com", "objectClass: top", |
| | | "objectClass: person", "objectClass: inetOrgPerson", "cn: John Doe", "sn: Doe", |
| | | "givenName: John", "description: one two", "description: three four", |
| | | "description: five six", "typeOnly: ", "localized;lang-fr:: w6dlZGlsbGE=", "", }; |
| | | new String[] { "dn: cn=John Doe,ou=people,dc=example,dc=com", |
| | | "cn: John Doe", |
| | | "description: one two", |
| | | "description: three four", |
| | | "description: five six", |
| | | "givenName: John", |
| | | "localized;lang-fr:: w6dlZGlsbGE=", |
| | | "objectClass: top", |
| | | "objectClass: person", |
| | | "objectClass: inetOrgPerson", |
| | | "sn: Doe", |
| | | "typeOnly: ", |
| | | |
| | | "", }; |
| | | |
| | | Assert.assertEquals(actual.size(), expected.length); |
| | | for (int i = 0; i < expected.length; i++) { |
| | |
| | | |
| | | dn: coretokenid=tokenId,dc=example,dc=com |
| | | coretokenid: tokenId |
| | | coretokenobject: {"redirectURI":["http://fake.com"],"acr":[],"clientID":["clientOIDC"],"lineFoldingTest":["This line should have been correctly folded"],"tokenName":["refresh_token"],"authModules":["LDAP"],"realm":["/myrealm"],"id":["fakeid"],"userName":["johndoe"],"tokenType":["Bearer"]} |
| | | coretokenstring07: Bearer |
| | | coretokenstring08: /myrealm |
| | | objectClass: top |
| | | objectClass: frCoreToken |
| | | coretokenstring08: /myrealm |
| | | coretokenstring07: Bearer |
| | | coretokenobject: {"redirectURI":["http://fake.com"],"acr":[],"clientID":["clientOIDC"],"lineFoldingTest":["This line should have been correctly folded"],"tokenName":["refresh_token"],"authModules":["LDAP"],"realm":["/myrealm"],"id":["fakeid"],"userName":["johndoe"],"tokenType":["Bearer"]} |
| | | |
| | |
| | | |
| | | dn: coretokenid=tokenId,dc=example,dc=com |
| | | coretokenid: tokenId |
| | | objectClass: top |
| | | objectClass: frCoreToken |
| | | coretokenstring08: /myrealm |
| | | coretokenstring07: Bearer |
| | | coretokenobject: {"redirectURI":["http://fake.com"],"acr":[],"clientID":["client |
| | | OIDC"],"lineFoldingTest":["This line should have been correctly folded"],"token |
| | | Name":["refresh_token"],"authModules":["LDAP"],"realm":["/myrealm"],"id":["fake |
| | | id"],"userName":["johndoe"],"tokenType":["Bearer"]} |
| | | coretokenstring07: Bearer |
| | | coretokenstring08: /myrealm |
| | | objectClass: top |
| | | objectClass: frCoreToken |
| | | |