OPENDJ-1368 (CR-3232) Remove AttributeValue
Help and some code review from Matthew Swift
Removed AttributeValue interface replaced by ByteString class.
Removed AttributeValues class.
Changed the code in several places to cater for the fact that AttributeValue.equals() and hashCode() were using the normalized values.
AttributeValue.java, TestAttributeValue.java, AttributeValues.java: REMOVED
PasswordPolicyState.java:
Extracted method getPwComponents().
ExternalSASLMechanismHandler.java:
Extracted find().
LDAPFilter.java:
In toSearchFilter(), simplified code.
SearchFilter.java:
In decodeExtensibleMatchFilter(), simplified code.
Extracted methods typeAndOptionsAndAssertionEqual(), equalsSubstring(), equalsExtensible(), typeAndAssertionHashCode(), hashCode() and appendOptions().
AttributeBuilder.java:
Changed values from Set<ByteString> to Map<ByteString, ByteString> + did the same in inner classes.
A subsequent commit should look at introducing a SmallMap to mimick the SmallSet.
VirtualAttributeProvider.java + sub classes:
In getValues(), changed return type from Set<AttributeValue> to Attribute.
Removed hasAnyValue(), only used by tests + removed all subtypes implementations + removed all tests testing it.
AbstractAttribute.java + sub classes:
Changed hashCode() to build the hashCode with normalized values, equals is already covered by contains().
These methods are more than likely only used by unit tests when comparing actual/expected attributes, thus performance is not a concern here.
SearchFilter.java:
Added normalizedAssertionValue field + getNormalizedAssertionValue() + normalizeAssertionValue()
AttributeBuilderTest.java:
In testAttributeIterator(), normalized the attribute values with the equality matching rule for comparison.
SubentryManagerTestCase.java:
In testCollectiveAttributeSubentries(), removed normalization to make the test pass.
TestModifyDNOperation.java:
In testModifyDNchangeCaseAndAddValue() and testModifyDNchangeCaseOfExistingEntryValue(), used non normalized values to make the tests pass.
ModifyConflictTest.java:
In delAndAddSameOp() and addAndDelSameOp(), ensured the attribute values used in the tests are exactly the same.
*.java:
Used Utils.joinAsString().
3 files deleted
241 files modified
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.AttributeValues; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | |
| | | { |
| | | bs = ByteString.valueOf(value.toString()); |
| | | } |
| | | AttributeValue attributeValue = |
| | | AttributeValues.create(attrType, bs); |
| | | builder.add(attributeValue); |
| | | builder.add(bs); |
| | | } |
| | | List<org.opends.server.types.Attribute> attrList = |
| | | new ArrayList<org.opends.server.types.Attribute>(1); |
| | |
| | | import javax.swing.SwingUtilities; |
| | | import javax.swing.tree.TreePath; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.guitools.controlpanel.browser.BrowserController; |
| | | import org.opends.guitools.controlpanel.datamodel.BackendDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.BaseDNDescriptor; |
| | |
| | | import org.opends.guitools.controlpanel.ui.nodes.BasicNode; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.messages.AdminToolMessages; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.config.ConfigConstants; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | |
| | | /** |
| | | * The task that is called when we must modify an entry. |
| | | * |
| | | */ |
| | | public class ModifyEntryTask extends Task |
| | | { |
| | |
| | | attrType = DirectoryServer.getDefaultAttributeType( |
| | | attr.getName().toLowerCase()); |
| | | } |
| | | List<AttributeValue> newValues = new ArrayList<AttributeValue>(); |
| | | Iterator<AttributeValue> it = attr.iterator(); |
| | | List<ByteString> newValues = new ArrayList<ByteString>(); |
| | | Iterator<ByteString> it = attr.iterator(); |
| | | while (it.hasNext()) |
| | | { |
| | | newValues.add(it.next()); |
| | |
| | | List<Object> oldValues = oldEntry.getAttributeValues(attrName); |
| | | |
| | | boolean isAttributeInNewRdn = false; |
| | | AttributeValue rdnValue = null; |
| | | ByteString rdnValue = null; |
| | | RDN rdn = newEntry.getName().rdn(); |
| | | for (int i=0; i<rdn.getNumValues() && !isAttributeInNewRdn; i++) |
| | | { |
| | |
| | | * will be deleted. Check that they are on the new entry but not in |
| | | * the new RDN. If it is the case we must add them after the renaming. |
| | | */ |
| | | AttributeValue oldRdnValueToAdd = null; |
| | | ByteString oldRdnValueToAdd = null; |
| | | /* Check the value in the RDN that will be deleted. If the value was |
| | | * on the previous RDN but not in the new entry it will be deleted. So |
| | | * we must avoid to include it as a delete modification in the |
| | | * modifications. |
| | | */ |
| | | AttributeValue oldRdnValueDeleted = null; |
| | | ByteString oldRdnValueDeleted = null; |
| | | RDN oldRDN = null; |
| | | try |
| | | { |
| | |
| | | { |
| | | if (oldRDN.getAttributeName(i).equalsIgnoreCase(attrName)) |
| | | { |
| | | AttributeValue value = oldRDN.getAttributeValue(i); |
| | | ByteString value = oldRDN.getAttributeValue(i); |
| | | boolean containsValue = false; |
| | | it = attr.iterator(); |
| | | while (it.hasNext()) |
| | |
| | | } |
| | | if (oldValues == null) |
| | | { |
| | | Set<AttributeValue> vs = new HashSet<AttributeValue>(); |
| | | vs.addAll(newValues); |
| | | Set<ByteString> vs = new HashSet<ByteString>(newValues); |
| | | if (rdnValue != null) |
| | | { |
| | | vs.remove(rdnValue); |
| | |
| | | createAttribute(attrName, newValues))); |
| | | } |
| | | } else { |
| | | List<AttributeValue> toDelete = getValuesToDelete(oldValues, newValues, |
| | | attrType); |
| | | List<ByteString> toDelete = getValuesToDelete(oldValues, newValues); |
| | | if (oldRdnValueDeleted != null) |
| | | { |
| | | toDelete.remove(oldRdnValueDeleted); |
| | | } |
| | | List<AttributeValue> toAdd = getValuesToAdd(oldValues, newValues, |
| | | attrType); |
| | | List<ByteString> toAdd = getValuesToAdd(oldValues, newValues); |
| | | if (oldRdnValueToAdd != null) |
| | | { |
| | | toAdd.add(oldRdnValueToAdd); |
| | |
| | | } |
| | | if (toAdd.size() > 0) |
| | | { |
| | | List<AttributeValue> vs = new ArrayList<AttributeValue>(); |
| | | vs.addAll(toAdd); |
| | | List<ByteString> vs = new ArrayList<ByteString>(toAdd); |
| | | if (rdnValue != null) |
| | | { |
| | | vs.remove(rdnValue); |
| | |
| | | * @param values the values. |
| | | * @return a JNDI attribute using an attribute name and a set of values. |
| | | */ |
| | | private static Attribute createAttribute(String attrName, |
| | | List<AttributeValue> values) { |
| | | private static Attribute createAttribute(String attrName, List<ByteString> values) { |
| | | Attribute attribute = new BasicAttribute(attrName); |
| | | for (AttributeValue value : values) |
| | | for (ByteString value : values) |
| | | { |
| | | attribute.add(value.getValue().toByteArray()); |
| | | attribute.add(value.toByteArray()); |
| | | } |
| | | return attribute; |
| | | } |
| | | |
| | | /** |
| | | * Creates an AttributeValue for an attribute and a value (the one we got |
| | | * Creates an ByteString for an attribute and a value (the one we got |
| | | * using JNDI). |
| | | * @param attrType the attribute type. |
| | | * @param value the value found using JNDI. |
| | | * @return an AttributeValue object. |
| | | * @return an ByteString object. |
| | | */ |
| | | private static AttributeValue createAttributeValue(AttributeType attrType, |
| | | Object value) |
| | | private static ByteString createAttributeValue(Object value) |
| | | { |
| | | ByteString v; |
| | | if (value instanceof String) |
| | | { |
| | | v = ByteString.valueOf((String)value); |
| | | return ByteString.valueOf((String) value); |
| | | } |
| | | else if (value instanceof byte[]) |
| | | { |
| | | v = ByteString.wrap((byte[])value); |
| | | return ByteString.wrap((byte[]) value); |
| | | } |
| | | else |
| | | { |
| | | v = ByteString.valueOf(String.valueOf(value)); |
| | | } |
| | | return AttributeValues.create(attrType, v); |
| | | return ByteString.valueOf(String.valueOf(value)); |
| | | } |
| | | |
| | | /** |
| | | * Returns the set of AttributeValue that must be deleted. |
| | | * Returns the set of ByteString that must be deleted. |
| | | * @param oldValues the old values of the entry. |
| | | * @param newValues the new values of the entry. |
| | | * @param attrType the attribute type. |
| | | * @return the set of AttributeValue that must be deleted. |
| | | * @return the set of ByteString that must be deleted. |
| | | */ |
| | | private static List<AttributeValue> getValuesToDelete(List<Object> oldValues, |
| | | List<AttributeValue> newValues, AttributeType attrType) |
| | | private static List<ByteString> getValuesToDelete(List<Object> oldValues, |
| | | List<ByteString> newValues) |
| | | { |
| | | List<AttributeValue> valuesToDelete = new ArrayList<AttributeValue>(); |
| | | List<ByteString> valuesToDelete = new ArrayList<ByteString>(); |
| | | for (Object o : oldValues) |
| | | { |
| | | AttributeValue oldValue = createAttributeValue(attrType, o); |
| | | ByteString oldValue = createAttributeValue(o); |
| | | if (!newValues.contains(oldValue)) |
| | | { |
| | | valuesToDelete.add(oldValue); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the set of AttributeValue that must be added. |
| | | * Returns the set of ByteString that must be added. |
| | | * @param oldValues the old values of the entry. |
| | | * @param newValues the new values of the entry. |
| | | * @param attrType the attribute type. |
| | | * @return the set of AttributeValue that must be added. |
| | | * @return the set of ByteString that must be added. |
| | | */ |
| | | private static List<AttributeValue> getValuesToAdd(List<Object> oldValues, |
| | | List<AttributeValue> newValues, AttributeType attrType) |
| | | private static List<ByteString> getValuesToAdd(List<Object> oldValues, |
| | | List<ByteString> newValues) |
| | | { |
| | | List<AttributeValue> valuesToAdd = new ArrayList<AttributeValue>(); |
| | | for (AttributeValue newValue : newValues) |
| | | List<ByteString> valuesToAdd = new ArrayList<ByteString>(); |
| | | for (ByteString newValue : newValues) |
| | | { |
| | | boolean found = false; |
| | | for (Object o : oldValues) |
| | | { |
| | | found = newValue.equals(createAttributeValue(attrType, o)); |
| | | if (found) |
| | | { |
| | | break; |
| | | } |
| | | } |
| | | if (!found) |
| | | if (!contains(oldValues, newValue)) |
| | | { |
| | | valuesToAdd.add(newValue); |
| | | } |
| | | } |
| | | return valuesToAdd; |
| | | } |
| | | |
| | | private static boolean contains(List<Object> oldValues, ByteString newValue) |
| | | { |
| | | for (Object o : oldValues) |
| | | { |
| | | if (createAttributeValue(o).equals(newValue)) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | } |
| | |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.config.ConfigConstants; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | |
| | |
| | | for (org.opends.server.types.Attribute attr : newEntry.getAttributes()) |
| | | { |
| | | String attrName = attr.getNameWithOptions(); |
| | | Set<AttributeValue> values = new LinkedHashSet<AttributeValue>(); |
| | | Iterator<AttributeValue> it = attr.iterator(); |
| | | Set<ByteString> values = new LinkedHashSet<ByteString>(); |
| | | Iterator<ByteString> it = attr.iterator(); |
| | | while (it.hasNext()) |
| | | { |
| | | values.add(it.next()); |
| | | } |
| | | BasicAttribute a = new BasicAttribute(attrName); |
| | | for (AttributeValue value : values) |
| | | for (ByteString value : values) |
| | | { |
| | | a.add(value.getValue().toByteArray()); |
| | | a.add(value.toByteArray()); |
| | | } |
| | | attrs.put(a); |
| | | } |
| | |
| | | import org.opends.guitools.controlpanel.ui.renderer.CustomListCellRenderer; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.quicksetup.UserDataCertificateException; |
| | | import org.opends.quicksetup.ui.CertificateDialog; |
| | | import org.opends.quicksetup.util.UIKeyStore; |
| | |
| | | getInfo().getServerDescriptor().getSchema().getAttributeType( |
| | | attr.toString().toLowerCase()); |
| | | LDAPFilter ldapFilter = |
| | | new LDAPFilter(SearchFilter.createEqualityFilter( |
| | | attrType, AttributeValues.create(attrType, s))); |
| | | new LDAPFilter(SearchFilter.createEqualityFilter( attrType, ByteString.valueOf(s))); |
| | | returnValue = ldapFilter.toString(); |
| | | } |
| | | } |
| | |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.AttributeValues; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | |
| | | { |
| | | bs = ByteString.valueOf(value.toString()); |
| | | } |
| | | AttributeValue attributeValue = |
| | | AttributeValues.create(attrType, bs); |
| | | builder.add(attributeValue); |
| | | builder.add(bs); |
| | | } |
| | | List<Attribute> attrList = new ArrayList<Attribute>(1); |
| | | attrList.add(builder.toAttribute()); |
| | |
| | | import org.opends.server.tools.ImportLDIF; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import org.opends.server.tools.makeldif.MakeLDIF; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | |
| | | Attributes attrs = new BasicAttributes(); |
| | | |
| | | BasicAttribute oc = new BasicAttribute("objectClass"); |
| | | Iterator<AttributeValue> it = |
| | | indexEntry.getObjectClassAttribute().iterator(); |
| | | |
| | | Iterator<ByteString> it = indexEntry.getObjectClassAttribute().iterator(); |
| | | while (it.hasNext()) |
| | | { |
| | | oc.add(it.next().getValue().toString()); |
| | | oc.add(it.next().toString()); |
| | | } |
| | | attrs.put(oc); |
| | | |
| | |
| | | it = odsAttr.iterator(); |
| | | while (it.hasNext()) |
| | | { |
| | | attr.add(it.next().getValue().toString()); |
| | | attr.add(it.next().toString()); |
| | | } |
| | | attrs.put(attr); |
| | | |
| | | if (attrName.equalsIgnoreCase("ds-cfg-attribute")) |
| | | { |
| | | args.add("--index-name"); |
| | | AttributeValue value = |
| | | odsAttr.iterator().next(); |
| | | args.add(value.getValue().toString()); |
| | | args.add(odsAttr.iterator().next().toString()); |
| | | } |
| | | else if (attrName.equalsIgnoreCase("ds-cfg-index-type")) |
| | | { |
| | |
| | | while (it.hasNext()) |
| | | { |
| | | args.add("--set"); |
| | | args.add("index-type:"+it.next().getValue().toString()); |
| | | args.add("index-type:" + it.next().toString()); |
| | | } |
| | | } |
| | | } |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | |
| | | |
| | | /** |
| | | * Panel that appears when the user defines a new index. |
| | | * |
| | | */ |
| | | public class NewIndexPanel extends AbstractIndexPanel |
| | | { |
| | |
| | | |
| | | private String getAttributeName() |
| | | { |
| | | String attrName; |
| | | CategorizedComboBoxElement o = |
| | | (CategorizedComboBoxElement)attributes.getSelectedItem(); |
| | | if (o != null) |
| | | { |
| | | attrName = o.getValue().toString(); |
| | | } |
| | | else |
| | | { |
| | | attrName = null; |
| | | } |
| | | return attrName; |
| | | return o != null ? o.toString() : null; |
| | | } |
| | | |
| | | /** |
| | |
| | | Attributes attrs = new BasicAttributes(); |
| | | |
| | | BasicAttribute oc = new BasicAttribute("objectClass"); |
| | | Iterator<AttributeValue> it = |
| | | Iterator<ByteString> it = |
| | | indexEntry.getObjectClassAttribute().iterator(); |
| | | while (it.hasNext()) |
| | | { |
| | | oc.add(it.next().getValue().toString()); |
| | | oc.add(it.next().toString()); |
| | | } |
| | | attrs.put(oc); |
| | | |
| | |
| | | it = odsAttr.iterator(); |
| | | while (it.hasNext()) |
| | | { |
| | | attr.add(it.next().getValue().toString()); |
| | | attr.add(it.next().toString()); |
| | | } |
| | | attrs.put(attr); |
| | | } |
| | |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2014 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.schema.SchemaConstants; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.Base64; |
| | |
| | | RDN rdn = oldDN.rdn(); |
| | | List<AttributeType> attributeTypes = new ArrayList<AttributeType>(); |
| | | List<String> attributeNames = new ArrayList<String>(); |
| | | List<AttributeValue> attributeValues = new ArrayList<AttributeValue>(); |
| | | List<ByteString> attributeValues = new ArrayList<ByteString>(); |
| | | for (int i=0; i<rdn.getNumValues(); i++) |
| | | { |
| | | String attrName = rdn.getAttributeName(i); |
| | | AttributeValue value = rdn.getAttributeValue(i); |
| | | |
| | | String sValue = value.getValue().toString(); |
| | | ByteString value = rdn.getAttributeValue(i); |
| | | |
| | | List<String> values = getDisplayedStringValues(attrName); |
| | | if (!values.contains(sValue)) |
| | | if (!values.contains(value.toString())) |
| | | { |
| | | if (values.size() > 0) |
| | | { |
| | |
| | | AttributeType attr = rdn.getAttributeType(i); |
| | | attributeTypes.add(attr); |
| | | attributeNames.add(rdn.getAttributeName(i)); |
| | | attributeValues.add(AttributeValues.create( |
| | | attr, firstNonEmpty)); |
| | | attributeValues.add(ByteString.valueOf(firstNonEmpty)); |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | attributeTypes.add(attr); |
| | | attributeNames.add(attrName); |
| | | attributeValues.add( |
| | | AttributeValues.create(attr, (String)o)); |
| | | attributeValues.add(ByteString.valueOf((String) o)); |
| | | } |
| | | break; |
| | | } |
| | |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | |
| | | import org.opends.guitools.controlpanel.ui.renderer.LDAPEntryTableCellRenderer; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.LDIFReader; |
| | | import org.opends.server.util.ServerConstants; |
| | | |
| | | /** |
| | | * The panel displaying a table view of an LDAP entry. |
| | | * |
| | | */ |
| | | |
| | | public class TableViewEntryPanel extends ViewEntryPanel |
| | | { |
| | | private static final long serialVersionUID = 2135331526526472175L; |
| | |
| | | RDN rdn = oldDN.rdn(); |
| | | List<AttributeType> attributeTypes = new ArrayList<AttributeType>(); |
| | | List<String> attributeNames = new ArrayList<String>(); |
| | | List<AttributeValue> attributeValues = new ArrayList<AttributeValue>(); |
| | | List<ByteString> attributeValues = new ArrayList<ByteString>(); |
| | | for (int i=0; i<rdn.getNumValues(); i++) |
| | | { |
| | | String attrName = rdn.getAttributeName(i); |
| | | AttributeValue value = rdn.getAttributeValue(i); |
| | | |
| | | String sValue = value.getValue().toString(); |
| | | ByteString value = rdn.getAttributeValue(i); |
| | | |
| | | Set<String> values = getDisplayedStringValues(attrName); |
| | | if (!values.contains(sValue)) |
| | | if (!values.contains(value.toString())) |
| | | { |
| | | if (values.size() > 0) |
| | | { |
| | |
| | | AttributeType attr = rdn.getAttributeType(i); |
| | | attributeTypes.add(attr); |
| | | attributeNames.add(rdn.getAttributeName(i)); |
| | | attributeValues.add(AttributeValues.create( |
| | | attr, firstNonEmpty)); |
| | | attributeValues.add(ByteString.valueOf(firstNonEmpty)); |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | attributeTypes.add(attr); |
| | | attributeNames.add(attrName); |
| | | attributeValues.add(AttributeValues.create( |
| | | attr, (String)o)); |
| | | attributeValues.add(ByteString.valueOf((String) o)); |
| | | } |
| | | break; |
| | | } |
| | |
| | | import org.opends.server.replication.plugin.EntryHistorical; |
| | | import org.opends.server.schema.SchemaConstants; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.ObjectClass; |
| | |
| | | for (int i=0; i<rdn.getNumValues(); i++) |
| | | { |
| | | String attrName = rdn.getAttributeName(i); |
| | | AttributeValue value = rdn.getAttributeValue(i); |
| | | ByteString value = rdn.getAttributeValue(i); |
| | | List<org.opends.server.types.Attribute> attrs = |
| | | entry.getAttribute(attrName.toLowerCase()); |
| | | boolean done = false; |
| | |
| | | { |
| | | if (attr.getNameWithOptions().equals(attrName)) |
| | | { |
| | | ArrayList<AttributeValue> newValues = |
| | | new ArrayList<AttributeValue>(); |
| | | Iterator<AttributeValue> it = attr.iterator(); |
| | | ArrayList<ByteString> newValues = new ArrayList<ByteString>(); |
| | | Iterator<ByteString> it = attr.iterator(); |
| | | while (it.hasNext()) |
| | | { |
| | | newValues.add(it.next()); |
| | |
| | | { |
| | | org.opends.server.types.Attribute attr = |
| | | Attributes.create(rdn.getAttributeType(i), value); |
| | | ArrayList<AttributeValue> newValues = |
| | | new ArrayList<AttributeValue>(); |
| | | ArrayList<ByteString> newValues = new ArrayList<ByteString>(); |
| | | newValues.add(value); |
| | | entry.addAttribute(attr, newValues); |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | result = rdn.getAttributeValue(0).getValue().toString(); |
| | | result = rdn.getAttributeValue(0).toString(); |
| | | } |
| | | } |
| | | else { |
| | |
| | | AccessibleTableHeaderRenderer; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.quicksetup.Installation; |
| | | import org.opends.quicksetup.ui.UIFactory; |
| | | import org.opends.quicksetup.util.Utils; |
| | |
| | | public static String getRDNString(String attrName, String attrValue) |
| | | { |
| | | AttributeType attrType = DirectoryServer.getDefaultAttributeType(attrName); |
| | | AttributeValue value = |
| | | AttributeValues.create(attrType, attrValue); |
| | | RDN rdn = new RDN(attrType, attrName, value); |
| | | RDN rdn = new RDN(attrType, attrName, ByteString.valueOf(attrValue)); |
| | | return rdn.toString(); |
| | | } |
| | | |
| | |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | |
| | | |
| | | import java.util.Collections; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.admin.std.client.RootCfgClient; |
| | | import org.opends.server.admin.std.meta.RootCfgDefn; |
| | | import org.opends.server.admin.std.server.RootCfg; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | |
| | | |
| | | /** |
| | | * A path which can be used to determine the location of a managed |
| | | * object instance. |
| | |
| | | String type = profile.getRelationChildRDNType(r); |
| | | AttributeType atype = DirectoryServer.getAttributeType( |
| | | type.toLowerCase(), true); |
| | | AttributeValue avalue = AttributeValues.create(atype, name); |
| | | ByteString avalue = ByteString.valueOf(name); |
| | | dn = dn.child(RDN.create(atype, avalue)); |
| | | } |
| | | |
| | |
| | | String type = profile.getRelationChildRDNType(r); |
| | | AttributeType atype = DirectoryServer.getAttributeType( |
| | | type.toLowerCase(), true); |
| | | AttributeValue avalue = AttributeValues.create(atype, d.getName()); |
| | | ByteString avalue = ByteString.valueOf(d.getName()); |
| | | dn = dn.child(RDN.create(atype, avalue)); |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.RDN; |
| | |
| | | + s + "\""); |
| | | } |
| | | |
| | | AttributeValue av = rdn.getAttributeValue(0); |
| | | ByteString av = rdn.getAttributeValue(0); |
| | | if (av == null) { |
| | | throw new IllegalArgumentException("Unabled to decode the DN string: \"" |
| | | + s + "\""); |
| | | } |
| | | |
| | | String name = av.getValue().toString(); |
| | | String name = av.toString(); |
| | | |
| | | // Check that the DN was valid. |
| | | DN expected = p.child(rd, name).toDN(); |
| | |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.opends.server.types.DN; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | |
| | | public boolean configAddIsAcceptable(ConfigEntry configEntry, |
| | | LocalizableMessageBuilder unacceptableReason) { |
| | | DN dn = configEntry.getDN(); |
| | | AttributeValue av = dn.rdn().getAttributeValue(0); |
| | | String name = av.getValue().toString().trim(); |
| | | ByteString av = dn.rdn().getAttributeValue(0); |
| | | String name = av.toString().trim(); |
| | | |
| | | try { |
| | | ManagedObjectPath<?, ? extends S> childPath; |
| | |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.opends.server.types.DN; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | |
| | | public boolean configDeleteIsAcceptable(ConfigEntry configEntry, |
| | | LocalizableMessageBuilder unacceptableReason) { |
| | | DN dn = configEntry.getDN(); |
| | | AttributeValue av = dn.rdn().getAttributeValue(0); |
| | | String name = av.getValue().toString().trim(); |
| | | ByteString av = dn.rdn().getAttributeValue(0); |
| | | String name = av.toString().trim(); |
| | | |
| | | try { |
| | | ManagedObjectPath<?, ? extends S> childPath; |
| | |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeValueIterable; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DN; |
| | | |
| | | /** |
| | |
| | | throw new PropertyNotFoundException(propertyName); |
| | | } |
| | | |
| | | List<AttributeValue> values = getAttribute(mod, pd2, configEntry); |
| | | List<ByteString> values = getAttribute(mod, pd2, configEntry); |
| | | if (values.isEmpty()) { |
| | | // Recursively retrieve this property's default values. |
| | | Collection<T> tmp = find(target, pd2); |
| | |
| | | return pvalues; |
| | | } else { |
| | | Collection<T> pvalues = new ArrayList<T>(values.size()); |
| | | for (AttributeValue value : values) { |
| | | for (ByteString value : values) { |
| | | pvalues.add(ValueDecoder.decode(pd1, value)); |
| | | } |
| | | return pvalues; |
| | |
| | | * was invalid. |
| | | */ |
| | | public static <PD> PD decode(PropertyDefinition<PD> pd, |
| | | AttributeValue value) throws PropertyException { |
| | | String s = value.getValue().toString(); |
| | | return pd.castValue(pd.accept(new ValueDecoder(), s)); |
| | | ByteString value) throws PropertyException { |
| | | return pd.castValue(pd.accept(new ValueDecoder(), value.toString())); |
| | | } |
| | | |
| | | |
| | |
| | | // definition. |
| | | pd = (PropertyDefinition<PD>) mod.getPropertyDefinition(pd.getName()); |
| | | |
| | | List<AttributeValue> values = getAttribute(mod, pd, configEntry); |
| | | List<ByteString> values = getAttribute(mod, pd, configEntry); |
| | | return decodeProperty(path.asSubType(mod), pd, values, null); |
| | | } |
| | | |
| | |
| | | ArrayList<String> names = new ArrayList<String>(children.size()); |
| | | for (DN child : children) { |
| | | // Assume that RDNs are single-valued and can be trimmed. |
| | | AttributeValue av = child.rdn().getAttributeValue(0); |
| | | names.add(av.getValue().toString().trim()); |
| | | ByteString av = child.rdn().getAttributeValue(0); |
| | | names.add(av.toString().trim()); |
| | | } |
| | | |
| | | return names.toArray(new String[names.size()]); |
| | |
| | | ArrayList<String> names = new ArrayList<String>(children.size()); |
| | | for (DN child : children) { |
| | | // Assume that RDNs are single-valued and can be trimmed. |
| | | AttributeValue av = child.rdn().getAttributeValue(0); |
| | | ByteString av = child.rdn().getAttributeValue(0); |
| | | names.add(av.toString().trim()); |
| | | } |
| | | |
| | |
| | | Map<PropertyDefinition<?>, SortedSet<?>> properties = |
| | | new HashMap<PropertyDefinition<?>, SortedSet<?>>(); |
| | | for (PropertyDefinition<?> pd : mod.getAllPropertyDefinitions()) { |
| | | List<AttributeValue> values = getAttribute(mod, pd, configEntry); |
| | | List<ByteString> values = getAttribute(mod, pd, configEntry); |
| | | try { |
| | | SortedSet<?> pvalues = decodeProperty(path, pd, values, newConfigEntry); |
| | | properties.put(pd, pvalues); |
| | |
| | | |
| | | // Create a property using the provided string values. |
| | | private <T> SortedSet<T> decodeProperty(ManagedObjectPath<?, ?> path, |
| | | PropertyDefinition<T> pd, List<AttributeValue> values, |
| | | PropertyDefinition<T> pd, List<ByteString> values, |
| | | ConfigEntry newConfigEntry) throws PropertyException { |
| | | PropertyException exception = null; |
| | | SortedSet<T> pvalues = new TreeSet<T>(pd); |
| | | |
| | | if (!values.isEmpty()) { |
| | | // The property has values defined for it. |
| | | for (AttributeValue value : values) { |
| | | for (ByteString value : values) { |
| | | try { |
| | | pvalues.add(ValueDecoder.decode(pd, value)); |
| | | } catch (PropertyException e) { |
| | |
| | | |
| | | |
| | | // Gets the attribute associated with a property from a ConfigEntry. |
| | | private List<AttributeValue> getAttribute(ManagedObjectDefinition<?, ?> d, |
| | | private List<ByteString> getAttribute(ManagedObjectDefinition<?, ?> d, |
| | | PropertyDefinition<?> pd, ConfigEntry configEntry) { |
| | | // TODO: we create a default attribute type if it is |
| | | // undefined. We should log a warning here if this is the case |
| | |
| | | AttributeType type = DirectoryServer.getAttributeType(attrID, true); |
| | | List<Attribute> attributes = configEntry.getEntry().getAttribute(type, true); |
| | | |
| | | List<AttributeValue> results = new LinkedList<AttributeValue>(); |
| | | for (AttributeValue v : new AttributeValueIterable(attributes)) |
| | | List<ByteString> results = new LinkedList<ByteString>(); |
| | | for (ByteString v : new AttributeValueIterable(attributes)) |
| | | { |
| | | results.add(v); |
| | | } |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | |
| | | { |
| | | if (a.isEmpty()) continue; |
| | | |
| | | AttributeValue v = a.iterator().next(); |
| | | ByteString v = a.iterator().next(); |
| | | DN subentryDN; |
| | | try |
| | | { |
| | | subentryDN = DN.decode(v.getValue()); |
| | | subentryDN = DN.decode(v); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | logger.trace( |
| | | "Could not parse password policy subentry DN %s for user %s", v |
| | | .getValue(), userDNString, e); |
| | | logger.trace("Could not parse password policy subentry DN %s for user %s", |
| | | v, userDNString, e); |
| | | |
| | | if (useDefaultOnError) |
| | | { |
| | | logger.error(ERR_PWPSTATE_CANNOT_DECODE_SUBENTRY_VALUE_AS_DN, |
| | | v.getValue(), userDNString, e.getMessage()); |
| | | v, userDNString, e.getMessage()); |
| | | return DirectoryServer.getDefaultPasswordPolicy(); |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_PWPSTATE_CANNOT_DECODE_SUBENTRY_VALUE_AS_DN |
| | | .get(v.getValue(), userDNString, e.getMessage()); |
| | | throw new DirectoryException(ResultCode.INVALID_DN_SYNTAX, message, |
| | | e); |
| | | .get(v, userDNString, e.getMessage()); |
| | | throw new DirectoryException(ResultCode.INVALID_DN_SYNTAX, message, e); |
| | | } |
| | | } |
| | | |
| | |
| | | continue; |
| | | } |
| | | |
| | | final String valueString = toLowerCase(a.iterator().next().getValue() |
| | | .toString()); |
| | | final String valueString = toLowerCase(a.iterator().next().toString()); |
| | | |
| | | if (valueString.equals("true") || valueString.equals("yes") |
| | | || valueString.equals("on") || valueString.equals("1")) |
| | |
| | | continue; |
| | | } |
| | | |
| | | final AttributeValue v = a.iterator().next(); |
| | | final ByteString v = a.iterator().next(); |
| | | try |
| | | { |
| | | MatchingRule rule = attributeType.getEqualityMatchingRule(); |
| | | ByteString normValue = rule.normalizeAttributeValue(v.getValue()); |
| | | ByteString normValue = rule.normalizeAttributeValue(v); |
| | | timeValue = GeneralizedTimeSyntax.decodeGeneralizedTimeValue(normValue); |
| | | } |
| | | catch (final Exception e) |
| | | { |
| | | logger.traceException(e, "Unable to decode value %s for attribute %s in user entry %s", |
| | | v.getValue(), attributeType.getNameOrOID(), entry.getName()); |
| | | v, attributeType.getNameOrOID(), entry.getName()); |
| | | |
| | | final LocalizableMessage message = ERR_PWPSTATE_CANNOT_DECODE_GENERALIZED_TIME |
| | | .get(v.getValue(), attributeType.getNameOrOID(), entry.getName(), e); |
| | | .get(v, attributeType.getNameOrOID(), entry.getName(), e); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message, e); |
| | | } |
| | |
| | | import org.opends.server.core.networkgroups.NetworkGroup; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.AuthenticationInfo; |
| | | import org.opends.server.types.CancelRequest; |
| | | import org.opends.server.types.CancelResult; |
| | |
| | | { |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | String privName = toLowerCase(v.getValue().toString()); |
| | | String privName = toLowerCase(v.toString()); |
| | | |
| | | // If the name of the privilege is prefixed with a minus |
| | | // sign, then we will take away that privilege from the |
| | |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.AttributeValues; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.Attributes; |
| | | import org.forgerock.opendj.ldap.ByteSequenceReader; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.ObjectClass; |
| | |
| | | final int valueLength = reader.getBERLength(); |
| | | final ByteString valueBytes = reader.getByteSequence(valueLength) |
| | | .toByteString(); |
| | | return Attributes.create(attrType, |
| | | AttributeValues.create(attrType, valueBytes)); |
| | | return Attributes.create(attrType, valueBytes); |
| | | } |
| | | else |
| | | { |
| | |
| | | final int valueLength = reader.getBERLength(); |
| | | final ByteString valueBytes = reader.getByteSequence(valueLength) |
| | | .toByteString(); |
| | | builder.add(AttributeValues.create(attrType, valueBytes)); |
| | | builder.add(valueBytes); |
| | | } |
| | | return builder.toAttribute(); |
| | | } |
| | |
| | | builder.appendBERLength(idBytes.length); |
| | | builder.append(idBytes); |
| | | builder.appendBERLength(attribute.size()); |
| | | for (final AttributeValue v : attribute) |
| | | for (final ByteString v : attribute) |
| | | { |
| | | builder.appendBERLength(v.getValue().length()); |
| | | builder.append(v.getValue()); |
| | | builder.appendBERLength(v.length()); |
| | | builder.append(v); |
| | | } |
| | | } |
| | | |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.opends.server.admin.std.server.VirtualAttributeCfg; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.VirtualAttributeRule; |
| | |
| | | |
| | | |
| | | /** |
| | | * Generates an unmodifiable set of values for the provided entry. |
| | | * Generates an unmodifiable attribute with the values for the provided entry. |
| | | * |
| | | * @param entry |
| | | * The entry for which the values are to be generated. |
| | | * @param rule |
| | | * The virtual attribute rule which defines the constraints |
| | | * for the virtual attribute. |
| | | * @return The unmodifiable set of values generated for the provided |
| | | * entry. It may be empty, but it must not be {@code null}. |
| | | * @return The unmodifiable attribute with the values generated for the |
| | | * provided entry. It may be empty, but it must not be {@code null}. |
| | | */ |
| | | public abstract Set<AttributeValue> getValues( |
| | | Entry entry, VirtualAttributeRule rule); |
| | | public abstract Attribute getValues(Entry entry, VirtualAttributeRule rule); |
| | | |
| | | |
| | | |
| | |
| | | */ |
| | | public boolean hasValue(Entry entry, VirtualAttributeRule rule) |
| | | { |
| | | return (! getValues(entry, rule).isEmpty()); |
| | | return !getValues(entry, rule).isEmpty(); |
| | | } |
| | | |
| | | |
| | |
| | | * generate the specified value for the provided entry, or |
| | | * {@code false} if not. |
| | | */ |
| | | public boolean hasValue(Entry entry, VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | public boolean hasValue(Entry entry, VirtualAttributeRule rule, ByteString value) |
| | | { |
| | | return getValues(entry, rule).contains(value); |
| | | } |
| | |
| | | * them. |
| | | */ |
| | | public boolean hasAllValues(Entry entry, VirtualAttributeRule rule, |
| | | Collection<AttributeValue> values) |
| | | Collection<ByteString> values) |
| | | { |
| | | Set<AttributeValue> virtualValues = getValues(entry, rule); |
| | | return virtualValues.containsAll(values); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether this virtual attribute provider will generate |
| | | * any of the values in the provided collection. |
| | | * |
| | | * @param entry The entry for which to make the determination. |
| | | * @param rule The virtual attribute rule which defines the |
| | | * constraints for the virtual attribute. |
| | | * @param values The set of values for which to make the |
| | | * determination. |
| | | * |
| | | * @return {@code true} if this attribute provider will generate |
| | | * at least one of the values in the provided collection, |
| | | * or {@code false} if it will not generate any of them. |
| | | */ |
| | | public boolean hasAnyValue(Entry entry, VirtualAttributeRule rule, |
| | | Collection<AttributeValue> values) |
| | | { |
| | | Set<AttributeValue> virtualValues = getValues(entry, rule); |
| | | for (AttributeValue value : values) |
| | | { |
| | | if (virtualValues.contains(value)) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | return getValues(entry, rule).containsAll(values); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | |
| | | ConditionResult result = ConditionResult.FALSE; |
| | | for (AttributeValue value : getValues(entry, rule)) |
| | | for (ByteString value : getValues(entry, rule)) |
| | | { |
| | | try |
| | | { |
| | | ByteString nv = matchingRule.normalizeAttributeValue(value.getValue()); |
| | | ByteString nv = matchingRule.normalizeAttributeValue(value); |
| | | if (matchingRule.valueMatchesSubstring( |
| | | nv, |
| | | normalizedSubInitial, |
| | |
| | | */ |
| | | public ConditionResult greaterThanOrEqualTo(Entry entry, |
| | | VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | ByteString value) |
| | | { |
| | | OrderingMatchingRule matchingRule = |
| | | rule.getAttributeType().getOrderingMatchingRule(); |
| | |
| | | ByteString normalizedValue; |
| | | try |
| | | { |
| | | normalizedValue = matchingRule.normalizeAttributeValue(value.getValue()); |
| | | normalizedValue = matchingRule.normalizeAttributeValue(value); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | } |
| | | |
| | | ConditionResult result = ConditionResult.FALSE; |
| | | for (AttributeValue v : getValues(entry, rule)) |
| | | for (ByteString v : getValues(entry, rule)) |
| | | { |
| | | try |
| | | { |
| | | ByteString nv = matchingRule.normalizeAttributeValue(v.getValue()); |
| | | ByteString nv = matchingRule.normalizeAttributeValue(v); |
| | | if (matchingRule.compareValues(nv, normalizedValue) >= 0) |
| | | { |
| | | return ConditionResult.TRUE; |
| | |
| | | */ |
| | | public ConditionResult lessThanOrEqualTo(Entry entry, |
| | | VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | ByteString value) |
| | | { |
| | | OrderingMatchingRule matchingRule = |
| | | rule.getAttributeType().getOrderingMatchingRule(); |
| | |
| | | ByteString normalizedValue; |
| | | try |
| | | { |
| | | normalizedValue = matchingRule.normalizeAttributeValue(value.getValue()); |
| | | normalizedValue = matchingRule.normalizeAttributeValue(value); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | } |
| | | |
| | | ConditionResult result = ConditionResult.FALSE; |
| | | for (AttributeValue v : getValues(entry, rule)) |
| | | for (ByteString v : getValues(entry, rule)) |
| | | { |
| | | try |
| | | { |
| | | ByteString nv = matchingRule.normalizeAttributeValue(v.getValue()); |
| | | ByteString nv = matchingRule.normalizeAttributeValue(v); |
| | | if (matchingRule.compareValues(nv, normalizedValue) <= 0) |
| | | { |
| | | return ConditionResult.TRUE; |
| | |
| | | */ |
| | | public ConditionResult approximatelyEqualTo(Entry entry, |
| | | VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | ByteString value) |
| | | { |
| | | MatchingRule matchingRule = rule.getAttributeType().getApproximateMatchingRule(); |
| | | if (matchingRule == null) |
| | |
| | | Assertion assertion = null; |
| | | try |
| | | { |
| | | assertion = matchingRule.getAssertion(value.getValue()); |
| | | assertion = matchingRule.getAssertion(value); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | } |
| | | |
| | | ConditionResult result = ConditionResult.FALSE; |
| | | for (AttributeValue v : getValues(entry, rule)) |
| | | for (ByteString v : getValues(entry, rule)) |
| | | { |
| | | try |
| | | { |
| | | ByteString nv = matchingRule.normalizeAttributeValue(v.getValue()); |
| | | result = assertion.matches(nv); |
| | | result = assertion.matches(matchingRule.normalizeAttributeValue(v)); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.api.ClientConnection; |
| | | import org.opends.server.api.Group; |
| | | import org.opends.server.controls.GetEffectiveRightsRequestControl; |
| | |
| | | * The attribute type value in the resource entry currently being |
| | | * evaluated. |
| | | */ |
| | | private AttributeValue attributeValue; |
| | | private ByteString attributeValue; |
| | | |
| | | /** |
| | | * True if this is the first attribute type in the resource entry being |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public AttributeValue getCurrentAttributeValue() { |
| | | public ByteString getCurrentAttributeValue() { |
| | | return attributeValue; |
| | | } |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void setCurrentAttributeValue(AttributeValue value) { |
| | | public void setCurrentAttributeValue(ByteString value) { |
| | | attributeValue=value; |
| | | } |
| | | |
| | |
| | | |
| | | import static org.opends.server.authorization.dseecompat.Aci.*; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import java.util.LinkedList; |
| | |
| | | //Write right is more complicated. Create a dummy value and set that as |
| | | //the attribute's value. Call the special writeRightsString method, rather |
| | | //than rightsString. |
| | | AttributeValue val= AttributeValues.create(a, "dum###Val"); |
| | | ByteString val= ByteString.valueOf("dum###Val"); |
| | | container.setCurrentAttributeValue(val); |
| | | evalInfo.append(attributeLevelWriteRights(container, handler, skipCheck)); |
| | | addAttrLevelRightsInfo(container, mask, a, retEntry, "write"); |
| | | evalInfo.append(','); |
| | | //Perform both selfwrite_add and selfwrite_delete and append results. |
| | | AttributeValue val1= |
| | | AttributeValues.create(a, |
| | | container.getClientDN().toString()); |
| | | ByteString val1 = ByteString.valueOf(container.getClientDN().toString()); |
| | | if(!specificAttr) |
| | | { |
| | | container.setCurrentAttributeType(dnAttributeType); |
| | | } |
| | | container.setCurrentAttributeValue(val1); |
| | | container.setRights(ACI_WRITE_ADD | ACI_SKIP_PROXY_CHECK); |
| | | evalInfo.append(rightsString(container, handler, skipCheck, |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | |
| | | baseName = toLowerCase(rawAttributeType); |
| | | } |
| | | |
| | | AttributeType attributeType = getAttributeType(baseName); |
| | | AttributeValue attributeValue = |
| | | AttributeValues.create(attributeType, operation.getAssertionValue()); |
| | | container.setCurrentAttributeType(attributeType); |
| | | container.setCurrentAttributeValue(attributeValue); |
| | | container.setCurrentAttributeType(getAttributeType(baseName)); |
| | | container.setCurrentAttributeValue(operation.getAssertionValue()); |
| | | return isAllowed(container, operation); |
| | | } |
| | | |
| | |
| | | final List<String> URLStrings = reference.getReferralURLs(); |
| | | for (String URLString : URLStrings) |
| | | { |
| | | builder.add(AttributeValues.create(refAttrType, URLString)); |
| | | builder.add(URLString); |
| | | } |
| | | |
| | | final Entry e = new Entry(dn, null, null, null); |
| | |
| | | && container.hasRights(ACI_WRITE) |
| | | && isAttributeDN(container.getCurrentAttributeType())) |
| | | { |
| | | String DNString = null; |
| | | String dnString = null; |
| | | try |
| | | { |
| | | DNString = |
| | | container.getCurrentAttributeValue().getValue().toString(); |
| | | DN tmpDN = DN.valueOf(DNString); |
| | | dnString = container.getCurrentAttributeValue().toString(); |
| | | DN tmpDN = DN.valueOf(dnString); |
| | | // Have a valid DN, compare to clientDN to see if the ACI_SELF |
| | | // right should be set. |
| | | if (tmpDN.equals(container.getClientDN())) |
| | |
| | | catch (DirectoryException ex) |
| | | { |
| | | // Log a message and keep going. |
| | | logger.warn(WARN_ACI_NOT_VALID_DN, DNString); |
| | | logger.warn(WARN_ACI_NOT_VALID_DN, dnString); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | container.setCurrentAttributeValue(v); |
| | | container.setRights(ACI_WRITE_DELETE); |
| | |
| | | |
| | | if (!modAttr.isEmpty()) |
| | | { |
| | | for (AttributeValue v : modAttr) |
| | | for (ByteString v : modAttr) |
| | | { |
| | | container.setCurrentAttributeType(modAttrType); |
| | | switch (m.getModificationType().asEnum()) |
| | |
| | | { |
| | | for (Attribute attr : modifiedAttrs) |
| | | { |
| | | for (AttributeValue val : attr) |
| | | for (ByteString val : attr) |
| | | { |
| | | container.setCurrentAttributeValue(val); |
| | | container.setRights(ACI_WRITE_ADD); |
| | |
| | | { |
| | | dn = DN.rootDN(); |
| | | } |
| | | Aci.decode(v.getValue(), dn); |
| | | // validate ACI syntax |
| | | Aci.decode(v, dn); |
| | | } |
| | | catch (AciException ex) |
| | | { |
| | |
| | | entry.getOperationalAttribute(aciType, null); |
| | | for (Attribute attribute : attributeList) |
| | | { |
| | | for (AttributeValue value : attribute) |
| | | for (ByteString value : attribute) |
| | | { |
| | | try |
| | | { |
| | | Aci.decode(value.getValue(), entry.getName()); |
| | | // validate ACI syntax |
| | | Aci.decode(value, entry.getName()); |
| | | } |
| | | catch (AciException ex) |
| | | { |
| | |
| | | int validAcis=0; |
| | | ArrayList<Aci> acis = new ArrayList<Aci>(); |
| | | for (Attribute attribute : attributeList) { |
| | | for (AttributeValue value : attribute) { |
| | | for (ByteString value : attribute) { |
| | | try { |
| | | Aci aci= Aci.decode(value.getValue(),dn); |
| | | acis.add(aci); |
| | | acis.add(Aci.decode(value, dn)); |
| | | validAcis++; |
| | | } catch (AciException ex) { |
| | | DN msgDN=dn; |
| | | if(dn == DN.rootDN()) { |
| | | msgDN=configDN; |
| | | } |
| | | failedACIMsgs.add(WARN_ACI_ADD_LIST_FAILED_DECODE.get( |
| | | value.getValue(), msgDN, ex.getMessage())); |
| | | failedACIMsgs.add(WARN_ACI_ADD_LIST_FAILED_DECODE.get(value, msgDN, ex.getMessage())); |
| | | } |
| | | } |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.authorization.dseecompat; |
| | | |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.Entry; |
| | | import java.util.List; |
| | | |
| | |
| | | * The current attribute type value being evaluated. |
| | | * @return The current attribute type value being evaluated. |
| | | */ |
| | | public AttributeValue getCurrentAttributeValue(); |
| | | public ByteString getCurrentAttributeValue(); |
| | | |
| | | /** |
| | | * True if the first attribute of the resource entry is being evaluated. |
| | |
| | | * Set the attribute value to be evaluated. |
| | | * @param v The current attribute value to set to. |
| | | */ |
| | | public void setCurrentAttributeValue(AttributeValue v); |
| | | public void setCurrentAttributeValue(ByteString v); |
| | | |
| | | /** |
| | | * True if the target matching code found an entry test rule. An |
| | |
| | | import java.util.regex.Pattern; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.api.Group; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.GroupManager; |
| | |
| | | DN suffixDN) { |
| | | EnumEvalResult matched= EnumEvalResult.FALSE; |
| | | List<Attribute> attrs = e.getAttribute(attributeType); |
| | | for(AttributeValue v : attrs.get(0)) { |
| | | for(ByteString v : attrs.get(0)) { |
| | | try { |
| | | DN groupDN=DN.valueOf(v.getValue().toString()); |
| | | if(suffixDN != null && |
| | | !groupDN.isDescendantOf(suffixDN)) |
| | | DN groupDN = DN.valueOf(v.toString()); |
| | | if(suffixDN != null && !groupDN.isDescendantOf(suffixDN)) |
| | | { |
| | | continue; |
| | | } |
| | | Group<?> group = getGroupManager().getGroupInstance(groupDN); |
| | | if((group != null) && (evalCtx.isMemberOf(group))) { |
| | | matched=EnumEvalResult.TRUE; |
| | |
| | | // Sort the attribute-value pairs by attribute type. |
| | | TreeMap<String,ArrayList<ByteString>> patternMap = |
| | | new TreeMap<String, ArrayList<ByteString>>(); |
| | | TreeMap<String,AttributeValue> rdnMap = |
| | | new TreeMap<String, AttributeValue>(); |
| | | TreeMap<String, ByteString> rdnMap = new TreeMap<String, ByteString>(); |
| | | |
| | | for (int i = 0; i < rdn.getNumValues(); i++) |
| | | { |
| | |
| | | */ |
| | | private boolean matchValuePattern(List<ByteString> pattern, |
| | | AttributeType type, |
| | | AttributeValue value) |
| | | ByteString value) |
| | | { |
| | | if (pattern == null) |
| | | { |
| | |
| | | { |
| | | // Handle this just like an equality filter. |
| | | MatchingRule rule = type.getEqualityMatchingRule(); |
| | | ByteString thatNormValue = rule.normalizeAttributeValue(value.getValue()); |
| | | ByteString thatNormValue = rule.normalizeAttributeValue(value); |
| | | return rule.getAssertion(pattern.get(0)).matches(thatNormValue).toBoolean(); |
| | | } |
| | | |
| | |
| | | import java.util.regex.Pattern; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.*; |
| | | |
| | | /** |
| | |
| | | // If the filter list does not contain the attribute type skip the |
| | | // attribute type. |
| | | if((attrType != null) && (filterList.containsKey(attrType))) { |
| | | AttributeValue value=matchCtx.getCurrentAttributeValue(); |
| | | ByteString value = matchCtx.getCurrentAttributeValue(); |
| | | SearchFilter filter = filterList.get(attrType); |
| | | attrMatched=matchFilterAttributeValue(attrType, value, filter); |
| | | //This flag causes any targattr checks to be bypassed in AciTargets. |
| | |
| | | AttributeType attrType, |
| | | SearchFilter filter) { |
| | | //Iterate through each value and apply the filter against it. |
| | | for (AttributeValue value : a) { |
| | | for (ByteString value : a) { |
| | | if (!matchFilterAttributeValue(attrType, value, filter)) { |
| | | return false; |
| | | } |
| | |
| | | * @return True if the value matches the filter. |
| | | */ |
| | | private boolean matchFilterAttributeValue(AttributeType attrType, |
| | | AttributeValue value, |
| | | ByteString value, |
| | | SearchFilter filter) { |
| | | Attribute attr = Attributes.create(attrType, value); |
| | | Entry e = new Entry(DN.rootDN(), null, null, null); |
| | | e.addAttribute(attr, new ArrayList<AttributeValue>()); |
| | | e.addAttribute(attr, new ArrayList<ByteString>()); |
| | | try { |
| | | return filter.matchesEntry(e); |
| | | } catch(DirectoryException ex) { |
| | |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | filter, null); |
| | | LinkedList<SearchResultEntry> result = op.getSearchEntries(); |
| | | if (!result.isEmpty()) { |
| | | AttributeValue val= AttributeValues.create(attrType, attrVal); |
| | | ByteString val= ByteString.valueOf(attrVal); |
| | | SearchResultEntry resultEntry = result.getFirst(); |
| | | if(resultEntry.hasValue(attrType, null, val)) { |
| | | Entry e=evalCtx.getResourceEntry(); |
| | | if(e.hasValue(attrType, null, val)) |
| | | { |
| | | matched=EnumEvalResult.TRUE; |
| | | } |
| | | } |
| | | } |
| | | return matched.getRet(type, undefined); |
| | | } |
| | | |
| | |
| | | List<Attribute> attrs=evalCtx.getResourceEntry().getAttribute(attrType); |
| | | if(!attrs.isEmpty()) { |
| | | for(Attribute a : attrs) { |
| | | for(AttributeValue v : a) { |
| | | String urlStr=v.getValue().toString(); |
| | | for(ByteString v : a) { |
| | | LDAPURL url; |
| | | try { |
| | | url=LDAPURL.decode(urlStr, true); |
| | | url = LDAPURL.decode(v.toString(), true); |
| | | } catch (DirectoryException e) { |
| | | break; |
| | | } |
| | | matched=UserDN.evalURL(evalCtx, url); |
| | | if(matched != EnumEvalResult.FALSE) |
| | | { |
| | | break; |
| | | } |
| | | } |
| | | if(matched == EnumEvalResult.TRUE) |
| | | { |
| | | break; |
| | | if(matched == EnumEvalResult.ERR) { |
| | | } |
| | | if (matched == EnumEvalResult.ERR) |
| | | { |
| | | undefined=true; |
| | | break; |
| | | } |
| | |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | |
| | | * TODO Evaluate making this method more efficient. |
| | | * |
| | | * The evalDNEntryAttr method isn't as efficient as it could be. It would |
| | | * probably be faster to to convert the clientDN to an AttributeValue and |
| | | * probably be faster to to convert the clientDN to an ByteString and |
| | | * see if the entry has that value than to decode each value as a DN and |
| | | * see if it matches the clientDN. |
| | | */ |
| | |
| | | AttributeType attrType) { |
| | | EnumEvalResult matched= EnumEvalResult.FALSE; |
| | | List<Attribute> attrs = e.getAttribute(attrType); |
| | | for(AttributeValue v : attrs.get(0)) { |
| | | for(ByteString v : attrs.get(0)) { |
| | | try { |
| | | DN dn=DN.valueOf(v.getValue().toString()); |
| | | DN dn = DN.valueOf(v.toString()); |
| | | if(dn.equals(clientDN)) { |
| | | matched=EnumEvalResult.TRUE; |
| | | break; |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.util.Reject; |
| | | import org.opends.server.admin.Configuration; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.BackupBackendCfg; |
| | | import org.opends.server.api.Backend; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.DeleteOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | import org.opends.server.schema.BooleanSyntax; |
| | | import org.opends.server.schema.GeneralizedTimeSyntax; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import static org.opends.messages.BackendMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | |
| | | List<Attribute> attrList = backupDirEntry.getAttribute(t); |
| | | if ((attrList != null) && (! attrList.isEmpty())) |
| | | { |
| | | for (AttributeValue v : attrList.get(0)) |
| | | for (ByteString v : attrList.get(0)) |
| | | { |
| | | try |
| | | { |
| | | BackupDirectory backupDirectory = |
| | | BackupDirectory.readBackupDirectoryDescriptor( |
| | | v.getValue().toString()); |
| | | BackupDirectory.readBackupDirectoryDescriptor(v.toString()); |
| | | count += backupDirectory.getBackups().keySet().size(); |
| | | } |
| | | catch (Exception e) |
| | |
| | | // Make sure that the DN specifies a backup directory. |
| | | AttributeType t = |
| | | DirectoryServer.getAttributeType(ATTR_BACKUP_DIRECTORY_PATH, true); |
| | | AttributeValue v = entryDN.rdn().getAttributeValue(t); |
| | | ByteString v = entryDN.rdn().getAttributeValue(t); |
| | | if (v == null) |
| | | { |
| | | LocalizableMessage message = |
| | |
| | | BackupDirectory backupDirectory; |
| | | try |
| | | { |
| | | backupDirectory = |
| | | BackupDirectory.readBackupDirectoryDescriptor( |
| | | v.getValue().toString()); |
| | | backupDirectory = BackupDirectory.readBackupDirectoryDescriptor(v.toString()); |
| | | } |
| | | catch (ConfigException ce) |
| | | { |
| | |
| | | |
| | | t = DirectoryServer.getAttributeType(ATTR_BACKUP_BACKEND_DN, true); |
| | | attrList = new ArrayList<Attribute>(1); |
| | | attrList.add(Attributes.create(t, AttributeValues.create(t, |
| | | backupDirectory.getConfigEntryDN().toString()))); |
| | | attrList.add(Attributes.create(t, ByteString.valueOf(backupDirectory.getConfigEntryDN().toString()))); |
| | | userAttrs.put(t, attrList); |
| | | |
| | | Entry e = new Entry(entryDN, ocMap, userAttrs, opAttrs); |
| | |
| | | // First, get the backup ID from the entry DN. |
| | | AttributeType idType = DirectoryServer.getAttributeType(ATTR_BACKUP_ID, |
| | | true); |
| | | AttributeValue idValue = entryDN.rdn().getAttributeValue(idType); |
| | | ByteString idValue = entryDN.rdn().getAttributeValue(idType); |
| | | if (idValue == null) { |
| | | LocalizableMessage message = ERR_BACKUP_NO_BACKUP_ID_IN_DN.get(entryDN); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | String backupID = idValue.getValue().toString(); |
| | | String backupID = idValue.toString(); |
| | | |
| | | // Next, get the backup directory from the parent DN. |
| | | DN parentDN = entryDN.getParentDNInSuffix(); |
| | |
| | | |
| | | AttributeType t = DirectoryServer.getAttributeType( |
| | | ATTR_BACKUP_DIRECTORY_PATH, true); |
| | | AttributeValue v = parentDN.rdn().getAttributeValue(t); |
| | | ByteString v = parentDN.rdn().getAttributeValue(t); |
| | | if (v == null) { |
| | | LocalizableMessage message = ERR_BACKUP_NO_BACKUP_DIR_IN_DN.get(entryDN); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | |
| | | |
| | | BackupDirectory backupDirectory; |
| | | try { |
| | | backupDirectory = BackupDirectory.readBackupDirectoryDescriptor(v |
| | | .getValue().toString()); |
| | | backupDirectory = BackupDirectory.readBackupDirectoryDescriptor(v.toString()); |
| | | } catch (ConfigException ce) { |
| | | logger.traceException(ce); |
| | | |
| | |
| | | if (backupDate != null) { |
| | | t = DirectoryServer.getAttributeType(ATTR_BACKUP_DATE, true); |
| | | attrList = new ArrayList<Attribute>(1); |
| | | attrList.add(Attributes.create(t, AttributeValues.create(t, |
| | | GeneralizedTimeSyntax.format(backupDate)))); |
| | | attrList.add(Attributes.create(t, ByteString.valueOf(GeneralizedTimeSyntax.format(backupDate)))); |
| | | userAttrs.put(t, attrList); |
| | | } |
| | | |
| | |
| | | t = DirectoryServer.getAttributeType(ATTR_BACKUP_DEPENDENCY, true); |
| | | AttributeBuilder builder = new AttributeBuilder(t); |
| | | for (String s : dependencies) { |
| | | builder.add(AttributeValues.create(t, s)); |
| | | builder.add(s); |
| | | } |
| | | attrList = new ArrayList<Attribute>(1); |
| | | attrList.add(builder.toAttribute()); |
| | |
| | | if (signedHash != null) { |
| | | t = DirectoryServer.getAttributeType(ATTR_BACKUP_SIGNED_HASH, true); |
| | | attrList = new ArrayList<Attribute>(1); |
| | | attrList.add(Attributes.create(t, |
| | | AttributeValues.create(t, |
| | | ByteString.wrap(signedHash)))); |
| | | attrList.add(Attributes.create(t, ByteString.wrap(signedHash))); |
| | | userAttrs.put(t, attrList); |
| | | } |
| | | |
| | |
| | | if (unsignedHash != null) { |
| | | t = DirectoryServer.getAttributeType(ATTR_BACKUP_UNSIGNED_HASH, true); |
| | | attrList = new ArrayList<Attribute>(1); |
| | | attrList.add(Attributes.create(t, |
| | | AttributeValues.create(t, |
| | | ByteString.wrap(unsignedHash)))); |
| | | attrList.add(Attributes.create(t, ByteString.wrap(unsignedHash))); |
| | | userAttrs.put(t, attrList); |
| | | } |
| | | |
| | |
| | | for (Map.Entry<String, String> e : properties.entrySet()) { |
| | | t = DirectoryServer.getAttributeType(toLowerCase(e.getKey()), true); |
| | | attrList = new ArrayList<Attribute>(1); |
| | | attrList.add(Attributes.create(t, AttributeValues.create( |
| | | t, e.getValue()))); |
| | | attrList.add(Attributes.create(t, ByteString.valueOf(e.getValue()))); |
| | | userAttrs.put(t, attrList); |
| | | } |
| | | } |
| | |
| | | backupDirEntry.getAttribute(backupPathType); |
| | | if ((attrList != null) && (! attrList.isEmpty())) |
| | | { |
| | | for (AttributeValue v : attrList.get(0)) |
| | | for (ByteString v : attrList.get(0)) |
| | | { |
| | | try |
| | | { |
| | | BackupDirectory backupDirectory = |
| | | BackupDirectory.readBackupDirectoryDescriptor( |
| | | v.getValue().toString()); |
| | | BackupDirectory.readBackupDirectoryDescriptor(v.toString()); |
| | | AttributeType idType = |
| | | DirectoryServer.getAttributeType(ATTR_BACKUP_ID, |
| | | true); |
| | |
| | | List<Attribute> attrList = backupDirEntry.getAttribute(t); |
| | | if ((attrList != null) && (! attrList.isEmpty())) |
| | | { |
| | | for (AttributeValue v : attrList.get(0)) |
| | | for (ByteString v : attrList.get(0)) |
| | | { |
| | | try |
| | | { |
| | | BackupDirectory backupDirectory = |
| | | BackupDirectory.readBackupDirectoryDescriptor( |
| | | v.getValue().toString()); |
| | | BackupDirectory.readBackupDirectoryDescriptor(v.toString()); |
| | | AttributeType idType = |
| | | DirectoryServer.getAttributeType(ATTR_BACKUP_ID, |
| | | true); |
| | |
| | | public static DN makeChildDN(DN parentDN, AttributeType rdnAttrType, |
| | | String rdnStringValue) |
| | | { |
| | | AttributeValue attrValue = |
| | | AttributeValues.create(rdnAttrType, rdnStringValue); |
| | | ByteString attrValue = ByteString.valueOf(rdnStringValue); |
| | | return parentDN.child(RDN.create(rdnAttrType, attrValue)); |
| | | } |
| | | |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.util.Reject; |
| | |
| | | for (int i = 0; i < rdn.getNumValues(); i++) |
| | | { |
| | | final AttributeType attributeType = rdn.getAttributeType(i); |
| | | final AttributeValue value = rdn.getAttributeValue(attributeType); |
| | | final ByteString value = rdn.getAttributeValue(attributeType); |
| | | final Attribute attr = Attributes.create(attributeType, value); |
| | | final List<Attribute> attrList = new ArrayList<Attribute>(1); |
| | | attrList.add(attr); |
| | |
| | | // Make sure to include the RDN attribute. |
| | | final RDN entryRDN = entryDN.rdn(); |
| | | final AttributeType rdnType = entryRDN.getAttributeType(0); |
| | | final AttributeValue rdnValue = entryRDN.getAttributeValue(0); |
| | | final ByteString rdnValue = entryRDN.getAttributeValue(0); |
| | | |
| | | final Attribute rdnAttr = Attributes.create(rdnType, rdnValue); |
| | | final ArrayList<Attribute> rdnList = new ArrayList<Attribute>(1); |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.util.Reject; |
| | | import org.opends.server.admin.Configuration; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.api.ClientConnection; |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.DeleteOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.core.WorkflowTopologyNode; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.util.LDIFWriter; |
| | | |
| | | import static org.opends.messages.BackendMessages.*; |
| | |
| | | |
| | | AttributeBuilder builder = new AttributeBuilder(type, name); |
| | | for (DN dn : values) { |
| | | builder.add( |
| | | AttributeValues.create(type, dn.toString())); |
| | | builder.add(dn.toString()); |
| | | } |
| | | |
| | | return builder.toAttribute(); |
| | | } |
| | | |
| | |
| | | AttributeBuilder builder = new AttributeBuilder(type, name); |
| | | builder.setInitialCapacity(values.size()); |
| | | for (String s : values) { |
| | | builder.add(AttributeValues.create(type, s)); |
| | | builder.add(s); |
| | | } |
| | | |
| | | return builder.toAttribute(); |
| | | } |
| | | |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | |
| | | /** |
| | | * The value containing DN of the user we'll say created the configuration. |
| | | */ |
| | | private AttributeValue creatorsName; |
| | | private ByteString creatorsName; |
| | | |
| | | /** |
| | | * The value containing the DN of the last user to modify the configuration. |
| | | */ |
| | | private AttributeValue modifiersName; |
| | | private ByteString modifiersName; |
| | | |
| | | /** The timestamp that will be used for the schema creation time. */ |
| | | private AttributeValue createTimestamp; |
| | | private ByteString createTimestamp; |
| | | |
| | | /** |
| | | * The timestamp that will be used for the latest schema modification time. |
| | | */ |
| | | private AttributeValue modifyTimestamp; |
| | | private ByteString modifyTimestamp; |
| | | |
| | | /** |
| | | * Indicates whether the attributes of the schema entry should always be |
| | |
| | | cfg.getBaseDN().toArray(newBaseDNs); |
| | | this.baseDNs = newBaseDNs; |
| | | |
| | | creatorsName = AttributeValues.create( |
| | | creatorsNameType, newBaseDNs[0].toString()); |
| | | modifiersName = AttributeValues.create( |
| | | modifiersNameType, newBaseDNs[0].toString()); |
| | | creatorsName = ByteString.valueOf(newBaseDNs[0].toString()); |
| | | modifiersName = ByteString.valueOf(newBaseDNs[0].toString()); |
| | | |
| | | long createTime = DirectoryServer.getSchema().getOldestModificationTime(); |
| | | createTimestamp = |
| | |
| | | case ADD: |
| | | if (at.equals(attributeTypesType)) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | AttributeType type; |
| | | try |
| | | { |
| | | type = AttributeTypeSyntax.decodeAttributeType(v.getValue(), |
| | | newSchema, false); |
| | | type = AttributeTypeSyntax.decodeAttributeType(v, newSchema, false); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_ATTRTYPE.get( |
| | | v.getValue(), de.getMessageObject()); |
| | | v, de.getMessageObject()); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de); |
| | | } |
| | |
| | | } |
| | | else if (at.equals(objectClassesType)) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | ObjectClass oc; |
| | | try |
| | | { |
| | | oc = ObjectClassSyntax.decodeObjectClass(v.getValue(), |
| | | newSchema, false); |
| | | oc = ObjectClassSyntax.decodeObjectClass(v, newSchema, false); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_OBJECTCLASS. |
| | | get(v.getValue(), de.getMessageObject()); |
| | | get(v, de.getMessageObject()); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de); |
| | | } |
| | |
| | | } |
| | | else if (at.equals(nameFormsType)) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | NameForm nf; |
| | | try |
| | | { |
| | | nf = NameFormSyntax.decodeNameForm(v.getValue(), newSchema, |
| | | false); |
| | | nf = NameFormSyntax.decodeNameForm(v, newSchema, false); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_NAME_FORM.get( |
| | | v.getValue(), de.getMessageObject()); |
| | | v, de.getMessageObject()); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de); |
| | | } |
| | |
| | | } |
| | | else if (at.equals(ditContentRulesType)) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | DITContentRule dcr; |
| | | try |
| | | { |
| | | dcr = DITContentRuleSyntax.decodeDITContentRule(v.getValue(), |
| | | newSchema, false); |
| | | dcr = DITContentRuleSyntax.decodeDITContentRule(v, newSchema, false); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_DCR.get( |
| | | v.getValue(), de.getMessageObject()); |
| | | v, de.getMessageObject()); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de); |
| | | } |
| | |
| | | } |
| | | else if (at.equals(ditStructureRulesType)) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | DITStructureRule dsr; |
| | | try |
| | | { |
| | | dsr = DITStructureRuleSyntax.decodeDITStructureRule( |
| | | v.getValue(), newSchema, false); |
| | | dsr = DITStructureRuleSyntax.decodeDITStructureRule(v, newSchema, false); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_DSR.get( |
| | | v.getValue(), de.getMessageObject()); |
| | | v, de.getMessageObject()); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de); |
| | | } |
| | |
| | | } |
| | | else if (at.equals(matchingRuleUsesType)) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | MatchingRuleUse mru; |
| | | try |
| | | { |
| | | mru = MatchingRuleUseSyntax.decodeMatchingRuleUse(v.getValue(), |
| | | newSchema, false); |
| | | mru = MatchingRuleUseSyntax.decodeMatchingRuleUse(v, newSchema, false); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_MR_USE.get( |
| | | v.getValue(), de.getMessageObject()); |
| | | v, de.getMessageObject()); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de); |
| | | } |
| | |
| | | } |
| | | else if (at.equals(ldapSyntaxesType)) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | LDAPSyntaxDescription lsd; |
| | | try |
| | | { |
| | | lsd = LDAPSyntaxDescriptionSyntax.decodeLDAPSyntax( |
| | | v.getValue(), newSchema, false); |
| | | lsd = LDAPSyntaxDescriptionSyntax.decodeLDAPSyntax(v, newSchema, false); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | LocalizableMessage message = |
| | | ERR_SCHEMA_MODIFY_CANNOT_DECODE_LDAP_SYNTAX.get( |
| | | v.getValue(), de.getMessageObject()); |
| | | ERR_SCHEMA_MODIFY_CANNOT_DECODE_LDAP_SYNTAX.get(v, de.getMessageObject()); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de); |
| | | } |
| | |
| | | |
| | | if (at.equals(attributeTypesType)) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | AttributeType type; |
| | | try |
| | | { |
| | | type = AttributeTypeSyntax.decodeAttributeType(v.getValue(), |
| | | newSchema, false); |
| | | type = AttributeTypeSyntax.decodeAttributeType(v, newSchema, false); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_ATTRTYPE.get( |
| | | v.getValue(), de.getMessageObject()); |
| | | v, de.getMessageObject()); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de); |
| | | } |
| | |
| | | } |
| | | else if (at.equals(objectClassesType)) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | ObjectClass oc; |
| | | try |
| | | { |
| | | oc = ObjectClassSyntax.decodeObjectClass(v.getValue(), |
| | | newSchema, false); |
| | | oc = ObjectClassSyntax.decodeObjectClass(v, newSchema, false); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_OBJECTCLASS. |
| | | get(v.getValue(), de.getMessageObject()); |
| | | get(v, de.getMessageObject()); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de); |
| | | } |
| | |
| | | } |
| | | else if (at.equals(nameFormsType)) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | NameForm nf; |
| | | try |
| | | { |
| | | nf = NameFormSyntax.decodeNameForm(v.getValue(), newSchema, |
| | | false); |
| | | nf = NameFormSyntax.decodeNameForm(v, newSchema, false); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_NAME_FORM.get( |
| | | v.getValue(), de.getMessageObject()); |
| | | v, de.getMessageObject()); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de); |
| | | } |
| | |
| | | } |
| | | else if (at.equals(ditContentRulesType)) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | DITContentRule dcr; |
| | | try |
| | | { |
| | | dcr = DITContentRuleSyntax.decodeDITContentRule(v.getValue(), |
| | | newSchema, false); |
| | | dcr = DITContentRuleSyntax.decodeDITContentRule(v, newSchema, false); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_DCR.get( |
| | | v.getValue(), de.getMessageObject()); |
| | | v, de.getMessageObject()); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de); |
| | | } |
| | |
| | | } |
| | | else if (at.equals(ditStructureRulesType)) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | DITStructureRule dsr; |
| | | try |
| | | { |
| | | dsr = DITStructureRuleSyntax.decodeDITStructureRule( |
| | | v.getValue(), newSchema, false); |
| | | dsr = DITStructureRuleSyntax.decodeDITStructureRule(v, newSchema, false); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_DSR.get( |
| | | v.getValue(), de.getMessageObject()); |
| | | v, de.getMessageObject()); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de); |
| | | } |
| | |
| | | } |
| | | else if (at.equals(matchingRuleUsesType)) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | MatchingRuleUse mru; |
| | | try |
| | | { |
| | | mru = MatchingRuleUseSyntax.decodeMatchingRuleUse(v.getValue(), |
| | | newSchema, false); |
| | | mru = MatchingRuleUseSyntax.decodeMatchingRuleUse(v, newSchema, false); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_MR_USE.get( |
| | | v.getValue(), de.getMessageObject()); |
| | | v, de.getMessageObject()); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de); |
| | | } |
| | |
| | | } |
| | | else if (at.equals(ldapSyntaxesType)) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | LDAPSyntaxDescription lsd; |
| | | try |
| | | { |
| | | lsd = LDAPSyntaxDescriptionSyntax.decodeLDAPSyntax( |
| | | v.getValue(), newSchema, false); |
| | | lsd = LDAPSyntaxDescriptionSyntax.decodeLDAPSyntax(v, newSchema, false); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | |
| | | |
| | | LocalizableMessage message = |
| | | ERR_SCHEMA_MODIFY_CANNOT_DECODE_LDAP_SYNTAX.get( |
| | | v.getValue(), de.getMessageObject()); |
| | | v, de.getMessageObject()); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de); |
| | | } |
| | |
| | | authzDN = DN.rootDN(); |
| | | } |
| | | |
| | | modifiersName = AttributeValues.create( |
| | | modifiersNameType, authzDN.toString()); |
| | | modifiersName = ByteString.valueOf(authzDN.toString()); |
| | | modifyTimestamp = GeneralizedTimeSyntax.createGeneralizedTimeValue( |
| | | System.currentTimeMillis()); |
| | | } |
| | |
| | | continue; |
| | | } |
| | | |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | AttributeType at; |
| | | try |
| | | { |
| | | at = AttributeTypeSyntax.decodeAttributeType(v.getValue(), schema, |
| | | true); |
| | | at = AttributeTypeSyntax.decodeAttributeType(v, schema, true); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_ATTRTYPE.get( |
| | | v.getValue(), de.getMessageObject()); |
| | | v, de.getMessageObject()); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, |
| | | de); |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de); |
| | | } |
| | | |
| | | if (attributeType.getOID().equals(at.getOID())) |
| | |
| | | continue; |
| | | } |
| | | |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | ObjectClass oc; |
| | | try |
| | | { |
| | | oc = ObjectClassSyntax.decodeObjectClass(v.getValue(), schema, true); |
| | | oc = ObjectClassSyntax.decodeObjectClass(v, schema, true); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_OBJECTCLASS.get( |
| | | v.getValue(), de.getMessageObject()); |
| | | v, de.getMessageObject()); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, |
| | | de); |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de); |
| | | } |
| | | |
| | | if (objectClass.getOID().equals(oc.getOID())) |
| | |
| | | continue; |
| | | } |
| | | |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | NameForm nf; |
| | | try |
| | | { |
| | | nf = NameFormSyntax.decodeNameForm(v.getValue(), schema, true); |
| | | nf = NameFormSyntax.decodeNameForm(v, schema, true); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_NAME_FORM.get( |
| | | v.getValue(), de.getMessageObject()); |
| | | v, de.getMessageObject()); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, |
| | | de); |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de); |
| | | } |
| | | |
| | | if (nameForm.getOID().equals(nf.getOID())) |
| | |
| | | continue; |
| | | } |
| | | |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | DITStructureRule dsr; |
| | | try |
| | | { |
| | | dsr = DITStructureRuleSyntax.decodeDITStructureRule( |
| | | v.getValue(), schema, true); |
| | | dsr = DITStructureRuleSyntax.decodeDITStructureRule(v, schema, true); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_DSR.get( |
| | | v.getValue(), de.getMessageObject()); |
| | | v, de.getMessageObject()); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, |
| | | de); |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de); |
| | | } |
| | | |
| | | if (ditStructureRule.getRuleID() == dsr.getRuleID()) |
| | |
| | | * this only for the real part of the ldapsyntaxes attribute. The real part |
| | | * is read and write to/from the schema files. |
| | | */ |
| | | Set<AttributeValue> values = new LinkedHashSet<AttributeValue>(); |
| | | Set<ByteString> values = new LinkedHashSet<ByteString>(); |
| | | for (LDAPSyntaxDescription ldapSyntax : |
| | | schema.getLdapSyntaxDescriptions().values()) |
| | | { |
| | | if (schemaFile.equals(getSchemaFile(ldapSyntax))) |
| | | { |
| | | values.add(AttributeValues.create(ldapSyntaxesType, |
| | | ldapSyntax.toString())); |
| | | values.add(ByteString.valueOf(ldapSyntax.toString())); |
| | | } |
| | | } |
| | | |
| | |
| | | // to be careful of the ordering to ensure that any superior types in the |
| | | // same file are written before the subordinate types. |
| | | Set<AttributeType> addedTypes = new HashSet<AttributeType>(); |
| | | values = new LinkedHashSet<AttributeValue>(); |
| | | values = new LinkedHashSet<ByteString>(); |
| | | for (AttributeType at : schema.getAttributeTypes().values()) |
| | | { |
| | | if (schemaFile.equals(getSchemaFile(at))) |
| | |
| | | // to be careful of the ordering to ensure that any superior classes in the |
| | | // same file are written before the subordinate classes. |
| | | Set<ObjectClass> addedClasses = new HashSet<ObjectClass>(); |
| | | values = new LinkedHashSet<AttributeValue>(); |
| | | values = new LinkedHashSet<ByteString>(); |
| | | for (ObjectClass oc : schema.getObjectClasses().values()) |
| | | { |
| | | if (schemaFile.equals(getSchemaFile(oc))) |
| | |
| | | // Add all of the appropriate name forms to the schema entry. Since there |
| | | // is no hierarchical relationship between name forms, we don't need to |
| | | // worry about ordering. |
| | | values = new LinkedHashSet<AttributeValue>(); |
| | | values = new LinkedHashSet<ByteString>(); |
| | | for (List<NameForm> forms : schema.getNameFormsByObjectClass().values()) |
| | | { |
| | | for(NameForm nf : forms) |
| | | { |
| | | if (schemaFile.equals(getSchemaFile(nf))) |
| | | { |
| | | values.add(AttributeValues.create(nameFormsType, nf.toString())); |
| | | values.add(ByteString.valueOf(nf.toString())); |
| | | } |
| | | } |
| | | } |
| | |
| | | // Add all of the appropriate DIT content rules to the schema entry. Since |
| | | // there is no hierarchical relationship between DIT content rules, we don't |
| | | // need to worry about ordering. |
| | | values = new LinkedHashSet<AttributeValue>(); |
| | | values = new LinkedHashSet<ByteString>(); |
| | | for (DITContentRule dcr : schema.getDITContentRules().values()) |
| | | { |
| | | if (schemaFile.equals(getSchemaFile(dcr))) |
| | | { |
| | | values.add(AttributeValues.create(ditContentRulesType, |
| | | dcr.toString())); |
| | | values.add(ByteString.valueOf(dcr.toString())); |
| | | } |
| | | } |
| | | |
| | |
| | | // need to be careful of the ordering to ensure that any superior rules in |
| | | // the same file are written before the subordinate rules. |
| | | Set<DITStructureRule> addedDSRs = new HashSet<DITStructureRule>(); |
| | | values = new LinkedHashSet<AttributeValue>(); |
| | | values = new LinkedHashSet<ByteString>(); |
| | | for (DITStructureRule dsr : schema.getDITStructureRulesByID().values()) |
| | | { |
| | | if (schemaFile.equals(getSchemaFile(dsr))) |
| | |
| | | // Add all of the appropriate matching rule uses to the schema entry. Since |
| | | // there is no hierarchical relationship between matching rule uses, we |
| | | // don't need to worry about ordering. |
| | | values = new LinkedHashSet<AttributeValue>(); |
| | | values = new LinkedHashSet<ByteString>(); |
| | | for (MatchingRuleUse mru : schema.getMatchingRuleUses().values()) |
| | | { |
| | | if (schemaFile.equals(getSchemaFile(mru))) |
| | | { |
| | | values.add(AttributeValues.create(matchingRuleUsesType, |
| | | mru.toString())); |
| | | values.add(ByteString.valueOf(mru.toString())); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | private void addAttrTypeToSchemaFile(Schema schema, String schemaFile, |
| | | AttributeType attributeType, |
| | | Set<AttributeValue> values, |
| | | Set<ByteString> values, |
| | | Set<AttributeType> addedTypes, |
| | | int depth) |
| | | throws DirectoryException |
| | |
| | | addedTypes, depth+1); |
| | | } |
| | | |
| | | values.add(AttributeValues.create(attributeTypesType, |
| | | attributeType.toString())); |
| | | values.add(ByteString.valueOf(attributeType.toString())); |
| | | addedTypes.add(attributeType); |
| | | } |
| | | |
| | |
| | | */ |
| | | private void addObjectClassToSchemaFile(Schema schema, String schemaFile, |
| | | ObjectClass objectClass, |
| | | Set<AttributeValue> values, |
| | | Set<ByteString> values, |
| | | Set<ObjectClass> addedClasses, |
| | | int depth) |
| | | throws DirectoryException |
| | |
| | | addedClasses, depth+1); |
| | | } |
| | | } |
| | | values.add(AttributeValues.create(objectClassesType, |
| | | objectClass.toString())); |
| | | values.add(ByteString.valueOf(objectClass.toString())); |
| | | addedClasses.add(objectClass); |
| | | } |
| | | |
| | |
| | | */ |
| | | private void addDITStructureRuleToSchemaFile(Schema schema, String schemaFile, |
| | | DITStructureRule ditStructureRule, |
| | | Set<AttributeValue> values, |
| | | Set<ByteString> values, |
| | | Set<DITStructureRule> addedDSRs, int depth) |
| | | throws DirectoryException |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | values.add(AttributeValues.create(ditStructureRulesType, |
| | | ditStructureRule.toString())); |
| | | values.add(ByteString.valueOf(ditStructureRule.toString())); |
| | | addedDSRs.add(ditStructureRule); |
| | | } |
| | | |
| | |
| | | { |
| | | // Look for attributetypes that could have been added to the schema |
| | | // or modified in the schema |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | // Parse the attribute type. |
| | | AttributeType attrType = AttributeTypeSyntax.decodeAttributeType( |
| | | v.getValue(), schema, false); |
| | | AttributeType attrType = AttributeTypeSyntax.decodeAttributeType(v, schema, false); |
| | | String schemaFile = getSchemaFile(attrType); |
| | | if ((schemaFile != null) && |
| | | (schemaFile.equals(CONFIG_SCHEMA_ELEMENTS_FILE))) |
| | |
| | | { |
| | | for (Attribute a : ocList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | // It IS important here to allow the unknown elements that could |
| | | // appear in the new config schema. |
| | | ObjectClass newObjectClass = ObjectClassSyntax.decodeObjectClass( |
| | | v.getValue(), newSchema, true); |
| | | ObjectClass newObjectClass = ObjectClassSyntax.decodeObjectClass(v, newSchema, true); |
| | | String schemaFile = getSchemaFile(newObjectClass); |
| | | if ((schemaFile != null) && |
| | | (schemaFile.equals(CONFIG_SCHEMA_ELEMENTS_FILE))) |
| | |
| | | // Now we know we are not in the config schema, let's check |
| | | // the unknown elements ... sadly but simply by redoing the |
| | | // whole decoding. |
| | | newObjectClass = ObjectClassSyntax.decodeObjectClass( |
| | | v.getValue(), newSchema, false); |
| | | newObjectClass = ObjectClassSyntax.decodeObjectClass(v, newSchema, false); |
| | | oidList.add(newObjectClass.getOID()); |
| | | try |
| | | { |
| | |
| | | // Make sure that the DN specifies a certificate alias. |
| | | AttributeType t = |
| | | DirectoryServer.getAttributeType(ATTR_CRYPTO_KEY_ID, true); |
| | | AttributeValue v = entryDN.rdn().getAttributeValue(t); |
| | | ByteString v = entryDN.rdn().getAttributeValue(t); |
| | | if (v == null) |
| | | { |
| | | LocalizableMessage message = ERR_TRUSTSTORE_DN_DOES_NOT_SPECIFY_CERTIFICATE.get(entryDN); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message, baseDN, null); |
| | | } |
| | | |
| | | String certAlias = v.getValue().toString(); |
| | | String certAlias = v.toString(); |
| | | ByteString certValue; |
| | | try |
| | | { |
| | |
| | | true); |
| | | AttributeBuilder builder = new AttributeBuilder(t); |
| | | builder.setOption("binary"); |
| | | builder.add(AttributeValues.create(t, certValue)); |
| | | builder.add(certValue); |
| | | attrList = new ArrayList<Attribute>(1); |
| | | attrList.add(builder.toAttribute()); |
| | | userAttrs.put(t, attrList); |
| | |
| | | public static DN makeChildDN(DN parentDN, AttributeType rdnAttrType, |
| | | String rdnStringValue) |
| | | { |
| | | AttributeValue attrValue = |
| | | AttributeValues.create(rdnAttrType, rdnStringValue); |
| | | ByteString attrValue = ByteString.valueOf(rdnStringValue); |
| | | return parentDN.child(RDN.create(rdnAttrType, attrValue)); |
| | | } |
| | | |
| | |
| | | // Make sure that the DN specifies a certificate alias. |
| | | AttributeType t = |
| | | DirectoryServer.getAttributeType(ATTR_CRYPTO_KEY_ID, true); |
| | | AttributeValue v = entryDN.rdn().getAttributeValue(t); |
| | | ByteString v = entryDN.rdn().getAttributeValue(t); |
| | | if (v == null) |
| | | { |
| | | LocalizableMessage message = ERR_TRUSTSTORE_DN_DOES_NOT_SPECIFY_CERTIFICATE.get(entryDN); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message, baseDN, null); |
| | | } |
| | | String certAlias = v.getValue().toString(); |
| | | |
| | | String certAlias = v.toString(); |
| | | try |
| | | { |
| | | if (certificateManager.aliasInUse(certAlias)) |
| | |
| | | } |
| | | |
| | | Attribute certAttr = certAttrs.get(0); |
| | | Iterator<AttributeValue> i = certAttr.iterator(); |
| | | Iterator<ByteString> i = certAttr.iterator(); |
| | | |
| | | if (!i.hasNext()) |
| | | { |
| | |
| | | DirectoryServer.getServerErrorResultCode(), message); |
| | | } |
| | | |
| | | ByteString certBytes = i.next().getValue(); |
| | | ByteString certBytes = i.next(); |
| | | |
| | | if (i.hasNext()) |
| | | { |
| | |
| | | // Make sure that the DN specifies a certificate alias. |
| | | AttributeType t = |
| | | DirectoryServer.getAttributeType(ATTR_CRYPTO_KEY_ID, true); |
| | | AttributeValue v = entryDN.rdn().getAttributeValue(t); |
| | | ByteString v = entryDN.rdn().getAttributeValue(t); |
| | | if (v == null) |
| | | { |
| | | LocalizableMessage message = ERR_TRUSTSTORE_DN_DOES_NOT_SPECIFY_CERTIFICATE.get(entryDN); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message, baseDN, null); |
| | | } |
| | | String certAlias = v.getValue().toString(); |
| | | |
| | | String certAlias = v.toString(); |
| | | try |
| | | { |
| | | if (!certificateManager.aliasInUse(certAlias)) |
| | |
| | | throw new DirectoryException( |
| | | DirectoryServer.getServerErrorResultCode(), message, e); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | // Make a key from the normalized assertion value. |
| | | MatchingRule equalityRule = equalityFilter.getAttributeType(). |
| | | getEqualityMatchingRule(); |
| | | byte[] keyBytes = equalityRule.normalizeAssertionValue(equalityFilter. |
| | | getAssertionValue().getValue()).toByteArray(); |
| | | byte[] keyBytes = equalityRule.normalizeAssertionValue( |
| | | equalityFilter.getAssertionValue()).toByteArray(); |
| | | DatabaseEntry key = new DatabaseEntry(keyBytes); |
| | | |
| | | if(debugBuffer != null) |
| | |
| | | filter.getAttributeType().getOrderingMatchingRule(); |
| | | // FIXME JNR this looks wrong, it should use normalizeAssertionValue() |
| | | byte[] normalizedValue = orderingRule.normalizeAttributeValue( |
| | | filter.getAssertionValue().getValue()).toByteArray(); |
| | | filter.getAssertionValue()).toByteArray(); |
| | | |
| | | // Set the lower and upper bounds for a range search. |
| | | byte[] lower; |
| | |
| | | * @param upperValue The upper bound value |
| | | * @return The candidate entry IDs. |
| | | */ |
| | | public EntryIDSet evaluateBoundedRange(AttributeValue lowerValue, |
| | | AttributeValue upperValue) |
| | | public EntryIDSet evaluateBoundedRange(ByteString lowerValue, ByteString upperValue) |
| | | { |
| | | if (orderingIndex == null) |
| | | { |
| | |
| | | OrderingMatchingRule orderingRule = |
| | | getAttributeType().getOrderingMatchingRule(); |
| | | |
| | | // Set the lower bound for a range search. |
| | | byte[] lower = |
| | | orderingRule.normalizeAttributeValue(lowerValue.getValue()).toByteArray(); |
| | | |
| | | // Set the upper bound for a range search. |
| | | byte[] upper = |
| | | orderingRule.normalizeAttributeValue(upperValue.getValue()).toByteArray(); |
| | | // Set the lower and upper bounds for a range search. |
| | | byte[] lower = orderingRule.normalizeAttributeValue(lowerValue).toByteArray(); |
| | | byte[] upper = orderingRule.normalizeAttributeValue(upperValue).toByteArray(); |
| | | |
| | | // Read the range: lower <= keys <= upper. |
| | | return orderingIndex.readRange(lower, upper, true, true); |
| | |
| | | approximateFilter.getAttributeType().getApproximateMatchingRule(); |
| | | // Make a key from the normalized assertion value. |
| | | // FIXME JNR this looks wrong, it should use normalizeAssertionValue() |
| | | byte[] keyBytes = |
| | | approximateMatchingRule.normalizeAttributeValue( |
| | | approximateFilter.getAssertionValue().getValue()).toByteArray(); |
| | | byte[] keyBytes = approximateMatchingRule.normalizeAttributeValue( |
| | | approximateFilter.getAssertionValue()).toByteArray(); |
| | | DatabaseEntry key = new DatabaseEntry(keyBytes); |
| | | |
| | | if(debugBuffer != null) |
| | |
| | | // Make a key from the normalized assertion value. |
| | | MatchingRule rule = |
| | | extensibleFilter.getAttributeType().getEqualityMatchingRule(); |
| | | ByteString value = extensibleFilter.getAssertionValue().getValue(); |
| | | ByteString value = extensibleFilter.getAssertionValue(); |
| | | byte[] keyBytes = rule.normalizeAssertionValue(value).toByteArray(); |
| | | DatabaseEntry key = new DatabaseEntry(keyBytes); |
| | | |
| | |
| | | } |
| | | debugBuffer.append("]"); |
| | | } |
| | | ByteString assertionValue = |
| | | extensibleFilter.getAssertionValue().getValue(); |
| | | ByteString assertionValue = extensibleFilter.getAssertionValue(); |
| | | IndexQuery expression = rule.createIndexQuery(assertionValue, factory); |
| | | List<LocalizableMessage> debugMessages = |
| | | monitor.isFilterUseEnabled() ? new ArrayList<LocalizableMessage>() : null; |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | case ADD: |
| | | if (a != null) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | insert(txn, entryDN, v.getValue().toString()); |
| | | insert(txn, entryDN, v.toString()); |
| | | } |
| | | } |
| | | break; |
| | |
| | | } |
| | | else |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | delete(txn, entryDN, v.getValue().toString()); |
| | | delete(txn, entryDN, v.toString()); |
| | | } |
| | | } |
| | | break; |
| | |
| | | delete(txn, entryDN); |
| | | if (a != null) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | insert(txn, entryDN, v.getValue().toString()); |
| | | insert(txn, entryDN, v.toString()); |
| | | } |
| | | } |
| | | break; |
| | |
| | | |
| | | Entry debugEntry = |
| | | new Entry(DN.valueOf("cn=debugsearch"), null, null, null); |
| | | debugEntry.addAttribute(attr, new ArrayList<AttributeValue>()); |
| | | debugEntry.addAttribute(attr, new ArrayList<ByteString>()); |
| | | |
| | | searchOperation.returnEntry(debugEntry, null); |
| | | return; |
| | |
| | | import java.util.TreeMap; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.controls.VLVRequestControl; |
| | | import org.opends.server.controls.VLVResponseControl; |
| | |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import com.sleepycat.je.LockMode; |
| | | |
| | |
| | | } |
| | | else |
| | | { |
| | | AttributeValue assertionValue = |
| | | AttributeValues.create( |
| | | sortOrder.getSortKeys()[0].getAttributeType(), |
| | | vlvRequest.getGreaterThanOrEqualAssertion()); |
| | | ByteString assertionValue = vlvRequest.getGreaterThanOrEqualAssertion(); |
| | | |
| | | boolean targetFound = false; |
| | | int targetOffset = 0; |
| | |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.ExtensibleIndexer; |
| | | import org.opends.server.api.MatchingRule; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.Attribute; |
| | | |
| | | /** |
| | | *This class implements an Indexer for extensible matching rules in JE Backend. |
| | |
| | | { |
| | | if (!attr.isVirtual()) |
| | | { |
| | | for (AttributeValue value : attr) |
| | | for (ByteString value : attr) |
| | | { |
| | | try |
| | | { |
| | | extensibleIndexer.createKeys(null, value.getValue(), null, keys); |
| | | extensibleIndexer.createKeys(null, value, null, keys); |
| | | } |
| | | catch (DecodeException e) |
| | | { |
| | |
| | | |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.SortKey; |
| | | import org.opends.server.types.SortOrder; |
| | |
| | | implements Comparable<SortValues> |
| | | { |
| | | /** The set of sort keys (attribute values) in this sort order. */ |
| | | private AttributeValue[] values; |
| | | private ByteString[] values; |
| | | /** |
| | | * The types of sort keys. |
| | | * |
| | |
| | | * @param values The attribute values for this sort values. |
| | | * @param sortOrder The sort order to use to obtain the necessary values. |
| | | */ |
| | | public SortValues(EntryID entryID, AttributeValue[] values, |
| | | public SortValues(EntryID entryID, ByteString[] values, |
| | | SortOrder sortOrder) |
| | | { |
| | | this.entryID = entryID; |
| | |
| | | this.sortOrder = sortOrder; |
| | | |
| | | SortKey[] sortKeys = sortOrder.getSortKeys(); |
| | | this.values = new AttributeValue[sortKeys.length]; |
| | | this.values = new ByteString[sortKeys.length]; |
| | | this.types = new AttributeType[sortKeys.length]; |
| | | for (int i=0; i < sortKeys.length; i++) |
| | | { |
| | |
| | | List<Attribute> attrList = entry.getAttribute(types[i]); |
| | | if (attrList != null) |
| | | { |
| | | AttributeValue sortValue = null; |
| | | ByteString sortValue = null; |
| | | |
| | | // There may be multiple versions of this attribute in the target entry |
| | | // (e.g., with different sets of options), and it may also be a |
| | |
| | | // handled by the SortKey.compareValues method. |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | if (sortValue == null) |
| | | { |
| | |
| | | * is equal to the first sort value, or a positive value if the |
| | | * provided assertion value should come after the first sort value. |
| | | */ |
| | | public int compareTo(AttributeValue assertionValue) |
| | | public int compareTo(ByteString assertionValue) |
| | | { |
| | | SortKey sortKey = sortOrder.getSortKeys()[0]; |
| | | return sortKey.compareValues(values[0], assertionValue); |
| | |
| | | } |
| | | else |
| | | { |
| | | buffer.append(values[i].getValue().toString()); |
| | | buffer.append(values[i].toString()); |
| | | } |
| | | } |
| | | |
| | |
| | | * |
| | | * @return The array of attribute values for this sort values. |
| | | */ |
| | | public AttributeValue[] getValues() |
| | | public ByteString[] getValues() |
| | | { |
| | | return values; |
| | | } |
| | |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.api.MatchingRule; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.SortKey; |
| | | |
| | | import com.sleepycat.je.DatabaseException; |
| | | |
| | |
| | | * @throws DirectoryException If a Directory Server error occurs. |
| | | * @throws DatabaseException If an error occurs in the JE database. |
| | | */ |
| | | public boolean add(long entryID, AttributeValue[] values, |
| | | AttributeType[] types) throws DatabaseException, DirectoryException |
| | | public boolean add(long entryID, ByteString[] values, AttributeType[] types) |
| | | throws DatabaseException, DirectoryException |
| | | { |
| | | if(values == null) |
| | | { |
| | |
| | | * @throws DirectoryException If a Directory Server error occurs. |
| | | * @throws DatabaseException If an error occurs in the JE database. |
| | | */ |
| | | public boolean remove(long entryID, AttributeValue[] values, AttributeType[] types) |
| | | public boolean remove(long entryID, ByteString[] values, AttributeType[] types) |
| | | throws DatabaseException, DirectoryException |
| | | { |
| | | if(entryIDs == null || entryIDs.length == 0) |
| | |
| | | * @throws DirectoryException If a Directory Server error occurs. |
| | | * @throws DatabaseException If an error occurs in the JE database. |
| | | */ |
| | | int binarySearch(long entryID, AttributeValue[] values, AttributeType[] types) |
| | | int binarySearch(long entryID, ByteString[] values, AttributeType[] types) |
| | | throws DatabaseException, DirectoryException |
| | | { |
| | | if(entryIDs == null || entryIDs.length == 0) |
| | |
| | | return entryIDs; |
| | | } |
| | | |
| | | private byte[] attributeValuesToDatabase(AttributeValue[] values, |
| | | private byte[] attributeValuesToDatabase(ByteString[] values, |
| | | AttributeType[] types) throws DirectoryException |
| | | { |
| | | try |
| | |
| | | |
| | | for (int i = 0; i < values.length; i++) |
| | | { |
| | | final AttributeValue v = values[i]; |
| | | final ByteString v = values[i]; |
| | | if (v == null) |
| | | { |
| | | builder.appendBERLength(0); |
| | |
| | | else |
| | | { |
| | | final MatchingRule eqRule = types[i].getEqualityMatchingRule(); |
| | | final ByteString nv = eqRule.normalizeAttributeValue(v.getValue()); |
| | | final ByteString nv = eqRule.normalizeAttributeValue(v); |
| | | builder.appendBERLength(nv.length()); |
| | | builder.append(nv); |
| | | } |
| | |
| | | EntryID id = new EntryID(entryIDs[entryIDs.length - 1]); |
| | | SortKey[] sortKeys = vlvIndex.sortOrder.getSortKeys(); |
| | | int numValues = sortKeys.length; |
| | | AttributeValue[] values = |
| | | new AttributeValue[numValues]; |
| | | ByteString[] values = new ByteString[numValues]; |
| | | for (int i = (entryIDs.length - 1) * numValues, j = 0; |
| | | i < entryIDs.length * numValues; |
| | | i++, j++) |
| | | { |
| | | values[j] = AttributeValues.create( |
| | | sortKeys[j].getAttributeType(), |
| | | getValue(i)); |
| | | values[j] = getValue(i); |
| | | } |
| | | |
| | | return new SortValues(id, values, vlvIndex.sortOrder); |
| | |
| | | EntryID id = new EntryID(entryIDs[index]); |
| | | SortKey[] sortKeys = vlvIndex.sortOrder.getSortKeys(); |
| | | int numValues = sortKeys.length; |
| | | AttributeValue[] values = new AttributeValue[numValues]; |
| | | ByteString[] values = new ByteString[numValues]; |
| | | for (int i = index * numValues, j = 0; |
| | | i < (index + 1) * numValues; |
| | | i++, j++) |
| | | { |
| | | ByteString value = getValue(i); |
| | | |
| | | if(value != null) |
| | | { |
| | | values[j] = AttributeValues.create( |
| | | sortKeys[j].getAttributeType(), value); |
| | | } |
| | | values[j] = getValue(i); |
| | | } |
| | | |
| | | return new SortValues(id, values, vlvIndex.sortOrder); |
| | |
| | | * @throws DirectoryException If a Directory Server error occurs. |
| | | */ |
| | | public SortValuesSet getSortValuesSet(Transaction txn, long entryID, |
| | | AttributeValue[] values, AttributeType[] types) throws DatabaseException, |
| | | ByteString[] values, AttributeType[] types) throws DatabaseException, |
| | | DirectoryException |
| | | { |
| | | SortValuesSet sortValuesSet = null; |
| | |
| | | * @throws DirectoryException If a Directory Server error occurs. |
| | | */ |
| | | public boolean containsValues(Transaction txn, long entryID, |
| | | AttributeValue[] values, AttributeType[] types) throws JebException, |
| | | ByteString[] values, AttributeType[] types) throws JebException, |
| | | DatabaseException, DirectoryException |
| | | { |
| | | SortValuesSet valuesSet = getSortValuesSet(txn, entryID, values, types); |
| | |
| | | private boolean insertValues(Transaction txn, long entryID, Entry entry) |
| | | throws JebException, DatabaseException, DirectoryException |
| | | { |
| | | AttributeValue[] values = getSortValues(entry); |
| | | ByteString[] values = getSortValues(entry); |
| | | AttributeType[] types = getSortTypes(); |
| | | DatabaseEntry key = new DatabaseEntry(); |
| | | OperationStatus status; |
| | |
| | | private boolean removeValues(Transaction txn, long entryID, Entry entry) |
| | | throws JebException, DatabaseException, DirectoryException |
| | | { |
| | | SortValuesSet sortValuesSet; |
| | | AttributeValue[] values = getSortValues(entry); |
| | | ByteString[] values = getSortValues(entry); |
| | | AttributeType[] types = getSortTypes(); |
| | | DatabaseEntry key = new DatabaseEntry(); |
| | | OperationStatus status; |
| | |
| | | searchKeyHex, |
| | | foundKeyHex); |
| | | } |
| | | sortValuesSet = new SortValuesSet(key.getData(), data.getData(), |
| | | this); |
| | | SortValuesSet sortValuesSet = new SortValuesSet(key.getData(), data.getData(), this); |
| | | boolean success = sortValuesSet.remove(entryID, values, types); |
| | | byte[] after = sortValuesSet.toDatabase(); |
| | | |
| | |
| | | } |
| | | SortValuesSet sortValuesSet = |
| | | new SortValuesSet(key.getData(), data.getData(), this); |
| | | AttributeType type = sortOrder.getSortKeys()[0].getAttributeType(); |
| | | AttributeValue[] assertionValue = new AttributeValue[] { |
| | | AttributeValues.create( |
| | | type, vlvRequest.getGreaterThanOrEqualAssertion()) |
| | | ByteString[] assertionValue = new ByteString[] { |
| | | vlvRequest.getGreaterThanOrEqualAssertion() |
| | | }; |
| | | AttributeType[] assertionType = new AttributeType[] { type }; |
| | | AttributeType[] assertionType = new AttributeType[] { |
| | | sortOrder.getSortKeys()[0].getAttributeType() |
| | | }; |
| | | |
| | | int adjustedTargetOffset = |
| | | sortValuesSet.binarySearch(-1, assertionValue, assertionType); |
| | |
| | | * @param entry The entry to get the values from. |
| | | * @return The attribute values to sort on. |
| | | */ |
| | | AttributeValue[] getSortValues(Entry entry) |
| | | ByteString[] getSortValues(Entry entry) |
| | | { |
| | | SortKey[] sortKeys = sortOrder.getSortKeys(); |
| | | AttributeValue[] values = new AttributeValue[sortKeys.length]; |
| | | ByteString[] values = new ByteString[sortKeys.length]; |
| | | for (int i=0; i < sortKeys.length; i++) |
| | | { |
| | | SortKey sortKey = sortKeys[i]; |
| | |
| | | List<Attribute> attrList = entry.getAttribute(attrType); |
| | | if (attrList != null) |
| | | { |
| | | AttributeValue sortValue = null; |
| | | ByteString sortValue = null; |
| | | |
| | | // There may be multiple versions of this attribute in the target entry |
| | | // (e.g., with different sets of options), and it may also be a |
| | |
| | | // handled by the SortKey.compareValues method. |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | if (sortValue == null) |
| | | { |
| | |
| | | * @return The encoded bytes. |
| | | * @throws DirectoryException If a Directory Server error occurs. |
| | | */ |
| | | byte[] encodeKey(long entryID, AttributeValue[] values, AttributeType[] types) |
| | | byte[] encodeKey(long entryID, ByteString[] values, AttributeType[] types) |
| | | throws DirectoryException |
| | | { |
| | | try |
| | |
| | | |
| | | for (int i = 0; i < values.length; i++) |
| | | { |
| | | final AttributeValue v = values[i]; |
| | | final ByteString v = values[i]; |
| | | if (v == null) |
| | | { |
| | | builder.appendBERLength(0); |
| | |
| | | else |
| | | { |
| | | final MatchingRule eqRule = types[i].getEqualityMatchingRule(); |
| | | final ByteString nv = eqRule.normalizeAttributeValue(v.getValue()); |
| | | final ByteString nv = eqRule.normalizeAttributeValue(v); |
| | | builder.appendBERLength(nv.length()); |
| | | builder.append(nv); |
| | | } |
| | |
| | | return null; |
| | | } |
| | | |
| | | AttributeValue[] attributeValues = |
| | | new AttributeValue[sortOrder.getSortKeys().length]; |
| | | ByteString[] attributeValues = new ByteString[sortOrder.getSortKeys().length]; |
| | | int vBytesPos = 0; |
| | | |
| | | for(int i = 0; i < attributeValues.length; i++) |
| | |
| | | { |
| | | byte[] valueBytes = new byte[valueLength]; |
| | | System.arraycopy(keyBytes, vBytesPos, valueBytes, 0, valueLength); |
| | | attributeValues[i] = |
| | | AttributeValues.create( |
| | | sortOrder.getSortKeys()[i].getAttributeType(), |
| | | ByteString.wrap(valueBytes)); |
| | | attributeValues[i] = ByteString.wrap(valueBytes); |
| | | } |
| | | |
| | | vBytesPos += valueLength; |
| | |
| | | import org.opends.server.api.MatchingRule; |
| | | import org.opends.server.api.OrderingMatchingRule; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.DirectoryException; |
| | | |
| | | import com.sleepycat.je.DatabaseException; |
| | |
| | | * associated equality matching rule). |
| | | */ |
| | | public int compare(SortValuesSet set, int index, long entryID, |
| | | AttributeValue[] values, AttributeType[] types) throws DatabaseException, |
| | | ByteString[] values, AttributeType[] types) throws DatabaseException, |
| | | DirectoryException |
| | | { |
| | | for (int j=0; j < orderingRules.length; j++) |
| | |
| | | try |
| | | { |
| | | final MatchingRule eqRule = types[j].getEqualityMatchingRule(); |
| | | b2Bytes = eqRule.normalizeAttributeValue(values[j].getValue()); |
| | | b2Bytes = eqRule.normalizeAttributeValue(values[j]); |
| | | } |
| | | catch (DecodeException e) |
| | | { |
| | |
| | | { |
| | | final AttributeType attrType = attr.getAttributeType(); |
| | | MatchingRule equalityRule = attrType.getEqualityMatchingRule(); |
| | | for (AttributeValue value : attr) |
| | | for (ByteString value : attr) |
| | | { |
| | | final ByteString bsValue = value.getValue(); |
| | | byte[] normalizedBytes = normalize(equalityRule, bsValue); |
| | | byte[] normalizedBytes = normalize(equalityRule, value); |
| | | |
| | | if (equalityIndex != null) |
| | | { |
| | |
| | | |
| | | if (orderingIndex != null) |
| | | { |
| | | key.setData(normalize(attrType.getOrderingMatchingRule(), bsValue)); |
| | | key.setData(normalize(attrType.getOrderingMatchingRule(), value)); |
| | | verifyAttributeInIndex(orderingIndex, txn, key, entryID); |
| | | } |
| | | |
| | | if (approximateIndex != null) |
| | | { |
| | | key.setData(normalize(attrType.getApproximateMatchingRule(), bsValue)); |
| | | key.setData(normalize(attrType.getApproximateMatchingRule(), value)); |
| | | verifyAttributeInIndex(approximateIndex, txn, key, entryID); |
| | | } |
| | | } |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | |
| | | Iterator<AttributeValue> iterator = attr.iterator(); |
| | | AttributeValue value = iterator.next(); |
| | | Iterator<ByteString> iterator = attr.iterator(); |
| | | ByteString value = iterator.next(); |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = |
| | |
| | | throw new DirectoryException(ResultCode.OBJECTCLASS_VIOLATION, message); |
| | | } |
| | | |
| | | recurringTaskID = value.getValue().toString(); |
| | | recurringTaskID = value.toString(); |
| | | |
| | | |
| | | // Get the schedule for this task. |
| | |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | |
| | | taskClassName = value.getValue().toString(); |
| | | taskClassName = value.toString(); |
| | | |
| | | |
| | | // Make sure that the specified class can be loaded. |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.opends.messages.Severity; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | throw new InitializationException(ERR_TASK_MULTIPLE_ATTRS_FOR_TYPE.get(attributeName, taskEntry.getName())); |
| | | } |
| | | |
| | | Iterator<AttributeValue> iterator = attrList.get(0).iterator(); |
| | | Iterator<ByteString> iterator = attrList.get(0).iterator(); |
| | | if (! iterator.hasNext()) |
| | | { |
| | | if (isRequired) |
| | |
| | | } |
| | | } |
| | | |
| | | AttributeValue value = iterator.next(); |
| | | ByteString value = iterator.next(); |
| | | if (iterator.hasNext()) |
| | | { |
| | | throw new InitializationException(ERR_TASK_MULTIPLE_VALUES_FOR_ATTR.get(attributeName, taskEntry.getName())); |
| | | } |
| | | |
| | | return value.getValue().toString(); |
| | | return value.toString(); |
| | | } |
| | | |
| | | |
| | |
| | | throw new InitializationException(ERR_TASK_MULTIPLE_ATTRS_FOR_TYPE.get(attributeName, taskEntry.getName())); |
| | | } |
| | | |
| | | Iterator<AttributeValue> iterator = attrList.get(0).iterator(); |
| | | Iterator<ByteString> iterator = attrList.get(0).iterator(); |
| | | while (iterator.hasNext()) |
| | | { |
| | | valueStrings.add(iterator.next().getValue().toString()); |
| | | valueStrings.add(iterator.next().toString()); |
| | | } |
| | | |
| | | return valueStrings; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | List<Attribute> attrList = taskEntry.getAttribute(type); |
| | | AttributeValue value = AttributeValues.create(type, messageString); |
| | | ByteString value = ByteString.valueOf(messageString); |
| | | if (attrList == null) |
| | | { |
| | | attrList = new ArrayList<Attribute>(); |
| | |
| | | */ |
| | | package org.opends.server.backends.task; |
| | | |
| | | |
| | | |
| | | import java.io.*; |
| | | import java.net.InetAddress; |
| | | import java.security.MessageDigest; |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class provides an implementation of a Directory Server backend that may |
| | | * be used to execute various kinds of administrative tasks on a one-time or |
| | |
| | | break; |
| | | } |
| | | |
| | | Iterator<AttributeValue> iterator = a.iterator(); |
| | | Iterator<ByteString> iterator = a.iterator(); |
| | | if (!iterator.hasNext()) { |
| | | acceptable = false; |
| | | break; |
| | | } |
| | | |
| | | AttributeValue v = iterator.next(); |
| | | ByteString v = iterator.next(); |
| | | String valueString = toLowerCase(v.toString()); |
| | | if (!(valueString.startsWith("cancel") || |
| | | valueString.startsWith("stop"))) { |
| | |
| | | */ |
| | | package org.opends.server.backends.task; |
| | | |
| | | |
| | | |
| | | import static org.opends.messages.BackendMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.util.LDIFException; |
| | | import org.opends.server.util.LDIFReader; |
| | | import org.opends.server.util.LDIFWriter; |
| | | import org.opends.server.util.TimeThread; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines a task scheduler for the Directory Server that will |
| | | * control the execution of scheduled tasks and other administrative functions |
| | |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | |
| | | Iterator<AttributeValue> iterator = attr.iterator(); |
| | | AttributeValue value = iterator.next(); |
| | | Iterator<ByteString> iterator = attr.iterator(); |
| | | ByteString value = iterator.next(); |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_TASKSCHED_MULTIPLE_CLASS_VALUES.get(ATTR_TASK_ID); |
| | |
| | | } |
| | | |
| | | // Try to load the specified class. |
| | | String taskClassName = value.getValue().toString(); |
| | | String taskClassName = value.toString(); |
| | | Class<?> taskClass; |
| | | try |
| | | { |
| | |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.config; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Iterator; |
| | | import java.util.LinkedHashSet; |
| | |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.AttributeValues; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines a Boolean configuration attribute, which can hold a single |
| | | * Boolean value of <CODE>true</CODE> or <CODE>false</CODE>. Boolean |
| | |
| | | * |
| | | * @return The value set constructed from the provided value. |
| | | */ |
| | | private static LinkedHashSet<AttributeValue> getValueSet(boolean booleanValue) |
| | | private static LinkedHashSet<ByteString> getValueSet(boolean booleanValue) |
| | | { |
| | | LinkedHashSet<AttributeValue> valueSet = |
| | | new LinkedHashSet<AttributeValue>(1); |
| | | if (booleanValue) |
| | | { |
| | | valueSet.add(AttributeValues.create( |
| | | ByteString.valueOf(CONFIG_VALUE_TRUE), |
| | | ByteString.valueOf(CONFIG_VALUE_TRUE))); |
| | | } |
| | | else |
| | | { |
| | | valueSet.add(AttributeValues.create( |
| | | ByteString.valueOf(CONFIG_VALUE_FALSE), |
| | | ByteString.valueOf(CONFIG_VALUE_FALSE))); |
| | | } |
| | | |
| | | LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(1); |
| | | valueSet.add(ByteString.valueOf( |
| | | booleanValue ? CONFIG_VALUE_TRUE : CONFIG_VALUE_FALSE)); |
| | | return valueSet; |
| | | } |
| | | |
| | |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use in |
| | | * this attribute, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(AttributeValue value, |
| | | public boolean valueIsAcceptable(ByteString value, |
| | | StringBuilder rejectReason) |
| | | { |
| | | String stringValue = value.getValue().toString(); |
| | | String stringValue = value.toString(); |
| | | if (stringValue.equalsIgnoreCase(CONFIG_VALUE_TRUE) || |
| | | stringValue.equalsIgnoreCase(CONFIG_VALUE_FALSE)) |
| | | { |
| | |
| | | * @throws ConfigException If an unrecoverable problem occurs while |
| | | * performing the conversion. |
| | | */ |
| | | public LinkedHashSet<AttributeValue> |
| | | stringsToValues(List<String> valueStrings, |
| | | boolean allowFailures) |
| | | throws ConfigException |
| | | public LinkedHashSet<ByteString> stringsToValues(List<String> valueStrings, |
| | | boolean allowFailures) throws ConfigException |
| | | { |
| | | if ((valueStrings == null) || valueStrings.isEmpty()) |
| | | { |
| | |
| | | else |
| | | { |
| | | // Get the value and parse it as a Boolean. |
| | | Iterator<AttributeValue> iterator = a.iterator(); |
| | | String valueString = |
| | | iterator.next().getValue().toString().toLowerCase(); |
| | | Iterator<ByteString> iterator = a.iterator(); |
| | | String valueString = iterator.next().toString().toLowerCase(); |
| | | |
| | | if (valueString.equals("true") || valueString.equals("yes") || |
| | | valueString.equals("on") || valueString.equals("1")) |
| | |
| | | else |
| | | { |
| | | // Get the value and parse it as a Boolean. |
| | | Iterator<AttributeValue> iterator = a.iterator(); |
| | | String valueString = |
| | | iterator.next().getValue().toString().toLowerCase(); |
| | | Iterator<ByteString> iterator = a.iterator(); |
| | | String valueString = iterator.next().toString().toLowerCase(); |
| | | |
| | | if (valueString.equals("true") || valueString.equals("yes") || |
| | | valueString.equals("on") || valueString.equals("1")) |
| | |
| | | |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | /** |
| | |
| | | |
| | | // The value or set of values that are currently in effect for this |
| | | // configuration attribute. |
| | | private LinkedHashSet<AttributeValue> activeValues; |
| | | private LinkedHashSet<ByteString> activeValues; |
| | | |
| | | // The value or set of values that will be in effect once the appropriate |
| | | // administrative action has been taken. |
| | | private LinkedHashSet<AttributeValue> pendingValues; |
| | | private LinkedHashSet<ByteString> pendingValues; |
| | | |
| | | // The description for this configuration attribute. |
| | | private LocalizableMessage description; |
| | |
| | | this.requiresAdminAction = requiresAdminAction; |
| | | |
| | | hasPendingValues = false; |
| | | activeValues = new LinkedHashSet<AttributeValue>(); |
| | | activeValues = new LinkedHashSet<ByteString>(); |
| | | pendingValues = activeValues; |
| | | } |
| | | |
| | |
| | | protected ConfigAttribute(String name, LocalizableMessage description, |
| | | boolean isRequired, boolean isMultiValued, |
| | | boolean requiresAdminAction, |
| | | LinkedHashSet<AttributeValue> activeValues) |
| | | LinkedHashSet<ByteString> activeValues) |
| | | { |
| | | this.name = name; |
| | | this.description = description; |
| | |
| | | |
| | | if (activeValues == null) |
| | | { |
| | | this.activeValues = new LinkedHashSet<AttributeValue>(); |
| | | this.activeValues = new LinkedHashSet<ByteString>(); |
| | | } |
| | | else |
| | | { |
| | |
| | | protected ConfigAttribute(String name, LocalizableMessage description, |
| | | boolean isRequired, boolean isMultiValued, |
| | | boolean requiresAdminAction, |
| | | LinkedHashSet<AttributeValue> activeValues, |
| | | LinkedHashSet<ByteString> activeValues, |
| | | boolean hasPendingValues, |
| | | LinkedHashSet<AttributeValue> pendingValues) |
| | | LinkedHashSet<ByteString> pendingValues) |
| | | { |
| | | this.name = name; |
| | | this.description = description; |
| | |
| | | |
| | | if (activeValues == null) |
| | | { |
| | | this.activeValues = new LinkedHashSet<AttributeValue>(); |
| | | this.activeValues = new LinkedHashSet<ByteString>(); |
| | | } |
| | | else |
| | | { |
| | |
| | | { |
| | | if (pendingValues == null) |
| | | { |
| | | this.pendingValues = new LinkedHashSet<AttributeValue>(); |
| | | this.pendingValues = new LinkedHashSet<ByteString>(); |
| | | } |
| | | else |
| | | { |
| | |
| | | * |
| | | * @return The set of active values for this configuration attribute. |
| | | */ |
| | | public LinkedHashSet<AttributeValue> getActiveValues() |
| | | public LinkedHashSet<ByteString> getActiveValues() |
| | | { |
| | | return activeValues; |
| | | } |
| | |
| | | * @return The set of values that this configuration attribute will have |
| | | * after any appropriate administrative action is taken. |
| | | */ |
| | | public LinkedHashSet<AttributeValue> getPendingValues() |
| | | public LinkedHashSet<ByteString> getPendingValues() |
| | | { |
| | | if (requiresAdminAction) |
| | | { |
| | |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use in |
| | | * this attribute, or <CODE>false</CODE> if not. |
| | | */ |
| | | public abstract boolean valueIsAcceptable(AttributeValue value, |
| | | public abstract boolean valueIsAcceptable(ByteString value, |
| | | StringBuilder rejectReason); |
| | | |
| | | |
| | |
| | | * @throws ConfigException If the provided set of values is not acceptable |
| | | * for some reason. |
| | | */ |
| | | protected void setValues(LinkedHashSet<AttributeValue> values) |
| | | protected void setValues(LinkedHashSet<ByteString> values) |
| | | throws ConfigException |
| | | { |
| | | // If no values are provided, then check to see if this is a required |
| | |
| | | { |
| | | if (values == null) |
| | | { |
| | | pendingValues = new LinkedHashSet<AttributeValue>(); |
| | | pendingValues = new LinkedHashSet<ByteString>(); |
| | | } |
| | | else |
| | | { |
| | |
| | | { |
| | | if (values == null) |
| | | { |
| | | activeValues = new LinkedHashSet<AttributeValue>(); |
| | | activeValues = new LinkedHashSet<ByteString>(); |
| | | } |
| | | else |
| | | { |
| | |
| | | |
| | | |
| | | // We know that we have at least one value, so get it and see if it is OK. |
| | | Iterator<AttributeValue> iterator = values.iterator(); |
| | | AttributeValue value = iterator.next(); |
| | | Iterator<ByteString> iterator = values.iterator(); |
| | | ByteString value = iterator.next(); |
| | | StringBuilder rejectReason = new StringBuilder(); |
| | | |
| | | if (! valueIsAcceptable(value, rejectReason)) |
| | | { |
| | | throw new ConfigException(ERR_CONFIG_ATTR_REJECTED_VALUE.get( |
| | | value.getValue(), name, rejectReason)); |
| | | value, name, rejectReason)); |
| | | } |
| | | |
| | | |
| | |
| | | if (! valueIsAcceptable(value, rejectReason)) |
| | | { |
| | | throw new ConfigException(ERR_CONFIG_ATTR_REJECTED_VALUE.get( |
| | | value.getValue(), name, rejectReason)); |
| | | value, name, rejectReason)); |
| | | } |
| | | } |
| | | |
| | |
| | | * |
| | | * @param values The set of active values for this configuration attribute. |
| | | */ |
| | | protected void setActiveValues(LinkedHashSet<AttributeValue> values) |
| | | protected void setActiveValues(LinkedHashSet<ByteString> values) |
| | | { |
| | | activeValues = values; |
| | | } |
| | |
| | | * |
| | | * @param values The set of pending values for this configuration attribute. |
| | | */ |
| | | protected void setPendingValues(LinkedHashSet<AttributeValue> values) |
| | | protected void setPendingValues(LinkedHashSet<ByteString> values) |
| | | { |
| | | pendingValues = values; |
| | | hasPendingValues = true; |
| | |
| | | * provided set of values to this configuration |
| | | * attribute. |
| | | */ |
| | | protected void addValues(List<AttributeValue> values) |
| | | throws ConfigException |
| | | protected void addValues(List<ByteString> values) throws ConfigException |
| | | { |
| | | // If there are no values provided, then do nothing. |
| | | if (values == null) |
| | |
| | | |
| | | // Create a temporary set of values that we will use for this change. It |
| | | // may not actually be applied if an error occurs for some reason. |
| | | LinkedHashSet<AttributeValue> tempValues; |
| | | LinkedHashSet<ByteString> tempValues; |
| | | if (requiresAdminAction && hasPendingValues) |
| | | { |
| | | tempValues = |
| | | new LinkedHashSet<AttributeValue>(pendingValues.size() + numValues); |
| | | new LinkedHashSet<ByteString>(pendingValues.size() + numValues); |
| | | tempValues.addAll(pendingValues); |
| | | } |
| | | else |
| | | { |
| | | tempValues = |
| | | new LinkedHashSet<AttributeValue>(activeValues.size() + numValues); |
| | | new LinkedHashSet<ByteString>(activeValues.size() + numValues); |
| | | tempValues.addAll(activeValues); |
| | | } |
| | | |
| | |
| | | // Iterate through all of the provided values. Make sure that each is |
| | | // acceptable for use and that it is not already contained in the value set. |
| | | StringBuilder rejectReason = new StringBuilder(); |
| | | for (AttributeValue value : values) |
| | | for (ByteString value : values) |
| | | { |
| | | if (tempValues.contains(value)) |
| | | { |
| | | throw new ConfigException(ERR_CONFIG_ATTR_ADD_VALUES_ALREADY_EXISTS.get( |
| | | name, value.getValue())); |
| | | name, value)); |
| | | } |
| | | |
| | | if (! valueIsAcceptable(value, rejectReason)) |
| | | { |
| | | throw new ConfigException(ERR_CONFIG_ATTR_REJECTED_VALUE.get( |
| | | value.getValue(), name, rejectReason)); |
| | | value, name, rejectReason)); |
| | | } |
| | | } |
| | | |
| | |
| | | * value set, or if this is a required attribute and |
| | | * the resulting value list would be empty. |
| | | */ |
| | | protected void removeValues(List<AttributeValue> values) |
| | | protected void removeValues(List<ByteString> values) |
| | | throws ConfigException |
| | | { |
| | | // Create a temporary set of values that we will use for this change. It |
| | | // may not actually be applied if an error occurs for some reason. |
| | | LinkedHashSet<AttributeValue> tempValues; |
| | | LinkedHashSet<ByteString> tempValues; |
| | | if (requiresAdminAction && hasPendingValues) |
| | | { |
| | | tempValues = |
| | | new LinkedHashSet<AttributeValue>(pendingValues.size()); |
| | | tempValues = new LinkedHashSet<ByteString>(pendingValues.size()); |
| | | tempValues.addAll(pendingValues); |
| | | } |
| | | else |
| | | { |
| | | tempValues = |
| | | new LinkedHashSet<AttributeValue>(activeValues.size()); |
| | | tempValues = new LinkedHashSet<ByteString>(activeValues.size()); |
| | | tempValues.addAll(activeValues); |
| | | } |
| | | |
| | |
| | | // Iterate through all the provided values and make sure that they are |
| | | // contained in the list. If not, then throw an exception. If so, then |
| | | // remove it. |
| | | for (AttributeValue value : values) |
| | | for (ByteString value : values) |
| | | { |
| | | if (! tempValues.remove(value)) |
| | | { |
| | | throw new ConfigException( |
| | | ERR_CONFIG_ATTR_NO_SUCH_VALUE.get(name, value.getValue())); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_NO_SUCH_VALUE.get(name, value)); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | if (pendingValues == null) |
| | | { |
| | | pendingValues = new LinkedHashSet<AttributeValue>(); |
| | | pendingValues = new LinkedHashSet<ByteString>(); |
| | | } |
| | | else |
| | | { |
| | |
| | | * @param values The initial set of values to assign to this configuration |
| | | * attribute. |
| | | */ |
| | | public void setInitialValues(LinkedHashSet<AttributeValue> values) |
| | | public void setInitialValues(LinkedHashSet<ByteString> values) |
| | | { |
| | | if (values == null) |
| | | { |
| | | values = new LinkedHashSet<AttributeValue>(); |
| | | values = new LinkedHashSet<ByteString>(); |
| | | } |
| | | |
| | | activeValues = values; |
| | |
| | | * @throws ConfigException If an unrecoverable problem occurs while |
| | | * performing the conversion. |
| | | */ |
| | | public abstract LinkedHashSet<AttributeValue> |
| | | stringsToValues(List<String> valueStrings, |
| | | boolean allowFailures) |
| | | throws ConfigException; |
| | | public abstract LinkedHashSet<ByteString> stringsToValues( |
| | | List<String> valueStrings, boolean allowFailures) throws ConfigException; |
| | | |
| | | |
| | | |
| | |
| | | { |
| | | if (requiresAdminAction()) |
| | | { |
| | | setPendingValues(new LinkedHashSet<AttributeValue>(0)); |
| | | setPendingValues(new LinkedHashSet<ByteString>(0)); |
| | | pendingValues = new ArrayList<DN>(); |
| | | } |
| | | else |
| | | { |
| | | setActiveValues(new LinkedHashSet<AttributeValue>(0)); |
| | | setActiveValues(new LinkedHashSet<ByteString>(0)); |
| | | activeValues.clear(); |
| | | } |
| | | } |
| | |
| | | |
| | | // Iterate through all the provided values, make sure that they are |
| | | // acceptable, and build the value set. |
| | | LinkedHashSet<AttributeValue> valueSet = |
| | | new LinkedHashSet<AttributeValue>(numValues); |
| | | LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(numValues); |
| | | for (DN value : values) |
| | | { |
| | | if (value == null) |
| | |
| | | throw new ConfigException(message); |
| | | } |
| | | |
| | | AttributeValue attrValue = |
| | | AttributeValues.create(ByteString.valueOf(value.toString()), |
| | | ByteString.valueOf(value.toNormalizedString())); |
| | | |
| | | ByteString attrValue = ByteString.valueOf(value.toString()); |
| | | if (valueSet.contains(attrValue)) |
| | | { |
| | | LocalizableMessage message = |
| | |
| | | * |
| | | * @return The constructed value set. |
| | | */ |
| | | private static LinkedHashSet<AttributeValue> getValueSet(DN value) |
| | | private static LinkedHashSet<ByteString> getValueSet(DN value) |
| | | { |
| | | LinkedHashSet<AttributeValue> valueSet; |
| | | LinkedHashSet<ByteString> valueSet; |
| | | if (value == null) |
| | | { |
| | | valueSet = new LinkedHashSet<AttributeValue>(0); |
| | | valueSet = new LinkedHashSet<ByteString>(0); |
| | | } |
| | | else |
| | | { |
| | | valueSet = new LinkedHashSet<AttributeValue>(1); |
| | | valueSet.add(AttributeValues.create(ByteString.valueOf(value.toString()), |
| | | ByteString.valueOf(value.toNormalizedString()))); |
| | | valueSet = new LinkedHashSet<ByteString>(1); |
| | | valueSet.add(ByteString.valueOf(value.toString())); |
| | | } |
| | | |
| | | return valueSet; |
| | | } |
| | | |
| | |
| | | * |
| | | * @return The constructed value set. |
| | | */ |
| | | private static LinkedHashSet<AttributeValue> getValueSet(List<DN> values) |
| | | private static LinkedHashSet<ByteString> getValueSet(List<DN> values) |
| | | { |
| | | if (values == null) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | LinkedHashSet<AttributeValue> valueSet = |
| | | new LinkedHashSet<AttributeValue>(values.size()); |
| | | |
| | | LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(values.size()); |
| | | for (DN value : values) |
| | | { |
| | | valueSet.add(AttributeValues.create(ByteString.valueOf(value.toString()), |
| | | ByteString.valueOf(value.toNormalizedString()))); |
| | | valueSet.add(ByteString.valueOf(value.toString())); |
| | | } |
| | | |
| | | return valueSet; |
| | | } |
| | | |
| | |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use in |
| | | * this attribute, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(AttributeValue value, |
| | | StringBuilder rejectReason) |
| | | public boolean valueIsAcceptable(ByteString value, StringBuilder rejectReason) |
| | | { |
| | | // Make sure that the value is not null. |
| | | if (value == null) |
| | |
| | | // Make sure that it can be parsed as a DN. |
| | | try |
| | | { |
| | | DN.valueOf(value.getValue().toString()); |
| | | DN.valueOf(value.toString()); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | rejectReason.append(ERR_CONFIG_ATTR_DN_CANNOT_PARSE.get( |
| | | value.getValue(), getName(), e)); |
| | | rejectReason.append(ERR_CONFIG_ATTR_DN_CANNOT_PARSE.get(value, getName(), e)); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | return true; |
| | | } |
| | | |
| | |
| | | * @throws ConfigException If an unrecoverable problem occurs while |
| | | * performing the conversion. |
| | | */ |
| | | public LinkedHashSet<AttributeValue> |
| | | public LinkedHashSet<ByteString> |
| | | stringsToValues(List<String> valueStrings, |
| | | boolean allowFailures) |
| | | throws ConfigException |
| | |
| | | } |
| | | else |
| | | { |
| | | return new LinkedHashSet<AttributeValue>(); |
| | | return new LinkedHashSet<ByteString>(); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | LinkedHashSet<AttributeValue> valueSet = |
| | | new LinkedHashSet<AttributeValue>(numValues); |
| | | LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(numValues); |
| | | for (String valueString : valueStrings) |
| | | { |
| | | if (valueString == null) |
| | |
| | | } |
| | | |
| | | |
| | | valueSet.add(AttributeValues.create(ByteString.valueOf(dn.toString()), |
| | | ByteString.valueOf(dn.toNormalizedString()))); |
| | | valueSet.add(ByteString.valueOf(dn.toString())); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | pendingValues = new ArrayList<DN>(numValues); |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | DN dn; |
| | | try |
| | | { |
| | | dn = DN.valueOf(v.getValue().toString()); |
| | | dn = DN.valueOf(v.toString()); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_DN_CANNOT_PARSE.get( |
| | | v.getValue(), getName(), e); |
| | | v, getName(), e); |
| | | throw new ConfigException(message, e); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | activeValues = new ArrayList<DN>(numValues); |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | DN dn; |
| | | try |
| | | { |
| | | dn = DN.valueOf(v.getValue().toString()); |
| | | dn = DN.valueOf(v.toString()); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_DN_CANNOT_PARSE.get( |
| | | v.getValue(), getName(), e); |
| | | v, getName(), e); |
| | | throw new ConfigException(message, e); |
| | | } |
| | | |
| | |
| | | { |
| | | if (requiresAdminAction()) |
| | | { |
| | | setPendingValues(new LinkedHashSet<AttributeValue>(0)); |
| | | setPendingValues(new LinkedHashSet<ByteString>(0)); |
| | | pendingValues = new ArrayList<Long>(); |
| | | } |
| | | else |
| | | { |
| | | setActiveValues(new LinkedHashSet<AttributeValue>(0)); |
| | | setActiveValues(new LinkedHashSet<ByteString>(0)); |
| | | activeValues.clear(); |
| | | } |
| | | } |
| | |
| | | |
| | | // Iterate through all the provided values, make sure that they are |
| | | // acceptable, and build the value set. |
| | | LinkedHashSet<AttributeValue> valueSet = |
| | | new LinkedHashSet<AttributeValue>(numValues); |
| | | LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(numValues); |
| | | for (long value : values) |
| | | { |
| | | if (hasLowerBound && (value < lowerBound)) |
| | |
| | | } |
| | | |
| | | String valueString = String.valueOf(value); |
| | | AttributeValue attrValue = |
| | | AttributeValues.create(ByteString.valueOf(valueString), |
| | | ByteString.valueOf(valueString)); |
| | | |
| | | ByteString attrValue = ByteString.valueOf(valueString); |
| | | if (valueSet.contains(attrValue)) |
| | | { |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_ADD_VALUES_ALREADY_EXISTS.get( |
| | |
| | | * |
| | | * @return The constructed value set. |
| | | */ |
| | | private static LinkedHashSet<AttributeValue> getValueSet(long value) |
| | | private static LinkedHashSet<ByteString> getValueSet(long value) |
| | | { |
| | | LinkedHashSet<AttributeValue> valueSet = |
| | | new LinkedHashSet<AttributeValue>(1); |
| | | |
| | | String valueString = String.valueOf(value); |
| | | valueSet.add(AttributeValues.create(ByteString.valueOf(valueString), |
| | | ByteString.valueOf(valueString))); |
| | | |
| | | LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(1); |
| | | valueSet.add(ByteString.valueOf(String.valueOf(value))); |
| | | return valueSet; |
| | | } |
| | | |
| | |
| | | * |
| | | * @return The constructed value set. |
| | | */ |
| | | private static LinkedHashSet<AttributeValue> getValueSet(List<Long> values) |
| | | private static LinkedHashSet<ByteString> getValueSet(List<Long> values) |
| | | { |
| | | if (values == null) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | LinkedHashSet<AttributeValue> valueSet = |
| | | new LinkedHashSet<AttributeValue>(values.size()); |
| | | |
| | | LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(values.size()); |
| | | for (long value : values) |
| | | { |
| | | String valueString = String.valueOf(value); |
| | | valueSet.add(AttributeValues.create(ByteString.valueOf(valueString), |
| | | ByteString.valueOf(valueString))); |
| | | valueSet.add(ByteString.valueOf(String.valueOf(value))); |
| | | } |
| | | |
| | | return valueSet; |
| | | } |
| | | |
| | |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use in |
| | | * this attribute, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(AttributeValue value, |
| | | StringBuilder rejectReason) |
| | | public boolean valueIsAcceptable(ByteString value, StringBuilder rejectReason) |
| | | { |
| | | // First, make sure we can represent it as a long. |
| | | String stringValue = value.getValue().toString(); |
| | | String stringValue = value.toString(); |
| | | long longValue; |
| | | try |
| | | { |
| | |
| | | * @throws ConfigException If an unrecoverable problem occurs while |
| | | * performing the conversion. |
| | | */ |
| | | public LinkedHashSet<AttributeValue> |
| | | stringsToValues(List<String> valueStrings, |
| | | boolean allowFailures) |
| | | public LinkedHashSet<ByteString> |
| | | stringsToValues(List<String> valueStrings, boolean allowFailures) |
| | | throws ConfigException |
| | | { |
| | | if ((valueStrings == null) || valueStrings.isEmpty()) |
| | |
| | | } |
| | | else |
| | | { |
| | | return new LinkedHashSet<AttributeValue>(); |
| | | return new LinkedHashSet<ByteString>(); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | LinkedHashSet<AttributeValue> valueSet = |
| | | new LinkedHashSet<AttributeValue>(numValues); |
| | | LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(numValues); |
| | | for (String valueString : valueStrings) |
| | | { |
| | | long longValue; |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | valueSet.add(AttributeValues.create(ByteString.valueOf(valueString), |
| | | ByteString.valueOf(valueString))); |
| | | valueSet.add(ByteString.valueOf(valueString)); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | pendingValues = new ArrayList<Long>(numValues); |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | long longValue; |
| | | try |
| | | { |
| | | longValue = Long.parseLong(v.getValue().toString()); |
| | | longValue = Long.parseLong(v.toString()); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_INT_COULD_NOT_PARSE.get( |
| | | v.getValue(), a.getName(), e); |
| | | v, a.getName(), e); |
| | | throw new ConfigException(message, e); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | activeValues = new ArrayList<Long>(numValues); |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | long longValue; |
| | | try |
| | | { |
| | | longValue = Long.parseLong(v.getValue().toString()); |
| | | longValue = Long.parseLong(v.toString()); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_INT_COULD_NOT_PARSE.get( |
| | | v.getValue(), a.getName(), e); |
| | | v, a.getName(), e); |
| | | throw new ConfigException(message, e); |
| | | } |
| | | |
| | |
| | | * |
| | | * @return The constructed value set. |
| | | */ |
| | | private static LinkedHashSet<AttributeValue> getValueSet(long intValue, |
| | | private static LinkedHashSet<ByteString> getValueSet(long intValue, |
| | | String unit) |
| | | { |
| | | if (unit == null) |
| | |
| | | return null; |
| | | } |
| | | |
| | | LinkedHashSet<AttributeValue> valueSet = |
| | | new LinkedHashSet<AttributeValue>(1); |
| | | |
| | | String valueString = intValue + " " + unit; |
| | | valueSet.add(AttributeValues.create(ByteString.valueOf(valueString), |
| | | ByteString.valueOf(valueString))); |
| | | |
| | | LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(1); |
| | | valueSet.add(ByteString.valueOf(intValue + " " + unit)); |
| | | return valueSet; |
| | | } |
| | | |
| | |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use in |
| | | * this attribute, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(AttributeValue value, |
| | | public boolean valueIsAcceptable(ByteString value, |
| | | StringBuilder rejectReason) |
| | | { |
| | | // Get a string representation of the value and convert it to lowercase. |
| | | String lowerValue = value.getValue().toString().toLowerCase(); |
| | | |
| | | String lowerValue = value.toString().toLowerCase(); |
| | | return valueIsAcceptable(lowerValue, rejectReason); |
| | | } |
| | | |
| | |
| | | * @throws ConfigException If an unrecoverable problem occurs while |
| | | * performing the conversion. |
| | | */ |
| | | public LinkedHashSet<AttributeValue> |
| | | public LinkedHashSet<ByteString> |
| | | stringsToValues(List<String> valueStrings, boolean allowFailures) |
| | | throws ConfigException |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | return new LinkedHashSet<AttributeValue>(); |
| | | return new LinkedHashSet<ByteString>(); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | LinkedHashSet<AttributeValue> valueSet = |
| | | new LinkedHashSet<AttributeValue>(numValues); |
| | | LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(numValues); |
| | | for (String valueString : valueStrings) |
| | | { |
| | | if ((valueString == null) || (valueString.length() == 0)) |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | valueSet.add(AttributeValues.create(ByteString.valueOf(valueString), |
| | | ByteString.valueOf(valueString))); |
| | | valueSet.add(ByteString.valueOf(valueString)); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | else |
| | | { |
| | | Iterator<AttributeValue> iterator = a.iterator(); |
| | | |
| | | String valueString = iterator.next().getValue().toString(); |
| | | |
| | | Iterator<ByteString> iterator = a.iterator(); |
| | | String valueString = iterator.next().toString(); |
| | | if (iterator.hasNext()) |
| | | { |
| | | // This is illegal -- the attribute is single-valued. |
| | |
| | | } |
| | | else |
| | | { |
| | | Iterator<AttributeValue> iterator = a.iterator(); |
| | | |
| | | String valueString = iterator.next().getValue().toString(); |
| | | |
| | | Iterator<ByteString> iterator = a.iterator(); |
| | | String valueString = iterator.next().toString(); |
| | | if (iterator.hasNext()) |
| | | { |
| | | // This is illegal -- the attribute is single-valued. |
| | |
| | | continue; |
| | | } |
| | | |
| | | Iterator<AttributeValue> iterator = a.iterator(); |
| | | AttributeValue value = iterator.next(); |
| | | Iterator<ByteString> iterator = a.iterator(); |
| | | ByteString value = iterator.next(); |
| | | |
| | | if (iterator.hasNext()) |
| | | { |
| | | List<String> stringValues = new ArrayList<String>(); |
| | | stringValues.add(value.getValue().toString()); |
| | | stringValues.add(value.toString()); |
| | | |
| | | while (iterator.hasNext()) |
| | | { |
| | | value = iterator.next(); |
| | | stringValues.add(value.getValue().toString()); |
| | | stringValues.add(value.toString()); |
| | | } |
| | | |
| | | String[] valueArray = new String[stringValues.size()]; |
| | |
| | | } |
| | | else |
| | | { |
| | | return new Attribute(name, value.getValue().toString()); |
| | | return new Attribute(name, value.toString()); |
| | | } |
| | | } |
| | | } |
| | |
| | | continue; |
| | | } |
| | | |
| | | Iterator<AttributeValue> iterator = a.iterator(); |
| | | AttributeValue value = iterator.next(); |
| | | Iterator<ByteString> iterator = a.iterator(); |
| | | ByteString value = iterator.next(); |
| | | |
| | | if (iterator.hasNext()) |
| | | { |
| | | List<String> stringValues = new ArrayList<String>(); |
| | | stringValues.add(value.getValue().toString()); |
| | | stringValues.add(value.toString()); |
| | | |
| | | while (iterator.hasNext()) |
| | | { |
| | | value = iterator.next(); |
| | | stringValues.add(value.getValue().toString()); |
| | | stringValues.add(value.toString()); |
| | | } |
| | | |
| | | String[] valueArray = new String[stringValues.size()]; |
| | |
| | | } |
| | | else |
| | | { |
| | | attrList.add(new Attribute(name, value.getValue().toString())); |
| | | attrList.add(new Attribute(name, value.toString())); |
| | | break monitorLoop; |
| | | } |
| | | } |
| | |
| | | { |
| | | if (requiresAdminAction()) |
| | | { |
| | | setPendingValues(new LinkedHashSet<AttributeValue>(0)); |
| | | setPendingValues(new LinkedHashSet<ByteString>(0)); |
| | | pendingValues = new ArrayList<String>(); |
| | | } |
| | | else |
| | | { |
| | | setActiveValues(new LinkedHashSet<AttributeValue>(0)); |
| | | setActiveValues(new LinkedHashSet<ByteString>(0)); |
| | | activeValues.clear(); |
| | | } |
| | | } |
| | |
| | | |
| | | // Iterate through all the provided values, make sure that they are |
| | | // acceptable, and build the value set. |
| | | LinkedHashSet<AttributeValue> valueSet = |
| | | new LinkedHashSet<AttributeValue>(numValues); |
| | | LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(numValues); |
| | | for (String value : values) |
| | | { |
| | | if ((value == null) || (value.length() == 0)) |
| | |
| | | throw new ConfigException(message); |
| | | } |
| | | |
| | | AttributeValue attrValue = |
| | | AttributeValues.create(ByteString.valueOf(value), |
| | | ByteString.valueOf(value)); |
| | | |
| | | ByteString attrValue = ByteString.valueOf(value); |
| | | if (valueSet.contains(attrValue)) |
| | | { |
| | | LocalizableMessage message = |
| | |
| | | * |
| | | * @return The constructed value set. |
| | | */ |
| | | private static LinkedHashSet<AttributeValue> getValueSet(String value) |
| | | private static LinkedHashSet<ByteString> getValueSet(String value) |
| | | { |
| | | LinkedHashSet<AttributeValue> valueSet = |
| | | new LinkedHashSet<AttributeValue>(1); |
| | | |
| | | valueSet.add(AttributeValues.create(ByteString.valueOf(value), |
| | | ByteString.valueOf(value))); |
| | | |
| | | LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(1); |
| | | valueSet.add(ByteString.valueOf(value)); |
| | | return valueSet; |
| | | } |
| | | |
| | |
| | | * |
| | | * @return The constructed value set. |
| | | */ |
| | | private static LinkedHashSet<AttributeValue> getValueSet(List<String> values) |
| | | private static LinkedHashSet<ByteString> getValueSet(List<String> values) |
| | | { |
| | | if (values == null) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | LinkedHashSet<AttributeValue> valueSet = |
| | | new LinkedHashSet<AttributeValue>(values.size()); |
| | | |
| | | LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(values.size()); |
| | | for (String value : values) |
| | | { |
| | | valueSet.add(AttributeValues.create(ByteString.valueOf(value), |
| | | ByteString.valueOf(value))); |
| | | valueSet.add(ByteString.valueOf(value)); |
| | | } |
| | | |
| | | return valueSet; |
| | | } |
| | | |
| | |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use in |
| | | * this attribute, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(AttributeValue value, |
| | | public boolean valueIsAcceptable(ByteString value, |
| | | StringBuilder rejectReason) |
| | | { |
| | | // Make sure that the value is non-empty. |
| | | String stringValue; |
| | | if ((value == null) || |
| | | ((stringValue = value.getValue().toString()).length() == 0)) |
| | | if (value == null || ((stringValue = value.toString()).length() == 0)) |
| | | { |
| | | rejectReason.append(ERR_CONFIG_ATTR_EMPTY_STRING_VALUE.get(getName())); |
| | | return false; |
| | |
| | | * @throws ConfigException If an unrecoverable problem occurs while |
| | | * performing the conversion. |
| | | */ |
| | | public LinkedHashSet<AttributeValue> |
| | | stringsToValues(List<String> valueStrings, |
| | | boolean allowFailures) |
| | | public LinkedHashSet<ByteString> |
| | | stringsToValues(List<String> valueStrings, boolean allowFailures) |
| | | throws ConfigException |
| | | { |
| | | if ((valueStrings == null) || valueStrings.isEmpty()) |
| | |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_IS_REQUIRED.get(getName()); |
| | | throw new ConfigException(message); |
| | | } |
| | | else |
| | | { |
| | | return new LinkedHashSet<AttributeValue>(); |
| | | } |
| | | return new LinkedHashSet<ByteString>(); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | LinkedHashSet<AttributeValue> valueSet = |
| | | new LinkedHashSet<AttributeValue>(numValues); |
| | | LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(numValues); |
| | | for (String valueString : valueStrings) |
| | | { |
| | | if ((valueString == null) || (valueString.length() == 0)) |
| | |
| | | } |
| | | } |
| | | |
| | | valueSet.add(AttributeValues.create(ByteString.valueOf(valueString), |
| | | ByteString.valueOf(valueString))); |
| | | valueSet.add(ByteString.valueOf(valueString)); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | return pendingValues; |
| | | } |
| | | else |
| | | { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | if (isRequired()) |
| | | { |
| | | // This is illegal -- it must have a value. |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_IS_REQUIRED.get(a.getName()); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_IS_REQUIRED.get(a.getName())); |
| | | } |
| | | else |
| | | { |
| | | // This is fine. The pending value set can be empty. |
| | | pendingValues = new ArrayList<String>(0); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | int numValues = a.size(); |
| | |
| | | } |
| | | |
| | | pendingValues = new ArrayList<String>(numValues); |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | String lowerValue = v.getValue().toString().toLowerCase(); |
| | | String lowerValue = v.toString().toLowerCase(); |
| | | if (! allowedValues.contains(lowerValue)) |
| | | { |
| | | // This is illegal -- the value is not allowed. |
| | | throw new ConfigException(ERR_CONFIG_ATTR_VALUE_NOT_ALLOWED.get( |
| | | v.getValue(), a.getName())); |
| | | v, a.getName())); |
| | | } |
| | | |
| | | pendingValues.add(v.getValue().toString()); |
| | | pendingValues.add(v.toString()); |
| | | } |
| | | } |
| | | } |
| | |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_IS_REQUIRED.get(a.getName()); |
| | | throw new ConfigException(message); |
| | | } |
| | | else |
| | | { |
| | | // This is fine. The active value set can be empty. |
| | | activeValues = new ArrayList<String>(0); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | int numValues = a.size(); |
| | |
| | | } |
| | | |
| | | activeValues = new ArrayList<String>(numValues); |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | String lowerValue = v.getValue().toString().toLowerCase(); |
| | | String lowerValue = v.toString().toLowerCase(); |
| | | if (! allowedValues.contains(lowerValue)) |
| | | { |
| | | // This is illegal -- the value is not allowed. |
| | | throw new ConfigException(ERR_CONFIG_ATTR_VALUE_NOT_ALLOWED.get( |
| | | v.getValue(), a.getName())); |
| | | v, a.getName())); |
| | | } |
| | | |
| | | activeValues.add(v.getValue().toString()); |
| | | activeValues.add(v.toString()); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | return new javax.management.Attribute(name, values); |
| | | } |
| | | else |
| | | { |
| | | if (requestedValues.isEmpty()) |
| | | { |
| | | return null; |
| | | } |
| | | else |
| | | else if (!requestedValues.isEmpty()) |
| | | { |
| | | return new javax.management.Attribute(name, requestedValues.get(0)); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.config; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.List; |
| | |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.AttributeValues; |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.messages.ConfigMessages.*; |
| | |
| | | * |
| | | * @return The constructed value set. |
| | | */ |
| | | private static LinkedHashSet<AttributeValue> getValueSet(String value) |
| | | private static LinkedHashSet<ByteString> getValueSet(String value) |
| | | { |
| | | LinkedHashSet<AttributeValue> valueSet = |
| | | new LinkedHashSet<AttributeValue>(1); |
| | | |
| | | valueSet.add(AttributeValues.create(ByteString.valueOf(value), |
| | | ByteString.valueOf(value))); |
| | | |
| | | LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(1); |
| | | valueSet.add(ByteString.valueOf(value)); |
| | | return valueSet; |
| | | } |
| | | |
| | |
| | | * |
| | | * @return The constructed value set. |
| | | */ |
| | | private static LinkedHashSet<AttributeValue> getValueSet(List<String> values) |
| | | private static LinkedHashSet<ByteString> getValueSet(List<String> values) |
| | | { |
| | | if (values == null) |
| | | if (values != null) |
| | | { |
| | | return toByteStrings(values); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | LinkedHashSet<AttributeValue> valueSet = |
| | | new LinkedHashSet<AttributeValue>(values.size()); |
| | | |
| | | for (String value : values) |
| | | { |
| | | valueSet.add(AttributeValues.create(ByteString.valueOf(value), |
| | | ByteString.valueOf(value))); |
| | | } |
| | | |
| | | return valueSet; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use in |
| | | * this attribute, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(AttributeValue value, |
| | | StringBuilder rejectReason) |
| | | public boolean valueIsAcceptable(ByteString value, StringBuilder rejectReason) |
| | | { |
| | | rejectReason.append(ERR_CONFIG_ATTR_READ_ONLY.get(getName())); |
| | | return false; |
| | |
| | | * @throws ConfigException If an unrecoverable problem occurs while |
| | | * performing the conversion. |
| | | */ |
| | | public LinkedHashSet<AttributeValue> |
| | | stringsToValues(List<String> valueStrings, |
| | | boolean allowFailures) |
| | | public LinkedHashSet<ByteString> |
| | | stringsToValues(List<String> valueStrings, boolean allowFailures) |
| | | throws ConfigException |
| | | { |
| | | if ((valueStrings == null) || valueStrings.isEmpty()) |
| | | { |
| | | return new LinkedHashSet<AttributeValue>(); |
| | | return new LinkedHashSet<ByteString>(); |
| | | } |
| | | return toByteStrings(valueStrings); |
| | | } |
| | | |
| | | |
| | | int numValues = valueStrings.size(); |
| | | LinkedHashSet<AttributeValue> valueSet = |
| | | new LinkedHashSet<AttributeValue>(numValues); |
| | | for (String valueString : valueStrings) |
| | | private static LinkedHashSet<ByteString> toByteStrings(List<String> strings) |
| | | { |
| | | valueSet.add(AttributeValues.create(ByteString.valueOf(valueString), |
| | | ByteString.valueOf(valueString))); |
| | | LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(strings.size()); |
| | | for (String valueString : strings) |
| | | { |
| | | valueSet.add(ByteString.valueOf(valueString)); |
| | | } |
| | | |
| | | |
| | | return valueSet; |
| | | } |
| | | |
| | |
| | | { |
| | | if (requiresAdminAction()) |
| | | { |
| | | setPendingValues(new LinkedHashSet<AttributeValue>(0)); |
| | | setPendingValues(new LinkedHashSet<ByteString>(0)); |
| | | pendingValues = new ArrayList<String>(); |
| | | } |
| | | else |
| | | { |
| | | setActiveValues(new LinkedHashSet<AttributeValue>(0)); |
| | | setActiveValues(new LinkedHashSet<ByteString>(0)); |
| | | activeValues.clear(); |
| | | } |
| | | } |
| | |
| | | |
| | | // Iterate through all the provided values, make sure that they are |
| | | // acceptable, and build the value set. |
| | | LinkedHashSet<AttributeValue> valueSet = |
| | | new LinkedHashSet<AttributeValue>(numValues); |
| | | LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(numValues); |
| | | for (String value : values) |
| | | { |
| | | if ((value == null) || (value.length() == 0)) |
| | |
| | | throw new ConfigException(message); |
| | | } |
| | | |
| | | AttributeValue attrValue = |
| | | AttributeValues.create(ByteString.valueOf(value), |
| | | ByteString.valueOf(value)); |
| | | |
| | | ByteString attrValue = ByteString.valueOf(value); |
| | | if (valueSet.contains(attrValue)) |
| | | { |
| | | LocalizableMessage message = |
| | |
| | | * |
| | | * @return The constructed value set. |
| | | */ |
| | | private static LinkedHashSet<AttributeValue> getValueSet(String value) |
| | | private static LinkedHashSet<ByteString> getValueSet(String value) |
| | | { |
| | | LinkedHashSet<AttributeValue> valueSet = |
| | | new LinkedHashSet<AttributeValue>(1); |
| | | |
| | | valueSet.add(AttributeValues.create(ByteString.valueOf(value), |
| | | ByteString.valueOf(value))); |
| | | |
| | | LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(1); |
| | | valueSet.add(ByteString.valueOf(value)); |
| | | return valueSet; |
| | | } |
| | | |
| | |
| | | * |
| | | * @return The constructed value set. |
| | | */ |
| | | private static LinkedHashSet<AttributeValue> getValueSet(List<String> values) |
| | | private static LinkedHashSet<ByteString> getValueSet(List<String> values) |
| | | { |
| | | if (values == null) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | LinkedHashSet<AttributeValue> valueSet = |
| | | new LinkedHashSet<AttributeValue>(values.size()); |
| | | |
| | | LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(values.size()); |
| | | for (String value : values) |
| | | { |
| | | valueSet.add(AttributeValues.create(ByteString.valueOf(value), |
| | | ByteString.valueOf(value))); |
| | | valueSet.add(ByteString.valueOf(value)); |
| | | } |
| | | |
| | | return valueSet; |
| | | } |
| | | |
| | |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use in |
| | | * this attribute, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(AttributeValue value, |
| | | public boolean valueIsAcceptable(ByteString value, |
| | | StringBuilder rejectReason) |
| | | { |
| | | // The only requirement is that the value is not null or empty. |
| | | if ((value == null) || (value.getValue().toString().length() == 0)) |
| | | if (value == null || value.toString().length() == 0) |
| | | { |
| | | rejectReason.append(ERR_CONFIG_ATTR_EMPTY_STRING_VALUE.get(getName())); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | return true; |
| | | } |
| | | |
| | |
| | | * @throws ConfigException If an unrecoverable problem occurs while |
| | | * performing the conversion. |
| | | */ |
| | | public LinkedHashSet<AttributeValue> |
| | | public LinkedHashSet<ByteString> |
| | | stringsToValues(List<String> valueStrings, |
| | | boolean allowFailures) |
| | | throws ConfigException |
| | |
| | | } |
| | | else |
| | | { |
| | | return new LinkedHashSet<AttributeValue>(); |
| | | return new LinkedHashSet<ByteString>(); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | LinkedHashSet<AttributeValue> valueSet = |
| | | new LinkedHashSet<AttributeValue>(numValues); |
| | | LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(numValues); |
| | | for (String valueString : valueStrings) |
| | | { |
| | | if ((valueString == null) || (valueString.length() == 0)) |
| | |
| | | } |
| | | } |
| | | |
| | | valueSet.add(AttributeValues.create(ByteString.valueOf(valueString), |
| | | ByteString.valueOf(valueString))); |
| | | valueSet.add(ByteString.valueOf(valueString)); |
| | | } |
| | | |
| | | |
| | | // If this method was configured to continue on error, then it is possible |
| | | // that we ended up with an empty list. Check to see if this is a required |
| | | // attribute and if so deal with it accordingly. |
| | |
| | | throw new ConfigException(message); |
| | | } |
| | | |
| | | |
| | | return valueSet; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | pendingValues = new ArrayList<String>(numValues); |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | pendingValues.add(v.getValue().toString()); |
| | | pendingValues.add(v.toString()); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | activeValues = new ArrayList<String>(numValues); |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | activeValues.add(v.getValue().toString()); |
| | | activeValues.add(v.toString()); |
| | | } |
| | | } |
| | | } |
| | |
| | | * this matched values control does match the provided attribute |
| | | * value, or <CODE>false</CODE> if none of the filters match. |
| | | */ |
| | | public boolean valueMatches(AttributeType type, AttributeValue value) |
| | | public boolean valueMatches(AttributeType type, ByteString value) |
| | | { |
| | | for (MatchedValuesFilter f : filters) |
| | | { |
| | |
| | | private AttributeType attributeType; |
| | | |
| | | // The processed assertion value for this matched values filter. |
| | | private AttributeValue assertionValue; |
| | | private ByteString assertionValue; |
| | | |
| | | // Indicates whether the elements of this matched values filter have been |
| | | // fully decoded. |
| | |
| | | */ |
| | | public static MatchedValuesFilter createEqualityFilter( |
| | | AttributeType attributeType, |
| | | AttributeValue assertionValue) |
| | | ByteString assertionValue) |
| | | { |
| | | Reject.ifNull(attributeType, assertionValue); |
| | | String rawAttributeType = attributeType.getNameOrOID(); |
| | | ByteString rawAssertionValue = assertionValue.getValue(); |
| | | |
| | | MatchedValuesFilter filter = |
| | | new MatchedValuesFilter(EQUALITY_MATCH_TYPE, rawAttributeType, |
| | | rawAssertionValue, null, null, null, null); |
| | | assertionValue, null, null, null, null); |
| | | filter.attributeType = attributeType; |
| | | filter.assertionValue = assertionValue; |
| | | |
| | |
| | | */ |
| | | public static MatchedValuesFilter createGreaterOrEqualFilter( |
| | | AttributeType attributeType, |
| | | AttributeValue assertionValue) |
| | | ByteString assertionValue) |
| | | { |
| | | Reject.ifNull(attributeType, assertionValue); |
| | | |
| | | String rawAttributeType = attributeType.getNameOrOID(); |
| | | ByteString rawAssertionValue = assertionValue.getValue(); |
| | | |
| | | MatchedValuesFilter filter = |
| | | new MatchedValuesFilter(GREATER_OR_EQUAL_TYPE, rawAttributeType, |
| | | rawAssertionValue, null, null, null, null); |
| | | assertionValue, null, null, null, null); |
| | | filter.attributeType = attributeType; |
| | | filter.assertionValue = assertionValue; |
| | | |
| | |
| | | */ |
| | | public static MatchedValuesFilter createLessOrEqualFilter( |
| | | AttributeType attributeType, |
| | | AttributeValue assertionValue) |
| | | ByteString assertionValue) |
| | | { |
| | | Reject.ifNull(attributeType, assertionValue); |
| | | |
| | | String rawAttributeType = attributeType.getNameOrOID(); |
| | | ByteString rawAssertionValue = assertionValue.getValue(); |
| | | |
| | | MatchedValuesFilter filter = |
| | | new MatchedValuesFilter(LESS_OR_EQUAL_TYPE, rawAttributeType, |
| | | rawAssertionValue, null, null, null, null); |
| | | assertionValue, null, null, null, null); |
| | | filter.attributeType = attributeType; |
| | | filter.assertionValue = assertionValue; |
| | | |
| | |
| | | */ |
| | | public static MatchedValuesFilter createApproximateFilter( |
| | | AttributeType attributeType, |
| | | AttributeValue assertionValue) |
| | | ByteString assertionValue) |
| | | { |
| | | Reject.ifNull(attributeType,assertionValue); |
| | | String rawAttributeType = attributeType.getNameOrOID(); |
| | | ByteString rawAssertionValue = assertionValue.getValue(); |
| | | |
| | | MatchedValuesFilter filter = |
| | | new MatchedValuesFilter(APPROXIMATE_MATCH_TYPE, rawAttributeType, |
| | | rawAssertionValue, null, null, null, null); |
| | | assertionValue, null, null, null, null); |
| | | filter.attributeType = attributeType; |
| | | filter.assertionValue = assertionValue; |
| | | |
| | |
| | | public static MatchedValuesFilter createExtensibleMatchFilter( |
| | | AttributeType attributeType, |
| | | MatchingRule matchingRule, |
| | | AttributeValue assertionValue) |
| | | ByteString assertionValue) |
| | | { |
| | | Reject.ifNull(attributeType, matchingRule, assertionValue); |
| | | String rawAttributeType = attributeType.getNameOrOID(); |
| | | String matchingRuleID = matchingRule.getOID(); |
| | | ByteString rawAssertionValue = assertionValue.getValue(); |
| | | |
| | | MatchedValuesFilter filter = |
| | | new MatchedValuesFilter(EXTENSIBLE_MATCH_TYPE, rawAttributeType, |
| | | rawAssertionValue, null, null, null, |
| | | assertionValue, null, null, null, |
| | | matchingRuleID); |
| | | filter.attributeType = attributeType; |
| | | filter.assertionValue = assertionValue; |
| | |
| | | |
| | | String rawAttributeType = null; |
| | | String matchingRuleID = null; |
| | | ByteString rawAssertionValue; |
| | | |
| | | if(reader.peekType() == TYPE_MATCHING_RULE_ID) |
| | | { |
| | |
| | | { |
| | | rawAttributeType = reader.readOctetStringAsString(); |
| | | } |
| | | rawAssertionValue = reader.readOctetString(); |
| | | ByteString rawAssertionValue = reader.readOctetString(); |
| | | reader.readEndSequence(); |
| | | |
| | | return new MatchedValuesFilter(type, rawAttributeType, |
| | |
| | | * @return The assertion value for this matched values filter, or |
| | | * <CODE>null</CODE> if there is none. |
| | | */ |
| | | public AttributeValue getAssertionValue() |
| | | public ByteString getAssertionValue() |
| | | { |
| | | if (assertionValue == null) |
| | | if (assertionValue == null && rawAssertionValue != null) |
| | | { |
| | | if (rawAssertionValue != null) |
| | | { |
| | | assertionValue = AttributeValues.create( |
| | | getAttributeType(), rawAssertionValue); |
| | | assertionValue = rawAssertionValue; |
| | | } |
| | | } |
| | | |
| | | return assertionValue; |
| | | } |
| | | |
| | |
| | | * criteria defined in this matched values filter, or |
| | | * <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueMatches(AttributeType type, AttributeValue value) |
| | | public boolean valueMatches(AttributeType type, ByteString value) |
| | | { |
| | | fullyDecode(); |
| | | |
| | |
| | | { |
| | | try |
| | | { |
| | | final ByteString normValue = equalityMatchingRule.normalizeAttributeValue(value.getValue()); |
| | | final ByteString normValue = equalityMatchingRule.normalizeAttributeValue(value); |
| | | final Assertion assertion = equalityMatchingRule.getAssertion(rawAssertionValue); |
| | | return assertion.matches(normValue).toBoolean(); |
| | | } |
| | |
| | | { |
| | | ArrayList<ByteSequence> normalizedSubAnyBS = |
| | | new ArrayList<ByteSequence>(normalizedSubAny); |
| | | |
| | | return substringMatchingRule.valueMatchesSubstring( |
| | | substringMatchingRule.normalizeAttributeValue(value.getValue()), |
| | | normalizedSubInitial, |
| | | normalizedSubAnyBS, normalizedSubFinal); |
| | | substringMatchingRule.normalizeAttributeValue(value), |
| | | normalizedSubInitial, normalizedSubAnyBS, normalizedSubFinal); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | { |
| | | try |
| | | { |
| | | ByteString nv = orderingMatchingRule.normalizeAssertionValue(value.getValue()); |
| | | ByteString nv = orderingMatchingRule.normalizeAssertionValue(value); |
| | | return orderingMatchingRule.compareValues( |
| | | nv, |
| | | orderingMatchingRule.normalizeAttributeValue( |
| | | value.getValue())) >= 0; |
| | | nv, orderingMatchingRule.normalizeAttributeValue(value)) >= 0; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | { |
| | | try |
| | | { |
| | | ByteString nv = orderingMatchingRule.normalizeAssertionValue(value.getValue()); |
| | | ByteString nv = orderingMatchingRule.normalizeAssertionValue(value); |
| | | return orderingMatchingRule.compareValues( |
| | | nv, |
| | | orderingMatchingRule.normalizeAttributeValue( |
| | | value.getValue())) <= 0; |
| | | nv, orderingMatchingRule.normalizeAttributeValue(value)) <= 0; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | { |
| | | try |
| | | { |
| | | Assertion assertion = approximateMatchingRule.getAssertion(assertionValue.getValue()); |
| | | ByteString nv = approximateMatchingRule.normalizeAttributeValue(value.getValue()); |
| | | Assertion assertion = approximateMatchingRule.getAssertion(assertionValue); |
| | | ByteString nv = approximateMatchingRule.normalizeAttributeValue(value); |
| | | return assertion.matches(nv).toBoolean(); |
| | | } |
| | | catch (Exception e) |
| | |
| | | |
| | | try |
| | | { |
| | | ByteString nv1 = |
| | | matchingRule.normalizeAttributeValue(value.getValue()); |
| | | Assertion assertion = matchingRule.getAssertion(assertionValue.getValue()); |
| | | ByteString nv1 = matchingRule.normalizeAttributeValue(value); |
| | | Assertion assertion = matchingRule.getAssertion(assertionValue); |
| | | return assertion.matches(nv1) == ConditionResult.TRUE; |
| | | } |
| | | catch (Exception e) |
| | |
| | | |
| | | try |
| | | { |
| | | ByteString normValue = equalityMatchingRule.normalizeAttributeValue(value.getValue()); |
| | | ByteString normValue = equalityMatchingRule.normalizeAttributeValue(value); |
| | | return equalityMatchingRule.getAssertion(rawAssertionValue).matches(normValue).toBoolean(); |
| | | } |
| | | catch (Exception e) |
| | |
| | | * This method always returns null. |
| | | */ |
| | | @Override |
| | | public List<AttributeValue> getCurrentPasswords() |
| | | public List<ByteString> getCurrentPasswords() |
| | | { |
| | | return null; |
| | | } |
| | |
| | | * This method always returns null. |
| | | */ |
| | | @Override |
| | | public List<AttributeValue> getNewPasswords() |
| | | public List<ByteString> getNewPasswords() |
| | | { |
| | | return null; |
| | | } |
| | |
| | | { |
| | | if (a.isEmpty()) continue; |
| | | |
| | | stringValue = a.iterator().next().getValue().toString(); |
| | | stringValue = a.iterator().next().toString(); |
| | | break ; |
| | | } |
| | | } |
| | |
| | | final MatchingRule rule = attributeType.getEqualityMatchingRule(); |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | try |
| | | { |
| | | ByteString normValue = rule.normalizeAttributeValue(v.getValue()); |
| | | ByteString normValue = rule.normalizeAttributeValue(v); |
| | | timeValues.add(GeneralizedTimeSyntax.decodeGeneralizedTimeValue(normValue)); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e, "Unable to decode value %s for attribute %s in user entry %s", |
| | | v.getValue(), attributeType.getNameOrOID(), userDNString); |
| | | v, attributeType.getNameOrOID(), userDNString); |
| | | |
| | | LocalizableMessage message = ERR_PWPSTATE_CANNOT_DECODE_GENERALIZED_TIME. |
| | | get(v.getValue(), attributeType.getNameOrOID(), userDNString, e); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message, e); |
| | | get(v, attributeType.getNameOrOID(), userDNString, e); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, e); |
| | | } |
| | | } |
| | | } |
| | |
| | | * @return The unmodifiable set of values for the password attribute |
| | | * from the user entry. |
| | | */ |
| | | public Set<AttributeValue> getPasswordValues() |
| | | public Set<ByteString> getPasswordValues() |
| | | { |
| | | List<Attribute> attrList = userEntry.getAttribute(passwordPolicy |
| | | .getPasswordAttribute()); |
| | |
| | | { |
| | | if (a.isEmpty()) continue; |
| | | |
| | | Set<AttributeValue> values = |
| | | new LinkedHashSet<AttributeValue>(a.size()); |
| | | for (AttributeValue value : a) |
| | | Set<ByteString> values = new LinkedHashSet<ByteString>(a.size()); |
| | | for (ByteString value : a) |
| | | { |
| | | values.add(value); |
| | | } |
| | |
| | | // Remove any expired failures from the list. |
| | | if (passwordPolicy.getLockoutFailureExpirationInterval() > 0) |
| | | { |
| | | LinkedHashSet<AttributeValue> valuesToRemove = null; |
| | | LinkedHashSet<ByteString> valuesToRemove = null; |
| | | |
| | | long expirationTime = currentTime - |
| | | (passwordPolicy.getLockoutFailureExpirationInterval() * 1000L); |
| | |
| | | |
| | | if (valuesToRemove == null) |
| | | { |
| | | valuesToRemove = new LinkedHashSet<AttributeValue>(); |
| | | valuesToRemove = new LinkedHashSet<ByteString>(); |
| | | } |
| | | |
| | | valuesToRemove.add(AttributeValues.create(type, |
| | | GeneralizedTimeSyntax.format(l))); |
| | | valuesToRemove.add(ByteString.valueOf(GeneralizedTimeSyntax.format(l))); |
| | | } |
| | | } |
| | | |
| | |
| | | OP_ATTR_PWPOLICY_FAILURE_TIME); |
| | | } |
| | | |
| | | Attribute addAttr = Attributes.create(type, AttributeValues.create(type, |
| | | GeneralizedTimeSyntax.format(highestFailureTime))); |
| | | |
| | | Attribute addAttr = Attributes.create(type, GeneralizedTimeSyntax.format(highestFailureTime)); |
| | | modifications.add(new Modification(ModificationType.ADD, addAttr, true)); |
| | | |
| | | // Now check to see if there have been sufficient failures to lock the |
| | |
| | | for (Long l : authFailureTimes) |
| | | { |
| | | highestFailureTime = Math.max(l, highestFailureTime); |
| | | builder |
| | | .add(AttributeValues.create(type, GeneralizedTimeSyntax.format(l))); |
| | | builder.add(GeneralizedTimeSyntax.format(l)); |
| | | } |
| | | Attribute a = builder.toAttribute(); |
| | | |
| | |
| | | OP_ATTR_PWPOLICY_LOCKED_TIME); |
| | | } |
| | | |
| | | Attribute a = Attributes.create(type, AttributeValues.create(type, |
| | | GeneralizedTimeSyntax.format(failureLockedTime))); |
| | | |
| | | Attribute a = Attributes.create(type, GeneralizedTimeSyntax.format(failureLockedTime)); |
| | | modifications.add(new Modification(ModificationType.REPLACE, a, true)); |
| | | } |
| | | |
| | |
| | | { |
| | | if (a.isEmpty()) continue; |
| | | |
| | | String valueString = a.iterator().next().getValue().toString(); |
| | | |
| | | String valueString = a.iterator().next().toString(); |
| | | try |
| | | { |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat(format); |
| | |
| | | OP_ATTR_PWPOLICY_GRACE_LOGIN_TIME); |
| | | } |
| | | |
| | | Attribute addAttr = Attributes.create(type, AttributeValues.create( |
| | | type, GeneralizedTimeSyntax.format(highestGraceTime))); |
| | | |
| | | Attribute addAttr = Attributes.create(type, GeneralizedTimeSyntax.format(highestGraceTime)); |
| | | modifications.add(new Modification(ModificationType.ADD, addAttr, true)); |
| | | } |
| | | |
| | |
| | | AttributeBuilder builder = new AttributeBuilder(type); |
| | | for (Long l : graceLoginTimes) |
| | | { |
| | | builder |
| | | .add(AttributeValues.create(type, GeneralizedTimeSyntax.format(l))); |
| | | builder.add(GeneralizedTimeSyntax.format(l)); |
| | | } |
| | | Attribute a = builder.toAttribute(); |
| | | |
| | |
| | | { |
| | | boolean usesAuthPasswordSyntax = passwordPolicy.isAuthPasswordSyntax(); |
| | | |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | try |
| | | { |
| | | StringBuilder[] pwComponents; |
| | | if (usesAuthPasswordSyntax) |
| | | { |
| | | pwComponents = |
| | | AuthPasswordSyntax.decodeAuthPassword(v.getValue().toString()); |
| | | } |
| | | else |
| | | { |
| | | String[] userPwComponents = |
| | | UserPasswordSyntax.decodeUserPassword(v.getValue().toString()); |
| | | pwComponents = new StringBuilder[userPwComponents.length]; |
| | | for (int i = 0; i < userPwComponents.length; ++i) |
| | | { |
| | | pwComponents[i] = new StringBuilder(userPwComponents[i]); |
| | | } |
| | | } |
| | | StringBuilder[] pwComponents = |
| | | getPwComponents(usesAuthPasswordSyntax, v); |
| | | |
| | | String schemeName = pwComponents[0].toString(); |
| | | PasswordStorageScheme<?> scheme = (usesAuthPasswordSyntax) |
| | |
| | | { |
| | | boolean usesAuthPasswordSyntax = passwordPolicy.isAuthPasswordSyntax(); |
| | | |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | try |
| | | { |
| | | StringBuilder[] pwComponents; |
| | | if (usesAuthPasswordSyntax) |
| | | { |
| | | pwComponents = |
| | | AuthPasswordSyntax.decodeAuthPassword(v.getValue().toString()); |
| | | } |
| | | else |
| | | { |
| | | String[] userPwComponents = |
| | | UserPasswordSyntax.decodeUserPassword(v.getValue().toString()); |
| | | pwComponents = new StringBuilder[userPwComponents.length]; |
| | | for (int i = 0; i < userPwComponents.length; ++i) |
| | | { |
| | | pwComponents[i] = new StringBuilder(userPwComponents[i]); |
| | | } |
| | | } |
| | | StringBuilder[] pwComponents = |
| | | getPwComponents(usesAuthPasswordSyntax, v); |
| | | |
| | | String schemeName = pwComponents[0].toString(); |
| | | PasswordStorageScheme<?> scheme = (usesAuthPasswordSyntax) |
| | |
| | | |
| | | |
| | | |
| | | private StringBuilder[] getPwComponents(boolean usesAuthPasswordSyntax, |
| | | ByteString v) throws DirectoryException |
| | | { |
| | | if (usesAuthPasswordSyntax) |
| | | { |
| | | return AuthPasswordSyntax.decodeAuthPassword(v.toString()); |
| | | } |
| | | |
| | | String[] userPwComponents = UserPasswordSyntax.decodeUserPassword(v.toString()); |
| | | StringBuilder[] pwComponents = new StringBuilder[userPwComponents.length]; |
| | | for (int i = 0; i < userPwComponents.length; ++i) |
| | | { |
| | | pwComponents[i] = new StringBuilder(userPwComponents[i]); |
| | | } |
| | | return pwComponents; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether the provided password value is pre-encoded. |
| | | * |
| | |
| | | |
| | | |
| | | HashSet<String> existingDefaultSchemes = new HashSet<String>(); |
| | | LinkedHashSet<AttributeValue> removedValues = |
| | | new LinkedHashSet<AttributeValue>(); |
| | | LinkedHashSet<AttributeValue> updatedValues = |
| | | new LinkedHashSet<AttributeValue>(); |
| | | LinkedHashSet<ByteString> removedValues = new LinkedHashSet<ByteString>(); |
| | | LinkedHashSet<ByteString> updatedValues = new LinkedHashSet<ByteString>(); |
| | | |
| | | boolean usesAuthPasswordSyntax = passwordPolicy.isAuthPasswordSyntax(); |
| | | |
| | | for (Attribute a : attrList) |
| | | { |
| | | Iterator<AttributeValue> iterator = a.iterator(); |
| | | Iterator<ByteString> iterator = a.iterator(); |
| | | while (iterator.hasNext()) |
| | | { |
| | | AttributeValue v = iterator.next(); |
| | | ByteString v = iterator.next(); |
| | | |
| | | try |
| | | { |
| | | StringBuilder[] pwComponents; |
| | | if (usesAuthPasswordSyntax) |
| | | { |
| | | pwComponents = |
| | | AuthPasswordSyntax.decodeAuthPassword(v.getValue().toString()); |
| | | } |
| | | else |
| | | { |
| | | String[] userPwComponents = |
| | | UserPasswordSyntax.decodeUserPassword(v.getValue().toString()); |
| | | pwComponents = new StringBuilder[userPwComponents.length]; |
| | | for (int i = 0; i < userPwComponents.length; ++i) |
| | | { |
| | | pwComponents[i] = new StringBuilder(userPwComponents[i]); |
| | | } |
| | | } |
| | | StringBuilder[] pwComponents = |
| | | getPwComponents(usesAuthPasswordSyntax, v); |
| | | |
| | | String schemeName = pwComponents[0].toString(); |
| | | PasswordStorageScheme<?> scheme = (usesAuthPasswordSyntax) |
| | |
| | | return; |
| | | } |
| | | |
| | | LinkedHashSet<AttributeValue> addedValues = new |
| | | LinkedHashSet<AttributeValue>(); |
| | | LinkedHashSet<ByteString> addedValues = new LinkedHashSet<ByteString>(); |
| | | for (PasswordStorageScheme<?> s : |
| | | passwordPolicy.getDefaultPasswordStorageSchemes()) |
| | | { |
| | |
| | | ByteString encodedPassword = (usesAuthPasswordSyntax) |
| | | ? s.encodeAuthPassword(password) |
| | | : s.encodePasswordWithScheme(password); |
| | | AttributeValue v = |
| | | AttributeValues.create(type, encodedPassword); |
| | | addedValues.add(v); |
| | | updatedValues.add(v); |
| | | addedValues.add(encodedPassword); |
| | | updatedValues.add(encodedPassword); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | // Get the attribute containing the history and check to see if any of the |
| | | // values is equal to the provided password. However, first prune the list |
| | | // by size and duration if necessary. |
| | | TreeMap<Long,AttributeValue> historyMap = getSortedHistoryValues(null); |
| | | TreeMap<Long, ByteString> historyMap = getSortedHistoryValues(null); |
| | | |
| | | int historyCount = passwordPolicy.getPasswordHistoryCount(); |
| | | if ((historyCount > 0) && (historyMap.size() > historyCount)) |
| | |
| | | } |
| | | } |
| | | |
| | | for (AttributeValue v : historyMap.values()) |
| | | for (ByteString v : historyMap.values()) |
| | | { |
| | | if (historyValueMatches(password, v)) |
| | | { |
| | |
| | | * not be properly decoded. It may be {@code null} if |
| | | * this is not needed. |
| | | */ |
| | | private TreeMap<Long,AttributeValue> getSortedHistoryValues(List<Attribute> |
| | | private TreeMap<Long,ByteString> getSortedHistoryValues(List<Attribute> |
| | | removeAttrs) |
| | | { |
| | | TreeMap<Long,AttributeValue> historyMap = |
| | | new TreeMap<Long,AttributeValue>(); |
| | | TreeMap<Long, ByteString> historyMap = new TreeMap<Long, ByteString>(); |
| | | AttributeType historyType = |
| | | DirectoryServer.getAttributeType(OP_ATTR_PWPOLICY_HISTORY_LC, true); |
| | | List<Attribute> attrList = userEntry.getAttribute(historyType); |
| | |
| | | { |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | String histStr = v.getValue().toString(); |
| | | String histStr = v.toString(); |
| | | int hashPos = histStr.indexOf('#'); |
| | | if (hashPos <= 0) |
| | | { |
| | |
| | | * or {@code false} if not. |
| | | */ |
| | | private boolean historyValueMatches(ByteString password, |
| | | AttributeValue historyValue) |
| | | ByteString historyValue) |
| | | { |
| | | // According to draft-behera-ldap-password-policy, password history values |
| | | // should be in the format time#syntaxoid#encodedvalue. In this method, |
| | | // we only care about the syntax OID and encoded password. |
| | | try |
| | | { |
| | | String histStr = historyValue.getValue().toString(); |
| | | String histStr = historyValue.toString(); |
| | | int hashPos1 = histStr.indexOf('#'); |
| | | if (hashPos1 <= 0) |
| | | { |
| | |
| | | { |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | addPasswordToHistory(v.getValue().toString()); |
| | | addPasswordToHistory(v.toString()); |
| | | } |
| | | } |
| | | } |
| | |
| | | // Get a sorted list of the existing values to see if there are any that |
| | | // should be removed. |
| | | LinkedList<Attribute> removeAttrs = new LinkedList<Attribute>(); |
| | | TreeMap<Long,AttributeValue> historyMap = |
| | | getSortedHistoryValues(removeAttrs); |
| | | TreeMap<Long, ByteString> historyMap = getSortedHistoryValues(removeAttrs); |
| | | |
| | | |
| | | // If there is a maximum number of values to retain and we would be over the |
| | |
| | | if ((historyCount > 0) && (historyMap.size() >= historyCount)) |
| | | { |
| | | int numToDelete = (historyMap.size() - historyCount) + 1; |
| | | LinkedHashSet<AttributeValue> removeValues = |
| | | new LinkedHashSet<AttributeValue>(numToDelete); |
| | | Iterator<AttributeValue> iterator = historyMap.values().iterator(); |
| | | LinkedHashSet<ByteString> removeValues = |
| | | new LinkedHashSet<ByteString>(numToDelete); |
| | | Iterator<ByteString> iterator = historyMap.values().iterator(); |
| | | while (iterator.hasNext() && (numToDelete > 0)) |
| | | { |
| | | AttributeValue v = iterator.next(); |
| | | ByteString v = iterator.next(); |
| | | removeValues.add(v); |
| | | iterator.remove(); |
| | | numToDelete--; |
| | | |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.trace("Removing history value %s to preserve the history count.", v.getValue()); |
| | | logger.trace("Removing history value %s to preserve the history count.", v); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | long minAgeToKeep = currentTime - (1000L * historyDuration); |
| | | Iterator<Long> iterator = historyMap.keySet().iterator(); |
| | | LinkedHashSet<AttributeValue> removeValues = |
| | | new LinkedHashSet<AttributeValue>(); |
| | | LinkedHashSet<ByteString> removeValues = new LinkedHashSet<ByteString>(); |
| | | while (iterator.hasNext()) |
| | | { |
| | | long timestamp = iterator.next(); |
| | | if (timestamp < minAgeToKeep) |
| | | { |
| | | AttributeValue v = historyMap.get(timestamp); |
| | | ByteString v = historyMap.get(timestamp); |
| | | removeValues.add(v); |
| | | iterator.remove(); |
| | | |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.trace("Removing history value %s to preserve the history duration.", v.getValue()); |
| | | logger.trace("Removing history value %s to preserve the history duration.", v); |
| | | } |
| | | } |
| | | else |
| | |
| | | { |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | historyValues.add(v.getValue().toString()); |
| | | historyValues.add(v.toString()); |
| | | } |
| | | } |
| | | } |
| | |
| | | for (DirectoryServerPlugin p : pluginArray) |
| | | { |
| | | DN dn = p.getPluginEntryDN(); |
| | | String lowerName = |
| | | toLowerCase(dn.rdn().getAttributeValue(0).getValue().toString()); |
| | | String lowerName = toLowerCase(dn.rdn().getAttributeValue(0).toString()); |
| | | if (initialPluginNames.contains(lowerName)) |
| | | { |
| | | initialPlugins.put(lowerName, p); |
| | |
| | | // Get the name of the provided plugin from its RDN value and put it in |
| | | // the correct category. |
| | | DN dn = plugin.getPluginEntryDN(); |
| | | String lowerName = |
| | | toLowerCase(dn.rdn().getAttributeValue(0).getValue().toString()); |
| | | String lowerName = toLowerCase(dn.rdn().getAttributeValue(0).toString()); |
| | | if (initialPluginNames.contains(lowerName)) |
| | | { |
| | | initialPlugins.put(lowerName, plugin); |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.schema.*; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.LDIFReader; |
| | |
| | | { |
| | | for (Attribute a : ldapSyntaxList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | LDAPSyntaxDescription syntaxDescription; |
| | | try |
| | | { |
| | | syntaxDescription = LDAPSyntaxDescriptionSyntax.decodeLDAPSyntax( |
| | | v.getValue(),schema,false); |
| | | syntaxDescription = LDAPSyntaxDescriptionSyntax.decodeLDAPSyntax(v, schema, false); |
| | | setExtraProperty(syntaxDescription, SCHEMA_PROPERTY_FILENAME, null); |
| | | setSchemaFile(syntaxDescription, schemaFile); |
| | | } |
| | |
| | | logger.traceException(e); |
| | | |
| | | LocalizableMessage message = WARN_CONFIG_SCHEMA_CANNOT_PARSE_LDAP_SYNTAX.get( |
| | | schemaFile, |
| | | v.getValue() + ": " + getExceptionMessage(e)); |
| | | schemaFile, v + ": " + getExceptionMessage(e)); |
| | | reportError(failOnError, e, message); |
| | | continue; |
| | | } |
| | |
| | | { |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | // Parse the attribute type. |
| | | AttributeType attrType; |
| | | try |
| | | { |
| | | attrType = AttributeTypeSyntax.decodeAttributeType(v.getValue(), |
| | | schema, false); |
| | | attrType = AttributeTypeSyntax.decodeAttributeType(v, schema, false); |
| | | setExtraProperty(attrType, SCHEMA_PROPERTY_FILENAME, null); |
| | | setSchemaFile(attrType, schemaFile); |
| | | } |
| | |
| | | logger.traceException(e); |
| | | |
| | | LocalizableMessage message = WARN_CONFIG_SCHEMA_CANNOT_PARSE_ATTR_TYPE.get( |
| | | schemaFile, v.getValue() + ": " + getExceptionMessage(e)); |
| | | schemaFile, v + ": " + getExceptionMessage(e)); |
| | | reportError(failOnError, e, message); |
| | | continue; |
| | | } |
| | |
| | | { |
| | | for (Attribute a : ocList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | // Parse the objectclass. |
| | | ObjectClass oc; |
| | | try |
| | | { |
| | | oc = |
| | | ObjectClassSyntax.decodeObjectClass(v.getValue(), schema, false); |
| | | oc = ObjectClassSyntax.decodeObjectClass(v, schema, false); |
| | | setExtraProperty(oc, SCHEMA_PROPERTY_FILENAME, null); |
| | | setSchemaFile(oc, schemaFile); |
| | | } |
| | |
| | | logger.traceException(e); |
| | | |
| | | LocalizableMessage message = WARN_CONFIG_SCHEMA_CANNOT_PARSE_OC.get( |
| | | schemaFile, |
| | | v.getValue() + ": " + getExceptionMessage(e)); |
| | | schemaFile, v + ": " + getExceptionMessage(e)); |
| | | reportError(failOnError, e, message); |
| | | continue; |
| | | } |
| | |
| | | { |
| | | for (Attribute a : nfList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | // Parse the name form. |
| | | NameForm nf; |
| | | try |
| | | { |
| | | nf = NameFormSyntax.decodeNameForm(v.getValue(), schema, false); |
| | | nf = NameFormSyntax.decodeNameForm(v, schema, false); |
| | | nf.getExtraProperties().remove(SCHEMA_PROPERTY_FILENAME); |
| | | setSchemaFile(nf, schemaFile); |
| | | } |
| | |
| | | logger.traceException(e); |
| | | |
| | | LocalizableMessage message = WARN_CONFIG_SCHEMA_CANNOT_PARSE_NAME_FORM.get( |
| | | schemaFile, v.getValue() + ": " + getExceptionMessage(e)); |
| | | schemaFile, v + ": " + getExceptionMessage(e)); |
| | | reportError(failOnError, e, message); |
| | | continue; |
| | | } |
| | |
| | | { |
| | | for (Attribute a : dcrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | // Parse the DIT content rule. |
| | | DITContentRule dcr; |
| | | try |
| | | { |
| | | dcr = DITContentRuleSyntax.decodeDITContentRule( |
| | | v.getValue(), schema, false); |
| | | dcr = DITContentRuleSyntax.decodeDITContentRule(v, schema, false); |
| | | dcr.getExtraProperties().remove(SCHEMA_PROPERTY_FILENAME); |
| | | setSchemaFile(dcr, schemaFile); |
| | | } |
| | |
| | | logger.traceException(e); |
| | | |
| | | LocalizableMessage message = WARN_CONFIG_SCHEMA_CANNOT_PARSE_DCR.get( |
| | | schemaFile,v.getValue() + ": " + getExceptionMessage(e)); |
| | | schemaFile, v + ": " + getExceptionMessage(e)); |
| | | reportError(failOnError, e, message); |
| | | continue; |
| | | } |
| | |
| | | { |
| | | for (Attribute a : dsrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | // Parse the DIT content rule. |
| | | DITStructureRule dsr; |
| | | try |
| | | { |
| | | dsr = DITStructureRuleSyntax.decodeDITStructureRule( |
| | | v.getValue(), schema, false); |
| | | dsr = DITStructureRuleSyntax.decodeDITStructureRule(v, schema, false); |
| | | dsr.getExtraProperties().remove(SCHEMA_PROPERTY_FILENAME); |
| | | setSchemaFile(dsr, schemaFile); |
| | | } |
| | |
| | | logger.traceException(e); |
| | | |
| | | LocalizableMessage message = WARN_CONFIG_SCHEMA_CANNOT_PARSE_DSR.get( |
| | | schemaFile, v.getValue() + ": " + getExceptionMessage(e)); |
| | | schemaFile, v + ": " + getExceptionMessage(e)); |
| | | reportError(failOnError, e, message); |
| | | continue; |
| | | } |
| | |
| | | { |
| | | for (Attribute a : mruList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | // Parse the matching rule use definition. |
| | | MatchingRuleUse mru; |
| | | try |
| | | { |
| | | mru = MatchingRuleUseSyntax.decodeMatchingRuleUse( |
| | | v.getValue(), schema, false); |
| | | mru = MatchingRuleUseSyntax.decodeMatchingRuleUse(v, schema, false); |
| | | mru.getExtraProperties().remove(SCHEMA_PROPERTY_FILENAME); |
| | | setSchemaFile(mru, schemaFile); |
| | | } |
| | |
| | | logger.traceException(e); |
| | | |
| | | LocalizableMessage message = WARN_CONFIG_SCHEMA_CANNOT_PARSE_MRU.get( |
| | | schemaFile, |
| | | v.getValue() + ": " + getExceptionMessage(e)); |
| | | schemaFile, v + ": " + getExceptionMessage(e)); |
| | | reportError(failOnError, e, message); |
| | | continue; |
| | | } |
| | |
| | | filteredEntry.getObjectClasses().values().iterator(); |
| | | while (ocIterator.hasNext()) |
| | | { |
| | | String ocName = ocIterator.next(); |
| | | AttributeValue v = |
| | | AttributeValues.create(attrType,ocName); |
| | | if (! matchedValuesControl.valueMatches(attrType, v)) |
| | | ByteString ocName = ByteString.valueOf(ocIterator.next()); |
| | | if (! matchedValuesControl.valueMatches(attrType, ocName)) |
| | | { |
| | | ocIterator.remove(); |
| | | } |
| | |
| | | // Assume that the attribute will be either empty or contain |
| | | // very few values. |
| | | AttributeBuilder builder = new AttributeBuilder(a, true); |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | if (matchedValuesControl.valueMatches(t, v)) |
| | | { |
| | |
| | | // Assume that the attribute will be either empty or contain |
| | | // very few values. |
| | | AttributeBuilder builder = new AttributeBuilder(a, true); |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | if (matchedValuesControl.valueMatches(t, v)) |
| | | { |
| | |
| | | case EQUALITY: |
| | | if (filter.getAttributeType().isObjectClass()) |
| | | { |
| | | AttributeValue v = filter.getAssertionValue(); |
| | | ByteString v = filter.getAssertionValue(); |
| | | // FIXME : technically this is not correct since the presence |
| | | // of draft oc would trigger rfc oc visibility and visa versa. |
| | | String stringValueLC = toLowerCase(v.getValue().toString()); |
| | | String stringValueLC = toLowerCase(v.toString()); |
| | | if (stringValueLC.equals(OC_LDAP_SUBENTRY_LC) || |
| | | stringValueLC.equals(OC_SUBENTRY)) |
| | | { |
| | |
| | | { |
| | | for (Attribute attr : pwdAttrList) |
| | | { |
| | | for (AttributeValue val : attr) |
| | | for (ByteString val : attr) |
| | | { |
| | | DN validatorDN = DN.decode(val.getValue()); |
| | | DN validatorDN = DN.decode(val); |
| | | if (DirectoryServer.getPasswordValidator(validatorDN) == null) |
| | | { |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | |
| | | { |
| | | for (Attribute attr : pwdAttrList) |
| | | { |
| | | for (AttributeValue value : attr) |
| | | for (ByteString value : attr) |
| | | { |
| | | return value.toString(); |
| | | } |
| | |
| | | static byte[] getInstanceKeyCertificateFromLocalTruststore() |
| | | throws CryptoManagerException { |
| | | // Construct the key entry DN. |
| | | final AttributeValue distinguishedValue = AttributeValues.create( |
| | | attrKeyID, ConfigConstants.ADS_CERTIFICATE_ALIAS); |
| | | final ByteString distinguishedValue = ByteString.valueOf(ConfigConstants.ADS_CERTIFICATE_ALIAS); |
| | | final DN entryDN = localTruststoreDN.child( |
| | | RDN.create(attrKeyID, distinguishedValue)); |
| | | // Construct the search filter. |
| | |
| | | final String instanceKeyID |
| | | = getInstanceKeyID(instanceKeyCertificate); |
| | | // Construct the key entry DN. |
| | | final AttributeValue distinguishedValue = |
| | | AttributeValues.create(attrKeyID, instanceKeyID); |
| | | final ByteString distinguishedValue = ByteString.valueOf(instanceKeyID); |
| | | final DN entryDN = instanceKeysDN.child( |
| | | RDN.create(attrKeyID, distinguishedValue)); |
| | | // Construct the search filter. |
| | |
| | | // Add the key ID attribute. |
| | | final Attribute keyIDAttr = Attributes.create(attrKeyID, |
| | | distinguishedValue); |
| | | entry.addAttribute(keyIDAttr, new ArrayList<AttributeValue>(0)); |
| | | entry.addAttribute(keyIDAttr, new ArrayList<ByteString>(0)); |
| | | |
| | | // Add the public key certificate attribute. |
| | | AttributeBuilder builder = new AttributeBuilder( |
| | | attrPublicKeyCertificate); |
| | | builder.setOption("binary"); |
| | | builder.add(AttributeValues.create( |
| | | attrPublicKeyCertificate, |
| | | ByteString.wrap(instanceKeyCertificate))); |
| | | builder.add(ByteString.wrap(instanceKeyCertificate)); |
| | | final Attribute certificateAttr = builder.toAttribute(); |
| | | entry.addAttribute(certificateAttr, |
| | | new ArrayList<AttributeValue>(0)); |
| | | entry.addAttribute(certificateAttr, new ArrayList<ByteString>(0)); |
| | | |
| | | AddOperation addOperation = icc.processAdd(entry.getName(), |
| | | entry.getObjectClasses(), |
| | |
| | | String value) |
| | | { |
| | | ArrayList<Attribute> attrList = new ArrayList<Attribute>(1); |
| | | attrList.add(Attributes.create(type, AttributeValues.create(type, value))); |
| | | attrList.add(Attributes.create(type, value)); |
| | | attrs.put(type, attrList); |
| | | } |
| | | |
| | |
| | | throws CryptoManagerException |
| | | { |
| | | // Construct the key entry DN. |
| | | AttributeValue distinguishedValue = |
| | | AttributeValues.create(attrKeyID, |
| | | keyEntry.getKeyID().getStringValue()); |
| | | ByteString distinguishedValue = |
| | | ByteString.valueOf(keyEntry.getKeyID().getStringValue()); |
| | | DN entryDN = secretKeysDN.child( |
| | | RDN.create(attrKeyID, distinguishedValue)); |
| | | |
| | |
| | | String symmetricKey = cryptoManager.encodeSymmetricKeyAttribute( |
| | | mapEntry.getKey(), mapEntry.getValue(), keyEntry.getSecretKey()); |
| | | |
| | | builder.add(AttributeValues.create(attrSymmetricKey, symmetricKey)); |
| | | builder.add(symmetricKey); |
| | | } |
| | | attrList = new ArrayList<Attribute>(1); |
| | | attrList.add(builder.toAttribute()); |
| | |
| | | throws CryptoManagerException |
| | | { |
| | | // Construct the key entry DN. |
| | | AttributeValue distinguishedValue = |
| | | AttributeValues.create(attrKeyID, |
| | | keyEntry.getKeyID().getStringValue()); |
| | | ByteString distinguishedValue = |
| | | ByteString.valueOf(keyEntry.getKeyID().getStringValue()); |
| | | DN entryDN = secretKeysDN.child( |
| | | RDN.create(attrKeyID, distinguishedValue)); |
| | | |
| | |
| | | mapEntry.getKey(), |
| | | mapEntry.getValue(), |
| | | keyEntry.getSecretKey()); |
| | | |
| | | builder.add( |
| | | AttributeValues.create(attrSymmetricKey, symmetricKey)); |
| | | builder.add(symmetricKey); |
| | | } |
| | | |
| | | attrList = new ArrayList<Attribute>(1); |
| | |
| | | { |
| | | Attribute substring = Attributes.create(a.getAttributeType(), |
| | | password.substring(i, j)); |
| | | for (AttributeValue val : a) |
| | | for (ByteString val : a) |
| | | { |
| | | if (substring.contains(val)) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | |
| | | continue; |
| | | } |
| | | |
| | | AttributeValue vf = AttributeValues.create(t, password); |
| | | AttributeValue vr = AttributeValues.create(t, reversed); |
| | | ByteString vf = ByteString.valueOf(password); |
| | | ByteString vr = ByteString.valueOf(reversed); |
| | | |
| | | for (Attribute a : attrList) |
| | | { |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.admin.std.server. |
| | | CollectiveAttributeSubentriesVirtualAttributeCfg; |
| | | import org.opends.server.api.VirtualAttributeProvider; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | |
| | | /** |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | public Set<AttributeValue> getValues(Entry entry, |
| | | VirtualAttributeRule rule) |
| | | public Attribute getValues(Entry entry, VirtualAttributeRule rule) |
| | | { |
| | | Set<AttributeValue> values = null; |
| | | |
| | | AttributeBuilder builder = new AttributeBuilder(rule.getAttributeType()); |
| | | if (!entry.isSubentry() && !entry.isLDAPSubentry()) |
| | | { |
| | | List<SubEntry> subentries = DirectoryServer.getSubentryManager() |
| | | .getCollectiveSubentries(entry); |
| | | |
| | | AttributeType dnAttrType = |
| | | DirectoryServer.getAttributeType("2.5.4.49"); |
| | | for (SubEntry subentry : subentries) |
| | | { |
| | | if (subentry.isCollective() || |
| | | subentry.isInheritedCollective()) |
| | | { |
| | | DN subentryDN = subentry.getDN(); |
| | | AttributeValue value = AttributeValues.create( |
| | | dnAttrType, subentryDN.toString()); |
| | | |
| | | if (values == null) |
| | | { |
| | | values = Collections.singleton(value); |
| | | } |
| | | else if (values.size() == 1) |
| | | { |
| | | Set<AttributeValue> tmp = new HashSet<AttributeValue>(2); |
| | | tmp.addAll(values); |
| | | tmp.add(value); |
| | | values = tmp; |
| | | } |
| | | else |
| | | { |
| | | values.add(value); |
| | | builder.add(subentry.getDN().toString()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (values != null) |
| | | { |
| | | return Collections.unmodifiableSet(values); |
| | | } |
| | | return Collections.emptySet(); |
| | | return builder.toAttribute(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DirectoryConfig; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.DN; |
| | |
| | | { |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | try |
| | | { |
| | | memberURLs.add(LDAPURL.decode(v.getValue().toString(), true)); |
| | | memberURLs.add(LDAPURL.decode(v.toString(), true)); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | logger.error(ERR_DYNAMICGROUP_CANNOT_DECODE_MEMBERURL, v.getValue(), |
| | | logger.error(ERR_DYNAMICGROUP_CANNOT_DECODE_MEMBERURL, v, |
| | | groupEntry.getName(), de.getMessageObject()); |
| | | } |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | |
| | | |
| | | import java.util.*; |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | import java.util.zip.Adler32; |
| | | import java.util.zip.CRC32; |
| | | import java.util.zip.Checksum; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.EntityTagVirtualAttributeCfg; |
| | | import org.opends.server.api.VirtualAttributeProvider; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.util.StaticUtils; |
| | | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class implements a virtual attribute provider which ensures that all |
| | | * entries contain an "entity tag" or "Etag" as defined in section 3.11 of RFC |
| | |
| | | */ |
| | | @Override() |
| | | public ConditionResult approximatelyEqualTo(final Entry entry, |
| | | final VirtualAttributeRule rule, final AttributeValue value) |
| | | final VirtualAttributeRule rule, final ByteString value) |
| | | { |
| | | // ETags cannot be used in approximate matching. |
| | | return ConditionResult.UNDEFINED; |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override() |
| | | public Set<AttributeValue> getValues(final Entry entry, |
| | | final VirtualAttributeRule rule) |
| | | public Attribute getValues(final Entry entry, final VirtualAttributeRule rule) |
| | | { |
| | | // Save reference to current configuration in case it changes. |
| | | final EntityTagVirtualAttributeCfg cfg = config; |
| | |
| | | } |
| | | |
| | | final ByteString etag = checksumEntry(cfg, checksummer, entry); |
| | | final AttributeValue value = AttributeValues.create(etag, etag); |
| | | return Collections.singleton(value); |
| | | return Attributes.create(rule.getAttributeType(), etag); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | @Override() |
| | | public ConditionResult greaterThanOrEqualTo(final Entry entry, |
| | | final VirtualAttributeRule rule, final AttributeValue value) |
| | | final VirtualAttributeRule rule, final ByteString value) |
| | | { |
| | | // ETags cannot be used in ordering matching. |
| | | return ConditionResult.UNDEFINED; |
| | |
| | | */ |
| | | @Override() |
| | | public ConditionResult lessThanOrEqualTo(final Entry entry, |
| | | final VirtualAttributeRule rule, final AttributeValue value) |
| | | final VirtualAttributeRule rule, final ByteString value) |
| | | { |
| | | // ETags cannot be used in ordering matching. |
| | | return ConditionResult.UNDEFINED; |
| | |
| | | break; |
| | | case 1: |
| | | // Avoid sorting single valued attributes. |
| | | checksumValue(checksummer, attribute.iterator().next().getValue()); |
| | | checksumValue(checksummer, attribute.iterator().next()); |
| | | break; |
| | | default: |
| | | // Multi-valued attributes need sorting. |
| | | final ByteString[] values = new ByteString[size]; |
| | | int i = 0; |
| | | for (final AttributeValue av : attribute) |
| | | for (final ByteString av : attribute) |
| | | { |
| | | values[i++] = av.getValue(); |
| | | values[i++] = av; |
| | | } |
| | | Arrays.sort(values); |
| | | for (final ByteString value : values) |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | public Set<AttributeValue> getValues(Entry entry, |
| | | VirtualAttributeRule rule) |
| | | public Attribute getValues(Entry entry, VirtualAttributeRule rule) |
| | | { |
| | | String normDNString = entry.getName().toNormalizedString(); |
| | | AttributeValue value = AttributeValues.create( |
| | | ByteString.valueOf(normDNString), |
| | | ByteString.valueOf(normDNString)); |
| | | return Collections.singleton(value); |
| | | return Attributes.create(rule.getAttributeType(), normDNString); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | public boolean hasValue(Entry entry, VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | public boolean hasValue(Entry entry, VirtualAttributeRule rule, ByteString value) |
| | | { |
| | | try |
| | | { |
| | | MatchingRule eqRule = rule.getAttributeType().getEqualityMatchingRule(); |
| | | ByteString dn = ByteString.valueOf(entry.getName().toString()); |
| | | ByteString normalizedDN = eqRule.normalizeAttributeValue(dn); |
| | | ByteString normalizedValue = eqRule.normalizeAttributeValue(value.getValue()); |
| | | ByteString normalizedValue = eqRule.normalizeAttributeValue(value); |
| | | return normalizedDN.equals(normalizedValue); |
| | | } |
| | | catch (DecodeException e) |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | public boolean hasAnyValue(Entry entry, VirtualAttributeRule rule, |
| | | Collection<AttributeValue> values) |
| | | { |
| | | String ndnString = entry.getName().toNormalizedString(); |
| | | |
| | | AttributeValue v = AttributeValues.create(ByteString.valueOf(ndnString), |
| | | ByteString.valueOf(ndnString)); |
| | | return values.contains(v); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | public ConditionResult matchesSubstring(Entry entry, |
| | | VirtualAttributeRule rule, |
| | | ByteString subInitial, |
| | |
| | | @Override() |
| | | public ConditionResult greaterThanOrEqualTo(Entry entry, |
| | | VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | ByteString value) |
| | | { |
| | | // DNs cannot be used in ordering matching. |
| | | return ConditionResult.UNDEFINED; |
| | |
| | | @Override() |
| | | public ConditionResult lessThanOrEqualTo(Entry entry, |
| | | VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | ByteString value) |
| | | { |
| | | // DNs cannot be used in ordering matching. |
| | | return ConditionResult.UNDEFINED; |
| | |
| | | @Override() |
| | | public ConditionResult approximatelyEqualTo(Entry entry, |
| | | VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | ByteString value) |
| | | { |
| | | // DNs cannot be used in approximate matching. |
| | | return ConditionResult.UNDEFINED; |
| | |
| | | { |
| | | try |
| | | { |
| | | dnSet.add(DN.decode(filter.getAssertionValue().getValue())); |
| | | dnSet.add(DN.decode(filter.getAssertionValue())); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.UUID; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | |
| | | import org.opends.server.api.MatchingRule; |
| | | import org.opends.server.api.VirtualAttributeProvider; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.AttributeValues; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.VirtualAttributeRule; |
| | | |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | public Set<AttributeValue> getValues(Entry entry, |
| | | VirtualAttributeRule rule) |
| | | public Attribute getValues(Entry entry, VirtualAttributeRule rule) |
| | | { |
| | | String normDNString = entry.getName().toNormalizedString(); |
| | | String uuidString = |
| | | UUID.nameUUIDFromBytes(getBytes(normDNString)).toString(); |
| | | AttributeValue value = AttributeValues.create( |
| | | ByteString.valueOf(uuidString), |
| | | ByteString.valueOf(uuidString)); |
| | | return Collections.singleton(value); |
| | | return Attributes.create(rule.getAttributeType(), uuidString); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | public boolean hasValue(Entry entry, VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | public boolean hasValue(Entry entry, VirtualAttributeRule rule, ByteString value) |
| | | { |
| | | MatchingRule matchingRule = |
| | | rule.getAttributeType().getEqualityMatchingRule(); |
| | |
| | | String uuidString = |
| | | UUID.nameUUIDFromBytes(getBytes(normalizedDN)).toString(); |
| | | |
| | | ByteString normValue = matchingRule.normalizeAttributeValue(value.getValue()); |
| | | ByteString normValue = matchingRule.normalizeAttributeValue(value); |
| | | return uuidString.equals(normValue.toString()); |
| | | } |
| | | catch (Exception e) |
| | |
| | | @Override() |
| | | public ConditionResult greaterThanOrEqualTo(Entry entry, |
| | | VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | ByteString value) |
| | | { |
| | | // DNs cannot be used in ordering matching. |
| | | return ConditionResult.UNDEFINED; |
| | |
| | | @Override() |
| | | public ConditionResult lessThanOrEqualTo(Entry entry, |
| | | VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | ByteString value) |
| | | { |
| | | // DNs cannot be used in ordering matching. |
| | | return ConditionResult.UNDEFINED; |
| | |
| | | @Override() |
| | | public ConditionResult approximatelyEqualTo(Entry entry, |
| | | VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | ByteString value) |
| | | { |
| | | // DNs cannot be used in approximate matching. |
| | | return ConditionResult.UNDEFINED; |
| | |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | |
| | | SearchFilter filter; |
| | | if (attributeTypes.length == 1) |
| | | { |
| | | AttributeValue value = AttributeValues.create(attributeTypes[0], id); |
| | | ByteString value = ByteString.valueOf(id); |
| | | filter = SearchFilter.createEqualityFilter(attributeTypes[0], value); |
| | | } |
| | | else |
| | |
| | | new ArrayList<SearchFilter>(attributeTypes.length); |
| | | for (AttributeType t : attributeTypes) |
| | | { |
| | | AttributeValue value = AttributeValues.create(t, id); |
| | | ByteString value = ByteString.valueOf(id); |
| | | filterComps.add(SearchFilter.createEqualityFilter(t, value)); |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | if (matchingEntry == null) |
| | | { |
| | | return null; |
| | | } |
| | | else |
| | | { |
| | | return matchingEntry; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | { |
| | | try |
| | | { |
| | | byte[] certBytes = clientCertChain[0].getEncoded(); |
| | | AttributeValue v = |
| | | AttributeValues.create( |
| | | certificateAttributeType, ByteString.wrap(certBytes)); |
| | | |
| | | boolean found = false; |
| | | for (Attribute a : certAttrList) |
| | | { |
| | | if (a.contains(v)) |
| | | { |
| | | found = true; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (! found) |
| | | ByteString certBytes = ByteString.wrap(clientCertChain[0].getEncoded()); |
| | | if (!find(certAttrList, certBytes)) |
| | | { |
| | | bindOperation.setResultCode(ResultCode.INVALID_CREDENTIALS); |
| | | |
| | |
| | | { |
| | | try |
| | | { |
| | | byte[] certBytes = clientCertChain[0].getEncoded(); |
| | | AttributeValue v = |
| | | AttributeValues.create( |
| | | certificateAttributeType, ByteString.wrap(certBytes)); |
| | | |
| | | boolean found = false; |
| | | for (Attribute a : certAttrList) |
| | | { |
| | | if (a.contains(v)) |
| | | { |
| | | found = true; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (! found) |
| | | ByteString certBytes = ByteString.wrap(clientCertChain[0].getEncoded()); |
| | | if (!find(certAttrList, certBytes)) |
| | | { |
| | | bindOperation.setResultCode(ResultCode.INVALID_CREDENTIALS); |
| | | |
| | |
| | | |
| | | |
| | | |
| | | private boolean find(List<Attribute> certAttrList, ByteString certBytes) |
| | | { |
| | | for (Attribute a : certAttrList) |
| | | { |
| | | if (a.contains(certBytes)) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | |
| | | |
| | | |
| | | // Create the search filter from the fingerprint. |
| | | AttributeValue value = |
| | | AttributeValues.create(fingerprintAttributeType, fingerprintString); |
| | | ByteString value = ByteString.valueOf(fingerprintString); |
| | | SearchFilter filter = |
| | | SearchFilter.createEqualityFilter(fingerprintAttributeType, value); |
| | | |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.admin.std.server.GoverningStructureRuleVirtualAttributeCfg; |
| | | import org.opends.server.api.VirtualAttributeProvider; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | public Set<AttributeValue> getValues(Entry entry, |
| | | VirtualAttributeRule rule) |
| | | public Attribute getValues(Entry entry, VirtualAttributeRule rule) |
| | | { |
| | | DITStructureRule ditRule = getDITStructureRule(entry); |
| | | |
| | | if(ditRule !=null) |
| | | { |
| | | return Collections.singleton(AttributeValues.create( |
| | | rule.getAttributeType(), |
| | | String.valueOf(ditRule.getRuleID()))); |
| | | return Attributes.create( |
| | | rule.getAttributeType(), String.valueOf(ditRule.getRuleID())); |
| | | } |
| | | |
| | | return Collections.<AttributeValue>emptySet(); |
| | | return Attributes.empty(rule.getAttributeType()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | @Override() |
| | | public ConditionResult greaterThanOrEqualTo(Entry entry, |
| | | VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | ByteString value) |
| | | { |
| | | // DITStructureRule cannot be used in ordering matching. |
| | | return ConditionResult.UNDEFINED; |
| | |
| | | @Override() |
| | | public ConditionResult lessThanOrEqualTo(Entry entry, |
| | | VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | ByteString value) |
| | | { |
| | | // DITStructureRule cannot be used in ordering matching. |
| | | return ConditionResult.UNDEFINED; |
| | |
| | | @Override() |
| | | public ConditionResult approximatelyEqualTo(Entry entry, |
| | | VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | ByteString value) |
| | | { |
| | | // DITStructureRule cannot be used in approximate matching. |
| | | return ConditionResult.UNDEFINED; |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | public Set<AttributeValue> getValues(Entry entry, |
| | | VirtualAttributeRule rule) |
| | | public Attribute getValues(Entry entry, VirtualAttributeRule rule) |
| | | { |
| | | Backend backend = DirectoryServer.getBackend(entry.getName()); |
| | | |
| | |
| | | ConditionResult ret = backend.hasSubordinates(entry.getName()); |
| | | if(ret != null && ret != ConditionResult.UNDEFINED) |
| | | { |
| | | AttributeValue value = |
| | | AttributeValues.create(ByteString.valueOf(ret.toString()), |
| | | ByteString.valueOf(ret.toString())); |
| | | return Collections.singleton(value); |
| | | return Attributes.create(rule.getAttributeType(), ret.toString()); |
| | | } |
| | | } |
| | | catch(DirectoryException de) |
| | |
| | | logger.traceException(de); |
| | | } |
| | | |
| | | return Collections.emptySet(); |
| | | return Attributes.empty(rule.getAttributeType()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | public boolean hasValue(Entry entry, VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | public boolean hasValue(Entry entry, VirtualAttributeRule rule, ByteString value) |
| | | { |
| | | Backend backend = DirectoryServer.getBackend(entry.getName()); |
| | | MatchingRule matchingRule = |
| | |
| | | |
| | | try |
| | | { |
| | | ByteString normValue = |
| | | matchingRule.normalizeAttributeValue(value.getValue()); |
| | | ByteString normValue = matchingRule.normalizeAttributeValue(value); |
| | | ConditionResult ret = backend.hasSubordinates(entry.getName()); |
| | | return ret != null |
| | | && ret != ConditionResult.UNDEFINED |
| | |
| | | @Override() |
| | | public ConditionResult greaterThanOrEqualTo(Entry entry, |
| | | VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | ByteString value) |
| | | { |
| | | // This virtual attribute does not support ordering matching. |
| | | return ConditionResult.UNDEFINED; |
| | |
| | | @Override() |
| | | public ConditionResult lessThanOrEqualTo(Entry entry, |
| | | VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | ByteString value) |
| | | { |
| | | // This virtual attribute does not support ordering matching. |
| | | return ConditionResult.UNDEFINED; |
| | |
| | | @Override() |
| | | public ConditionResult approximatelyEqualTo(Entry entry, |
| | | VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | ByteString value) |
| | | { |
| | | // This virtual attribute does not support approximate matching. |
| | | return ConditionResult.UNDEFINED; |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | import java.util.*; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | public Set<AttributeValue> getValues(Entry entry, |
| | | VirtualAttributeRule rule) |
| | | public Attribute getValues(Entry entry, VirtualAttributeRule rule) |
| | | { |
| | | // FIXME -- This probably isn't the most efficient implementation. |
| | | Set<AttributeValue> values = null; |
| | | AttributeBuilder builder = new AttributeBuilder(rule.getAttributeType()); |
| | | for (Group<?> g : DirectoryServer.getGroupManager().getGroupInstances()) |
| | | { |
| | | try |
| | | { |
| | | if (g.isMember(entry)) |
| | | { |
| | | AttributeValue value = AttributeValues.create( |
| | | rule.getAttributeType(), g.getGroupDN().toString()); |
| | | if (values == null) |
| | | { |
| | | values = Collections.singleton(value); |
| | | } |
| | | else if (values.size() == 1) |
| | | { |
| | | Set<AttributeValue> tmp = new HashSet<AttributeValue>(2); |
| | | tmp.addAll(values); |
| | | tmp.add(value); |
| | | values = tmp; |
| | | } |
| | | else |
| | | { |
| | | values.add(value); |
| | | } |
| | | builder.add(g.getGroupDN().toString()); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | |
| | | logger.traceException(e); |
| | | } |
| | | } |
| | | |
| | | if (values != null) |
| | | { |
| | | return Collections.unmodifiableSet(values); |
| | | } |
| | | return Collections.emptySet(); |
| | | return builder.toAttribute(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | public boolean hasValue(Entry entry, VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | ByteString value) |
| | | { |
| | | try |
| | | { |
| | | DN groupDN = DN.decode(value.getValue()); |
| | | DN groupDN = DN.decode(value); |
| | | Group<?> g = DirectoryServer.getGroupManager().getGroupInstance(groupDN); |
| | | return g != null && g.isMember(entry); |
| | | } |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | public boolean hasAnyValue(Entry entry, VirtualAttributeRule rule, |
| | | Collection<AttributeValue> values) |
| | | { |
| | | for (AttributeValue value : values) |
| | | { |
| | | if (hasValue(entry, rule, value)) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | public ConditionResult matchesSubstring(Entry entry, |
| | | VirtualAttributeRule rule, |
| | | ByteString subInitial, |
| | |
| | | @Override() |
| | | public ConditionResult greaterThanOrEqualTo(Entry entry, |
| | | VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | ByteString value) |
| | | { |
| | | // DNs cannot be used in ordering matching. |
| | | return ConditionResult.UNDEFINED; |
| | |
| | | @Override() |
| | | public ConditionResult lessThanOrEqualTo(Entry entry, |
| | | VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | ByteString value) |
| | | { |
| | | // DNs cannot be used in ordering matching. |
| | | return ConditionResult.UNDEFINED; |
| | |
| | | @Override() |
| | | public ConditionResult approximatelyEqualTo(Entry entry, |
| | | VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | ByteString value) |
| | | { |
| | | // DNs cannot be used in approximate matching. |
| | | return ConditionResult.UNDEFINED; |
| | |
| | | { |
| | | try |
| | | { |
| | | DN dn = DN.decode(filter.getAssertionValue().getValue()); |
| | | DN dn = DN.decode(filter.getAssertionValue()); |
| | | return DirectoryServer.getGroupManager().getGroupInstance(dn); |
| | | } |
| | | catch (Exception e) |
| | |
| | | import org.opends.server.tools.LDAPWriter; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.opends.server.types.DN; |
| | |
| | | { |
| | | if (!attribute.isEmpty()) |
| | | { |
| | | username = attribute.iterator().next().getValue(); |
| | | username = attribute.iterator().next(); |
| | | break mapBind; |
| | | } |
| | | } |
| | |
| | | { |
| | | for (final Attribute attribute : attributes) |
| | | { |
| | | for (final AttributeValue value : attribute) |
| | | for (final ByteString value : attribute) |
| | | { |
| | | filterComponents.add(SearchFilter.createEqualityFilter(at, |
| | | value)); |
| | |
| | | { |
| | | MatchingRule rule = |
| | | attribute.getAttributeType().getEqualityMatchingRule(); |
| | | for (AttributeValue value : attribute) |
| | | for (ByteString value : attribute) |
| | | { |
| | | try |
| | | { |
| | | ByteString normValue = |
| | | rule.normalizeAttributeValue(value.getValue()); |
| | | ByteString normValue = rule.normalizeAttributeValue(value); |
| | | long cachedPasswordTime = GeneralizedTimeSyntax |
| | | .decodeGeneralizedTimeValue(normValue); |
| | | long currentTime = provider.getCurrentTimeMS(); |
| | |
| | | // Ignore any attributes with options. |
| | | if (!attribute.hasOptions()) |
| | | { |
| | | for (AttributeValue value : attribute) |
| | | for (ByteString value : attribute) |
| | | { |
| | | cachedPassword = value.getValue(); |
| | | cachedPassword = value; |
| | | break foundCachedPassword; |
| | | } |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.MemberVirtualAttributeCfg; |
| | | import org.opends.server.api.Group; |
| | | import org.opends.server.api.VirtualAttributeProvider; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.AttributeValues; |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.MemberList; |
| | | import org.opends.server.types.MembershipException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.types.VirtualAttributeRule; |
| | | |
| | | /** |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override() |
| | | public Set<AttributeValue> getValues(Entry entry, |
| | | VirtualAttributeRule rule) |
| | | public Attribute getValues(Entry entry, VirtualAttributeRule rule) |
| | | { |
| | | if (! currentConfig.isAllowRetrievingMembership()) |
| | | { |
| | | return Collections.emptySet(); |
| | | return Attributes.empty(rule.getAttributeType()); |
| | | } |
| | | |
| | | Group<?> g = |
| | | DirectoryServer.getGroupManager().getGroupInstance(entry.getName()); |
| | | if (g == null) |
| | | { |
| | | return Collections.emptySet(); |
| | | return Attributes.empty(rule.getAttributeType()); |
| | | } |
| | | |
| | | HashSet<AttributeValue> values = new HashSet<AttributeValue>(); |
| | | AttributeBuilder builder = new AttributeBuilder(rule.getAttributeType()); |
| | | try |
| | | { |
| | | MemberList memberList = g.getMembers(); |
| | |
| | | DN memberDN = memberList.nextMemberDN(); |
| | | if (memberDN != null) |
| | | { |
| | | values.add(AttributeValues.create(rule.getAttributeType(), |
| | | memberDN.toString())); |
| | | builder.add(ByteString.valueOf(memberDN.toString())); |
| | | } |
| | | } |
| | | catch (MembershipException me) |
| | |
| | | logger.traceException(e); |
| | | } |
| | | |
| | | return Collections.unmodifiableSet(values); |
| | | return builder.toAttribute(); |
| | | } |
| | | |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override() |
| | | public boolean hasValue(Entry entry, VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | public boolean hasValue(Entry entry, VirtualAttributeRule rule, ByteString value) |
| | | { |
| | | Group<?> g = |
| | | DirectoryServer.getGroupManager().getGroupInstance(entry.getName()); |
| | |
| | | |
| | | try |
| | | { |
| | | return g.isMember(DN.decode(value.getValue())); |
| | | return g.isMember(DN.decode(value)); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override() |
| | | public boolean hasAnyValue(Entry entry, VirtualAttributeRule rule, |
| | | Collection<AttributeValue> values) |
| | | { |
| | | for (AttributeValue v : values) |
| | | { |
| | | if (hasValue(entry, rule, v)) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override() |
| | | public ConditionResult matchesSubstring(Entry entry, |
| | | VirtualAttributeRule rule, |
| | | ByteString subInitial, |
| | |
| | | @Override() |
| | | public ConditionResult greaterThanOrEqualTo(Entry entry, |
| | | VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | ByteString value) |
| | | { |
| | | // DNs cannot be used in ordering matching. |
| | | return ConditionResult.UNDEFINED; |
| | |
| | | @Override() |
| | | public ConditionResult lessThanOrEqualTo(Entry entry, |
| | | VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | ByteString value) |
| | | { |
| | | // DNs cannot be used in ordering matching. |
| | | return ConditionResult.UNDEFINED; |
| | |
| | | @Override() |
| | | public ConditionResult approximatelyEqualTo(Entry entry, |
| | | VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | ByteString value) |
| | | { |
| | | // DNs cannot be used in approximate matching. |
| | | return ConditionResult.UNDEFINED; |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | public Set<AttributeValue> getValues(Entry entry, |
| | | VirtualAttributeRule rule) |
| | | public Attribute getValues(Entry entry, VirtualAttributeRule rule) |
| | | { |
| | | Backend backend = DirectoryServer.getBackend(entry.getName()); |
| | | |
| | |
| | | long count = backend.numSubordinates(entry.getName(), false); |
| | | if(count >= 0) |
| | | { |
| | | AttributeValue value = |
| | | AttributeValues.create(ByteString.valueOf(String.valueOf(count)), |
| | | ByteString.valueOf(String.valueOf(count))); |
| | | return Collections.singleton(value); |
| | | return Attributes.create(rule.getAttributeType(), String.valueOf(count)); |
| | | } |
| | | } |
| | | catch(DirectoryException de) |
| | |
| | | logger.traceException(de); |
| | | } |
| | | |
| | | return Collections.emptySet(); |
| | | return Attributes.empty(rule.getAttributeType()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | public boolean hasValue(Entry entry, VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | public boolean hasValue(Entry entry, VirtualAttributeRule rule, ByteString value) |
| | | { |
| | | Backend backend = DirectoryServer.getBackend(entry.getName()); |
| | | MatchingRule eqRule = rule.getAttributeType().getEqualityMatchingRule(); |
| | | |
| | | try |
| | | { |
| | | String nv = eqRule.normalizeAttributeValue(value.getValue()).toString(); |
| | | String nv = eqRule.normalizeAttributeValue(value).toString(); |
| | | long count = backend.numSubordinates(entry.getName(), false); |
| | | return count >= 0 && Long.parseLong(nv) == count; |
| | | } |
| | |
| | | @Override() |
| | | public ConditionResult approximatelyEqualTo(Entry entry, |
| | | VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | ByteString value) |
| | | { |
| | | // This virtual attribute does not support approximate matching. |
| | | return ConditionResult.UNDEFINED; |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import |
| | | org.opends.server.admin.std.server.PasswordExpirationTimeVirtualAttributeCfg; |
| | | import org.opends.server.api.AuthenticationPolicy; |
| | | import org.opends.server.api.VirtualAttributeProvider; |
| | | import org.opends.server.core.PasswordPolicyState; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.schema.GeneralizedTimeSyntax; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | |
| | | /** |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Set<AttributeValue> getValues(Entry entry, |
| | | VirtualAttributeRule rule) |
| | | public Attribute getValues(Entry entry, VirtualAttributeRule rule) |
| | | { |
| | | // Do not process LDAP operational entries. |
| | | if (!entry.isSubentry() && !entry.isLDAPSubentry()) |
| | | { |
| | | long expirationTime = getPasswordExpirationTime(entry); |
| | | |
| | | if (expirationTime == -1) |
| | | { |
| | | // It does not expire. |
| | | return Collections.emptySet(); |
| | | return Attributes.empty(rule.getAttributeType()); |
| | | } |
| | | return Attributes.create(rule.getAttributeType(), |
| | | GeneralizedTimeSyntax.createGeneralizedTimeValue(expirationTime)); |
| | | } |
| | | |
| | | AttributeValue value = |
| | | GeneralizedTimeSyntax.createGeneralizedTimeValue(expirationTime); |
| | | |
| | | return Collections.singleton(value); |
| | | } |
| | | |
| | | return Collections.emptySet(); |
| | | return Attributes.empty(rule.getAttributeType()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | if (oldPassword != null) |
| | | { |
| | | // Remove all existing encoded values that match the old password. |
| | | Set<AttributeValue> existingValues = pwPolicyState.getPasswordValues(); |
| | | Set<AttributeValue> deleteValues = |
| | | new LinkedHashSet<AttributeValue>(existingValues.size()); |
| | | Set<ByteString> existingValues = pwPolicyState.getPasswordValues(); |
| | | Set<ByteString> deleteValues = |
| | | new LinkedHashSet<ByteString>(existingValues.size()); |
| | | if (pwPolicyState.getAuthenticationPolicy().isAuthPasswordSyntax()) |
| | | { |
| | | for (AttributeValue v : existingValues) |
| | | for (ByteString v : existingValues) |
| | | { |
| | | try |
| | | { |
| | | StringBuilder[] components = |
| | | AuthPasswordSyntax.decodeAuthPassword(v.getValue().toString()); |
| | | AuthPasswordSyntax.decodeAuthPassword(v.toString()); |
| | | PasswordStorageScheme<?> scheme = |
| | | DirectoryServer.getAuthPasswordStorageScheme( |
| | | components[0].toString()); |
| | |
| | | } |
| | | else |
| | | { |
| | | for (AttributeValue v : existingValues) |
| | | for (ByteString v : existingValues) |
| | | { |
| | | try |
| | | { |
| | | String[] components = |
| | | UserPasswordSyntax.decodeUserPassword(v.getValue().toString()); |
| | | UserPasswordSyntax.decodeUserPassword(v.toString()); |
| | | PasswordStorageScheme<?> scheme = |
| | | DirectoryServer.getPasswordStorageScheme( |
| | | toLowerCase(components[0])); |
| | |
| | | |
| | | |
| | | builder = new AttributeBuilder(attrType); |
| | | builder.addAll(toAttributeValues(attrType, encodedPasswords)); |
| | | builder.addAll(toAttributeValues(encodedPasswords)); |
| | | Attribute addAttr = builder.toAttribute(); |
| | | modList.add(new Modification(ModificationType.ADD, addAttr)); |
| | | } |
| | | else |
| | | { |
| | | AttributeBuilder builder = new AttributeBuilder(attrType); |
| | | builder.addAll(toAttributeValues(attrType, encodedPasswords)); |
| | | builder.addAll(toAttributeValues(encodedPasswords)); |
| | | Attribute addAttr = builder.toAttribute(); |
| | | modList.add(new Modification(ModificationType.REPLACE, addAttr)); |
| | | } |
| | |
| | | |
| | | // Handle Account Status Notifications that may be needed. |
| | | // They are not handled by the backend for internal operations. |
| | | List<AttributeValue> currentPasswords = null; |
| | | List<ByteString> currentPasswords = null; |
| | | if (oldPassword != null) |
| | | { |
| | | currentPasswords = new ArrayList<AttributeValue>(1); |
| | | currentPasswords.add(AttributeValues |
| | | .create(oldPassword, oldPassword)); |
| | | currentPasswords = new ArrayList<ByteString>(1); |
| | | currentPasswords.add(oldPassword); |
| | | } |
| | | List<AttributeValue> newPasswords = null; |
| | | List<ByteString> newPasswords = null; |
| | | if (newPassword != null) |
| | | { |
| | | newPasswords = new ArrayList<AttributeValue>(1); |
| | | newPasswords.add(AttributeValues |
| | | .create(newPassword, newPassword)); |
| | | newPasswords = new ArrayList<ByteString>(1); |
| | | newPasswords.add(newPassword); |
| | | } |
| | | if (selfChange) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | private Collection<AttributeValue> toAttributeValues(AttributeType attrType, |
| | | Collection<ByteString> values) |
| | | private Collection<ByteString> toAttributeValues(Collection<ByteString> values) |
| | | { |
| | | Set<AttributeValue> results = |
| | | new LinkedHashSet<AttributeValue>(values.size()); |
| | | Set<ByteString> results = new LinkedHashSet<ByteString>(values.size()); |
| | | for (ByteString s : values) |
| | | { |
| | | results.add(AttributeValues.create(attrType, s)); |
| | | results.add(s); |
| | | } |
| | | return results; |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.admin.std.server. |
| | | PasswordPolicySubentryVirtualAttributeCfg; |
| | | import org.opends.server.api.AuthenticationPolicy; |
| | | import org.opends.server.api.VirtualAttributeProvider; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | |
| | | /** |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | public Set<AttributeValue> getValues(Entry entry, |
| | | VirtualAttributeRule rule) |
| | | public Attribute getValues(Entry entry, VirtualAttributeRule rule) |
| | | { |
| | | if (!entry.isSubentry() && !entry.isLDAPSubentry()) |
| | | { |
| | |
| | | } |
| | | else if (policy.isPasswordPolicy()) |
| | | { |
| | | AttributeType dnAttrType = DirectoryServer |
| | | .getAttributeType("1.3.6.1.4.1.42.2.27.8.1.23"); |
| | | DN policyDN = policy.getDN(); |
| | | AttributeValue value = AttributeValues.create(dnAttrType, |
| | | policyDN.toString()); |
| | | return Collections.singleton(value); |
| | | return Attributes.create(rule.getAttributeType(), |
| | | policy.getDN().toString()); |
| | | } |
| | | else |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | return Collections.emptySet(); |
| | | return Attributes.empty(rule.getAttributeType()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | import java.util.regex.PatternSyntaxException; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | |
| | | SearchFilter filter; |
| | | if (attributeTypes.length == 1) |
| | | { |
| | | AttributeValue value = |
| | | AttributeValues.create(attributeTypes[0], processedID); |
| | | ByteString value = ByteString.valueOf(processedID); |
| | | filter = SearchFilter.createEqualityFilter(attributeTypes[0], value); |
| | | } |
| | | else |
| | |
| | | new ArrayList<SearchFilter>(attributeTypes.length); |
| | | for (AttributeType t : attributeTypes) |
| | | { |
| | | AttributeValue value = AttributeValues.create(t, processedID); |
| | | ByteString value = ByteString.valueOf(processedID); |
| | | filterComps.add(SearchFilter.createEqualityFilter(t, value)); |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | if (matchingEntry == null) |
| | | { |
| | | return null; |
| | | } |
| | | else |
| | | { |
| | | return matchingEntry; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | import org.opends.server.types.AccountStatusNotificationType; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | |
| | | { |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.trace("Adding end user recipient %s from attr %s", |
| | | v.getValue(), a.getNameWithOptions()); |
| | | v, a.getNameWithOptions()); |
| | | } |
| | | |
| | | recipients.add(v.getValue().toString()); |
| | | recipients.add(v.toString()); |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | |
| | | |
| | | import java.util.Collections; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.LinkedList; |
| | |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DirectoryConfig; |
| | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.forgerock.util.Reject.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class provides a static group implementation, in which the DNs |
| | | * of all members are explicitly listed. There are three variants of |
| | |
| | | { |
| | | for (Attribute a : memberAttrList) |
| | | { |
| | | MatchingRule eqRule = |
| | | a.getAttributeType().getEqualityMatchingRule(); |
| | | for (AttributeValue v : a) |
| | | MatchingRule eqRule = a.getAttributeType().getEqualityMatchingRule(); |
| | | for (ByteString v : a) |
| | | { |
| | | try |
| | | { |
| | | someMemberDNs.add(eqRule.normalizeAttributeValue(v.getValue())); |
| | | someMemberDNs.add(eqRule.normalizeAttributeValue(v)); |
| | | } |
| | | catch (DecodeException de) |
| | | { |
| | | logger.traceException(de); |
| | | logger.error(ERR_STATICGROUP_CANNOT_DECODE_MEMBER_VALUE_AS_DN, v.getValue(), |
| | | logger.error(ERR_STATICGROUP_CANNOT_DECODE_MEMBER_VALUE_AS_DN, v, |
| | | someMemberAttributeType.getNameOrOID(), groupEntry.getName(), de.getMessageObject()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | return new StaticGroup(groupEntry.getName(), |
| | | someMemberAttributeType, someMemberDNs); |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.admin.std.server.StructuralObjectClassVirtualAttributeCfg; |
| | | import org.opends.server.api.VirtualAttributeProvider; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.VirtualAttributeRule; |
| | | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | public Set<AttributeValue> getValues(Entry entry, |
| | | VirtualAttributeRule rule) |
| | | public Attribute getValues(Entry entry, VirtualAttributeRule rule) |
| | | { |
| | | AttributeValue value = |
| | | AttributeValues.create(rule.getAttributeType(), |
| | | entry.getStructuralObjectClass().getNameOrOID()); |
| | | return Collections.singleton(value); |
| | | return Attributes.create(rule.getAttributeType(), entry |
| | | .getStructuralObjectClass().getNameOrOID()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | @Override() |
| | | public ConditionResult greaterThanOrEqualTo(Entry entry, |
| | | VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | ByteString value) |
| | | { |
| | | // An object class can not be used for ordering. |
| | | return ConditionResult.UNDEFINED; |
| | |
| | | @Override() |
| | | public ConditionResult lessThanOrEqualTo(Entry entry, |
| | | VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | ByteString value) |
| | | { |
| | | // An object class can not be used for ordering. |
| | | return ConditionResult.UNDEFINED; |
| | |
| | | @Override() |
| | | public ConditionResult approximatelyEqualTo(Entry entry, |
| | | VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | ByteString value) |
| | | { |
| | | // An object class can not be used in approximate matching. |
| | | return ConditionResult.UNDEFINED; |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.CertificateMapperCfg; |
| | |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | |
| | |
| | | // filter. |
| | | X500Principal peerPrincipal = peerCertificate.getSubjectX500Principal(); |
| | | String peerName = peerPrincipal.getName(X500Principal.RFC2253); |
| | | AttributeValue value = |
| | | AttributeValues.create(subjectAttributeType, peerName); |
| | | SearchFilter filter = |
| | | SearchFilter.createEqualityFilter(subjectAttributeType, value); |
| | | SearchFilter filter = SearchFilter.createEqualityFilter( |
| | | subjectAttributeType, ByteString.valueOf(peerName)); |
| | | |
| | | |
| | | // If we have an explicit set of base DNs, then use it. Otherwise, use the |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.admin.std.server.SubschemaSubentryVirtualAttributeCfg; |
| | | import org.opends.server.api.VirtualAttributeProvider; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | public Set<AttributeValue> getValues(Entry entry, |
| | | VirtualAttributeRule rule) |
| | | public Attribute getValues(Entry entry, VirtualAttributeRule rule) |
| | | { |
| | | DN schemaDN = DirectoryServer.getSchemaDN(); |
| | | if (schemaDN == null) |
| | | { |
| | | return Collections.emptySet(); |
| | | return Attributes.empty(rule.getAttributeType()); |
| | | } |
| | | AttributeValue value = |
| | | AttributeValues.create(rule.getAttributeType(), |
| | | schemaDN.toString()); |
| | | return Collections.singleton(value); |
| | | return Attributes.create(rule.getAttributeType(), schemaDN.toString()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | @Override() |
| | | public ConditionResult greaterThanOrEqualTo(Entry entry, |
| | | VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | ByteString value) |
| | | { |
| | | // DNs cannot be used in ordering matching. |
| | | return ConditionResult.UNDEFINED; |
| | |
| | | @Override() |
| | | public ConditionResult lessThanOrEqualTo(Entry entry, |
| | | VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | ByteString value) |
| | | { |
| | | // DNs cannot be used in ordering matching. |
| | | return ConditionResult.UNDEFINED; |
| | |
| | | @Override() |
| | | public ConditionResult approximatelyEqualTo(Entry entry, |
| | | VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | ByteString value) |
| | | { |
| | | // DNs cannot be used in approximate matching. |
| | | return ConditionResult.UNDEFINED; |
| | |
| | | import org.opends.server.types.AccountStatusNotification; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.Entry; |
| | | |
| | | |
| | |
| | | { |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | buffer.append(v.getValue().toString()); |
| | | buffer.append(v.toString()); |
| | | return; |
| | | } |
| | | } |
| | |
| | | * Portions Copyright 2012-2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | |
| | | |
| | | import java.util.Collections; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.UserDefinedVirtualAttributeCfg; |
| | | import org.opends.server.api.VirtualAttributeProvider; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | |
| | | /** |
| | | * This class implements a virtual attribute provider that allows administrators |
| | |
| | | @Override() |
| | | public boolean isMultiValued() |
| | | { |
| | | if (currentConfig == null) |
| | | if (currentConfig != null) |
| | | { |
| | | return currentConfig.getValue().size() > 1; |
| | | } |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | return (currentConfig.getValue().size() > 1); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override() |
| | | public Set<AttributeValue> getValues(Entry entry, |
| | | VirtualAttributeRule rule) |
| | | public Attribute getValues(Entry entry, VirtualAttributeRule rule) |
| | | { |
| | | AttributeType attributeType = rule.getAttributeType(); |
| | | Set<String> userDefinedValues = currentConfig.getValue(); |
| | | |
| | | switch (userDefinedValues.size()) { |
| | | case 0: |
| | | return Collections.emptySet(); |
| | | return Attributes.empty(rule.getAttributeType()); |
| | | case 1: |
| | | String valueString = userDefinedValues.iterator().next(); |
| | | AttributeValue value = |
| | | AttributeValues.create(attributeType, valueString); |
| | | return Collections.singleton(value); |
| | | return Attributes.create(rule.getAttributeType(), valueString); |
| | | default: |
| | | HashSet<AttributeValue> values = |
| | | new HashSet<AttributeValue>(userDefinedValues.size()); |
| | | for (String valueString2 : userDefinedValues) |
| | | AttributeBuilder builder = new AttributeBuilder(rule.getAttributeType()); |
| | | for (String valueStr : userDefinedValues) |
| | | { |
| | | values.add(AttributeValues.create(attributeType, valueString2)); |
| | | builder.add(valueStr); |
| | | } |
| | | return Collections.unmodifiableSet(values); |
| | | return builder.toAttribute(); |
| | | } |
| | | } |
| | | |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable( |
| | | UserDefinedVirtualAttributeCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | UserDefinedVirtualAttributeCfg configuration) |
| | | { |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | |
| | | { |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | if (targetDN != null) |
| | | { |
| | |
| | | |
| | | try |
| | | { |
| | | targetDN = DN.decode(v.getValue()); |
| | | targetDN = DN.decode(v); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | LocalizableMessage message = ERR_VIRTUAL_STATIC_GROUP_CANNOT_DECODE_TARGET. |
| | | get(v.getValue(), groupEntry.getName(), de.getMessageObject()); |
| | | get(v, groupEntry.getName(), de.getMessageObject()); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message, de); |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.loggers; |
| | | |
| | | |
| | | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.forgerock.opendj.ldap.ResultCode.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.*; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.util.Base64; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.opends.server.util.TimeThread; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class provides the implementation of the audit logger used by |
| | | * the directory server. |
| | |
| | | { |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | { |
| | | buffer.append(a.getName()); |
| | | buffer.append(":"); |
| | | encodeValue(v.getValue(), buffer); |
| | | buffer.append(EOL); |
| | | } |
| | | append(buffer, a); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | { |
| | | buffer.append(a.getName()); |
| | | buffer.append(":"); |
| | | encodeValue(v.getValue(), buffer); |
| | | buffer.append(EOL); |
| | | } |
| | | append(buffer, a); |
| | | } |
| | | } |
| | | |
| | |
| | | buffer.append(a.getName()); |
| | | buffer.append(EOL); |
| | | |
| | | for (AttributeValue v : a) |
| | | { |
| | | buffer.append(a.getName()); |
| | | buffer.append(":"); |
| | | encodeValue(v.getValue(), buffer); |
| | | buffer.append(EOL); |
| | | } |
| | | append(buffer, a); |
| | | } |
| | | |
| | | writer.writeRecord(buffer.toString()); |
| | |
| | | |
| | | |
| | | |
| | | private void append(StringBuilder buffer, Attribute a) |
| | | { |
| | | for (ByteString v : a) |
| | | { |
| | | buffer.append(a.getName()); |
| | | buffer.append(":"); |
| | | encodeValue(v, buffer); |
| | | buffer.append(EOL); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | // Appends the common log header information to the provided buffer. |
| | | private void appendHeader(Operation operation, StringBuilder buffer) |
| | | { |
| | |
| | | DN[] baseDNs = backend.getBaseDNs(); |
| | | for (DN dn : baseDNs) |
| | | { |
| | | builder.add(AttributeValues.create(baseDNType, dn.toString())); |
| | | builder.add(dn.toString()); |
| | | } |
| | | attrs.add(builder.toAttribute()); |
| | | |
| | |
| | | { |
| | | logger.traceException(ex); |
| | | } |
| | | String s = entryCount + " " + dn.toString(); |
| | | builder.add(AttributeValues.create(baseDNEntryCountType, s)); |
| | | builder.add(entryCount + " " + dn.toString()); |
| | | } |
| | | } |
| | | else |
| | |
| | | // This is done to avoid recalculating the number of entries |
| | | // using the numSubordinates method in the case where the |
| | | // backend has a single base DN. |
| | | String s = backendCount + " " + baseDNs[0].toString(); |
| | | builder.add(AttributeValues.create(baseDNEntryCountType, s)); |
| | | builder.add(backendCount + " " + baseDNs[0].toString()); |
| | | } |
| | | attrs.add(builder.toAttribute()); |
| | | |
| | |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValues; |
| | | import org.opends.server.types.InitializationException; |
| | | |
| | | |
| | |
| | | AttributeBuilder builder = new AttributeBuilder(attrType); |
| | | for (ClientConnection conn : connMap.values()) |
| | | { |
| | | builder.add(AttributeValues.create(attrType, conn |
| | | .getMonitorSummary())); |
| | | builder.add(conn.getMonitorSummary()); |
| | | } |
| | | |
| | | ArrayList<Attribute> attrs = new ArrayList<Attribute>(1); |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.monitors; |
| | | |
| | | |
| | | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | import java.util.LinkedList; |
| | |
| | | import org.opends.server.api.MonitorProvider; |
| | | import org.opends.server.types.*; |
| | | |
| | | |
| | | /** |
| | | * This class implements a monitor provider that will report generic information |
| | | * for an enabled Directory Server connection handler, including its protocol, |
| | |
| | | AttributeBuilder builder = new AttributeBuilder(listenerType); |
| | | for (HostPort hp : listeners) |
| | | { |
| | | builder.add(AttributeValues.create(listenerType, hp.toString())); |
| | | builder.add(hp.toString()); |
| | | } |
| | | attrs.add(builder.toAttribute()); |
| | | } |
| | |
| | | for (ClientConnection c : conns) |
| | | { |
| | | numConnections++; |
| | | builder.add(AttributeValues.create(connectionsType, c |
| | | .getMonitorSummary())); |
| | | builder.add(c.getMonitorSummary()); |
| | | } |
| | | attrs.add(builder.toAttribute()); |
| | | } |
| | |
| | | private Attribute createAttribute(String name, String value) |
| | | { |
| | | AttributeType attrType = DirectoryServer.getDefaultAttributeType(name); |
| | | |
| | | AttributeBuilder builder = new AttributeBuilder(attrType); |
| | | builder.add(AttributeValues.create(attrType, value)); |
| | | |
| | | return builder.toAttribute(); |
| | | return Attributes.create(attrType, value); |
| | | } |
| | | |
| | | |
| | |
| | | buffer.append(" ---------- "); |
| | | buffer.append(t.getName()); |
| | | buffer.append(" ----------"); |
| | | builder.add(AttributeValues.create(attrType, buffer.toString())); |
| | | builder.add(buffer.toString()); |
| | | |
| | | // Create an attribute for the stack trace. |
| | | if (stackElements != null) |
| | |
| | | } |
| | | buffer.append(")"); |
| | | |
| | | builder.add(AttributeValues.create(attrType, buffer.toString())); |
| | | builder.add(buffer.toString()); |
| | | } |
| | | } |
| | | } |
| | |
| | | private Attribute createAttribute(String name, String value) |
| | | { |
| | | AttributeType attrType = DirectoryServer.getDefaultAttributeType(name); |
| | | |
| | | AttributeBuilder builder = new AttributeBuilder(attrType); |
| | | |
| | | builder.add(AttributeValues.create(attrType, value)); |
| | | |
| | | return builder.toAttribute(); |
| | | return Attributes.create(attrType, value); |
| | | } |
| | | } |
| | | |
| | |
| | | private Attribute createAttribute(String name, String value) |
| | | { |
| | | AttributeType attrType = DirectoryServer.getDefaultAttributeType(name); |
| | | |
| | | AttributeBuilder builder = new AttributeBuilder(attrType); |
| | | |
| | | builder.add(AttributeValues.create(attrType, value)); |
| | | |
| | | return builder.toAttribute(); |
| | | return Attributes.create(attrType, value); |
| | | } |
| | | } |
| | | |
| | |
| | | import java.util.UUID; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.AttributeUsage; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.meta.PluginCfgDefn; |
| | |
| | | byte[] dnBytes = getBytes(entry.getName().toNormalizedString()); |
| | | UUID uuid = UUID.nameUUIDFromBytes(dnBytes); |
| | | |
| | | Attribute uuidAttr = Attributes.create(entryUUIDType, |
| | | AttributeValues.create(entryUUIDType, |
| | | ByteString.valueOf(uuid.toString()))); |
| | | Attribute uuidAttr = Attributes.create(entryUUIDType, uuid.toString()); |
| | | uuidList = new ArrayList<Attribute>(1); |
| | | uuidList.add(uuidAttr); |
| | | entry.putAttribute(entryUUIDType, uuidList); |
| | |
| | | |
| | | // Construct a new random UUID. |
| | | UUID uuid = UUID.randomUUID(); |
| | | Attribute uuidAttr = Attributes.create(entryUUIDType, |
| | | AttributeValues.create(entryUUIDType,uuid.toString())); |
| | | Attribute uuidAttr = Attributes.create(entryUUIDType, uuid.toString()); |
| | | uuidList = new ArrayList<Attribute>(1); |
| | | uuidList.add(uuidAttr); |
| | | |
| | |
| | | { |
| | | // This must mean that the operation was performed anonymously. |
| | | // Even so, we still need to update the creatorsName attribute. |
| | | builder.add(AttributeValues.create(creatorsNameType, |
| | | ByteString.empty())); |
| | | builder.add(ByteString.empty()); |
| | | } |
| | | else |
| | | { |
| | | builder.add(AttributeValues.create(creatorsNameType, |
| | | ByteString.valueOf(creatorDN.toString()))); |
| | | builder.add(creatorDN.toString()); |
| | | } |
| | | Attribute nameAttr = builder.toAttribute(); |
| | | ArrayList<Attribute> nameList = new ArrayList<Attribute>(1); |
| | |
| | | |
| | | // Create the attribute list for the createTimestamp attribute. |
| | | Attribute timeAttr = Attributes.create(createTimestampType, |
| | | OP_ATTR_CREATE_TIMESTAMP, |
| | | AttributeValues.create(createTimestampType, |
| | | ByteString.valueOf(getGMTTime()))); |
| | | OP_ATTR_CREATE_TIMESTAMP, getGMTTime()); |
| | | ArrayList<Attribute> timeList = new ArrayList<Attribute>(1); |
| | | timeList.add(timeAttr); |
| | | addOperation.setAttribute(createTimestampType, timeList); |
| | |
| | | { |
| | | // This must mean that the operation was performed anonymously. |
| | | // Even so, we still need to update the modifiersName attribute. |
| | | builder.add(AttributeValues.create(modifiersNameType, |
| | | ByteString.empty())); |
| | | builder.add(ByteString.empty()); |
| | | } |
| | | else |
| | | { |
| | | builder.add(AttributeValues.create(modifiersNameType, |
| | | ByteString.valueOf(modifierDN.toString()))); |
| | | builder.add(modifierDN.toString()); |
| | | } |
| | | Attribute nameAttr = builder.toAttribute(); |
| | | try |
| | |
| | | |
| | | // Create the modifyTimestamp attribute. |
| | | Attribute timeAttr = Attributes.create(modifyTimestampType, |
| | | OP_ATTR_MODIFY_TIMESTAMP, |
| | | AttributeValues.create(modifyTimestampType, |
| | | ByteString.valueOf(getGMTTime()))); |
| | | OP_ATTR_MODIFY_TIMESTAMP, getGMTTime()); |
| | | try |
| | | { |
| | | modifyOperation.addModification(new Modification(ModificationType.REPLACE, |
| | |
| | | { |
| | | // This must mean that the operation was performed anonymously. |
| | | // Even so, we still need to update the modifiersName attribute. |
| | | builder.add(AttributeValues.create(modifiersNameType, |
| | | ByteString.empty())); |
| | | builder.add(ByteString.empty()); |
| | | } |
| | | else |
| | | { |
| | | builder.add(AttributeValues.create(modifiersNameType, |
| | | ByteString.valueOf(modifierDN.toString()))); |
| | | builder.add(modifierDN.toString()); |
| | | } |
| | | Attribute nameAttr = builder.toAttribute(); |
| | | modifyDNOperation.addModification(new Modification( |
| | |
| | | |
| | | // Create the modifyTimestamp attribute. |
| | | Attribute timeAttr = Attributes.create(modifyTimestampType, |
| | | OP_ATTR_MODIFY_TIMESTAMP, |
| | | AttributeValues.create(modifyTimestampType, |
| | | ByteString.valueOf(getGMTTime()))); |
| | | OP_ATTR_MODIFY_TIMESTAMP, getGMTTime()); |
| | | modifyDNOperation.addModification(new Modification( |
| | | ModificationType.REPLACE, timeAttr, true)); |
| | | |
| | |
| | | policyLoop: |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | try |
| | | { |
| | | policyDN = DN.decode(v.getValue()); |
| | | policyDN = DN.decode(v); |
| | | AuthenticationPolicy authPolicy = DirectoryServer |
| | | .getAuthenticationPolicy(policyDN); |
| | | if (authPolicy == null) |
| | |
| | | AttributeBuilder builder = new AttributeBuilder(a, true); |
| | | boolean gotError = false; |
| | | |
| | | for (AttributeValue v : a) |
| | | for (ByteString value : a) |
| | | { |
| | | ByteString value = v.getValue(); |
| | | |
| | | if (policy.isAuthPasswordSyntax()) |
| | | { |
| | | if (!AuthPasswordSyntax.isEncoded(value)) |
| | |
| | | { |
| | | for (PasswordStorageScheme<?> s : schemes) |
| | | { |
| | | ByteString nv = s.encodeAuthPassword(value); |
| | | builder.add(AttributeValues.create(policy |
| | | .getPasswordAttribute(), nv)); |
| | | builder.add(s.encodeAuthPassword(value)); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | |
| | | } |
| | | else |
| | | { |
| | | builder.add(v); |
| | | builder.add(value); |
| | | } |
| | | } |
| | | else |
| | |
| | | { |
| | | for (PasswordStorageScheme<?> s : schemes) |
| | | { |
| | | ByteString nv = s.encodePasswordWithScheme(value); |
| | | builder.add(AttributeValues.create(policy |
| | | .getPasswordAttribute(), nv)); |
| | | builder.add(s.encodePasswordWithScheme(value)); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | |
| | | } |
| | | else |
| | | { |
| | | builder.add(v); |
| | | builder.add(value); |
| | | } |
| | | } |
| | | } |
| | |
| | | AttributeBuilder builder = new AttributeBuilder(a, true); |
| | | boolean gotError = false; |
| | | |
| | | for (AttributeValue v : a) |
| | | for (ByteString value : a) |
| | | { |
| | | ByteString value = v.getValue(); |
| | | if (!AuthPasswordSyntax.isEncoded(value)) |
| | | { |
| | | try |
| | | { |
| | | for (PasswordStorageScheme<?> s : defaultAuthPasswordSchemes) |
| | | { |
| | | ByteString nv = s.encodeAuthPassword(value); |
| | | builder.add(AttributeValues.create(t, nv)); |
| | | builder.add(s.encodeAuthPassword(value)); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | |
| | | } |
| | | else |
| | | { |
| | | builder.add(v); |
| | | builder.add(value); |
| | | } |
| | | } |
| | | |
| | |
| | | AttributeBuilder builder = new AttributeBuilder(a, true); |
| | | boolean gotError = false; |
| | | |
| | | for (AttributeValue v : a) |
| | | for (ByteString value : a) |
| | | { |
| | | ByteString value = v.getValue(); |
| | | if (!UserPasswordSyntax.isEncoded(value)) |
| | | { |
| | | try |
| | | { |
| | | for (PasswordStorageScheme<?> s : defaultUserPasswordSchemes) |
| | | { |
| | | ByteString nv = s.encodePasswordWithScheme(value); |
| | | builder.add(AttributeValues.create(t, nv)); |
| | | builder.add(s.encodePasswordWithScheme(value)); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | |
| | | } |
| | | else |
| | | { |
| | | builder.add(v); |
| | | builder.add(value); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | |
| | | for(AttributeType attributeType : attributeTypes) |
| | | { |
| | | componentFilters.add(SearchFilter.createEqualityFilter(attributeType, |
| | | AttributeValues.create(attributeType, oldEntryDN.toString()))); |
| | | ByteString.valueOf(oldEntryDN.toString()))); |
| | | } |
| | | |
| | | InternalClientConnection conn = |
| | |
| | | { |
| | | if(e.hasAttribute(type)) |
| | | { |
| | | AttributeValue value = AttributeValues |
| | | .create(type, oldEntryDN.toString()); |
| | | ByteString value = ByteString.valueOf(oldEntryDN.toString()); |
| | | if (e.hasValue(type, null, value)) |
| | | { |
| | | mods.add(new Modification(ModificationType.DELETE, Attributes |
| | | .create(type, value))); |
| | | |
| | | // If the new entry DN exists, create an ADD modification for |
| | | // it. |
| | | // If the new entry DN exists, create an ADD modification for it. |
| | | if(newEntryDN != null) |
| | | { |
| | | mods.add(new Modification(ModificationType.ADD, Attributes |
| | |
| | | final MatchingRule rule = attr.getAttributeType().getEqualityMatchingRule(); |
| | | try |
| | | { |
| | | for (AttributeValue attrVal : attr) |
| | | for (ByteString attrVal : attr) |
| | | { |
| | | DN valueEntryDN = |
| | | DN.decode(rule.normalizeAttributeValue(attrVal.getValue())); |
| | | DN valueEntryDN = DN.decode(rule.normalizeAttributeValue(attrVal)); |
| | | |
| | | final Entry valueEntry; |
| | | if (currentConfiguration.getCheckReferencesScopeCriteria() |
| | |
| | | * the getNewPasswords() method. If they are encoded the method would return |
| | | * null. The list of passwords should not be modified. |
| | | */ |
| | | final List<AttributeValue> passwords = modifyOperation.getNewPasswords(); |
| | | final List<ByteString> passwords = modifyOperation.getNewPasswords(); |
| | | |
| | | /* |
| | | * If the password list is not empty, we can be sure the current operation |
| | |
| | | */ |
| | | private void processModification( |
| | | final PreOperationModifyOperation modifyOperation, |
| | | final List<AttributeValue> passwords) |
| | | final List<ByteString> passwords) |
| | | { |
| | | // Get the last password (in case there is more then one). |
| | | final String password = passwords.get(passwords.size() - 1).toString(); |
| | |
| | | */ |
| | | package org.opends.server.plugins; |
| | | |
| | | |
| | | |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | |
| | | import org.opends.server.admin.std.meta.PluginCfgDefn; |
| | | import org.opends.server.admin.std.server.SevenBitCleanPluginCfg; |
| | | import org.opends.server.admin.std.server.PluginCfg; |
| | | import org.opends.server.api.plugin.*; |
| | | import org.opends.server.api.plugin.DirectoryServerPlugin; |
| | | import org.opends.server.api.plugin.PluginResult; |
| | | import org.opends.server.api.plugin.PluginType; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | |
| | | |
| | | import static org.opends.messages.PluginMessages.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class implements a Directory Server plugin that can be used to ensure |
| | | * that the values for a specified set of attributes (optionally, below a |
| | |
| | | { |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | if (! is7BitClean(v.getValue())) |
| | | if (!is7BitClean(v)) |
| | | { |
| | | LocalizableMessage rejectMessage = |
| | | ERR_PLUGIN_7BIT_IMPORT_ATTR_NOT_CLEAN.get( |
| | |
| | | continue; |
| | | } |
| | | |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | if (! is7BitClean(v.getValue())) |
| | | if (!is7BitClean(v)) |
| | | { |
| | | return PluginResult.PreParse.stopProcessing( |
| | | ResultCode.CONSTRAINT_VIOLATION, |
| | |
| | | continue; |
| | | } |
| | | |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | if (! is7BitClean(v.getValue())) |
| | | if (!is7BitClean(v)) |
| | | { |
| | | return PluginResult.PreParse.stopProcessing( |
| | | ResultCode.CONSTRAINT_VIOLATION, |
| | |
| | | continue; |
| | | } |
| | | |
| | | if (! is7BitClean(newRDN.getAttributeValue(i).getValue())) |
| | | if (!is7BitClean(newRDN.getAttributeValue(i))) |
| | | { |
| | | return PluginResult.PreParse.stopProcessing( |
| | | ResultCode.CONSTRAINT_VIOLATION, |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable( |
| | | SevenBitCleanPluginCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | SevenBitCleanPluginCfg configuration) |
| | | { |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.meta.PluginCfgDefn; |
| | |
| | | import org.opends.server.api.plugin.*; |
| | | import org.opends.server.api.plugin.PluginResult.PostOperation; |
| | | import org.opends.server.api.plugin.PluginResult.PreOperation; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.schema.SchemaConstants; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.types.operation.*; |
| | | |
| | | import static org.opends.messages.PluginMessages.*; |
| | |
| | | * The data structure to store the mapping between the attribute value and the |
| | | * corresponding dn. |
| | | */ |
| | | private ConcurrentHashMap<AttributeValue,DN> uniqueAttrValue2Dn; |
| | | private ConcurrentHashMap<ByteString,DN> uniqueAttrValue2Dn; |
| | | |
| | | |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | uniqueAttrValue2Dn = new ConcurrentHashMap<AttributeValue,DN>(); |
| | | uniqueAttrValue2Dn = new ConcurrentHashMap<ByteString,DN>(); |
| | | DirectoryServer.registerAlertGenerator(this); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | DN entryDN = entry.getName(); |
| | | List<AttributeValue> recordedValues = new LinkedList<AttributeValue>(); |
| | | List<ByteString> recordedValues = new LinkedList<ByteString>(); |
| | | for (AttributeType t : config.getType()) |
| | | { |
| | | List<Attribute> attrList = entry.getAttribute(t); |
| | |
| | | { |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | PreOperation stop = |
| | | checkUniqueness(entryDN, t, v, baseDNs, recordedValues, config); |
| | |
| | | return PluginResult.PreOperation.continueOperationProcessing(); |
| | | } |
| | | |
| | | List<AttributeValue> recordedValues = new LinkedList<AttributeValue>(); |
| | | List<ByteString> recordedValues = new LinkedList<ByteString>(); |
| | | for (Modification m : modifyOperation.getModifications()) |
| | | { |
| | | Attribute a = m.getAttribute(); |
| | |
| | | { |
| | | case ADD: |
| | | case REPLACE: |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | PreOperation stop = |
| | | checkUniqueness(entryDN, t, v, baseDNs, recordedValues, config); |
| | |
| | | continue; |
| | | } |
| | | |
| | | for (AttributeValue v : updatedAttr) |
| | | for (ByteString v : updatedAttr) |
| | | { |
| | | PreOperation stop = checkUniqueness( |
| | | entryDN, t, v, baseDNs, recordedValues, config); |
| | |
| | | |
| | | |
| | | private PreOperation checkUniqueness(DN entryDN, AttributeType t, |
| | | AttributeValue v, Set<DN> baseDNs, List<AttributeValue> recordedValues, |
| | | ByteString v, Set<DN> baseDNs, List<ByteString> recordedValues, |
| | | UniqueAttributePluginCfg config) |
| | | { |
| | | try |
| | |
| | | // Before returning, we need to remove all values added |
| | | // in the uniqueAttrValue2Dn map, because PostOperation |
| | | // plugin does not get called. |
| | | for (AttributeValue v2 : recordedValues) |
| | | for (ByteString v2 : recordedValues) |
| | | { |
| | | uniqueAttrValue2Dn.remove(v2); |
| | | } |
| | | LocalizableMessage msg = ERR_PLUGIN_UNIQUEATTR_ATTR_NOT_UNIQUE.get( |
| | | t.getNameOrOID(), v.getValue(), conflictDN); |
| | | t.getNameOrOID(), v, conflictDN); |
| | | return PluginResult.PreOperation.stopProcessing( |
| | | ResultCode.CONSTRAINT_VIOLATION, msg); |
| | | } |
| | |
| | | de.getResultCode(), de.getMessageObject()); |
| | | |
| | | // Try some cleanup before returning, to avoid memory leaks |
| | | for (AttributeValue v2 : recordedValues) |
| | | for (ByteString v2 : recordedValues) |
| | | { |
| | | uniqueAttrValue2Dn.remove(v2); |
| | | } |
| | |
| | | return PluginResult.PreOperation.continueOperationProcessing(); |
| | | } |
| | | |
| | | List<AttributeValue> recordedValues = new LinkedList<AttributeValue>(); |
| | | List<ByteString> recordedValues = new LinkedList<ByteString>(); |
| | | RDN newRDN = modifyDNOperation.getNewRDN(); |
| | | for (int i=0; i < newRDN.getNumValues(); i++) |
| | | { |
| | |
| | | continue; |
| | | } |
| | | |
| | | AttributeValue v = newRDN.getAttributeValue(i); |
| | | ByteString v = newRDN.getAttributeValue(i); |
| | | DN entryDN = modifyDNOperation.getEntryDN(); |
| | | PreOperation stop = |
| | | checkUniqueness(entryDN, t, v, baseDNs, recordedValues, config); |
| | |
| | | { |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | sendAlertForUnresolvedConflict(addOperation, entryDN, entryDN, t, |
| | | v, baseDNs, config); |
| | |
| | | { |
| | | case ADD: |
| | | case REPLACE: |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | sendAlertForUnresolvedConflict(modifyOperation, entryDN, entryDN, t, |
| | | v, baseDNs, config); |
| | |
| | | continue; |
| | | } |
| | | |
| | | for (AttributeValue v : updatedAttr) |
| | | for (ByteString v : updatedAttr) |
| | | { |
| | | sendAlertForUnresolvedConflict(modifyOperation, entryDN, |
| | | entryDN, t, v, baseDNs, config); |
| | |
| | | continue; |
| | | } |
| | | |
| | | AttributeValue v = newRDN.getAttributeValue(i); |
| | | ByteString v = newRDN.getAttributeValue(i); |
| | | sendAlertForUnresolvedConflict(modifyDNOperation, entryDN, |
| | | updatedEntryDN, t, v, baseDNs, config); |
| | | } |
| | |
| | | |
| | | |
| | | private void sendAlertForUnresolvedConflict(PluginOperation operation, |
| | | DN entryDN, DN updatedEntryDN, AttributeType t, AttributeValue v, |
| | | DN entryDN, DN updatedEntryDN, AttributeType t, ByteString v, |
| | | Set<DN> baseDNs, UniqueAttributePluginCfg config) |
| | | { |
| | | try |
| | |
| | | t.getNameOrOID(), |
| | | operation.getConnectionID(), |
| | | operation.getOperationID(), |
| | | v.getValue(), |
| | | v, |
| | | updatedEntryDN, |
| | | conflictDN); |
| | | DirectoryServer.sendAlertNotification(this, |
| | |
| | | */ |
| | | private DN getConflictingEntryDN(Set<DN> baseDNs, DN targetDN, |
| | | UniqueAttributePluginCfg config, |
| | | AttributeValue value) |
| | | ByteString value) |
| | | throws DirectoryException |
| | | { |
| | | SearchFilter filter; |
| | |
| | | { |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | uniqueAttrValue2Dn.remove(v); |
| | | } |
| | |
| | | { |
| | | case ADD: |
| | | case REPLACE: |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | uniqueAttrValue2Dn.remove(v); |
| | | } |
| | |
| | | continue; |
| | | } |
| | | |
| | | for (AttributeValue v : updatedAttr) |
| | | for (ByteString v : updatedAttr) |
| | | { |
| | | uniqueAttrValue2Dn.remove(v); |
| | | } |
| | |
| | | // We aren't interested in this attribute type. |
| | | continue; |
| | | } |
| | | AttributeValue v = newRDN.getAttributeValue(i); |
| | | uniqueAttrValue2Dn.remove(v); |
| | | uniqueAttrValue2Dn.remove(newRDN.getAttributeValue(i)); |
| | | } |
| | | return PostOperation.continueOperationProcessing(); |
| | | } |
| | |
| | | AttributeBuilder builder = new AttributeBuilder(privType); |
| | | for (Privilege p : Privilege.getDefaultRootPrivileges()) |
| | | { |
| | | builder.add(AttributeValues.create(privType, p.getName())); |
| | | builder.add(p.getName()); |
| | | } |
| | | attrList = new LinkedList<Attribute>(); |
| | | attrList.add(builder.toAttribute()); |
| | |
| | | public AddOperation processAdd(String rawEntryDN, |
| | | List<RawAttribute> rawAttributes) |
| | | { |
| | | return processAdd(ByteString.valueOf(rawEntryDN), rawAttributes, |
| | | null); |
| | | return processAdd(ByteString.valueOf(rawEntryDN), rawAttributes, null); |
| | | } |
| | | |
| | | |
| | |
| | | LinkedHashMap<AttributeType,List<Attribute>> opAttrs = |
| | | new LinkedHashMap<AttributeType,List<Attribute>>(); |
| | | |
| | | Entry e = new Entry(addRecord.getDN(), objectClasses, userAttrs, |
| | | opAttrs); |
| | | Entry e = new Entry(addRecord.getDN(), objectClasses, userAttrs, opAttrs); |
| | | |
| | | ArrayList<AttributeValue> duplicateValues = |
| | | new ArrayList<AttributeValue>(); |
| | | ArrayList<ByteString> duplicateValues = new ArrayList<ByteString>(); |
| | | for (Attribute a : addRecord.getAttributes()) |
| | | { |
| | | if (a.getAttributeType().isObjectClass()) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | String ocName = v.getValue().toString(); |
| | | String ocName = v.toString(); |
| | | String lowerName = toLowerCase(ocName); |
| | | ObjectClass oc = DirectoryServer.getObjectClass(lowerName, |
| | | true); |
| | | ObjectClass oc = DirectoryServer.getObjectClass(lowerName, true); |
| | | objectClasses.put(oc, ocName); |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | return processAdd(addRecord.getDN(), objectClasses, userAttrs, |
| | | opAttrs); |
| | | return processAdd(addRecord.getDN(), objectClasses, userAttrs, opAttrs); |
| | | } |
| | | |
| | | |
| | |
| | | String password) |
| | | { |
| | | return processSimpleBind(ByteString.valueOf(rawBindDN), |
| | | ByteString.valueOf(password), |
| | | null); |
| | | ByteString.valueOf(password), null); |
| | | } |
| | | |
| | | |
| | |
| | | String attributeType, |
| | | String assertionValue) |
| | | { |
| | | return processCompare(ByteString.valueOf(rawEntryDN), |
| | | attributeType, |
| | | return processCompare(ByteString.valueOf(rawEntryDN), attributeType, |
| | | ByteString.valueOf(assertionValue), null); |
| | | } |
| | | |
| | |
| | | String assertionValue, |
| | | List<Control> controls) |
| | | { |
| | | return processCompare(ByteString.valueOf(rawEntryDN), |
| | | attributeType, |
| | | ByteString.valueOf(assertionValue), |
| | | controls); |
| | | return processCompare(ByteString.valueOf(rawEntryDN), attributeType, |
| | | ByteString.valueOf(assertionValue), controls); |
| | | } |
| | | |
| | | |
| | |
| | | String rawNewSuperior) |
| | | { |
| | | return processModifyDN(ByteString.valueOf(rawEntryDN), |
| | | ByteString.valueOf(rawNewRDN), |
| | | deleteOldRDN, |
| | | ByteString.valueOf(rawNewRDN), deleteOldRDN, |
| | | ByteString.valueOf(rawNewSuperior), null); |
| | | } |
| | | |
| | |
| | | List<Control> controls) |
| | | { |
| | | return processModifyDN(ByteString.valueOf(rawEntryDN), |
| | | ByteString.valueOf(rawNewRDN), |
| | | deleteOldRDN, |
| | | ByteString.valueOf(rawNewSuperior), |
| | | controls); |
| | | ByteString.valueOf(rawNewRDN), deleteOldRDN, |
| | | ByteString.valueOf(rawNewSuperior), controls); |
| | | } |
| | | |
| | | |
| | |
| | | le.getErrorMessage(), le); |
| | | } |
| | | |
| | | return processSearch(ByteString.valueOf(rawBaseDN), scope, |
| | | rawFilter); |
| | | return processSearch(ByteString.valueOf(rawBaseDN), scope, rawFilter); |
| | | } |
| | | |
| | | |
| | |
| | | values = new ArrayList<ByteString>(attribute.size()); |
| | | } |
| | | |
| | | for (AttributeValue v : attribute) |
| | | for (ByteString v : attribute) |
| | | { |
| | | values.add(v.getValue()); |
| | | values.add(v); |
| | | } |
| | | } |
| | | |
| | |
| | | builder = new AttributeBuilder(attributeType); |
| | | } |
| | | |
| | | AttributeType attrType = builder.getAttributeType(); |
| | | for (ByteString value : values) |
| | | { |
| | | if (!builder.add( |
| | | AttributeValues.create(attrType, value))) |
| | | if (!builder.add(value)) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAP_ATTRIBUTE_DUPLICATE_VALUES.get(attributeType); |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.api.MatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | case LESS_OR_EQUAL: |
| | | case APPROXIMATE_MATCH: |
| | | attributeType = filter.getAttributeType().getNameOrOID(); |
| | | assertionValue = filter.getAssertionValue().getValue(); |
| | | assertionValue = filter.getAssertionValue(); |
| | | |
| | | filterComponents = null; |
| | | notComponent = null; |
| | |
| | | attributeType = attrType.getNameOrOID(); |
| | | } |
| | | |
| | | AttributeValue av = filter.getAssertionValue(); |
| | | if (av == null) |
| | | { |
| | | assertionValue = null; |
| | | } |
| | | else |
| | | { |
| | | assertionValue = av.getValue(); |
| | | } |
| | | |
| | | assertionValue = filter.getAssertionValue(); |
| | | filterComponents = null; |
| | | notComponent = null; |
| | | subInitialElement = null; |
| | |
| | | } |
| | | |
| | | |
| | | AttributeValue value; |
| | | if (assertionValue == null) |
| | | { |
| | | value = null; |
| | | } |
| | | else if (attrType == null) |
| | | if (assertionValue != null && attrType == null) |
| | | { |
| | | if (matchingRuleID == null) |
| | | { |
| | | LocalizableMessage message = ERR_LDAP_FILTER_VALUE_WITH_NO_ATTR_OR_MR.get(); |
| | | throw new DirectoryException(ResultCode.PROTOCOL_ERROR, message); |
| | | throw new DirectoryException(ResultCode.PROTOCOL_ERROR, |
| | | ERR_LDAP_FILTER_VALUE_WITH_NO_ATTR_OR_MR.get()); |
| | | } |
| | | else |
| | | { |
| | | MatchingRule mr = |
| | | DirectoryServer.getMatchingRule(toLowerCase(matchingRuleID)); |
| | | |
| | | MatchingRule mr = DirectoryServer.getMatchingRule(toLowerCase(matchingRuleID)); |
| | | if (mr == null) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAP_FILTER_UNKNOWN_MATCHING_RULE.get(matchingRuleID); |
| | | throw new DirectoryException(ResultCode.INAPPROPRIATE_MATCHING, |
| | | message); |
| | | ERR_LDAP_FILTER_UNKNOWN_MATCHING_RULE.get(matchingRuleID)); |
| | | } |
| | | else |
| | | { |
| | | try |
| | | { |
| | | ByteString normalizedValue = |
| | | mr.normalizeAttributeValue(assertionValue); |
| | | value = AttributeValues.create(assertionValue, normalizedValue); |
| | | } |
| | | catch (DecodeException e) |
| | | { |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | e.getMessageObject(), e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | value = AttributeValues.create(attrType, assertionValue); |
| | | } |
| | | |
| | | |
| | | ArrayList<ByteString> subAnyComps; |
| | | if (subAnyElements == null) |
| | | { |
| | | subAnyComps = null; |
| | | } |
| | | else |
| | | { |
| | | subAnyComps = new ArrayList<ByteString>(subAnyElements); |
| | | } |
| | | |
| | | ArrayList<ByteString> subAnyComps = |
| | | subAnyElements != null ? new ArrayList<ByteString>(subAnyElements) : null; |
| | | |
| | | return new SearchFilter(filterType, subComps, notComp, attrType, |
| | | options, value, subInitialElement, subAnyComps, |
| | | options, assertionValue, subInitialElement, subAnyComps, |
| | | subFinalElement, matchingRuleID, dnAttributes); |
| | | } |
| | | |
| | |
| | | { |
| | | AttributeType attrType = |
| | | DirectoryServer.getAttributeType(name.toLowerCase()); |
| | | |
| | | AttributeBuilder builder = new AttributeBuilder(attrType, name); |
| | | builder.add(AttributeValues.create(attrType, value)); |
| | | |
| | | return builder.toAttribute(); |
| | | return Attributes.create(attrType, value); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | | |
| | | |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | |
| | | import org.opends.server.types.SearchResultEntry; |
| | | import org.opends.server.util.Base64; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines the structures and methods for an LDAP search result entry |
| | | * protocol op, which is used to return entries that match the associated search |
| | |
| | | stream.writeStartSequence(); |
| | | stream.writeOctetString(a.getNameWithOptions()); |
| | | stream.writeStartSet(); |
| | | for (AttributeValue value : a) |
| | | for (ByteString value : a) |
| | | { |
| | | stream.writeOctetString(value.getValue()); |
| | | stream.writeOctetString(value); |
| | | } |
| | | stream.writeEndSequence(); |
| | | stream.writeEndSequence(); |
| | |
| | | */ |
| | | package org.opends.server.replication.common; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.UserDefinedVirtualAttributeCfg; |
| | | import org.opends.server.api.VirtualAttributeProvider; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.util.ServerConstants; |
| | | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | |
| | | * TODO: This shouldn't be a virtual attribute, but directly |
| | | * registered in the RootDSE. |
| | | */ |
| | | private final Set<AttributeValue> values; |
| | | private Attribute values; |
| | | |
| | | |
| | | /** |
| | |
| | | public ChangelogBaseDNVirtualAttributeProvider() |
| | | { |
| | | super(); |
| | | |
| | | ByteString dn = |
| | | ByteString.valueOf(ServerConstants.DN_EXTERNAL_CHANGELOG_ROOT); |
| | | values = Collections.singleton(AttributeValues.create(dn, dn)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | public Set<AttributeValue> getValues(Entry entry,VirtualAttributeRule rule) |
| | | public Attribute getValues(Entry entry, VirtualAttributeRule rule) |
| | | { |
| | | if (values == null) |
| | | { |
| | | values = Attributes.create(rule.getAttributeType(), |
| | | ServerConstants.DN_EXTERNAL_CHANGELOG_ROOT); |
| | | } |
| | | return values; |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.replication.common; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.UserDefinedVirtualAttributeCfg; |
| | | import org.opends.server.api.VirtualAttributeProvider; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.replication.server.ReplicationServer; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.workflowelement.externalchangelog.ECLWorkflowElement; |
| | | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | public Set<AttributeValue> getValues(Entry entry,VirtualAttributeRule rule) |
| | | public Attribute getValues(Entry entry,VirtualAttributeRule rule) |
| | | { |
| | | String value = "0"; |
| | | try |
| | |
| | | value = "-1"; |
| | | logger.traceException(e); |
| | | } |
| | | ByteString valueBS = ByteString.valueOf(value); |
| | | return Collections.singleton(AttributeValues.create(valueBS, valueBS)); |
| | | return Attributes.create(rule.getAttributeType(), value); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | */ |
| | | package org.opends.server.replication.common; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.UserDefinedVirtualAttributeCfg; |
| | | import org.opends.server.api.VirtualAttributeProvider; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.replication.server.ReplicationServer; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.workflowelement.externalchangelog.ECLWorkflowElement; |
| | | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | public Set<AttributeValue> getValues(Entry entry,VirtualAttributeRule rule) |
| | | public Attribute getValues(Entry entry,VirtualAttributeRule rule) |
| | | { |
| | | String value = "0"; |
| | | try |
| | |
| | | value = "-1"; |
| | | logger.traceException(e); |
| | | } |
| | | ByteString valueBS = ByteString.valueOf(value); |
| | | return Collections.singleton(AttributeValues.create(valueBS, valueBS)); |
| | | return Attributes.create(rule.getAttributeType(), value); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | */ |
| | | package org.opends.server.replication.common; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.UserDefinedVirtualAttributeCfg; |
| | | import org.opends.server.api.VirtualAttributeProvider; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.replication.plugin.MultimasterReplication; |
| | | import org.opends.server.replication.server.ReplicationServer; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.util.ServerConstants; |
| | | import org.opends.server.workflowelement.externalchangelog.ECLWorkflowElement; |
| | | |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | public Set<AttributeValue> getValues(Entry entry,VirtualAttributeRule rule) |
| | | public Attribute getValues(Entry entry, VirtualAttributeRule rule) |
| | | { |
| | | try |
| | | { |
| | |
| | | |
| | | final ReplicationServer rs = eclwe.getReplicationServer(); |
| | | String newestCookie = rs.getNewestECLCookie(excludedDomains).toString(); |
| | | final ByteString cookie = ByteString.valueOf(newestCookie); |
| | | return Collections.singleton(AttributeValues.create(cookie, cookie)); |
| | | return Attributes.create(rule.getAttributeType(), newestCookie); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | } |
| | | return Collections.emptySet(); |
| | | return Attributes.empty(rule.getAttributeType()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013 ForgeRock, AS. |
| | | * Portions Copyright 2013-2014 ForgeRock, AS. |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | |
| | | |
| | | import org.opends.server.replication.common.CSN; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.Modification; |
| | | |
| | |
| | | * @param csn the associated CSN. |
| | | */ |
| | | public abstract void assign( |
| | | HistAttrModificationKey histKey, AttributeValue value, CSN csn); |
| | | HistAttrModificationKey histKey, ByteString value, CSN csn); |
| | | |
| | | } |
| | | |
| | |
| | | import java.util.LinkedHashMap; |
| | | import java.util.Map; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.opends.server.replication.common.CSN; |
| | | import org.opends.server.types.*; |
| | |
| | | * LinkedHashMap here because we want: |
| | | * <ol> |
| | | * <li>Fast access for removing/adding a AttrValueHistorical keyed by the |
| | | * AttributeValue => Use a Map</li> |
| | | * attribute value => Use a Map</li> |
| | | * <li>Ordering changes according to the CSN of each changes => Use a |
| | | * LinkedHashMap</li> |
| | | * </ol> |
| | |
| | | * @param val value that was deleted |
| | | * @param csn time when the delete was done |
| | | */ |
| | | protected void delete(AttributeValue val, CSN csn) |
| | | protected void delete(ByteString val, CSN csn) |
| | | { |
| | | AttrValueHistorical info = new AttrValueHistorical(val, null, csn); |
| | | valuesHist.remove(info); |
| | |
| | | */ |
| | | protected void delete(Attribute attr, CSN csn) |
| | | { |
| | | for (AttributeValue val : attr) |
| | | for (ByteString val : attr) |
| | | { |
| | | AttrValueHistorical info = new AttrValueHistorical(val, null, csn); |
| | | valuesHist.remove(info); |
| | |
| | | * @param csn |
| | | * time when the value was added |
| | | */ |
| | | protected void add(AttributeValue addedValue, CSN csn) |
| | | protected void add(ByteString addedValue, CSN csn) |
| | | { |
| | | AttrValueHistorical info = new AttrValueHistorical(addedValue, csn, null); |
| | | valuesHist.remove(info); |
| | |
| | | */ |
| | | private void add(Attribute attr, CSN csn) |
| | | { |
| | | for (AttributeValue val : attr) |
| | | for (ByteString val : attr) |
| | | { |
| | | AttrValueHistorical info = new AttrValueHistorical(val, csn, null); |
| | | valuesHist.remove(info); |
| | |
| | | // we are processing DELETE of some attribute values |
| | | AttributeBuilder builder = new AttributeBuilder(modAttr); |
| | | |
| | | for (AttributeValue val : modAttr) |
| | | for (ByteString val : modAttr) |
| | | { |
| | | boolean deleteIt = true; // true if the delete must be done |
| | | boolean addedInCurrentOp = false; |
| | |
| | | } |
| | | |
| | | AttributeBuilder builder = new AttributeBuilder(m.getAttribute()); |
| | | for (AttributeValue addVal : m.getAttribute()) |
| | | for (ByteString addVal : m.getAttribute()) |
| | | { |
| | | AttrValueHistorical valInfo = |
| | | new AttrValueHistorical(addVal, csn, null); |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void assign(HistAttrModificationKey histKey, AttributeValue value, |
| | | CSN csn) |
| | | public void assign(HistAttrModificationKey histKey, ByteString value, CSN csn) |
| | | { |
| | | switch (histKey) |
| | | { |
| | |
| | | import java.util.Iterator; |
| | | import java.util.Map; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.opends.server.replication.common.CSN; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.Modification; |
| | | |
| | | /** |
| | | * This class is used to store historical information for single valued |
| | |
| | | public class AttrHistoricalSingle extends AttrHistorical |
| | | { |
| | | /** Last time when the attribute was deleted. */ |
| | | private CSN deleteTime = null; |
| | | private CSN deleteTime; |
| | | /** Last time when a value was added. */ |
| | | private CSN addTime = null; |
| | | private CSN addTime; |
| | | /** Last added value. */ |
| | | private AttributeValue value = null; |
| | | private ByteString value; |
| | | |
| | | /** |
| | | * last operation applied. This is only used for multiple mods on the same |
| | | * single valued attribute in the same modification. |
| | | */ |
| | | private HistAttrModificationKey lastMod = null; |
| | | private HistAttrModificationKey lastMod; |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | |
| | | @Override |
| | | public void processLocalOrNonConflictModification(CSN csn, Modification mod) |
| | | { |
| | | AttributeValue newValue = null; |
| | | ByteString newValue = null; |
| | | Attribute modAttr = mod.getAttribute(); |
| | | if (modAttr != null && !modAttr.isEmpty()) |
| | | { |
| | |
| | | { |
| | | boolean conflict = false; |
| | | |
| | | AttributeValue newValue = null; |
| | | ByteString newValue = null; |
| | | Attribute modAttr = mod.getAttribute(); |
| | | if (modAttr != null && !modAttr.isEmpty()) |
| | | { |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void assign(HistAttrModificationKey histKey, |
| | | AttributeValue value, CSN csn) |
| | | public void assign(HistAttrModificationKey histKey, ByteString value, CSN csn) |
| | | { |
| | | switch (histKey) |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013 ForgeRock AS. |
| | | * Portions Copyright 2013-2014 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | | import org.opends.server.replication.common.CSN; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | |
| | | /** |
| | | * Store historical information for an attribute value. |
| | | */ |
| | | public class AttrValueHistorical |
| | | { |
| | | private AttributeValue value; |
| | | private ByteString value; |
| | | private CSN valueDeleteTime; |
| | | private CSN valueUpdateTime; |
| | | |
| | | /** |
| | | * Build an AttrValueHistorical for a provided AttributeValue, providing |
| | | * Build an AttrValueHistorical for a provided attribute value, providing |
| | | * the last time the provided value is either updated or deleted. |
| | | * @param value the provided attributeValue |
| | | * @param csnUpdate last time when this value was updated |
| | | * @param csnDelete last time when this value for deleted |
| | | */ |
| | | public AttrValueHistorical(AttributeValue value, |
| | | CSN csnUpdate, |
| | | CSN csnDelete) |
| | | public AttrValueHistorical(ByteString value, CSN csnUpdate, CSN csnDelete) |
| | | { |
| | | this.value = value; |
| | | this.valueUpdateTime = csnUpdate; |
| | |
| | | * Get the attributeValue for which this object was generated. |
| | | * @return the value for which this object was generated |
| | | */ |
| | | public AttributeValue getAttributeValue() |
| | | public ByteString getAttributeValue() |
| | | { |
| | | return value; |
| | | } |
| | |
| | | import java.util.*; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.replication.common.CSN; |
| | |
| | | // Get the CSN from the attached synchronization context |
| | | // Create the attribute (encoded) |
| | | CSN addCSN = OperationContext.getCSN(addOperation); |
| | | AttributeValue attrValue = encodeHistorical(addCSN, "add"); |
| | | String attrValue = encodeHistorical(addCSN, "add"); |
| | | Attribute attr = Attributes.create(historicalAttrType, attrValue); |
| | | |
| | | // Set the created attribute to the operation |
| | |
| | | * @return The attribute value containing the historical information for the |
| | | * Operation type. |
| | | */ |
| | | private static AttributeValue encodeHistorical(CSN csn, String operationType) |
| | | private static String encodeHistorical(CSN csn, String operationType) |
| | | { |
| | | AttributeType historicalAttrType = |
| | | DirectoryServer.getSchema().getAttributeType(HISTORICAL_ATTRIBUTE_NAME); |
| | | |
| | | String strValue = "dn:" + csn + ":" + operationType; |
| | | return AttributeValues.create(historicalAttrType, strValue); |
| | | return "dn:" + csn + ":" + operationType; |
| | | } |
| | | |
| | | /** |
| | |
| | | for (AttrValueHistorical attrValHist : attrHist.getValuesHistorical() |
| | | .keySet()) |
| | | { |
| | | final AttributeValue value = attrValHist.getAttributeValue(); |
| | | final ByteString value = attrValHist.getAttributeValue(); |
| | | |
| | | // Encode an attribute value |
| | | final String strValue; |
| | |
| | | } |
| | | strValue = encode("del", type, optionsString, attrValHist |
| | | .getValueDeleteTime(), value); |
| | | builder.add(AttributeValues.create(historicalAttrType, strValue)); |
| | | builder.add(strValue); |
| | | } |
| | | else if (attrValHist.getValueUpdateTime() != null) |
| | | { |
| | |
| | | strValue = encode("add", type, optionsString, updateTime); |
| | | } |
| | | |
| | | builder.add(AttributeValues.create(historicalAttrType, strValue)); |
| | | builder.add(strValue); |
| | | } |
| | | } |
| | | |
| | |
| | | continue; |
| | | } |
| | | String strValue = encode("attrDel", type, optionsString, deleteTime); |
| | | builder.add(AttributeValues.create(historicalAttrType, strValue)); |
| | | builder.add(strValue); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | private String encode(String operation, AttributeType type, |
| | | String optionsString, CSN changeTime, AttributeValue value) |
| | | String optionsString, CSN changeTime, ByteString value) |
| | | { |
| | | return type.getNormalizedPrimaryName() + optionsString + ":" + changeTime |
| | | + ":" + operation + ":" + value; |
| | |
| | | for (Attribute histAttrFromEntry : histAttrWithOptionsFromEntry) |
| | | { |
| | | // For each Attribute (option), traverse the values |
| | | for (AttributeValue histAttrValueFromEntry : histAttrFromEntry) |
| | | for (ByteString histAttrValueFromEntry : histAttrFromEntry) |
| | | { |
| | | // From each value of the hist attr, create an object |
| | | HistoricalAttributeValue histVal = new HistoricalAttributeValue( |
| | | histAttrValueFromEntry.getValue().toString()); |
| | | histAttrValueFromEntry.toString()); |
| | | |
| | | AttributeType attrType = histVal.getAttrType(); |
| | | Set<String> options = histVal.getOptions(); |
| | | CSN csn = histVal.getCSN(); |
| | | AttributeValue value = histVal.getAttributeValue(); |
| | | ByteString value = histVal.getAttributeValue(); |
| | | HistAttrModificationKey histKey = histVal.getHistKey(); |
| | | |
| | | // update the oldest CSN stored in the new entry historical |
| | |
| | | { |
| | | for (Attribute attr : attrs) |
| | | { |
| | | for (AttributeValue val : attr) |
| | | for (ByteString val : attr) |
| | | { |
| | | HistoricalAttributeValue histVal = |
| | | new HistoricalAttributeValue(val.getValue().toString()); |
| | | new HistoricalAttributeValue(val.toString()); |
| | | if (histVal.isADDOperation()) |
| | | { |
| | | // Found some historical information indicating that this |
| | |
| | | { |
| | | if (entryUUIDAttributes != null) |
| | | { |
| | | Attribute uuid = entryUUIDAttributes.get(0); |
| | | if (!uuid.isEmpty()) |
| | | Attribute uuidAttr = entryUUIDAttributes.get(0); |
| | | if (!uuidAttr.isEmpty()) |
| | | { |
| | | AttributeValue uuidVal = uuid.iterator().next(); |
| | | return uuidVal.getValue().toString(); |
| | | return uuidAttr.iterator().next().toString(); |
| | | } |
| | | } |
| | | |
| | |
| | | if (domain==null) |
| | | { |
| | | RDN rdn = configuration.dn().parent().rdn(); |
| | | DN rdns = DN.decode(rdn.getAttributeValue(0).getValue()); |
| | | DN rdns = DN.decode(rdn.getAttributeValue(0)); |
| | | domain = MultimasterReplication.findDomain(rdns, null); |
| | | } |
| | | return null; |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.replication.plugin.LDAPReplicationDomain.*; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import static org.opends.messages.ReplicationMessages.*; |
| | | import static org.opends.server.replication.plugin.LDAPReplicationDomain.*; |
| | |
| | | // Now flush attribute values into entry |
| | | if (somethingToFlush) |
| | | { |
| | | List<AttributeValue> duplicateValues = new ArrayList<AttributeValue>(); |
| | | List<ByteString> duplicateValues = new ArrayList<ByteString>(); |
| | | entry.addAttribute(attrBuilder.toAttribute(), duplicateValues); |
| | | } |
| | | } |
| | |
| | | import java.util.LinkedHashSet; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.replication.common.CSN; |
| | |
| | | { |
| | | private AttributeType attrType; |
| | | private String attrString; |
| | | private AttributeValue attributeValue; |
| | | private ByteString attributeValue; |
| | | private CSN csn; |
| | | private Set<String> options; |
| | | private HistAttrModificationKey histKey; |
| | |
| | | if (token.length == 4) |
| | | { |
| | | stringValue = token[3]; |
| | | attributeValue = AttributeValues.create(attrType, stringValue); |
| | | attributeValue = ByteString.valueOf(stringValue); |
| | | } |
| | | else |
| | | { |
| | | attributeValue = null; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | stringValue = null; |
| | |
| | | * Get the Attribute Value. |
| | | * @return The Attribute Value. |
| | | */ |
| | | public AttributeValue getAttributeValue() |
| | | public ByteString getAttributeValue() |
| | | { |
| | | return attributeValue; |
| | | } |
| | |
| | | */ |
| | | public static class AttributeValueStringIterator implements Iterator<String> |
| | | { |
| | | private Iterator<AttributeValue> attrValIt; |
| | | private Iterator<ByteString> attrValIt; |
| | | |
| | | /** |
| | | * Creates a new AttributeValueStringIterator object. |
| | | * @param attrValIt The underlying attribute iterator to use, assuming |
| | | * internal values are strings. |
| | | */ |
| | | public AttributeValueStringIterator(Iterator<AttributeValue> attrValIt) |
| | | public AttributeValueStringIterator(Iterator<ByteString> attrValIt) |
| | | { |
| | | this.attrValIt = attrValIt; |
| | | } |
| | |
| | | @Override |
| | | public String next() |
| | | { |
| | | return attrValIt.next().getValue().toString(); |
| | | return attrValIt.next().toString(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | support remove so we have to create a new list, keeping only the |
| | | attribute value which is the same as in the RDN |
| | | */ |
| | | AttributeValue rdnAttributeValue = |
| | | ByteString rdnAttributeValue = |
| | | entryRdn.getAttributeValue(attributeType); |
| | | List<Attribute> attrList = attributesMap.get(attributeType); |
| | | AttributeValue sameAttrValue = null; |
| | | ByteString sameAttrValue = null; |
| | | // Locate the attribute value identical to the one in the RDN |
| | | for (Attribute attr : attrList) |
| | | { |
| | | if (attr.contains(rdnAttributeValue)) |
| | | { |
| | | for (AttributeValue attrValue : attr) { |
| | | for (ByteString attrValue : attr) { |
| | | if (rdnAttributeValue.equals(attrValue)) { |
| | | // Keep the value we want |
| | | sameAttrValue = attrValue; |
| | |
| | | // create new internal modify operation and run it. |
| | | AttributeType attrType = DirectoryServer.getAttributeType(DS_SYNC_CONFLICT, |
| | | true); |
| | | Attribute attr = Attributes.create(attrType, AttributeValues.create( |
| | | attrType, conflictDN.toNormalizedString())); |
| | | Attribute attr = Attributes.create(attrType, conflictDN.toNormalizedString()); |
| | | List<Modification> mods = new ArrayList<Modification>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, attr)); |
| | | |
| | |
| | | if (attrs != null) |
| | | { |
| | | Attribute attr = attrs.get(0); |
| | | for (AttributeValue value : attr) |
| | | for (ByteString value : attr) |
| | | { |
| | | update(new CSN(value.toString())); |
| | | } |
| | |
| | | dbMaxCsn = serverStateMaxCsn; |
| | | for (SearchResultEntry resEntry : op.getSearchEntries()) |
| | | { |
| | | for (AttributeValue attrValue : |
| | | resEntry.getAttribute(histType).get(0)) |
| | | for (ByteString attrValue : resEntry.getAttribute(histType).get(0)) |
| | | { |
| | | HistoricalAttributeValue histVal = |
| | | new HistoricalAttributeValue(attrValue.toString()); |
| | |
| | | import org.opends.server.types.operation.PostOperationAddOperation; |
| | | |
| | | import static org.opends.server.replication.protocol.OperationContext.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | /** |
| | | * This class is used to exchange Add operation between LDAP servers |
| | |
| | | builder.setInitialCapacity(objectClasses.size()); |
| | | for (String s : objectClasses.values()) |
| | | { |
| | | builder.add(AttributeValues.create(ByteString.valueOf(s), |
| | | ByteString.valueOf(toLowerCase(s)))); |
| | | builder.add(s); |
| | | } |
| | | Attribute attr = builder.toAttribute(); |
| | | |
| | |
| | | { |
| | | for (Attribute a : list) |
| | | { |
| | | if (!EntryHistorical.isHistoricalAttribute(a)) |
| | | if (!a.isVirtual()) |
| | | if (!EntryHistorical.isHistoricalAttribute(a) && !a.isVirtual()) |
| | | { |
| | | new LDAPAttribute(a).write(writer); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // Encode the operational attributes (AttributeList). |
| | | for (List<Attribute> list : operationalAttributes.values()) |
| | |
| | | { |
| | | try |
| | | { |
| | | CSN startingCSN = |
| | | new CSN(filter.getAssertionValue().getValue().toString()); |
| | | CSN startingCSN = new CSN(filter.getAssertionValue().toString()); |
| | | return new CSN(startingCSN.getTime(), |
| | | startingCSN.getSeqnum() - 1, startingCSN.getServerId()); |
| | | } |
| | |
| | | AttributeBuilder builder = new AttributeBuilder(type, ATTR_SERVER_STATE); |
| | | for (String str : domain.getServerState().toStringSet()) |
| | | { |
| | | builder.add(AttributeValues.create(type,str)); |
| | | builder.add(str); |
| | | } |
| | | attributes.add(builder.toAttribute()); |
| | | |
| | |
| | | { |
| | | final Integer serverId = entry.getKey(); |
| | | final Integer nb = entry.getValue(); |
| | | builder.add(AttributeValues.create(type, serverId + ":" + nb)); |
| | | builder.add(serverId + ":" + nb); |
| | | } |
| | | attributes.add(builder.toAttribute()); |
| | | } |
| | |
| | | public static void addMonitorData(List<Attribute> attributes, String name, |
| | | int value) |
| | | { |
| | | AttributeType type = DirectoryServer.getDefaultAttributeType(name); |
| | | attributes.add(Attributes.create(type, AttributeValues.create(type, |
| | | String.valueOf(value)))); |
| | | addMonitorData(attributes, name, String.valueOf(value)); |
| | | } |
| | | |
| | | /** |
| | |
| | | public static void addMonitorData(List<Attribute> attributes, String name, |
| | | long value) |
| | | { |
| | | AttributeType type = DirectoryServer.getDefaultAttributeType(name); |
| | | attributes.add(Attributes.create(type, AttributeValues.create(type, |
| | | String.valueOf(value)))); |
| | | addMonitorData(attributes, name, String.valueOf(value)); |
| | | } |
| | | |
| | | /** |
| | |
| | | String value) |
| | | { |
| | | AttributeType type = DirectoryServer.getDefaultAttributeType(name); |
| | | attributes |
| | | .add(Attributes.create(type, AttributeValues.create(type, value))); |
| | | attributes.add(Attributes.create(type, value)); |
| | | } |
| | | } |
| | |
| | | import org.opends.server.api.OrderingMatchingRule; |
| | | import org.opends.server.api.SubstringMatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.AttributeValues; |
| | | import org.opends.server.util.ServerConstants; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | |
| | | * |
| | | * @return The attribute value created from the provided boolean value. |
| | | */ |
| | | public static AttributeValue createBooleanValue(boolean b) |
| | | public static ByteString createBooleanValue(boolean b) |
| | | { |
| | | ByteString value = b |
| | | ? ServerConstants.TRUE_VALUE |
| | | : ServerConstants.FALSE_VALUE; |
| | | return AttributeValues.create(value, value); |
| | | return b ? ServerConstants.TRUE_VALUE : ServerConstants.FALSE_VALUE; |
| | | } |
| | | |
| | | |
| | |
| | | * |
| | | * @return The attribute value created from the date. |
| | | */ |
| | | public static AttributeValue createGeneralizedTimeValue(long time) |
| | | public static ByteString createGeneralizedTimeValue(long time) |
| | | { |
| | | String valueString = format(time); |
| | | return AttributeValues.create(ByteString.valueOf(valueString), |
| | | ByteString.valueOf(valueString)); |
| | | return ByteString.valueOf(format(time)); |
| | | } |
| | | |
| | | |
| | |
| | | * |
| | | * @return The attribute value created from the date. |
| | | */ |
| | | public static AttributeValue createUTCTimeValue(Date d) |
| | | public static ByteString createUTCTimeValue(Date d) |
| | | { |
| | | String valueString; |
| | | |
| | | synchronized (dateFormatLock) |
| | | { |
| | | valueString = dateFormat.format(d); |
| | | } |
| | | |
| | | return AttributeValues.create(ByteString.valueOf(valueString), |
| | | ByteString.valueOf(valueString)); |
| | | return ByteString.valueOf(valueString); |
| | | } |
| | | |
| | | |
| | |
| | | import org.opends.server.core.SchemaConfigManager; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import static org.opends.messages.TaskMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The list of files to be added to the server schema. */ |
| | | TreeSet<String> filesToAdd; |
| | | private TreeSet<String> filesToAdd; |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | |
| | | filesToAdd = new TreeSet<String>(); |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | String filename = v.getValue().toString(); |
| | | String filename = v.toString(); |
| | | filesToAdd.add(filename); |
| | | |
| | | try |
| | |
| | | Attribute a = m.getAttribute(); |
| | | AttributeBuilder builder = new AttributeBuilder(a |
| | | .getAttributeType(), a.getName()); |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | String s = v.getValue().toString(); |
| | | String s = v.toString(); |
| | | if (!s.contains(SCHEMA_PROPERTY_FILENAME)) |
| | | { |
| | | if (s.endsWith(" )")) |
| | |
| | | } |
| | | } |
| | | |
| | | builder.add(AttributeValues.create(a.getAttributeType(), s)); |
| | | builder.add(s); |
| | | } |
| | | |
| | | mods.add(new Modification(m.getModificationType(), builder |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.DisconnectReason; |
| | | import org.opends.server.types.Entry; |
| | |
| | | connIDLoop: |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | try |
| | | { |
| | | connectionID = Long.parseLong(v.getValue().toString()); |
| | | connectionID = Long.parseLong(v.toString()); |
| | | break connIDLoop; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_TASK_DISCONNECT_INVALID_CONN_ID.get(v.getValue()); |
| | | LocalizableMessage message = ERR_TASK_DISCONNECT_INVALID_CONN_ID.get(v); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message, e); |
| | | } |
| | |
| | | notifyClientLoop: |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | String stringValue = toLowerCase(v.getValue().toString()); |
| | | String stringValue = toLowerCase(v.toString()); |
| | | if (stringValue.equals("true")) |
| | | { |
| | | notifyClient = true; |
| | |
| | | disconnectMessageLoop: |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | disconnectMessage = LocalizableMessage.raw(v.getValue().toString()); |
| | | disconnectMessage = LocalizableMessage.raw(v.toString()); |
| | | break disconnectMessageLoop; |
| | | } |
| | | } |
| | |
| | | Attribute attr = attrList.get(0); |
| | | if (!attr.isEmpty()) |
| | | { |
| | | String valueString = attr.iterator().next().getValue().toString(); |
| | | String valueString = attr.iterator().next().toString(); |
| | | shutdownMessage = INFO_TASK_SHUTDOWN_CUSTOM_MESSAGE.get(taskEntry.getName(), valueString); |
| | | } |
| | | } |
| | |
| | | Attribute attr = attrList.get(0); |
| | | if (!attr.isEmpty()) |
| | | { |
| | | String valueString = toLowerCase(attr.iterator().next() |
| | | .getValue().toString()); |
| | | |
| | | String valueString = toLowerCase(attr.iterator().next().toString()); |
| | | restart = (valueString.equals("true") || valueString.equals("yes") |
| | | || valueString.equals("on") || valueString.equals("1")); |
| | | } |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.messages.TaskMessages; |
| | | import org.opends.server.admin.server.ServerManagementContext; |
| | | import org.opends.server.admin.std.server.BackendCfg; |
| | | import org.opends.server.admin.std.server.RootCfg; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.config.StringConfigAttribute; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.ldap.LDAPAttribute; |
| | | import org.opends.server.protocols.ldap.LDAPModification; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.RawModification; |
| | | import org.opends.server.util.ServerConstants; |
| | | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | |
| | | |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | String valueString = toLowerCase(v.getValue().toString()); |
| | | String valueString = toLowerCase(v.toString()); |
| | | if (valueString.equals("true") || valueString.equals("yes") || |
| | | valueString.equals("on") || valueString.equals("1")) |
| | | { |
| | |
| | | Attribute attr = attrList.get(0); |
| | | if (!attr.isEmpty()) |
| | | { |
| | | for (AttributeValue value : attr) |
| | | for (ByteString value : attr) |
| | | { |
| | | valueStrings.add(value.getValue().toString()); |
| | | valueStrings.add(value.toString()); |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | public static String getSingleValueString(List<Attribute> attrList) |
| | | { |
| | | if (attrList == null || attrList.isEmpty()) |
| | | if (attrList != null && !attrList.isEmpty()) |
| | | { |
| | | return null; |
| | | } |
| | | String valueString = null; |
| | | Attribute attr = attrList.get(0); |
| | | if (!attr.isEmpty()) |
| | | { |
| | | valueString = attr.iterator().next().getValue().toString(); |
| | | return attr.iterator().next().toString(); |
| | | } |
| | | return valueString; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | |
| | | Attribute attr = attrList.get(0); |
| | | if (!attr.isEmpty()) |
| | | { |
| | | String valueString = attr.iterator().next() |
| | | .getValue().toString(); |
| | | try |
| | | { |
| | | return Integer.parseInt(valueString); |
| | | return Integer.parseInt(attr.iterator().next().toString()); |
| | | } |
| | | catch (NumberFormatException e) |
| | | { |
| | |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.AttributeValues; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | |
| | | AttributeBuilder builder = new AttributeBuilder(attrType); |
| | | for (ObjectClass oc : sourceClasses) |
| | | { |
| | | builder.add(AttributeValues.create(attrType, oc.getNameOrOID())); |
| | | builder.add(oc.getNameOrOID()); |
| | | } |
| | | |
| | | modifications.add(new Modification(ModificationType.DELETE, builder |
| | |
| | | AttributeBuilder builder = new AttributeBuilder(attrType); |
| | | for (ObjectClass oc : targetClasses) |
| | | { |
| | | builder.add(AttributeValues.create(attrType, oc.getNameOrOID())); |
| | | builder.add(oc.getNameOrOID()); |
| | | } |
| | | |
| | | modifications.add(new Modification(ModificationType.ADD, builder |
| | |
| | | else |
| | | { |
| | | LinkedList<Modification> attrMods = new LinkedList<Modification>(); |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | AttributeBuilder builder = new AttributeBuilder(a, true); |
| | | builder.add(v); |
| | |
| | | import java.util.TreeMap; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.extensions.ConfigFileHandler; |
| | | import org.opends.server.loggers.JDKLogging; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | |
| | | AttributeType t = a.getAttributeType(); |
| | | if (t.isObjectClass()) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | String stringValue = v.getValue().toString(); |
| | | String stringValue = v.toString(); |
| | | String lowerValue = toLowerCase(stringValue); |
| | | ObjectClass oc = DirectoryServer.getObjectClass(lowerValue, true); |
| | | objectClasses.put(oc, stringValue); |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | |
| | |
| | | { |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | try |
| | | { |
| | | String[] valueStrings = new String[] { v.getValue().toString()}; |
| | | Tag[] tags = new Tag[1]; |
| | | tags[0] = new StaticTextTag(); |
| | | tags[0].initializeForBranch(templateFile, this, valueStrings, 0, |
| | | warnings); |
| | | String[] valueStrings = new String[] { v.toString() }; |
| | | Tag[] tags = new Tag[] { new StaticTextTag() }; |
| | | tags[0].initializeForBranch(templateFile, this, valueStrings, 0, warnings); |
| | | lineList.add(new TemplateLine(a.getAttributeType(), 0, tags)); |
| | | } |
| | | catch (Exception e) |
| | |
| | | { |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | try |
| | | { |
| | | String[] valueStrings = new String[] { v.getValue().toString()}; |
| | | Tag[] tags = new Tag[1]; |
| | | tags[0] = new StaticTextTag(); |
| | | tags[0].initializeForBranch(templateFile, this, valueStrings, 0, |
| | | warnings); |
| | | String[] valueStrings = new String[] { v.toString() }; |
| | | Tag[] tags = new Tag[] { new StaticTextTag() }; |
| | | tags[0].initializeForBranch(templateFile, this, valueStrings, 0, warnings); |
| | | lineList.add(new TemplateLine(a.getAttributeType(), 0, tags)); |
| | | } |
| | | catch (Exception e) |
| | |
| | | */ |
| | | package org.opends.server.tools.makeldif; |
| | | |
| | | |
| | | |
| | | import java.io.BufferedWriter; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.util.LDIFException; |
| | | |
| | | import static org.opends.server.util.LDIFWriter.appendLDIFSeparatorAndValue; |
| | | import static org.opends.server.util.LDIFWriter.writeLDIFLine; |
| | | import static org.opends.server.util.LDIFWriter.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines an entry that is generated using a MakeLDIF branch or |
| | | * template. |
| | |
| | | return null; |
| | | } |
| | | |
| | | AttributeValue value = |
| | | AttributeValues.create(t, v.getValue().toString()); |
| | | rdn = new RDN(t, value); |
| | | rdn = new RDN(t, ByteString.valueOf(v.getValue().toString())); |
| | | } |
| | | else |
| | | { |
| | | String[] names = new String[rdnAttrs.length]; |
| | | AttributeValue[] values = new AttributeValue[rdnAttrs.length]; |
| | | ByteString[] values = new ByteString[rdnAttrs.length]; |
| | | for (int i=0; i < rdnAttrs.length; i++) |
| | | { |
| | | AttributeType t = rdnAttrs[i]; |
| | |
| | | } |
| | | |
| | | names[i] = t.getPrimaryName(); |
| | | values[i] = AttributeValues.create(t, v.getValue().toString()); |
| | | values[i] = ByteString.valueOf(v.getValue().toString()); |
| | | } |
| | | |
| | | rdn = new RDN(rdnAttrs, names, values); |
| | |
| | | public TemplateValue getValue(AttributeType attributeType) |
| | | { |
| | | ArrayList<TemplateValue> valueList = attributes.get(attributeType); |
| | | if ((valueList == null) || valueList.isEmpty()) |
| | | { |
| | | return null; |
| | | } |
| | | else |
| | | if (valueList != null && !valueList.isEmpty()) |
| | | { |
| | | return valueList.get(0); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | public List<TemplateValue> getValues(AttributeType attributeType) |
| | | { |
| | | ArrayList<TemplateValue> valueList = attributes.get(attributeType); |
| | | return valueList; |
| | | return attributes.get(attributeType); |
| | | } |
| | | |
| | | |
| | |
| | | if (valueList == null) |
| | | { |
| | | valueList = new ArrayList<TemplateValue>(); |
| | | valueList.add(value); |
| | | attributes.put(value.getAttributeType(), valueList); |
| | | } |
| | | else |
| | | { |
| | | valueList.add(value); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | AttributeBuilder builder = new AttributeBuilder(t, t.getNameOrOID()); |
| | | for (TemplateValue v : valueList) |
| | | { |
| | | builder.add(AttributeValues.create(t, v.getValue().toString())); |
| | | builder.add(v.getValue().toString()); |
| | | } |
| | | |
| | | ArrayList<Attribute> attrList = new ArrayList<Attribute>(1); |
| | |
| | | AttributeBuilder base64Builder = null; |
| | | for (TemplateValue v : valueList) |
| | | { |
| | | AttributeValue value = |
| | | AttributeValues.create(t, v.getValue().toString()); |
| | | ByteString value = ByteString.valueOf(v.getValue().toString()); |
| | | builder.add(value); |
| | | if (v.getTemplateLine().isURL()) |
| | | { |
| | |
| | | List<Attribute> urlAttrList = urlAttributes.get(attrType); |
| | | List<Attribute> base64AttrList = base64Attributes.get(attrType); |
| | | |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | StringBuilder attrLine = new StringBuilder(); |
| | | attrLine.append(attrName); |
| | |
| | | { |
| | | for (Attribute urlAttr : urlAttrList) |
| | | { |
| | | for (AttributeValue urlValue : urlAttr) |
| | | for (ByteString urlValue : urlAttr) |
| | | { |
| | | if (urlValue.equals(v)) |
| | | { |
| | |
| | | { |
| | | for (Attribute base64Attr : base64AttrList) |
| | | { |
| | | for (AttributeValue base64Value : base64Attr) |
| | | for (ByteString base64Value : base64Attr) |
| | | { |
| | | if (base64Value.equals(v)) |
| | | { |
| | |
| | | } |
| | | } |
| | | appendLDIFSeparatorAndValue(attrLine, |
| | | v.getValue(), |
| | | v, |
| | | isURLValue, |
| | | isBase64Value); |
| | | writeLDIFLine(attrLine, writer, wrapLines, wrapColumn); |
| | |
| | | attrName.append(o); |
| | | } |
| | | |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | StringBuilder attrLine = new StringBuilder(); |
| | | attrLine.append(attrName); |
| | | appendLDIFSeparatorAndValue(attrLine, |
| | | v.getValue()); |
| | | writeLDIFLine(attrLine, writer, wrapLines, |
| | | wrapColumn); |
| | | appendLDIFSeparatorAndValue(attrLine, v); |
| | | writeLDIFLine(attrLine, writer, wrapLines, wrapColumn); |
| | | } |
| | | } |
| | | } |
| | |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DN; |
| | | |
| | | import java.util.Map; |
| | |
| | | type.getNormalizedPrimaryName()); |
| | | List<Attribute> attrList = entry.getUserAttribute(type); |
| | | for (Attribute attr : attrList) { |
| | | for (AttributeValue av : attr) { |
| | | for (ByteString av : attr) { |
| | | List<String> valueList = taskSpecificAttrValues.get(attrTypeName); |
| | | if (valueList == null) { |
| | | valueList = new ArrayList<String>(); |
| | | taskSpecificAttrValues.put(attrTypeName, valueList); |
| | | } |
| | | valueList.add(av.getValue().toString()); |
| | | valueList.add(av.toString()); |
| | | } |
| | | } |
| | | } |
| | |
| | | if (attrList != null && attrList.size() == 1) { |
| | | Attribute attr = attrList.get(0); |
| | | if (!attr.isEmpty()) { |
| | | return attr.iterator().next().getValue().toString(); |
| | | return attr.iterator().next().toString(); |
| | | } |
| | | } |
| | | return ""; |
| | |
| | | List<Attribute> attrList = entry.getAttribute(attrName); |
| | | if (attrList != null) { |
| | | for (Attribute attr : attrList) { |
| | | for (AttributeValue value : attr) { |
| | | valuesList.add(value.getValue().toString()); |
| | | for (ByteString value : attr) { |
| | | valuesList.add(value.toString()); |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | /** |
| | | * An abstract base class for implementing new types of |
| | |
| | | * <p> |
| | | * This implementation iterates through each attribute value in the |
| | | * provided collection, checking to see if this attribute contains |
| | | * the value using {@link #contains(AttributeValue)}. |
| | | * the value using {@link #contains(ByteString)}. |
| | | */ |
| | | public boolean containsAll(Collection<AttributeValue> values) |
| | | @Override |
| | | public boolean containsAll(Collection<ByteString> values) |
| | | { |
| | | for (AttributeValue value : values) |
| | | for (ByteString value : values) |
| | | { |
| | | if (!contains(value)) |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | |
| | | return false; |
| | | } |
| | | |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | if (!contains(v)) |
| | | { |
| | |
| | | * attribute's attribute type or, if there is no primary name, the |
| | | * attribute type's OID. |
| | | */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return getAttributeType().getNameOrOID(); |
| | |
| | | * this attribute's name followed by a semi-colon and a semi-colon |
| | | * separated list of its attribute options. |
| | | */ |
| | | @Override |
| | | public String getNameWithOptions() |
| | | { |
| | | if (!hasOptions()) |
| | |
| | | * {@link #hasOption(String)} and <code>true</code> is |
| | | * returned if all the provided options are present. |
| | | */ |
| | | @Override |
| | | public boolean hasAllOptions(Collection<String> options) |
| | | { |
| | | if (options == null || options.isEmpty()) |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public final int hashCode() |
| | | public int hashCode() |
| | | { |
| | | int hashCode = getAttributeType().hashCode(); |
| | | |
| | | for (AttributeValue value : this) |
| | | for (ByteString value : this) |
| | | { |
| | | hashCode += value.hashCode(); |
| | | } |
| | | |
| | | return hashCode; |
| | | } |
| | | |
| | |
| | | * case insensitive (this is why we iterate through the set of |
| | | * options, rather than doing a simpler set membership test). |
| | | */ |
| | | @Override |
| | | public boolean hasOption(String option) |
| | | { |
| | | String noption = toLowerCase(option); |
| | |
| | | * This implementation retrieves the set of options associated with |
| | | * this attribute and tests to see if it is empty. |
| | | */ |
| | | @Override |
| | | public boolean hasOptions() |
| | | { |
| | | return !getOptions().isEmpty(); |
| | |
| | | * This implementation returns <code>true</code> if the |
| | | * {@link #size()} of this attribute is zero. |
| | | */ |
| | | @Override |
| | | public boolean isEmpty() |
| | | { |
| | | return size() == 0; |
| | |
| | | * {@link #hasOption(String)} and <code>true</code> is |
| | | * returned if all the provided options are present. |
| | | */ |
| | | @Override |
| | | public boolean optionsEqual(Set<String> options) |
| | | { |
| | | if (options == null) |
| | |
| | | import java.util.Map; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.core.PasswordPolicy; |
| | | import org.opends.server.core.PasswordPolicyState; |
| | | |
| | |
| | | AccountStatusNotificationProperty.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines a data type for storing information associated |
| | | * with an account status notification. |
| | |
| | | createProperties( |
| | | PasswordPolicyState pwPolicyState, |
| | | boolean tempLocked, int timeToExpiration, |
| | | List<AttributeValue> oldPasswords, |
| | | List<AttributeValue> newPasswords) |
| | | List<ByteString> oldPasswords, |
| | | List<ByteString> newPasswords) |
| | | { |
| | | HashMap<AccountStatusNotificationProperty,List<String>> props = |
| | | new HashMap<AccountStatusNotificationProperty, |
| | |
| | | |
| | | if ((oldPasswords != null) && (! oldPasswords.isEmpty())) |
| | | { |
| | | propList = new ArrayList<String>(oldPasswords.size()); |
| | | for (AttributeValue v : oldPasswords) |
| | | { |
| | | propList.add(v.getValue().toString()); |
| | | } |
| | | |
| | | props.put(OLD_PASSWORD, propList); |
| | | props.put(OLD_PASSWORD, toStrings(oldPasswords)); |
| | | } |
| | | |
| | | if ((newPasswords != null) && (! newPasswords.isEmpty())) |
| | | { |
| | | propList = new ArrayList<String>(newPasswords.size()); |
| | | for (AttributeValue v : newPasswords) |
| | | { |
| | | propList.add(v.getValue().toString()); |
| | | } |
| | | |
| | | props.put(NEW_PASSWORD, propList); |
| | | props.put(NEW_PASSWORD, toStrings(newPasswords)); |
| | | } |
| | | |
| | | return props; |
| | | } |
| | | |
| | | private static ArrayList<String> toStrings(List<ByteString> byteStrings) |
| | | { |
| | | ArrayList<String> results = new ArrayList<String>(byteStrings.size()); |
| | | for (ByteString v : byteStrings) |
| | | { |
| | | results.add(v.toString()); |
| | | } |
| | | return results; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | mayInstantiate = false, |
| | | mayExtend = false, |
| | | mayInvoke = true) |
| | | public interface Attribute extends Iterable<AttributeValue> |
| | | public interface Attribute extends Iterable<ByteString> |
| | | { |
| | | |
| | | /** |
| | |
| | | * least one value is approximately equal to the provided |
| | | * value, or <CODE>false</CODE> otherwise. |
| | | */ |
| | | ConditionResult approximatelyEqualTo(AttributeValue value); |
| | | ConditionResult approximatelyEqualTo(ByteString value); |
| | | |
| | | |
| | | |
| | |
| | | * @return <CODE>true</CODE> if this attribute has the specified |
| | | * value, or <CODE>false</CODE> if not. |
| | | */ |
| | | boolean contains(AttributeValue value); |
| | | boolean contains(ByteString value); |
| | | |
| | | |
| | | |
| | |
| | | * values in the provided collection, or <CODE>false</CODE> |
| | | * if it does not contain at least one of them. |
| | | */ |
| | | boolean containsAll(Collection<AttributeValue> values); |
| | | boolean containsAll(Collection<ByteString> values); |
| | | |
| | | |
| | | |
| | |
| | | * least one value is greater than or equal to the provided |
| | | * value, or <CODE>false</CODE> otherwise. |
| | | */ |
| | | ConditionResult greaterThanOrEqualTo(AttributeValue value); |
| | | ConditionResult greaterThanOrEqualTo(ByteString value); |
| | | |
| | | |
| | | |
| | |
| | | * @return An iterator over the attribute values in this attribute. |
| | | */ |
| | | @Override |
| | | Iterator<AttributeValue> iterator(); |
| | | Iterator<ByteString> iterator(); |
| | | |
| | | |
| | | |
| | |
| | | * least one value is less than or equal to the provided |
| | | * value, or <CODE>false</CODE> otherwise. |
| | | */ |
| | | ConditionResult lessThanOrEqualTo(AttributeValue value); |
| | | ConditionResult lessThanOrEqualTo(ByteString value); |
| | | |
| | | |
| | | |
| | |
| | | import java.util.Collections; |
| | | import java.util.Iterator; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Map.Entry; |
| | | import java.util.NoSuchElementException; |
| | | import java.util.Set; |
| | | import java.util.SortedSet; |
| | |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.util.Reject; |
| | | import org.forgerock.util.Utils; |
| | | import org.opends.server.api.MatchingRule; |
| | | import org.opends.server.api.OrderingMatchingRule; |
| | | import org.opends.server.api.SubstringMatchingRule; |
| | |
| | | * {@link #AttributeBuilder(AttributeType)} or |
| | | * {@link #AttributeBuilder(AttributeType, String)}. The caller is |
| | | * then free to add new options using {@link #setOption(String)} and |
| | | * new values using {@link #add(AttributeValue)} or |
| | | * new values using {@link #add(ByteString)} or |
| | | * {@link #addAll(Collection)}. Once all the options and values have |
| | | * been added, the attribute can be retrieved using the |
| | | * {@link #toAttribute()} method. |
| | |
| | | mayExtend = false, |
| | | mayInvoke = true) |
| | | public final class AttributeBuilder |
| | | implements Iterable<AttributeValue> |
| | | implements Iterable<ByteString> |
| | | { |
| | | |
| | | /** |
| | |
| | | private final String name; |
| | | |
| | | // The unmodifiable set of values for this attribute. |
| | | private final Set<AttributeValue> values; |
| | | private final Map<ByteString, ByteString> values; |
| | | |
| | | |
| | | |
| | |
| | | private RealAttribute( |
| | | AttributeType attributeType, |
| | | String name, |
| | | Set<AttributeValue> values) |
| | | Map<ByteString, ByteString> values) |
| | | { |
| | | this.attributeType = attributeType; |
| | | this.name = name; |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public final ConditionResult approximatelyEqualTo(AttributeValue value) |
| | | public final ConditionResult approximatelyEqualTo(ByteString value) |
| | | { |
| | | MatchingRule matchingRule = attributeType.getApproximateMatchingRule(); |
| | | if (matchingRule == null) |
| | |
| | | Assertion assertion = null; |
| | | try |
| | | { |
| | | assertion = matchingRule.getAssertion(value.getValue()); |
| | | assertion = matchingRule.getAssertion(value); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | } |
| | | |
| | | ConditionResult result = ConditionResult.FALSE; |
| | | for (AttributeValue v : values) |
| | | for (ByteString v : values.values()) |
| | | { |
| | | try |
| | | { |
| | | result = assertion.matches(matchingRule.normalizeAttributeValue(v.getValue())); |
| | | result = assertion.matches(matchingRule.normalizeAttributeValue(v)); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public final boolean contains(AttributeValue value) |
| | | public final boolean contains(ByteString value) |
| | | { |
| | | return values.contains(value); |
| | | return values.containsKey(normalize(attributeType, value)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public final boolean containsAll( |
| | | Collection<AttributeValue> values) |
| | | { |
| | | return this.values.containsAll(values); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public final ConditionResult greaterThanOrEqualTo( |
| | | AttributeValue value) |
| | | public final ConditionResult greaterThanOrEqualTo(ByteString value) |
| | | { |
| | | OrderingMatchingRule matchingRule = attributeType |
| | | .getOrderingMatchingRule(); |
| | |
| | | ByteString normalizedValue; |
| | | try |
| | | { |
| | | normalizedValue = matchingRule.normalizeAttributeValue(value.getValue()); |
| | | normalizedValue = matchingRule.normalizeAttributeValue(value); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | } |
| | | |
| | | ConditionResult result = ConditionResult.FALSE; |
| | | for (AttributeValue v : values) |
| | | for (ByteString v : values.values()) |
| | | { |
| | | try |
| | | { |
| | | ByteString nv = matchingRule.normalizeAttributeValue(v.getValue()); |
| | | int comparisonResult = matchingRule |
| | | .compareValues(nv, normalizedValue); |
| | | if (comparisonResult >= 0) |
| | | ByteString nv = matchingRule.normalizeAttributeValue(v); |
| | | if (matchingRule.compareValues(nv, normalizedValue) >= 0) |
| | | { |
| | | return ConditionResult.TRUE; |
| | | } |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public final Iterator<AttributeValue> iterator() |
| | | public final Iterator<ByteString> iterator() |
| | | { |
| | | return values.iterator(); |
| | | return values.values().iterator(); |
| | | } |
| | | |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public final ConditionResult lessThanOrEqualTo( |
| | | AttributeValue value) |
| | | public final ConditionResult lessThanOrEqualTo(ByteString value) |
| | | { |
| | | OrderingMatchingRule matchingRule = attributeType |
| | | .getOrderingMatchingRule(); |
| | |
| | | ByteString normalizedValue; |
| | | try |
| | | { |
| | | normalizedValue = matchingRule.normalizeAttributeValue(value.getValue()); |
| | | normalizedValue = matchingRule.normalizeAttributeValue(value); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | } |
| | | |
| | | ConditionResult result = ConditionResult.FALSE; |
| | | for (AttributeValue v : values) |
| | | for (ByteString v : values.values()) |
| | | { |
| | | try |
| | | { |
| | | ByteString nv = matchingRule.normalizeAttributeValue(v.getValue()); |
| | | int comparisonResult = matchingRule |
| | | .compareValues(nv, normalizedValue); |
| | | if (comparisonResult <= 0) |
| | | ByteString nv = matchingRule.normalizeAttributeValue(v); |
| | | if (matchingRule.compareValues(nv, normalizedValue) <= 0) |
| | | { |
| | | return ConditionResult.TRUE; |
| | | } |
| | |
| | | } |
| | | |
| | | ConditionResult result = ConditionResult.FALSE; |
| | | for (AttributeValue value : values) |
| | | for (ByteString value : values.values()) |
| | | { |
| | | try |
| | | { |
| | | if (matchingRule.valueMatchesSubstring( |
| | | attributeType.getSubstringMatchingRule(). |
| | | normalizeAttributeValue(value.getValue()), |
| | | matchingRule.normalizeAttributeValue(value), |
| | | normalizedSubInitial, |
| | | normalizedSubAny, |
| | | normalizedSubFinal)) |
| | |
| | | return values.size(); |
| | | } |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int hashCode() |
| | | { |
| | | int hashCode = getAttributeType().hashCode(); |
| | | for (ByteString value : values.keySet()) |
| | | { |
| | | hashCode += value.hashCode(); |
| | | } |
| | | return hashCode; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | |
| | | buffer.append("Attribute("); |
| | | buffer.append(getNameWithOptions()); |
| | | buffer.append(", {"); |
| | | |
| | | boolean firstValue = true; |
| | | for (AttributeValue value : values) |
| | | { |
| | | if (!firstValue) |
| | | { |
| | | buffer.append(", "); |
| | | } |
| | | |
| | | value.toString(buffer); |
| | | firstValue = false; |
| | | } |
| | | |
| | | buffer.append(Utils.joinAsString(", ", values.keySet())); |
| | | buffer.append("})"); |
| | | } |
| | | |
| | |
| | | private RealAttributeManyOptions( |
| | | AttributeType attributeType, |
| | | String name, |
| | | Set<AttributeValue> values, |
| | | Map<ByteString, ByteString> values, |
| | | Set<String> options, |
| | | SortedSet<String> normalizedOptions) |
| | | { |
| | |
| | | private RealAttributeNoOptions( |
| | | AttributeType attributeType, |
| | | String name, |
| | | Set<AttributeValue> values) |
| | | Map<ByteString, ByteString> values) |
| | | { |
| | | super(attributeType, name, values); |
| | | } |
| | |
| | | private RealAttributeSingleOption( |
| | | AttributeType attributeType, |
| | | String name, |
| | | Set<AttributeValue> values, |
| | | Map<ByteString, ByteString> values, |
| | | String option) |
| | | { |
| | | super(attributeType, name, values); |
| | |
| | | */ |
| | | private static final class SmallSet<T> |
| | | extends AbstractSet<T> |
| | | implements Set<T> |
| | | { |
| | | |
| | | // The set of elements if there are more than one. |
| | |
| | | * @return The new attribute. |
| | | */ |
| | | static Attribute create(AttributeType attributeType, String name, |
| | | Set<AttributeValue> values) |
| | | Set<ByteString> values) |
| | | { |
| | | return new RealAttributeNoOptions(attributeType, name, values); |
| | | final AttributeBuilder builder = new AttributeBuilder(attributeType, name); |
| | | builder.addAll(values); |
| | | return builder.toAttribute(); |
| | | } |
| | | |
| | | |
| | |
| | | // The set of options. |
| | | private final SmallSet<String> options = new SmallSet<String>(); |
| | | |
| | | // The set of values for this attribute. |
| | | private final SmallSet<AttributeValue> values = |
| | | new SmallSet<AttributeValue>(); |
| | | /** The map of normalized values => values for this attribute. */ |
| | | private LinkedHashMap<ByteString, ByteString> values = |
| | | new LinkedHashMap<ByteString, ByteString>(); |
| | | |
| | | |
| | | |
| | |
| | | * Adds the specified attribute value to this attribute builder if |
| | | * it is not already present. |
| | | * |
| | | * @param value |
| | | * The attribute value to be added to this attribute |
| | | * builder. |
| | | * @return <code>true</code> if this attribute builder did not |
| | | * already contain the specified attribute value. |
| | | */ |
| | | public boolean add(AttributeValue value) |
| | | { |
| | | return values.add(value); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Adds the specified attribute value to this attribute builder if |
| | | * it is not already present. |
| | | * |
| | | * @param valueString |
| | | * The string representation of the attribute value to be |
| | | * added to this attribute builder. |
| | |
| | | */ |
| | | public boolean add(String valueString) |
| | | { |
| | | return add(AttributeValues.create(attributeType, valueString)); |
| | | return add(ByteString.valueOf(valueString)); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | public boolean add(ByteString value) |
| | | { |
| | | return add(AttributeValues.create(attributeType, value)); |
| | | return values.put(normalize(value), value) == null; |
| | | } |
| | | |
| | | private ByteString normalize(ByteString value) |
| | | { |
| | | return normalize(attributeType, value); |
| | | } |
| | | |
| | | private static ByteString normalize(AttributeType attributeType, ByteString value) |
| | | { |
| | | try |
| | | { |
| | | if (attributeType != null) |
| | | { |
| | | final MatchingRule eqRule = attributeType.getEqualityMatchingRule(); |
| | | return eqRule.normalizeAttributeValue(value); |
| | | } |
| | | } |
| | | catch (DecodeException e) |
| | | { |
| | | // nothing to do here |
| | | } |
| | | return value; |
| | | } |
| | | |
| | | /** |
| | |
| | | public boolean addAll(Attribute attribute) |
| | | { |
| | | boolean wasModified = false; |
| | | for (AttributeValue v : attribute) |
| | | for (ByteString v : attribute) |
| | | { |
| | | wasModified |= add(v); |
| | | } |
| | |
| | | * @return <code>true</code> if this attribute builder was |
| | | * modified. |
| | | */ |
| | | public boolean addAll(Collection<AttributeValue> values) |
| | | public boolean addAll(Collection<ByteString> values) |
| | | { |
| | | return this.values.addAll(values); |
| | | boolean wasModified = false; |
| | | for (ByteString v : values) |
| | | { |
| | | wasModified |= add(v); |
| | | } |
| | | return wasModified; |
| | | } |
| | | |
| | | |
| | |
| | | * @return <CODE>true</CODE> if this attribute builder has the |
| | | * specified value, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean contains(AttributeValue value) |
| | | public boolean contains(ByteString value) |
| | | { |
| | | return values.contains(value); |
| | | return values.containsKey(normalize(value)); |
| | | } |
| | | |
| | | |
| | |
| | | * <CODE>false</CODE> if it does not contain at least one |
| | | * of them. |
| | | */ |
| | | public boolean containsAll(Collection<AttributeValue> values) |
| | | public boolean containsAll(Collection<ByteString> values) |
| | | { |
| | | return this.values.containsAll(values); |
| | | for (ByteString v : values) |
| | | { |
| | | if (!contains(v)) |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | |
| | |
| | | * builder. |
| | | */ |
| | | @Override |
| | | public Iterator<AttributeValue> iterator() |
| | | public Iterator<ByteString> iterator() |
| | | { |
| | | return values.iterator(); |
| | | return values.values().iterator(); |
| | | } |
| | | |
| | | |
| | |
| | | * @return <code>true</code> if this attribute builder contained |
| | | * the specified attribute value. |
| | | */ |
| | | public boolean remove(AttributeValue value) |
| | | public boolean remove(ByteString value) |
| | | { |
| | | return values.remove(value); |
| | | return values.remove(normalize(value)) != null; |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | public boolean remove(String valueString) |
| | | { |
| | | AttributeValue value = |
| | | AttributeValues.create(attributeType, valueString); |
| | | return remove(value); |
| | | return remove(ByteString.valueOf(valueString)); |
| | | } |
| | | |
| | | |
| | |
| | | public boolean removeAll(Attribute attribute) |
| | | { |
| | | boolean wasModified = false; |
| | | for (AttributeValue v : attribute) |
| | | for (ByteString v : attribute) |
| | | { |
| | | wasModified |= remove(v); |
| | | } |
| | |
| | | * @return <code>true</code> if this attribute builder was |
| | | * modified. |
| | | */ |
| | | public boolean removeAll(Collection<AttributeValue> values) |
| | | public boolean removeAll(Collection<ByteString> values) |
| | | { |
| | | return this.values.removeAll(values); |
| | | boolean wasModified = false; |
| | | for (ByteString v : values) |
| | | { |
| | | wasModified |= remove(v); |
| | | } |
| | | return wasModified; |
| | | } |
| | | |
| | | |
| | |
| | | * @param value |
| | | * The attribute value to replace all existing values. |
| | | */ |
| | | public void replace(AttributeValue value) |
| | | public void replace(ByteString value) |
| | | { |
| | | clear(); |
| | | add(value); |
| | |
| | | */ |
| | | public void replace(String valueString) |
| | | { |
| | | AttributeValue value = |
| | | AttributeValues.create(attributeType, valueString); |
| | | replace(value); |
| | | replace(ByteString.valueOf(valueString)); |
| | | } |
| | | |
| | | |
| | |
| | | * @param values |
| | | * The attribute values to replace all existing values. |
| | | */ |
| | | public void replaceAll(Collection<AttributeValue> values) |
| | | public void replaceAll(Collection<ByteString> values) |
| | | { |
| | | clear(); |
| | | addAll(values); |
| | |
| | | public AttributeBuilder setInitialCapacity(int initialCapacity) |
| | | throws IllegalStateException |
| | | { |
| | | values.setInitialCapacity(initialCapacity); |
| | | // This is now a no op. |
| | | return this; |
| | | } |
| | | |
| | |
| | | |
| | | // First determine the minimum representation required for the set |
| | | // of values. |
| | | Set<AttributeValue> newValues; |
| | | if (values.elements != null) |
| | | final int size = values.size(); |
| | | Map<ByteString, ByteString> newValues; |
| | | if (size == 0) |
| | | { |
| | | newValues = Collections.unmodifiableSet(values.elements); |
| | | newValues = Collections.emptyMap(); |
| | | } |
| | | else if (values.firstElement != null) |
| | | else if (size == 1) |
| | | { |
| | | newValues = Collections.singleton(values.firstElement); |
| | | Entry<ByteString, ByteString> entry = values.entrySet().iterator().next(); |
| | | newValues = Collections.singletonMap(entry.getKey(), entry.getValue()); |
| | | values.clear(); |
| | | } |
| | | else |
| | | { |
| | | newValues = Collections.emptySet(); |
| | | newValues = Collections.unmodifiableMap(values); |
| | | values = new LinkedHashMap<ByteString, ByteString>(); |
| | | } |
| | | |
| | | // Now create the appropriate attribute based on the options. |
| | |
| | | switch (options.size()) |
| | | { |
| | | case 0: |
| | | attribute = |
| | | new RealAttributeNoOptions(attributeType, name, newValues); |
| | | attribute = new RealAttributeNoOptions(attributeType, name, newValues); |
| | | break; |
| | | case 1: |
| | | attribute = |
| | |
| | | name = null; |
| | | normalizedOptions = null; |
| | | options.clear(); |
| | | values.clear(); |
| | | |
| | | return attribute; |
| | | } |
| | |
| | | StringBuilder builder = new StringBuilder(); |
| | | |
| | | builder.append("AttributeBuilder("); |
| | | builder.append(String.valueOf(name)); |
| | | builder.append(name); |
| | | |
| | | for (String option : options) |
| | | { |
| | |
| | | } |
| | | |
| | | builder.append(", {"); |
| | | |
| | | boolean firstValue = true; |
| | | for (AttributeValue value : values) |
| | | { |
| | | if (!firstValue) |
| | | { |
| | | builder.append(", "); |
| | | } |
| | | |
| | | value.toString(builder); |
| | | firstValue = false; |
| | | } |
| | | |
| | | builder.append(Utils.joinAsString(", ", values.keySet())); |
| | | builder.append("})"); |
| | | |
| | | return builder.toString(); |
| | |
| | | */ |
| | | public <T> T as(final Function<ByteString, ? extends T, Void> f, final T defaultValue) { |
| | | if (!isEmpty(attribute)) { |
| | | return f.apply(attribute.iterator().next().getValue(), null); |
| | | return f.apply(attribute.iterator().next(), null); |
| | | } else { |
| | | return defaultValue; |
| | | } |
| | |
| | | final Collection<? extends T> defaultValues) { |
| | | if (!isEmpty(attribute)) { |
| | | final LinkedHashSet<T> result = new LinkedHashSet<T>(attribute.size()); |
| | | for (final AttributeValue v : attribute) { |
| | | result.add(f.apply(v.getValue(), null)); |
| | | for (final ByteString v : attribute) { |
| | | result.add(f.apply(v, null)); |
| | | } |
| | | return result; |
| | | } else if (defaultValues != null) { |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | |
| | | import java.util.Iterator; |
| | | import java.util.NoSuchElementException; |
| | | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | |
| | | /** |
| | | * An iterable read-only view of of a set of attribute values returned |
| | |
| | | mayInstantiate=false, |
| | | mayExtend=false, |
| | | mayInvoke=true) |
| | | public final class AttributeValueIterable implements |
| | | Iterable<AttributeValue> { |
| | | public final class AttributeValueIterable implements Iterable<ByteString> { |
| | | |
| | | // The set of attributes having the same type and options. |
| | | private Iterable<Attribute> attributes; |
| | |
| | | * @return An iterator that can be used to cursor through the set |
| | | * of attribute values. |
| | | */ |
| | | public Iterator<AttributeValue> iterator() { |
| | | |
| | | public Iterator<ByteString> iterator() { |
| | | return new AttributeValueIterator(); |
| | | } |
| | | |
| | | /** |
| | | * Private iterator implementation. |
| | | */ |
| | | private class AttributeValueIterator |
| | | implements Iterator<AttributeValue> { |
| | | private class AttributeValueIterator implements Iterator<ByteString> { |
| | | // Flag indicating whether iteration can proceed. |
| | | private boolean hasNext; |
| | | |
| | |
| | | private Iterator<Attribute> attributeIterator; |
| | | |
| | | // The current value iterator. |
| | | private Iterator<AttributeValue> valueIterator; |
| | | private Iterator<ByteString> valueIterator; |
| | | |
| | | /** |
| | | * Create a new attribute value iterator over the attribute set. |
| | |
| | | * return, or {@code false} if not. |
| | | */ |
| | | public boolean hasNext() { |
| | | |
| | | return hasNext; |
| | | } |
| | | |
| | |
| | | * @throws NoSuchElementException If there are no more values to |
| | | * return. |
| | | */ |
| | | public AttributeValue next() |
| | | throws NoSuchElementException |
| | | public ByteString next() throws NoSuchElementException |
| | | { |
| | | if (hasNext == false) { |
| | | throw new NoSuchElementException(); |
| | | } |
| | | |
| | | AttributeValue value = valueIterator.next(); |
| | | ByteString value = valueIterator.next(); |
| | | |
| | | // We've reached the end of this array list, so skip to the next |
| | | // non-empty one. |
| | |
| | | * @throws UnsupportedOperationException If the last value |
| | | * cannot be removed. |
| | | */ |
| | | public void remove() |
| | | throws UnsupportedOperationException |
| | | public void remove() throws UnsupportedOperationException |
| | | { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.core.DirectoryServer; |
| | | |
| | | |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | /** |
| | | * This class contains various methods for manipulating |
| | |
| | | * The attribute value. |
| | | * @return A new attribute with the attribute type and value. |
| | | */ |
| | | public static Attribute create(AttributeType attributeType, |
| | | AttributeValue value) |
| | | public static Attribute create(AttributeType attributeType, ByteString value) |
| | | { |
| | | return create(attributeType, attributeType.getNameOrOID(), value); |
| | | } |
| | |
| | | * @return A new attribute with the attribute type and value. |
| | | */ |
| | | public static Attribute create(AttributeType attributeType, |
| | | String name, AttributeValue value) |
| | | String name, ByteString value) |
| | | { |
| | | return AttributeBuilder.create(attributeType, name, Collections |
| | | .singleton(value)); |
| | |
| | | public static Attribute create(AttributeType attributeType, |
| | | String name, String valueString) |
| | | { |
| | | AttributeValue value = AttributeValues.create(attributeType, |
| | | valueString); |
| | | ByteString value = ByteString.valueOf(valueString); |
| | | return create(attributeType, name, value); |
| | | } |
| | | |
| | |
| | | String name) |
| | | { |
| | | return AttributeBuilder.create(attributeType, name, Collections |
| | | .<AttributeValue> emptySet()); |
| | | .<ByteString> emptySet()); |
| | | } |
| | | |
| | | |
| | |
| | | * provided attributes. |
| | | */ |
| | | public static Attribute merge(Attribute a1, Attribute a2, |
| | | Collection<AttributeValue> duplicateValues) |
| | | Collection<ByteString> duplicateValues) |
| | | { |
| | | AttributeBuilder builder = new AttributeBuilder(a1); |
| | | for (AttributeValue av : a2) |
| | | for (ByteString av : a2) |
| | | { |
| | | if (!builder.add(av) && duplicateValues != null) |
| | | { |
| | |
| | | * attribute which are not in the second attribute. |
| | | */ |
| | | public static Attribute subtract(Attribute a1, Attribute a2, |
| | | Collection<AttributeValue> missingValues) |
| | | Collection<ByteString> missingValues) |
| | | { |
| | | AttributeBuilder builder = new AttributeBuilder(a1); |
| | | for (AttributeValue av : a2) |
| | | for (ByteString av : a2) |
| | | { |
| | | if (!builder.remove(av) && missingValues != null) |
| | | { |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConditionResult approximatelyEqualTo(AttributeValue value) { |
| | | public ConditionResult approximatelyEqualTo(ByteString value) { |
| | | return attribute.approximatelyEqualTo(value); |
| | | } |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean contains(AttributeValue value) { |
| | | public boolean contains(ByteString value) { |
| | | return attribute.contains(value); |
| | | } |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConditionResult greaterThanOrEqualTo(AttributeValue value) { |
| | | public ConditionResult greaterThanOrEqualTo(ByteString value) { |
| | | return attribute.greaterThanOrEqualTo(value); |
| | | } |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public Iterator<AttributeValue> iterator() { |
| | | public Iterator<ByteString> iterator() { |
| | | return attribute.iterator(); |
| | | } |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConditionResult lessThanOrEqualTo(AttributeValue value) { |
| | | public ConditionResult lessThanOrEqualTo(ByteString value) { |
| | | return attribute.lessThanOrEqualTo(value); |
| | | } |
| | | |
| | |
| | | return attribute.size(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int hashCode() |
| | | { |
| | | return attribute.hashCode(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | |
| | | attributeNameString); |
| | | } |
| | | |
| | | AttributeValue value = |
| | | AttributeValues.create(ByteString.empty(), |
| | | ByteString.empty()); |
| | | rdnComponents.add( |
| | | new RDN(attrType, attributeNameString, value)); |
| | | new RDN(attrType, attributeNameString, ByteString.empty())); |
| | | return new DN(rdnComponents); |
| | | } |
| | | |
| | |
| | | attributeNameString); |
| | | } |
| | | |
| | | AttributeValue value = |
| | | AttributeValues.create(attrType, parsedValue); |
| | | RDN rdn = new RDN(attrType, attributeNameString, value); |
| | | RDN rdn = new RDN(attrType, attributeNameString, parsedValue); |
| | | |
| | | |
| | | // Skip over any spaces that might be after the attribute value. |
| | |
| | | attributeNameString); |
| | | } |
| | | |
| | | value = AttributeValues.create(ByteString.empty(), |
| | | ByteString.empty()); |
| | | rdn.addValue(attrType, attributeNameString, value); |
| | | rdn.addValue(attrType, attributeNameString, ByteString.empty()); |
| | | rdnComponents.add(rdn); |
| | | return new DN(rdnComponents); |
| | | } |
| | |
| | | attributeNameString); |
| | | } |
| | | |
| | | value = AttributeValues.create(attrType, parsedValue); |
| | | rdn.addValue(attrType, attributeNameString, value); |
| | | rdn.addValue(attrType, attributeNameString, parsedValue); |
| | | |
| | | |
| | | // Skip over any spaces that might be after the attribute |
| | |
| | | attrType = DirectoryServer.getDefaultAttributeType(name); |
| | | } |
| | | |
| | | AttributeValue value = |
| | | AttributeValues.create(ByteString.empty(), |
| | | ByteString.empty()); |
| | | rdnComponents.add(new RDN(attrType, name, value)); |
| | | rdnComponents.add(new RDN(attrType, name, ByteString.empty())); |
| | | return new DN(rdnComponents); |
| | | } |
| | | |
| | |
| | | attrType = DirectoryServer.getDefaultAttributeType(name); |
| | | } |
| | | |
| | | AttributeValue value = |
| | | AttributeValues.create(attrType, |
| | | parsedValue.toByteString()); |
| | | RDN rdn = new RDN(attrType, name, value); |
| | | RDN rdn = new RDN(attrType, name, parsedValue.toByteString()); |
| | | |
| | | |
| | | // Skip over any spaces that might be after the attribute value. |
| | |
| | | attrType = DirectoryServer.getDefaultAttributeType(name); |
| | | } |
| | | |
| | | value = AttributeValues.create(ByteString.empty(), |
| | | ByteString.empty()); |
| | | rdn.addValue(attrType, name, value); |
| | | rdn.addValue(attrType, name, ByteString.empty()); |
| | | rdnComponents.add(rdn); |
| | | return new DN(rdnComponents); |
| | | } |
| | |
| | | attrType = DirectoryServer.getDefaultAttributeType(name); |
| | | } |
| | | |
| | | value = AttributeValues.create(attrType, |
| | | parsedValue.toByteString()); |
| | | rdn.addValue(attrType, name, value); |
| | | rdn.addValue(attrType, name, parsedValue.toByteString()); |
| | | |
| | | |
| | | // Skip over any spaces that might be after the attribute |
| | |
| | | |
| | | if(objectClassAttribute == null) |
| | | { |
| | | AttributeType ocType = |
| | | DirectoryServer.getObjectClassAttributeType(); |
| | | AttributeBuilder builder = |
| | | new AttributeBuilder(ocType, ATTR_OBJECTCLASS); |
| | | |
| | | for (Map.Entry<ObjectClass, String> e : |
| | | objectClasses.entrySet()) |
| | | AttributeType ocType = DirectoryServer.getObjectClassAttributeType(); |
| | | AttributeBuilder builder = new AttributeBuilder(ocType, ATTR_OBJECTCLASS); |
| | | for (Map.Entry<ObjectClass, String> e : objectClasses.entrySet()) |
| | | { |
| | | builder.add(AttributeValues.create( |
| | | ByteString.valueOf(e.getValue()), |
| | | ByteString.valueOf(e.getKey() |
| | | .getNormalizedPrimaryName()))); |
| | | builder.add(e.getValue()); |
| | | } |
| | | |
| | | objectClassAttribute = builder.toAttribute(); |
| | |
| | | * @param duplicateValues |
| | | * A list to which any duplicate values will be added. |
| | | */ |
| | | public void addAttribute(Attribute attribute, |
| | | List<AttributeValue> duplicateValues) |
| | | public void addAttribute(Attribute attribute, List<ByteString> duplicateValues) |
| | | { |
| | | setAttribute(attribute, duplicateValues, false /* merge */); |
| | | } |
| | |
| | | } |
| | | |
| | | // Decode the increment. |
| | | Iterator<AttributeValue> i = attribute.iterator(); |
| | | Iterator<ByteString> i = attribute.iterator(); |
| | | if (!i.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_ENTRY_INCREMENT_INVALID_VALUE_COUNT.get( |
| | |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | |
| | | String incrementValue = i.next().getValue().toString(); |
| | | String incrementValue = i.next().toString(); |
| | | long increment; |
| | | try |
| | | { |
| | |
| | | // Increment each attribute value by the specified amount. |
| | | AttributeBuilder builder = new AttributeBuilder(a, true); |
| | | |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | String s = v.getValue().toString(); |
| | | long currentValue; |
| | | try |
| | | { |
| | | currentValue = Long.parseLong(s); |
| | | currentValue = Long.parseLong(v.toString()); |
| | | } |
| | | catch (NumberFormatException e) |
| | | { |
| | |
| | | } |
| | | |
| | | long newValue = currentValue + increment; |
| | | builder.add(AttributeValues.create(attributeType, String |
| | | .valueOf(newValue))); |
| | | builder.add(String.valueOf(newValue)); |
| | | } |
| | | |
| | | replaceAttribute(builder.toAttribute()); |
| | |
| | | * but will add those values to the provided list. |
| | | */ |
| | | public boolean removeAttribute(Attribute attribute, |
| | | List<AttributeValue> missingValues) |
| | | List<ByteString> missingValues) |
| | | { |
| | | attachment = null; |
| | | |
| | |
| | | |
| | | MatchingRule rule = |
| | | attribute.getAttributeType().getEqualityMatchingRule(); |
| | | for (AttributeValue v : attribute) |
| | | for (ByteString v : attribute) |
| | | { |
| | | String ocName = toLowerName(rule, v.getValue()); |
| | | String ocName = toLowerName(rule, v); |
| | | |
| | | boolean matchFound = false; |
| | | for (ObjectClass oc : objectClasses.keySet()) |
| | |
| | | if (attributes == null) |
| | | { |
| | | // There are no attributes with the same attribute type. |
| | | for (AttributeValue v : attribute) |
| | | for (ByteString v : attribute) |
| | | { |
| | | missingValues.add(v); |
| | | } |
| | |
| | | { |
| | | // Remove Specified values. |
| | | AttributeBuilder builder = new AttributeBuilder(a); |
| | | for (AttributeValue v : attribute) |
| | | for (ByteString v : attribute) |
| | | { |
| | | if (!builder.remove(v)) |
| | | { |
| | |
| | | * attribute value, or <CODE>false</CODE> if it does not. |
| | | */ |
| | | public boolean hasValue(AttributeType attributeType, |
| | | Set<String> options, AttributeValue value) |
| | | Set<String> options, ByteString value) |
| | | { |
| | | List<Attribute> attrList = getAttribute(attributeType, true); |
| | | if (attrList == null || attrList.isEmpty()) |
| | |
| | | if (t.isObjectClass()) |
| | | { |
| | | Map<ObjectClass, String> ocs = new LinkedHashMap<ObjectClass, String>(); |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | String ocName = v.getValue().toString(); |
| | | String ocName = v.toString(); |
| | | String lowerName = toLowerCase(ocName); |
| | | ObjectClass oc = |
| | | DirectoryServer.getObjectClass(lowerName, true); |
| | |
| | | switch (mod.getModificationType().asEnum()) |
| | | { |
| | | case ADD: |
| | | List<AttributeValue> duplicateValues = new LinkedList<AttributeValue>(); |
| | | List<ByteString> duplicateValues = new LinkedList<ByteString>(); |
| | | addAttribute(a, duplicateValues); |
| | | if (!duplicateValues.isEmpty() && !relaxConstraints) |
| | | { |
| | |
| | | break; |
| | | |
| | | case DELETE: |
| | | List<AttributeValue> missingValues = new LinkedList<AttributeValue>(); |
| | | List<ByteString> missingValues = new LinkedList<ByteString>(); |
| | | removeAttribute(a, missingValues); |
| | | if (!missingValues.isEmpty() && !relaxConstraints) |
| | | { |
| | |
| | | Set<String> referralURLs = new LinkedHashSet<String>(); |
| | | for (Attribute a : refAttrs) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | referralURLs.add(v.getValue().toString()); |
| | | referralURLs.add(v.toString()); |
| | | } |
| | | } |
| | | |
| | |
| | | Attribute aliasAttr = aliasAttrs.get(0); |
| | | if (!aliasAttr.isEmpty()) |
| | | { |
| | | return DN.valueOf(aliasAttr.iterator().next().getValue().toString()); |
| | | return DN.valueOf(aliasAttr.iterator().next().toString()); |
| | | } |
| | | } |
| | | return null; |
| | |
| | | { |
| | | for (Attribute attr : exclusionsAttrList) |
| | | { |
| | | for (AttributeValue attrValue : attr) |
| | | for (ByteString attrValue : attr) |
| | | { |
| | | String exclusionsName = attrValue.toString().toLowerCase(); |
| | | if (VALUE_COLLECTIVE_EXCLUSIONS_EXCLUDE_ALL_LC.equals(exclusionsName) |
| | |
| | | for (Attribute attr : getAttribute( |
| | | subEntry.getInheritFromDNType())) |
| | | { |
| | | for (AttributeValue value : attr) |
| | | for (ByteString value : attr) |
| | | { |
| | | inheritFromDN = DN.decode(value.getValue()); |
| | | inheritFromDN = DN.decode(value); |
| | | // Respect subentry root scope. |
| | | if (!inheritFromDN.isDescendantOf( |
| | | subEntry.getDN().parent())) |
| | |
| | | subEntry.getInheritFromRDNAttrType())) |
| | | { |
| | | inheritFromDN = subEntry.getInheritFromBaseDN(); |
| | | for (AttributeValue value : attr) |
| | | for (ByteString value : attr) |
| | | { |
| | | inheritFromDN = inheritFromDN.child( |
| | | RDN.create(subEntry.getInheritFromRDNType(), |
| | |
| | | buffer.append((byte)0x00); |
| | | |
| | | buffer.appendBERLength(a.size()); |
| | | for(AttributeValue v : a) |
| | | for(ByteString v : a) |
| | | { |
| | | buffer.appendBERLength(v.getValue().length()); |
| | | buffer.append(v.getValue()); |
| | | buffer.appendBERLength(v.length()); |
| | | buffer.append(v); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | ByteString valueBytes = |
| | | entryBuffer.getByteSequence(valueLength).toByteString(); |
| | | builder.add(AttributeValues.create(attributeType, valueBytes)); |
| | | builder.add(valueBytes); |
| | | } |
| | | |
| | | |
| | |
| | | attrName.append(o); |
| | | } |
| | | |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | StringBuilder attrLine = new StringBuilder(attrName); |
| | | appendLDIFSeparatorAndValue(attrLine, v.getValue()); |
| | | appendLDIFSeparatorAndValue(attrLine, v); |
| | | ldifLines.add(attrLine); |
| | | } |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | for (AttributeValue v : attribute) |
| | | for (ByteString v : attribute) |
| | | { |
| | | StringBuilder attrLine = new StringBuilder(attrName); |
| | | appendLDIFSeparatorAndValue(attrLine, v.getValue()); |
| | | appendLDIFSeparatorAndValue(attrLine, v); |
| | | LDIFWriter.writeLDIFLine(attrLine, writer, wrapLines, wrapColumn); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | buffer.append("={"); |
| | | Iterator<AttributeValue> valueIterator = a.iterator(); |
| | | Iterator<ByteString> valueIterator = a.iterator(); |
| | | if (valueIterator.hasNext()) |
| | | { |
| | | buffer.append(valueIterator.next().getValue().toString()); |
| | | buffer.append(valueIterator.next().toString()); |
| | | |
| | | while (valueIterator.hasNext()) |
| | | { |
| | | buffer.append(","); |
| | | buffer.append(valueIterator.next().getValue().toString()); |
| | | buffer.append(valueIterator.next().toString()); |
| | | } |
| | | } |
| | | |
| | |
| | | * existing attribute. |
| | | */ |
| | | private void setAttribute(Attribute attribute, |
| | | List<AttributeValue> duplicateValues, boolean replace) |
| | | List<ByteString> duplicateValues, boolean replace) |
| | | { |
| | | attachment = null; |
| | | |
| | |
| | | |
| | | MatchingRule rule = |
| | | attribute.getAttributeType().getEqualityMatchingRule(); |
| | | for (AttributeValue v : attribute) |
| | | for (ByteString v : attribute) |
| | | { |
| | | String name = v.getValue().toString(); |
| | | String lowerName = toLowerName(rule, v.getValue()); |
| | | String name = v.toString(); |
| | | String lowerName = toLowerName(rule, v); |
| | | |
| | | // Create a default object class if necessary. |
| | | ObjectClass oc = |
| | |
| | | else |
| | | { |
| | | AttributeBuilder builder = new AttributeBuilder(a); |
| | | for (AttributeValue v : attribute) |
| | | for (ByteString v : attribute) |
| | | { |
| | | if (!builder.add(v)) |
| | | { |
| | |
| | | private AttributeType[] attributeTypes; |
| | | |
| | | /** The set of values for the elements in this RDN. */ |
| | | private AttributeValue[] attributeValues; |
| | | private ByteString[] attributeValues; |
| | | |
| | | /** The number of values for this RDN. */ |
| | | private int numValues; |
| | |
| | | * {@code null}. |
| | | */ |
| | | public RDN(AttributeType attributeType, |
| | | AttributeValue attributeValue) |
| | | ByteString attributeValue) |
| | | { |
| | | attributeTypes = new AttributeType[] { attributeType }; |
| | | attributeNames = new String[] { attributeType.getPrimaryName() }; |
| | | attributeValues = new AttributeValue[] { attributeValue }; |
| | | attributeValues = new ByteString[] { attributeValue }; |
| | | |
| | | numValues = 1; |
| | | rdnString = null; |
| | |
| | | * {@code null}. |
| | | */ |
| | | public RDN(AttributeType attributeType, String attributeName, |
| | | AttributeValue attributeValue) |
| | | ByteString attributeValue) |
| | | { |
| | | attributeTypes = new AttributeType[] { attributeType }; |
| | | attributeNames = new String[] { attributeName }; |
| | | attributeValues = new AttributeValue[] { attributeValue }; |
| | | attributeValues = new ByteString[] { attributeValue }; |
| | | |
| | | numValues = 1; |
| | | rdnString = null; |
| | |
| | | */ |
| | | public RDN(List<AttributeType> attributeTypes, |
| | | List<String> attributeNames, |
| | | List<AttributeValue> attributeValues) |
| | | List<ByteString> attributeValues) |
| | | { |
| | | this.attributeTypes = new AttributeType[attributeTypes.size()]; |
| | | this.attributeNames = new String[attributeNames.size()]; |
| | | this.attributeValues = new AttributeValue[attributeValues.size()]; |
| | | this.attributeValues = new ByteString[attributeValues.size()]; |
| | | |
| | | attributeTypes.toArray(this.attributeTypes); |
| | | attributeNames.toArray(this.attributeNames); |
| | |
| | | * {@code attributeTypes} argument. |
| | | */ |
| | | public RDN(AttributeType[] attributeTypes, String[] attributeNames, |
| | | AttributeValue[] attributeValues) |
| | | ByteString[] attributeValues) |
| | | { |
| | | this.numValues = attributeTypes.length; |
| | | this.attributeTypes = attributeTypes; |
| | |
| | | * |
| | | * @return The RDN created with the provided information. |
| | | */ |
| | | public static RDN create(AttributeType attributeType, |
| | | AttributeValue attributeValue) |
| | | public static RDN create(AttributeType attributeType, ByteString attributeValue) |
| | | { |
| | | return new RDN(attributeType, attributeValue); |
| | | } |
| | |
| | | * <CODE>null</CODE> if the specified attribute type is not |
| | | * present in the RDN. |
| | | */ |
| | | public AttributeValue getAttributeValue(AttributeType attributeType) |
| | | public ByteString getAttributeValue(AttributeType attributeType) |
| | | { |
| | | for (int i=0; i < numValues; i++) |
| | | { |
| | |
| | | * @return The value for the attribute type at the specified |
| | | * position in the set of attribute types for this RDN. |
| | | */ |
| | | public AttributeValue getAttributeValue(int pos) |
| | | public ByteString getAttributeValue(int pos) |
| | | { |
| | | return attributeValues[pos]; |
| | | } |
| | |
| | | * @return <CODE>true</CODE> if this RDN contains the specified |
| | | * attribute value, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean hasValue(AttributeType type, AttributeValue value) |
| | | public boolean hasValue(AttributeType type, ByteString value) |
| | | { |
| | | for (int i=0; i < numValues; i++) |
| | | { |
| | |
| | | * this RDN, or <CODE>false</CODE> if it was not (e.g., it |
| | | * was already present). |
| | | */ |
| | | boolean addValue(AttributeType type, String name, AttributeValue value) |
| | | boolean addValue(AttributeType type, String name, ByteString value) |
| | | { |
| | | for (int i=0; i < numValues; i++) |
| | | { |
| | |
| | | newNames[attributeNames.length] = name; |
| | | attributeNames = newNames; |
| | | |
| | | AttributeValue[] newValues = new AttributeValue[numValues]; |
| | | ByteString[] newValues = new ByteString[numValues]; |
| | | System.arraycopy(attributeValues, 0, newValues, 0, attributeValues.length); |
| | | newValues[attributeValues.length] = value; |
| | | attributeValues = newValues; |
| | |
| | | attrType = DirectoryServer.getDefaultAttributeType(name); |
| | | } |
| | | |
| | | AttributeValue value = AttributeValues.create(attrType, |
| | | parsedValue.toByteString()); |
| | | RDN rdn = new RDN(attrType, name, value); |
| | | RDN rdn = new RDN(attrType, name, parsedValue.toByteString()); |
| | | |
| | | |
| | | // Skip over any spaces that might be after the attribute value. |
| | |
| | | attrType = DirectoryServer.getDefaultAttributeType(name); |
| | | } |
| | | |
| | | value = AttributeValues.create(ByteString.empty(), ByteString.empty()); |
| | | rdn.addValue(attrType, name, value); |
| | | rdn.addValue(attrType, name, ByteString.empty()); |
| | | return rdn; |
| | | } |
| | | |
| | |
| | | attrType = DirectoryServer.getDefaultAttributeType(name); |
| | | } |
| | | |
| | | value = AttributeValues.create(attrType, parsedValue.toByteString()); |
| | | rdn.addValue(attrType, name, value); |
| | | rdn.addValue(attrType, name, parsedValue.toByteString()); |
| | | |
| | | |
| | | // Skip over any spaces that might be after the attribute value. |
| | |
| | | String[] newNames = new String[numValues]; |
| | | System.arraycopy(attributeNames, 0, newNames, 0, numValues); |
| | | |
| | | AttributeValue[] newValues = new AttributeValue[numValues]; |
| | | ByteString[] newValues = new ByteString[numValues]; |
| | | System.arraycopy(attributeValues, 0, newValues, 0, numValues); |
| | | |
| | | return new RDN(newTypes, newNames, newValues); |
| | |
| | | |
| | | buffer.append(attributeNames[0]); |
| | | buffer.append("="); |
| | | buffer.append(getDNValue(attributeValues[0].getValue())); |
| | | buffer.append(getDNValue(attributeValues[0])); |
| | | |
| | | for (int i=1; i < numValues; i++) |
| | | { |
| | | buffer.append("+"); |
| | | buffer.append(attributeNames[i]); |
| | | buffer.append("="); |
| | | buffer.append(getDNValue(attributeValues[i].getValue())); |
| | | buffer.append(getDNValue(attributeValues[i])); |
| | | } |
| | | |
| | | rdnString = buffer.toString(); |
| | |
| | | buffer.append(type.getNormalizedPrimaryNameOrOID()); |
| | | buffer.append('='); |
| | | |
| | | AttributeValue value = attributeValues[pos]; |
| | | ByteString value = attributeValues[pos]; |
| | | try |
| | | { |
| | | MatchingRule rule = type.getEqualityMatchingRule(); |
| | | ByteString normValue = rule.normalizeAttributeValue(value.getValue()); |
| | | ByteString normValue = rule.normalizeAttributeValue(value); |
| | | buffer.append(getDNValue(normValue)); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | buffer.append(getDNValue(value.getValue())); |
| | | buffer.append(getDNValue(value)); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | TreeMap<String,AttributeType> typeMap1 = |
| | | new TreeMap<String,AttributeType>(); |
| | | TreeMap<String,AttributeValue> valueMap1 = |
| | | new TreeMap<String,AttributeValue>(); |
| | | TreeMap<String, ByteString> valueMap1 = new TreeMap<String, ByteString>(); |
| | | for (int i=0; i < attributeTypes.length; i++) |
| | | { |
| | | String lowerName = attributeTypes[i].getNormalizedPrimaryNameOrOID(); |
| | |
| | | |
| | | TreeMap<String,AttributeType> typeMap2 = |
| | | new TreeMap<String,AttributeType>(); |
| | | TreeMap<String,AttributeValue> valueMap2 = |
| | | new TreeMap<String,AttributeValue>(); |
| | | TreeMap<String, ByteString> valueMap2 = new TreeMap<String, ByteString>(); |
| | | for (int i=0; i < rdn.attributeTypes.length; i++) |
| | | { |
| | | String lowerName = rdn.attributeTypes[i].getNormalizedPrimaryNameOrOID(); |
| | |
| | | String name2 = iterator2.next(); |
| | | AttributeType type1 = typeMap1.get(name1); |
| | | AttributeType type2 = typeMap2.get(name2); |
| | | AttributeValue value1 = valueMap1.get(name1); |
| | | AttributeValue value2 = valueMap2.get(name2); |
| | | ByteString value1 = valueMap1.get(name1); |
| | | ByteString value2 = valueMap2.get(name2); |
| | | |
| | | while (true) |
| | | { |
| | |
| | | * positive integer if value1 should come after value2, or zero if |
| | | * there is no difference with regard to ordering. |
| | | */ |
| | | private int compare(AttributeValue value1, AttributeValue value2, |
| | | AttributeType type) |
| | | private int compare(ByteString value1, ByteString value2, AttributeType type) |
| | | { |
| | | final OrderingMatchingRule omr = type.getOrderingMatchingRule(); |
| | | final MatchingRule emr = type.getEqualityMatchingRule(); |
| | |
| | | try |
| | | { |
| | | final MatchingRule rule = omr != null ? omr : emr; |
| | | val1 = rule.normalizeAttributeValue(value1.getValue()); |
| | | val2 = rule.normalizeAttributeValue(value2.getValue()); |
| | | val1 = rule.normalizeAttributeValue(value1); |
| | | val2 = rule.normalizeAttributeValue(value2); |
| | | } |
| | | catch (DecodeException e) |
| | | { |
| | | logger.traceException(e); |
| | | val1 = value1.getValue(); |
| | | val2 = value2.getValue(); |
| | | val1 = value1; |
| | | val2 = value2; |
| | | } |
| | | |
| | | if (omr != null) |
| | |
| | | { |
| | | if (!newElements.contains(s)) |
| | | { |
| | | builder.add(AttributeValues.create(attributeTypesType, s)); |
| | | builder.add(s); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | if (!oldElements.contains(s)) |
| | | { |
| | | builder.add(AttributeValues.create(attributeTypesType, s)); |
| | | builder.add(s); |
| | | } |
| | | } |
| | | |
| | |
| | | private final AttributeType attributeType; |
| | | |
| | | // The assertion value for this filter. |
| | | private final AttributeValue assertionValue; |
| | | private final ByteString assertionValue; |
| | | private ByteString normalizedAssertionValue; |
| | | |
| | | // Indicates whether to match on DN attributes for extensible match |
| | | // filters. |
| | |
| | | SearchFilter notComponent, |
| | | AttributeType attributeType, |
| | | Set<String> attributeOptions, |
| | | AttributeValue assertionValue, |
| | | ByteString assertionValue, |
| | | ByteString subInitialElement, |
| | | List<ByteString> subAnyElements, |
| | | ByteString subFinalElement, |
| | |
| | | */ |
| | | public static SearchFilter createEqualityFilter( |
| | | AttributeType attributeType, |
| | | AttributeValue assertionValue) |
| | | ByteString assertionValue) |
| | | { |
| | | return new SearchFilter(FilterType.EQUALITY, null, null, |
| | | attributeType, null, assertionValue, null, |
| | |
| | | public static SearchFilter createEqualityFilter( |
| | | AttributeType attributeType, |
| | | Set<String> attributeOptions, |
| | | AttributeValue assertionValue) |
| | | ByteString assertionValue) |
| | | { |
| | | return new SearchFilter(FilterType.EQUALITY, null, null, |
| | | attributeType, attributeOptions, |
| | |
| | | */ |
| | | public static SearchFilter createGreaterOrEqualFilter( |
| | | AttributeType attributeType, |
| | | AttributeValue assertionValue) |
| | | ByteString assertionValue) |
| | | { |
| | | return new SearchFilter(FilterType.GREATER_OR_EQUAL, null, null, |
| | | attributeType, null, assertionValue, null, |
| | |
| | | public static SearchFilter createGreaterOrEqualFilter( |
| | | AttributeType attributeType, |
| | | Set<String> attributeOptions, |
| | | AttributeValue assertionValue) |
| | | ByteString assertionValue) |
| | | { |
| | | return new SearchFilter(FilterType.GREATER_OR_EQUAL, null, null, |
| | | attributeType, attributeOptions, |
| | |
| | | */ |
| | | public static SearchFilter createLessOrEqualFilter( |
| | | AttributeType attributeType, |
| | | AttributeValue assertionValue) |
| | | ByteString assertionValue) |
| | | { |
| | | return new SearchFilter(FilterType.LESS_OR_EQUAL, null, null, |
| | | attributeType, null, assertionValue, null, |
| | |
| | | public static SearchFilter createLessOrEqualFilter( |
| | | AttributeType attributeType, |
| | | Set<String> attributeOptions, |
| | | AttributeValue assertionValue) |
| | | ByteString assertionValue) |
| | | { |
| | | return new SearchFilter(FilterType.LESS_OR_EQUAL, null, null, |
| | | attributeType, attributeOptions, |
| | |
| | | */ |
| | | public static SearchFilter createApproximateFilter( |
| | | AttributeType attributeType, |
| | | AttributeValue assertionValue) |
| | | ByteString assertionValue) |
| | | { |
| | | return new SearchFilter(FilterType.APPROXIMATE_MATCH, null, null, |
| | | attributeType, null, assertionValue, null, |
| | |
| | | public static SearchFilter createApproximateFilter( |
| | | AttributeType attributeType, |
| | | Set<String> attributeOptions, |
| | | AttributeValue assertionValue) |
| | | ByteString assertionValue) |
| | | { |
| | | return new SearchFilter(FilterType.APPROXIMATE_MATCH, null, null, |
| | | attributeType, attributeOptions, |
| | |
| | | */ |
| | | public static SearchFilter createExtensibleMatchFilter( |
| | | AttributeType attributeType, |
| | | AttributeValue assertionValue, |
| | | ByteString assertionValue, |
| | | String matchingRuleID, |
| | | boolean dnAttributes) |
| | | throws DirectoryException |
| | |
| | | public static SearchFilter createExtensibleMatchFilter( |
| | | AttributeType attributeType, |
| | | Set<String> attributeOptions, |
| | | AttributeValue assertionValue, |
| | | ByteString assertionValue, |
| | | String matchingRuleID, |
| | | boolean dnAttributes) |
| | | throws DirectoryException |
| | |
| | | if (valueStr.length() == 0) |
| | | { |
| | | return new SearchFilter(filterType, null, null, attributeType, |
| | | attributeOptions, |
| | | AttributeValues.create(ByteString.empty(), |
| | | ByteString.empty()), |
| | | attributeOptions, ByteString.empty(), |
| | | null, null, null, null, false); |
| | | } |
| | | else if (valueStr.equals("*")) |
| | |
| | | userValue = ByteString.wrap(valueBytes); |
| | | } |
| | | |
| | | AttributeValue value = |
| | | AttributeValues.create(attributeType, userValue); |
| | | return new SearchFilter(filterType, null, null, attributeType, |
| | | attributeOptions, value, null, null, |
| | | attributeOptions, userValue, null, null, |
| | | null, null, false); |
| | | } |
| | | } |
| | |
| | | // Make sure that the filter contains at least one of an attribute |
| | | // type or a matching rule ID. Also, construct the appropriate |
| | | // attribute value. |
| | | AttributeValue value; |
| | | if (attributeType == null) |
| | | { |
| | | if (matchingRuleID == null) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_SEARCH_FILTER_EXTENSIBLE_MATCH_NO_AD_OR_MR. |
| | | get(filterString, startPos); |
| | | throw new DirectoryException(ResultCode.PROTOCOL_ERROR, |
| | | message); |
| | | ERR_SEARCH_FILTER_EXTENSIBLE_MATCH_NO_AD_OR_MR.get(filterString, startPos)); |
| | | } |
| | | else |
| | | { |
| | | MatchingRule mr = DirectoryServer.getMatchingRule( |
| | | toLowerCase(matchingRuleID)); |
| | | |
| | | MatchingRule mr = DirectoryServer.getMatchingRule(toLowerCase(matchingRuleID)); |
| | | if (mr == null) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_SEARCH_FILTER_EXTENSIBLE_MATCH_NO_SUCH_MR. |
| | | get(filterString, startPos, matchingRuleID); |
| | | throw new DirectoryException(ResultCode.PROTOCOL_ERROR, |
| | | message); |
| | | ERR_SEARCH_FILTER_EXTENSIBLE_MATCH_NO_SUCH_MR.get(filterString, startPos, matchingRuleID)); |
| | | } |
| | | else |
| | | { |
| | | try |
| | | { |
| | | value = AttributeValues.create( |
| | | userValue, mr.normalizeAttributeValue(userValue)); |
| | | } |
| | | catch (DecodeException e) |
| | | { |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | e.getMessageObject(), e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | value = AttributeValues.create(attributeType, |
| | | userValue); |
| | | } |
| | | |
| | | return new SearchFilter(FilterType.EXTENSIBLE_MATCH, null, null, |
| | | attributeType, attributeOptions, value, |
| | | attributeType, attributeOptions, userValue, |
| | | null, null, null, matchingRuleID, |
| | | dnAttributes); |
| | | } |
| | |
| | | * @return The assertion value for this filter, or |
| | | * <CODE>null</CODE> if there is none. |
| | | */ |
| | | public AttributeValue getAssertionValue() |
| | | public ByteString getAssertionValue() |
| | | { |
| | | return assertionValue; |
| | | } |
| | | |
| | | private ByteString getNormalizedAssertionValue() throws DecodeException |
| | | { |
| | | if (normalizedAssertionValue == null) |
| | | { |
| | | return normalizedAssertionValue = normalizeAssertionValue(); |
| | | } |
| | | return normalizedAssertionValue; |
| | | } |
| | | |
| | | private ByteString normalizeAssertionValue() throws DecodeException |
| | | { |
| | | switch (filterType) |
| | | { |
| | | case EQUALITY: |
| | | return attributeType.getEqualityMatchingRule() |
| | | .normalizeAssertionValue(assertionValue); |
| | | case GREATER_OR_EQUAL: |
| | | case LESS_OR_EQUAL: |
| | | return attributeType.getOrderingMatchingRule() |
| | | .normalizeAssertionValue(assertionValue); |
| | | case APPROXIMATE_MATCH: |
| | | return attributeType.getApproximateMatchingRule() |
| | | .normalizeAssertionValue(assertionValue); |
| | | case AND: |
| | | case OR: |
| | | case NOT: |
| | | case PRESENT: |
| | | case SUBSTRING: |
| | | case EXTENSIBLE_MATCH: |
| | | default: |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | return ConditionResult.UNDEFINED; |
| | | } |
| | | |
| | | // Normalize the assertion value |
| | | ByteString value = assertionValue.getValue(); |
| | | ByteString normalizedValue; |
| | | ByteString normAssertionValue; |
| | | try |
| | | { |
| | | normalizedValue = matchingRule.normalizeAssertionValue(value); |
| | | normAssertionValue = matchingRule.normalizeAssertionValue(assertionValue); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | } |
| | | |
| | | // Iterate through all the attributes and see if we can find a match. |
| | | AttributeValue dummyAttributeValue = AttributeValues.create(value, |
| | | normalizedValue); |
| | | |
| | | for (Attribute a : attrs) |
| | | { |
| | | if (a.contains(dummyAttributeValue)) |
| | | // FIXME next if is incorrect |
| | | if (a.contains(normAssertionValue)) |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | |
| | | logger.trace( |
| | | "Returning FALSE for equality component %s in filter " + |
| | | "%s because entry %s didn't have attribute type %s with value %s", |
| | | this, completeFilter, entry.getName(), attributeType.getNameOrOID(), assertionValue.getValue()); |
| | | this, completeFilter, entry.getName(), attributeType.getNameOrOID(), assertionValue); |
| | | } |
| | | return ConditionResult.FALSE; |
| | | } |
| | |
| | | Assertion assertion; |
| | | try |
| | | { |
| | | assertion = matchingRule.getAssertion(assertionValue.getValue()); |
| | | assertion = matchingRule.getAssertion(assertionValue); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | { |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | try |
| | | { |
| | | ByteString nv = |
| | | matchingRule.normalizeAttributeValue(v.getValue()); |
| | | ByteString nv = matchingRule.normalizeAttributeValue(v); |
| | | ConditionResult r = assertion.matches(nv); |
| | | switch (r) |
| | | { |
| | |
| | | { |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | try |
| | | { |
| | | ByteString nv = |
| | | matchingRule.normalizeAttributeValue(v.getValue()); |
| | | ByteString nv = matchingRule.normalizeAttributeValue(v); |
| | | ConditionResult r = assertion.matches(nv); |
| | | switch (r) |
| | | { |
| | |
| | | } |
| | | |
| | | Attribute a = entry.getObjectClassAttribute(); |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | try |
| | | { |
| | | ByteString nv = matchingRule.normalizeAttributeValue(v.getValue()); |
| | | ByteString nv = matchingRule.normalizeAttributeValue(v); |
| | | ConditionResult r = assertion.matches(nv); |
| | | switch (r) |
| | | { |
| | |
| | | { |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | try |
| | | { |
| | | ByteString nv = |
| | | matchingRule.normalizeAttributeValue(v.getValue()); |
| | | ByteString nv = matchingRule.normalizeAttributeValue(v); |
| | | ConditionResult r = assertion.matches(nv); |
| | | switch (r) |
| | | { |
| | |
| | | if ((attributeType == null) || |
| | | attributeType.equals(rdn.getAttributeType(i))) |
| | | { |
| | | AttributeValue v = rdn.getAttributeValue(i); |
| | | ByteString nv = |
| | | matchingRule.normalizeAttributeValue(v.getValue()); |
| | | ByteString v = rdn.getAttributeValue(i); |
| | | ByteString nv = matchingRule.normalizeAttributeValue(v); |
| | | ConditionResult r = assertion.matches(nv); |
| | | switch (r) |
| | | { |
| | |
| | | continue outerComponentLoop; |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | return true; |
| | | case NOT: |
| | | return notComponent.equals(f.notComponent); |
| | | case EQUALITY: |
| | | return (attributeType.equals(f.attributeType) && |
| | | optionsEqual(attributeOptions, f.attributeOptions) && |
| | | assertionValue.equals(f.assertionValue)); |
| | | return typeAndOptionsAndAssertionEqual(f); |
| | | case SUBSTRING: |
| | | return equalsSubstring(f); |
| | | case GREATER_OR_EQUAL: |
| | | return typeAndOptionsAndAssertionEqual(f); |
| | | case LESS_OR_EQUAL: |
| | | return typeAndOptionsAndAssertionEqual(f); |
| | | case PRESENT: |
| | | return (attributeType.equals(f.attributeType) && |
| | | optionsEqual(attributeOptions, f.attributeOptions)); |
| | | case APPROXIMATE_MATCH: |
| | | return typeAndOptionsAndAssertionEqual(f); |
| | | case EXTENSIBLE_MATCH: |
| | | return equalsExtensible(f); |
| | | default: |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | |
| | | private boolean typeAndOptionsAndAssertionEqual(SearchFilter f) |
| | | { |
| | | final boolean tmp = |
| | | attributeType.equals(f.attributeType) |
| | | && optionsEqual(attributeOptions, f.attributeOptions); |
| | | try |
| | | { |
| | | return tmp && getNormalizedAssertionValue().equals(f.getNormalizedAssertionValue()); |
| | | } |
| | | catch (DecodeException e) |
| | | { |
| | | return tmp && assertionValue.equals(f.assertionValue); |
| | | } |
| | | } |
| | | |
| | | |
| | | private boolean equalsSubstring(SearchFilter f) |
| | | { |
| | | if (! attributeType.equals(f.attributeType)) |
| | | { |
| | | return false; |
| | |
| | | } |
| | | |
| | | return true; |
| | | case GREATER_OR_EQUAL: |
| | | return (attributeType.equals(f.attributeType) && |
| | | optionsEqual(attributeOptions, f.attributeOptions) && |
| | | assertionValue.equals(f.assertionValue)); |
| | | case LESS_OR_EQUAL: |
| | | return (attributeType.equals(f.attributeType) && |
| | | optionsEqual(attributeOptions, f.attributeOptions) && |
| | | assertionValue.equals(f.assertionValue)); |
| | | case PRESENT: |
| | | return (attributeType.equals(f.attributeType) && |
| | | optionsEqual(attributeOptions, f.attributeOptions)); |
| | | case APPROXIMATE_MATCH: |
| | | return (attributeType.equals(f.attributeType) && |
| | | optionsEqual(attributeOptions, f.attributeOptions) && |
| | | assertionValue.equals(f.assertionValue)); |
| | | case EXTENSIBLE_MATCH: |
| | | } |
| | | |
| | | |
| | | private boolean equalsExtensible(SearchFilter f) |
| | | { |
| | | if (attributeType == null) |
| | | { |
| | | if (f.attributeType != null) |
| | |
| | | { |
| | | try |
| | | { |
| | | Assertion assertion = mr.getAssertion(f.assertionValue.getValue()); |
| | | return assertion.matches(mr.normalizeAttributeValue(assertionValue.getValue())) == ConditionResult.TRUE; |
| | | Assertion assertion = mr.getAssertion(f.assertionValue); |
| | | return assertion.matches(mr.normalizeAttributeValue(assertionValue)).toBoolean(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | } |
| | | |
| | | return true; |
| | | default: |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | case NOT: |
| | | return notComponent.hashCode(); |
| | | case EQUALITY: |
| | | return (attributeType.hashCode() + assertionValue.hashCode()); |
| | | return typeAndAssertionHashCode(); |
| | | case SUBSTRING: |
| | | hashCode = attributeType.hashCode(); |
| | | |
| | | SubstringMatchingRule smr = |
| | | attributeType.getSubstringMatchingRule(); |
| | | |
| | | if (subInitialElement != null) |
| | | { |
| | | if (smr == null) |
| | | { |
| | | hashCode += subInitialElement.hashCode(); |
| | | } |
| | | else |
| | | { |
| | | try |
| | | { |
| | | hashCode += smr.normalizeSubstring( |
| | | subInitialElement).hashCode(); |
| | | } |
| | | catch (Exception e) {} |
| | | } |
| | | } |
| | | hashCode = hashCode(hashCode, smr, subInitialElement); |
| | | |
| | | if (subAnyElements != null) |
| | | { |
| | | for (ByteString e : subAnyElements) |
| | | { |
| | | if (smr == null) |
| | | { |
| | | hashCode += e.hashCode(); |
| | | } |
| | | else |
| | | { |
| | | try |
| | | { |
| | | hashCode += smr.normalizeSubstring(e).hashCode(); |
| | | } |
| | | catch (Exception e2) {} |
| | | } |
| | | hashCode = hashCode(hashCode, smr, e); |
| | | } |
| | | } |
| | | |
| | | if (subFinalElement != null) |
| | | { |
| | | if (smr == null) |
| | | { |
| | | hashCode += subFinalElement.hashCode(); |
| | | } |
| | | else |
| | | { |
| | | try |
| | | { |
| | | hashCode += |
| | | smr.normalizeSubstring(subFinalElement).hashCode(); |
| | | } |
| | | catch (Exception e) {} |
| | | } |
| | | } |
| | | hashCode = hashCode(hashCode, smr, subFinalElement); |
| | | |
| | | return hashCode; |
| | | case GREATER_OR_EQUAL: |
| | | return (attributeType.hashCode() + assertionValue.hashCode()); |
| | | return typeAndAssertionHashCode(); |
| | | case LESS_OR_EQUAL: |
| | | return (attributeType.hashCode() + assertionValue.hashCode()); |
| | | return typeAndAssertionHashCode(); |
| | | case PRESENT: |
| | | return attributeType.hashCode(); |
| | | case APPROXIMATE_MATCH: |
| | | return (attributeType.hashCode() + assertionValue.hashCode()); |
| | | return typeAndAssertionHashCode(); |
| | | case EXTENSIBLE_MATCH: |
| | | hashCode = 0; |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | private int typeAndAssertionHashCode() |
| | | { |
| | | final int hashCode = attributeType.hashCode(); |
| | | try |
| | | { |
| | | return hashCode + getNormalizedAssertionValue().hashCode(); |
| | | } |
| | | catch (DecodeException e) |
| | | { |
| | | return hashCode + assertionValue.hashCode(); |
| | | } |
| | | } |
| | | |
| | | |
| | | private int hashCode(int hashCode, SubstringMatchingRule smr, |
| | | ByteString subElem) |
| | | { |
| | | if (subElem != null) |
| | | { |
| | | if (smr == null) |
| | | { |
| | | hashCode += subElem.hashCode(); |
| | | } |
| | | else |
| | | { |
| | | try |
| | | { |
| | | hashCode += smr.normalizeSubstring(subElem).hashCode(); |
| | | } |
| | | catch (Exception e) {} |
| | | } |
| | | } |
| | | return hashCode; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves a string representation of this search filter. |
| | |
| | | case EQUALITY: |
| | | buffer.append("("); |
| | | buffer.append(attributeType.getNameOrOID()); |
| | | |
| | | if ((attributeOptions != null) && |
| | | (! attributeOptions.isEmpty())) |
| | | { |
| | | for (String option : attributeOptions) |
| | | { |
| | | buffer.append(";"); |
| | | buffer.append(option); |
| | | } |
| | | } |
| | | |
| | | appendOptions(buffer); |
| | | buffer.append("="); |
| | | valueToFilterString(buffer, assertionValue.getValue()); |
| | | valueToFilterString(buffer, assertionValue); |
| | | buffer.append(")"); |
| | | break; |
| | | case SUBSTRING: |
| | | buffer.append("("); |
| | | buffer.append(attributeType.getNameOrOID()); |
| | | |
| | | if ((attributeOptions != null) && |
| | | (! attributeOptions.isEmpty())) |
| | | { |
| | | for (String option : attributeOptions) |
| | | { |
| | | buffer.append(";"); |
| | | buffer.append(option); |
| | | } |
| | | } |
| | | |
| | | appendOptions(buffer); |
| | | buffer.append("="); |
| | | |
| | | if (subInitialElement != null) |
| | |
| | | case GREATER_OR_EQUAL: |
| | | buffer.append("("); |
| | | buffer.append(attributeType.getNameOrOID()); |
| | | |
| | | if ((attributeOptions != null) && |
| | | (! attributeOptions.isEmpty())) |
| | | { |
| | | for (String option : attributeOptions) |
| | | { |
| | | buffer.append(";"); |
| | | buffer.append(option); |
| | | } |
| | | } |
| | | |
| | | appendOptions(buffer); |
| | | buffer.append(">="); |
| | | valueToFilterString(buffer, assertionValue.getValue()); |
| | | valueToFilterString(buffer, assertionValue); |
| | | buffer.append(")"); |
| | | break; |
| | | case LESS_OR_EQUAL: |
| | | buffer.append("("); |
| | | buffer.append(attributeType.getNameOrOID()); |
| | | |
| | | if ((attributeOptions != null) && |
| | | (! attributeOptions.isEmpty())) |
| | | { |
| | | for (String option : attributeOptions) |
| | | { |
| | | buffer.append(";"); |
| | | buffer.append(option); |
| | | } |
| | | } |
| | | |
| | | appendOptions(buffer); |
| | | buffer.append("<="); |
| | | valueToFilterString(buffer, assertionValue.getValue()); |
| | | valueToFilterString(buffer, assertionValue); |
| | | buffer.append(")"); |
| | | break; |
| | | case PRESENT: |
| | | buffer.append("("); |
| | | buffer.append(attributeType.getNameOrOID()); |
| | | |
| | | if ((attributeOptions != null) && |
| | | (! attributeOptions.isEmpty())) |
| | | { |
| | | for (String option : attributeOptions) |
| | | { |
| | | buffer.append(";"); |
| | | buffer.append(option); |
| | | } |
| | | } |
| | | |
| | | appendOptions(buffer); |
| | | buffer.append("=*)"); |
| | | break; |
| | | case APPROXIMATE_MATCH: |
| | | buffer.append("("); |
| | | buffer.append(attributeType.getNameOrOID()); |
| | | |
| | | if ((attributeOptions != null) && |
| | | (! attributeOptions.isEmpty())) |
| | | { |
| | | for (String option : attributeOptions) |
| | | { |
| | | buffer.append(";"); |
| | | buffer.append(option); |
| | | } |
| | | } |
| | | |
| | | appendOptions(buffer); |
| | | buffer.append("~="); |
| | | valueToFilterString(buffer, assertionValue.getValue()); |
| | | valueToFilterString(buffer, assertionValue); |
| | | buffer.append(")"); |
| | | break; |
| | | case EXTENSIBLE_MATCH: |
| | |
| | | if (attributeType != null) |
| | | { |
| | | buffer.append(attributeType.getNameOrOID()); |
| | | |
| | | if ((attributeOptions != null) && |
| | | (! attributeOptions.isEmpty())) |
| | | { |
| | | for (String option : attributeOptions) |
| | | { |
| | | buffer.append(";"); |
| | | buffer.append(option); |
| | | } |
| | | } |
| | | appendOptions(buffer); |
| | | } |
| | | |
| | | if (dnAttributes) |
| | |
| | | } |
| | | |
| | | buffer.append(":="); |
| | | valueToFilterString(buffer, assertionValue.getValue()); |
| | | valueToFilterString(buffer, assertionValue); |
| | | buffer.append(")"); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | |
| | | private void appendOptions(StringBuilder buffer) |
| | | { |
| | | if (attributeOptions != null && !attributeOptions.isEmpty()) |
| | | { |
| | | for (String option : attributeOptions) |
| | | { |
| | | buffer.append(";"); |
| | | buffer.append(option); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Appends a properly-cleaned version of the provided value to the |
| | |
| | | * list, or zero if there is no relative difference between |
| | | * the values. |
| | | */ |
| | | public int compareValues(AttributeValue value1, |
| | | AttributeValue value2) |
| | | public int compareValues(ByteString value1, ByteString value2) |
| | | { |
| | | // A null value will always come after a non-null value. |
| | | if (value1 == null) |
| | |
| | | return 0; |
| | | } |
| | | |
| | | private int compareValues(OrderingMatchingRule rule, AttributeValue value1, |
| | | AttributeValue value2) |
| | | private int compareValues(OrderingMatchingRule rule, ByteString value1, |
| | | ByteString value2) |
| | | { |
| | | try |
| | | { |
| | | final ByteString val1 = rule.normalizeAttributeValue(value1.getValue()); |
| | | final ByteString val2 = rule.normalizeAttributeValue(value2.getValue()); |
| | | final ByteString val1 = rule.normalizeAttributeValue(value1); |
| | | final ByteString val2 = rule.normalizeAttributeValue(value2); |
| | | if (ascending) |
| | | { |
| | | return rule.compareValues(val1, val2); |
| | |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.core.DirectoryServer; |
| | | |
| | |
| | | private boolean isInheritedFromRDNCollective = false; |
| | | |
| | | // Inherited collective DN attribute type. |
| | | private AttributeType inheritFromDNType = null; |
| | | private AttributeType inheritFromDNType; |
| | | |
| | | // Inherited collective RDN attribute type. |
| | | private AttributeType inheritFromRDNAttrType = null; |
| | | private AttributeType inheritFromRDNAttrType; |
| | | |
| | | // Inherited collective RDN type attribute type. |
| | | private AttributeType inheritFromRDNType = null; |
| | | private AttributeType inheritFromRDNType; |
| | | |
| | | // Inherited collective RDN attribute value. |
| | | private AttributeValue inheritFromRDNAttrValue = null; |
| | | private ByteString inheritFromRDNAttrValue; |
| | | |
| | | // Inherited collective from DN value. |
| | | private AttributeValue inheritFromDNAttrValue = null; |
| | | private ByteString inheritFromDNAttrValue; |
| | | |
| | | // Inherited collective from base DN. |
| | | private DN inheritFromBaseDN = null; |
| | | private DN inheritFromBaseDN; |
| | | |
| | | // Collective attributes. |
| | | private List<Attribute> collectiveAttributes; |
| | |
| | | { |
| | | for (Attribute attr : specAttrList) |
| | | { |
| | | for (AttributeValue value : attr) |
| | | for (ByteString value : attr) |
| | | { |
| | | specString = value.toString(); |
| | | try |
| | |
| | | { |
| | | for (Attribute attr : attrList) |
| | | { |
| | | for (AttributeValue value : attr) |
| | | for (ByteString value : attr) |
| | | { |
| | | this.inheritFromDNType = |
| | | DirectoryServer.getAttributeType( |
| | |
| | | { |
| | | for (Attribute attr : attrList) |
| | | { |
| | | for (AttributeValue value : attr) |
| | | for (ByteString value : attr) |
| | | { |
| | | this.inheritFromRDNAttrType = |
| | | DirectoryServer.getAttributeType( |
| | |
| | | { |
| | | for (Attribute attr : attrList) |
| | | { |
| | | for (AttributeValue value : attr) |
| | | for (ByteString value : attr) |
| | | { |
| | | this.inheritFromRDNType = |
| | | DirectoryServer.getAttributeType( |
| | |
| | | { |
| | | for (Attribute attr : attrList) |
| | | { |
| | | for (AttributeValue value : attr) |
| | | for (ByteString value : attr) |
| | | { |
| | | // Has to have a parent since subentry itself |
| | | // cannot be a suffix entry within the server. |
| | | this.inheritFromBaseDN = |
| | | getDN().parent().child(DN.decode(value.getValue())); |
| | | this.inheritFromBaseDN = getDN().parent().child(DN.decode(value)); |
| | | break; |
| | | } |
| | | } |
| | |
| | | { |
| | | for (Attribute attr : attrList) |
| | | { |
| | | for (AttributeValue value : attr) |
| | | for (ByteString value : attr) |
| | | { |
| | | CollectiveVirtualAttribute collectiveAttr = |
| | | new CollectiveVirtualAttribute( |
| | |
| | | { |
| | | for (Attribute attr : attrList) |
| | | { |
| | | for (AttributeValue value : attr) |
| | | for (ByteString value : attr) |
| | | { |
| | | for (CollectiveConflictBehavior behavior : |
| | | CollectiveConflictBehavior.values()) |
| | |
| | | /** |
| | | * Getter to retrieve inheritFromRDNAttribute value |
| | | * for inherited collective attribute subentry. |
| | | * @return AttributeValue of inheritFromRDNAttribute |
| | | * @return ByteString of inheritFromRDNAttribute |
| | | * or, <code>null</code> if there is none. |
| | | */ |
| | | public AttributeValue getInheritFromRDNAttrValue() |
| | | public ByteString getInheritFromRDNAttrValue() |
| | | { |
| | | return this.inheritFromRDNAttrValue; |
| | | } |
| | |
| | | /** |
| | | * Getter to retrieve inheritFromDNAttribute value |
| | | * for inherited collective attribute subentry. |
| | | * @return AttributeValue of inheritFromDNAttribute |
| | | * @return ByteString of inheritFromDNAttribute |
| | | * or, <code>null</code> if there is none. |
| | | */ |
| | | public AttributeValue getInheritFromDNAttrValue() |
| | | public ByteString getInheritFromDNAttrValue() |
| | | { |
| | | return this.inheritFromDNAttrValue; |
| | | } |
| | |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.util.Utils; |
| | | import org.opends.server.api.MatchingRule; |
| | | import org.opends.server.api.VirtualAttributeProvider; |
| | | |
| | | /** |
| | |
| | | mayInvoke = true) |
| | | public final class VirtualAttribute |
| | | extends AbstractAttribute |
| | | implements Attribute |
| | | { |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | // The attribute type. |
| | | /** The attribute type. */ |
| | | private final AttributeType attributeType; |
| | | |
| | | // The entry with which this virtual attribute is associated. |
| | | /** The entry with which this virtual attribute is associated. */ |
| | | private final Entry entry; |
| | | |
| | | // The virtual attribute provider for this virtual attribute. |
| | | /** The virtual attribute provider for this virtual attribute. */ |
| | | private final VirtualAttributeProvider<?> provider; |
| | | |
| | | // The virtual attribute rule for this virtual attribute. |
| | | /** The virtual attribute rule for this virtual attribute. */ |
| | | private final VirtualAttributeRule rule; |
| | | |
| | | |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConditionResult approximatelyEqualTo(AttributeValue value) |
| | | public ConditionResult approximatelyEqualTo(ByteString value) |
| | | { |
| | | return provider.approximatelyEqualTo(entry, rule, value); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean contains(AttributeValue value) |
| | | public boolean contains(ByteString value) |
| | | { |
| | | return provider.hasValue(entry, rule, value); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean containsAll(Collection<AttributeValue> values) |
| | | public boolean containsAll(Collection<ByteString> values) |
| | | { |
| | | return provider.hasAllValues(entry, rule, values); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public AttributeType getAttributeType() |
| | | { |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getNameWithOptions() |
| | | { |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Set<String> getOptions() |
| | | { |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConditionResult greaterThanOrEqualTo(AttributeValue value) |
| | | public ConditionResult greaterThanOrEqualTo(ByteString value) |
| | | { |
| | | return provider.greaterThanOrEqualTo(entry, rule, value); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean hasAllOptions(Collection<String> options) |
| | | { |
| | | return (options == null || options.isEmpty()); |
| | | return options == null || options.isEmpty(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean hasOption(String option) |
| | | { |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean hasOptions() |
| | | { |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isEmpty() |
| | | { |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isVirtual() |
| | | { |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Iterator<AttributeValue> iterator() |
| | | public Iterator<ByteString> iterator() |
| | | { |
| | | Set<AttributeValue> values = provider.getValues(entry, rule); |
| | | return values.iterator(); |
| | | return provider.getValues(entry, rule).iterator(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConditionResult lessThanOrEqualTo(AttributeValue value) |
| | | public ConditionResult lessThanOrEqualTo(ByteString value) |
| | | { |
| | | return provider.lessThanOrEqualTo(entry, rule, value); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConditionResult matchesSubstring(ByteString subInitial, |
| | | List<ByteString> subAny, ByteString subFinal) |
| | | { |
| | | return provider.matchesSubstring(entry, rule, subInitial, subAny, |
| | | subFinal); |
| | | return provider.matchesSubstring(entry, rule, subInitial, subAny, subFinal); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean optionsEqual(Set<String> options) |
| | | { |
| | | return (options == null || options.isEmpty()); |
| | | return options == null || options.isEmpty(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int size() |
| | | { |
| | | if (!provider.isMultiValued()) |
| | | { |
| | | return provider.hasValue(entry, rule) ? 1 : 0; |
| | | } |
| | | else |
| | | if (provider.isMultiValued()) |
| | | { |
| | | return provider.getValues(entry, rule).size(); |
| | | } |
| | | return provider.hasValue(entry, rule) ? 1 : 0; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int hashCode() |
| | | { |
| | | int hashCode = getAttributeType().hashCode(); |
| | | for (ByteString value : this) |
| | | { |
| | | try |
| | | { |
| | | final MatchingRule eqRule = attributeType.getEqualityMatchingRule(); |
| | | final ByteString nv = eqRule.normalizeAttributeValue(value); |
| | | hashCode += nv.hashCode(); |
| | | } |
| | | catch (DecodeException e) |
| | | { |
| | | logger.traceException(e); |
| | | } |
| | | } |
| | | return hashCode; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void toString(StringBuilder buffer) |
| | | { |
| | | buffer.append("VirtualAttribute("); |
| | | buffer.append(getAttributeType().getNameOrOID()); |
| | | buffer.append(", {"); |
| | | |
| | | boolean firstValue = true; |
| | | for (AttributeValue value : this) |
| | | { |
| | | if (!firstValue) |
| | | { |
| | | buffer.append(", "); |
| | | } |
| | | |
| | | value.toString(buffer); |
| | | firstValue = false; |
| | | } |
| | | |
| | | buffer.append(Utils.joinAsString(", ", this)); |
| | | buffer.append("})"); |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.types.operation; |
| | | |
| | | |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.RawModification; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines a set of methods that are available for use by |
| | | * post-operation plugins for modify operations. Note that this |
| | |
| | | * provided in the modify request, or <CODE>null</CODE> if |
| | | * there were none. |
| | | */ |
| | | public List<AttributeValue> getCurrentPasswords(); |
| | | List<ByteString> getCurrentPasswords(); |
| | | |
| | | |
| | | |
| | |
| | | * @return The set of clear-text new passwords as provided in the |
| | | * modify request, or <CODE>null</CODE> if there were none. |
| | | */ |
| | | public List<AttributeValue> getNewPasswords(); |
| | | List<ByteString> getNewPasswords(); |
| | | } |
| | | |
| | |
| | | * provided in the modify request, or <CODE>null</CODE> if |
| | | * there were none. |
| | | */ |
| | | public List<AttributeValue> getCurrentPasswords(); |
| | | List<ByteString> getCurrentPasswords(); |
| | | |
| | | |
| | | |
| | |
| | | * @return The set of clear-text new passwords as provided in the |
| | | * modify request, or <CODE>null</CODE> if there were none. |
| | | */ |
| | | public List<AttributeValue> getNewPasswords(); |
| | | List<ByteString> getNewPasswords(); |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.types.operation; |
| | | |
| | | |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.RawModification; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines a set of methods that are available for use by |
| | | * post-synchronization plugins for modify operations. Note that this |
| | |
| | | * provided in the modify request, or <CODE>null</CODE> if |
| | | * there were none. |
| | | */ |
| | | public List<AttributeValue> getCurrentPasswords(); |
| | | List<ByteString> getCurrentPasswords(); |
| | | |
| | | |
| | | |
| | |
| | | * @return The set of clear-text new passwords as provided in the |
| | | * modify request, or <CODE>null</CODE> if there were none. |
| | | */ |
| | | public List<AttributeValue> getNewPasswords(); |
| | | List<ByteString> getNewPasswords(); |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.types.operation; |
| | | |
| | | |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.DN; |
| | |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.RawModification; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines a set of methods that are available for use by |
| | | * pre-operation plugins for modify operations. Note that this |
| | |
| | | * provided in the modify request, or <CODE>null</CODE> if |
| | | * there were none. |
| | | */ |
| | | public List<AttributeValue> getCurrentPasswords(); |
| | | List<ByteString> getCurrentPasswords(); |
| | | |
| | | |
| | | |
| | |
| | | * @return The set of clear-text new passwords as provided in the |
| | | * modify request, or <CODE>null</CODE> if there were none. |
| | | */ |
| | | public List<AttributeValue> getNewPasswords(); |
| | | List<ByteString> getNewPasswords(); |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | AttributeValue attributeValue = AttributeValues.create(attrType, value); |
| | | ByteString attributeValue = value; |
| | | final Map<AttributeType, List<AttributeBuilder>> attrBuilders; |
| | | if (attrType.isOperational()) |
| | | { |
| | |
| | | colonPos, attrName); |
| | | |
| | | AttributeBuilder builder = new AttributeBuilder(attribute, true); |
| | | AttributeType attrType = attribute.getAttributeType(); |
| | | builder.add(AttributeValues.create(attrType, value)); |
| | | |
| | | builder.add(value); |
| | | return builder.toAttribute(); |
| | | } |
| | | |
| | |
| | | { |
| | | Attribute attr = |
| | | readSingleValueAttribute(lines, line, entryDN, attributeName); |
| | | return attr.iterator().next().getValue().toString(); |
| | | return attr.iterator().next().toString(); |
| | | } |
| | | |
| | | |
| | |
| | | String name = attr.getName(); |
| | | |
| | | // Get the attribute description |
| | | String attrDescr = attr.iterator().next().getValue().toString(); |
| | | String attrDescr = attr.iterator().next().toString(); |
| | | |
| | | ModificationType modType; |
| | | String lowerName = toLowerCase(name); |
| | |
| | | AttributeType ocType = DirectoryServer.getObjectClassAttributeType(); |
| | | AttributeBuilder builder = new AttributeBuilder(ocType, "objectClass"); |
| | | for (String value : objectClasses.values()) { |
| | | builder.add(AttributeValues.create(ocType, value)); |
| | | builder.add(value); |
| | | } |
| | | Map<AttributeType, List<Attribute>> attributes = |
| | | toAttributesMap(attrBuilders); |
| | |
| | | for (int i=0; i < numAVAs; i++) |
| | | { |
| | | AttributeType t = rdn.getAttributeType(i); |
| | | AttributeValue v = rdn.getAttributeValue(i); |
| | | ByteString v = rdn.getAttributeValue(i); |
| | | String n = rdn.getAttributeName(i); |
| | | if (t.isOperational()) |
| | | { |
| | |
| | | |
| | | private void addRDNAttributesIfNecessary( |
| | | Map<AttributeType, List<Attribute>> attributes, AttributeType t, |
| | | AttributeValue v, String n) |
| | | ByteString v, String n) |
| | | { |
| | | List<Attribute> attrList = attributes.get(t); |
| | | if (attrList == null) |
| | |
| | | AddChangeRecordEntry addRecord = (AddChangeRecordEntry) changeRecord; |
| | | for (Attribute a : addRecord.getAttributes()) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | final String attrName = a.getNameWithOptions(); |
| | | writeAttribute(attrName, v, writer, wrapLines, wrapColumn); |
| | |
| | | attrName.append(o); |
| | | } |
| | | |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | writeAttribute(attrName, v, writer, wrapLines, wrapColumn); |
| | | } |
| | |
| | | attrName.append(o); |
| | | } |
| | | |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | writeAttribute(attrName, v, writer, wrapLines, wrapColumn); |
| | | } |
| | |
| | | modTypeLine.append(name); |
| | | writeLDIFLine(modTypeLine, writer, wrapLines, wrapColumn); |
| | | |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | writeAttribute(name, v, writer, wrapLines, wrapColumn); |
| | | } |
| | |
| | | writeLDIFLine(newLine, writer, wrapLines, wrapColumn); |
| | | } |
| | | |
| | | private void writeAttribute(CharSequence attrName, AttributeValue v, |
| | | private void writeAttribute(CharSequence attrName, ByteString v, |
| | | BufferedWriter writer, boolean wrapLines, int wrapColumn) |
| | | throws IOException |
| | | { |
| | | StringBuilder newLine = new StringBuilder(attrName); |
| | | appendLDIFSeparatorAndValue(newLine, v.getValue()); |
| | | appendLDIFSeparatorAndValue(newLine, v); |
| | | writeLDIFLine(newLine, writer, wrapLines, wrapColumn); |
| | | } |
| | | |
| | |
| | | import org.forgerock.i18n.LocalizableMessageDescriptor; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.util.Reject; |
| | | import org.opends.messages.ToolMessages; |
| | | import org.opends.server.api.ClientConnection; |
| | |
| | | for (int i=0; i < numAVAs; i++) |
| | | { |
| | | AttributeType attrType = rdn.getAttributeType(i); |
| | | AttributeValue attrValue = rdn.getAttributeValue(i); |
| | | ByteString attrValue = rdn.getAttributeValue(i); |
| | | String attrName = rdn.getAttributeName(i); |
| | | |
| | | // First, see if this type is allowed by the untypedObject class. If not, |
| | |
| | | } |
| | | |
| | | String attrName = a.getNameWithOptions(); |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | builder.append(attrName); |
| | | appendLDIFSeparatorAndValue(builder, v.getValue()); |
| | | appendLDIFSeparatorAndValue(builder, v); |
| | | builder.append('\n'); |
| | | } |
| | | } |
| | |
| | | builder.append(attrName); |
| | | builder.append('\n'); |
| | | |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | builder.append(attrName); |
| | | appendLDIFSeparatorAndValue(builder, v.getValue()); |
| | | appendLDIFSeparatorAndValue(builder, v); |
| | | builder.append('\n'); |
| | | } |
| | | builder.append("-\n"); |
| | |
| | | at = DirectoryServer.getDefaultAttributeType("changeNumber"); |
| | | } |
| | | |
| | | AttributeValue av = rdn.getAttributeValue(at); |
| | | ByteString av = rdn.getAttributeValue(at); |
| | | if (av != null) |
| | | { |
| | | sf = SearchFilter.createEqualityFilter(at, av); |
| | |
| | | try |
| | | { |
| | | MatchingRule rule = sf.getAttributeType().getEqualityMatchingRule(); |
| | | ByteString normValue = |
| | | rule.normalizeAssertionValue(sf.getAssertionValue().getValue()); |
| | | ByteString normValue = rule.normalizeAssertionValue(sf.getAssertionValue()); |
| | | return Integer.decode(normValue.toString()); |
| | | } |
| | | catch (DecodeException e) |
| | |
| | | for (int i=0; i < numAVAs; i++) |
| | | { |
| | | AttributeType t = rdn.getAttributeType(i); |
| | | AttributeValue v = rdn.getAttributeValue(i); |
| | | ByteString v = rdn.getAttributeValue(i); |
| | | String n = rdn.getAttributeName(i); |
| | | if (t.isOperational()) |
| | | { |
| | |
| | | |
| | | private void addRDNAttributesIfNecessary( |
| | | Map<AttributeType, List<Attribute>> attributes, AttributeType t, |
| | | AttributeValue v, String n) throws DirectoryException |
| | | ByteString v, String n) throws DirectoryException |
| | | { |
| | | List<Attribute> attrList = attributes.get(t); |
| | | if (attrList == null) |
| | |
| | | passwordPolicy.getDefaultPasswordStorageSchemes(); |
| | | AttributeBuilder builder = new AttributeBuilder(passwordAttr, true); |
| | | builder.setInitialCapacity(defaultStorageSchemes.size()); |
| | | for (AttributeValue v : passwordAttr) |
| | | for (ByteString value : passwordAttr) |
| | | { |
| | | ByteString value = v.getValue(); |
| | | |
| | | // See if the password is pre-encoded. |
| | | if (passwordPolicy.isAuthPasswordSyntax()) |
| | | { |
| | |
| | | if (isInternalOperation() || |
| | | passwordPolicy.isAllowPreEncodedPasswords()) |
| | | { |
| | | builder.add(v); |
| | | builder.add(value); |
| | | continue; |
| | | } |
| | | else |
| | |
| | | if (isInternalOperation() || |
| | | passwordPolicy.isAllowPreEncodedPasswords()) |
| | | { |
| | | builder.add(v); |
| | | builder.add(value); |
| | | continue; |
| | | } |
| | | else |
| | |
| | | { |
| | | for (PasswordStorageScheme<?> s : defaultStorageSchemes) |
| | | { |
| | | ByteString encodedValue = s.encodeAuthPassword(value); |
| | | builder.add(AttributeValues.create( |
| | | passwordAttribute, encodedValue)); |
| | | builder.add(s.encodeAuthPassword(value)); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | for (PasswordStorageScheme<?> s : defaultStorageSchemes) |
| | | { |
| | | ByteString encodedValue = s.encodePasswordWithScheme(value); |
| | | builder.add(AttributeValues.create( |
| | | passwordAttribute, encodedValue)); |
| | | builder.add(s.encodePasswordWithScheme(value)); |
| | | } |
| | | } |
| | | } |
| | |
| | | AttributeSyntax<?> syntax = a.getAttributeType().getSyntax(); |
| | | if (syntax != null) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | if (!syntax.valueIsAcceptable(v.getValue(), invalidReason)) |
| | | if (!syntax.valueIsAcceptable(v, invalidReason)) |
| | | { |
| | | LocalizableMessage message; |
| | | if (!syntax.isHumanReadable() || syntax.isBEREncodingRequired()) |
| | |
| | | else |
| | | { |
| | | message = WARN_ADD_OP_INVALID_SYNTAX. |
| | | get(entryDN, v.getValue(), a.getName(), invalidReason); |
| | | get(entryDN, v, a.getName(), invalidReason); |
| | | } |
| | | |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | |
| | | } |
| | | |
| | | // See if the user's entry contains a custom idle time limit. |
| | | // idleTimeLimit = 1000L * Long.parseLong(v.getValue().toString()); |
| | | // idleTimeLimit = 1000L * Long.parseLong(v.toString()); |
| | | Integer customIdleTimeLimitInSec = |
| | | getIntegerUserAttribute(userEntry, OP_ATTR_USER_IDLE_TIME_LIMIT, |
| | | WARN_BIND_MULTIPLE_USER_IDLE_TIME_LIMITS, |
| | |
| | | Attribute a = attrList.get(0); |
| | | if (a.size() == 1) |
| | | { |
| | | AttributeValue v = a.iterator().next(); |
| | | ByteString v = a.iterator().next(); |
| | | try |
| | | { |
| | | return Integer.valueOf(v.getValue().toString()); |
| | | return Integer.valueOf(v.toString()); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | logger.error(cannotProcessAttributeMessage.get(v.getValue(), userEntry.getName())); |
| | | logger.error(cannotProcessAttributeMessage.get(v, userEntry.getName())); |
| | | } |
| | | } |
| | | else if (a.size() > 1) |
| | |
| | | import org.opends.server.core.*; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.types.operation.PostOperationCompareOperation; |
| | | import org.opends.server.types.operation.PostResponseCompareOperation; |
| | |
| | | } |
| | | else |
| | | { |
| | | AttributeValue value = |
| | | AttributeValues.create(attrType, getAssertionValue()); |
| | | ByteString value = getAssertionValue(); |
| | | |
| | | boolean matchFound = false; |
| | | for (Attribute a : attrList) |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.api.ChangeNotificationListener; |
| | |
| | | } |
| | | } |
| | | |
| | | List<AttributeValue> missingValues = new LinkedList<AttributeValue>(); |
| | | List<ByteString> missingValues = new LinkedList<ByteString>(); |
| | | newEntry.removeAttribute(a, missingValues); |
| | | |
| | | if (missingValues.isEmpty()) |
| | |
| | | newRDN.getAttributeName(i), |
| | | newRDN.getAttributeValue(i)); |
| | | |
| | | List<AttributeValue> duplicateValues = new LinkedList<AttributeValue>(); |
| | | List<ByteString> duplicateValues = new LinkedList<ByteString>(); |
| | | newEntry.addAttribute(a, duplicateValues); |
| | | |
| | | if (duplicateValues.isEmpty()) |
| | |
| | | switch (m.getModificationType().asEnum()) |
| | | { |
| | | case ADD: |
| | | List<AttributeValue> duplicateValues = |
| | | new LinkedList<AttributeValue>(); |
| | | List<ByteString> duplicateValues = new LinkedList<ByteString>(); |
| | | newEntry.addAttribute(a, duplicateValues); |
| | | break; |
| | | |
| | | case DELETE: |
| | | List<AttributeValue> missingValues = new LinkedList<AttributeValue>(); |
| | | List<ByteString> missingValues = new LinkedList<ByteString>(); |
| | | newEntry.removeAttribute(a, missingValues); |
| | | break; |
| | | |
| | |
| | | private LDAPPreReadRequestControl preReadRequest; |
| | | |
| | | /** The set of clear-text current passwords (if any were provided).*/ |
| | | private List<AttributeValue> currentPasswords = null; |
| | | private List<ByteString> currentPasswords; |
| | | |
| | | /** The set of clear-text new passwords (if any were provided).*/ |
| | | private List<AttributeValue> newPasswords = null; |
| | | private List<ByteString> newPasswords; |
| | | |
| | | /** |
| | | * The set of modifications contained in this request. |
| | |
| | | * information is not yet available. |
| | | */ |
| | | @Override |
| | | public final List<AttributeValue> getCurrentPasswords() |
| | | public final List<ByteString> getCurrentPasswords() |
| | | { |
| | | return currentPasswords; |
| | | } |
| | |
| | | * information is not yet available. |
| | | */ |
| | | @Override |
| | | public final List<AttributeValue> getNewPasswords() |
| | | public final List<ByteString> getNewPasswords() |
| | | { |
| | | return newPasswords; |
| | | } |
| | |
| | | // Otherwise, store the clear-text values for later validation and |
| | | // update the attribute with the encoded values. |
| | | AttributeBuilder builder = new AttributeBuilder(pwAttr, true); |
| | | for (AttributeValue v : pwAttr) |
| | | for (ByteString v : pwAttr) |
| | | { |
| | | if (pwPolicyState.passwordIsPreEncoded(v.getValue())) |
| | | if (pwPolicyState.passwordIsPreEncoded(v)) |
| | | { |
| | | if ((!isInternalOperation()) |
| | | && !pwPolicyState.getAuthenticationPolicy() |
| | |
| | | if (m.getModificationType() == ModificationType.ADD) |
| | | { |
| | | // Make sure that the password value doesn't already exist. |
| | | if (pwPolicyState.passwordMatches(v.getValue())) |
| | | if (pwPolicyState.passwordMatches(v)) |
| | | { |
| | | pwpErrorType = PasswordPolicyErrorType.PASSWORD_IN_HISTORY; |
| | | throw new DirectoryException(ResultCode.ATTRIBUTE_OR_VALUE_EXISTS, |
| | |
| | | |
| | | if (newPasswords == null) |
| | | { |
| | | newPasswords = new LinkedList<AttributeValue>(); |
| | | newPasswords = new LinkedList<ByteString>(); |
| | | } |
| | | |
| | | newPasswords.add(v); |
| | | |
| | | for (ByteString s : pwPolicyState.encodePassword(v.getValue())) |
| | | { |
| | | builder.add(AttributeValues.create( |
| | | pwAttr.getAttributeType(), s)); |
| | | } |
| | | builder.addAll(pwPolicyState.encodePassword(v)); |
| | | } |
| | | } |
| | | |
| | |
| | | numPasswords = 0; |
| | | } |
| | | |
| | | for (AttributeValue v : pwAttr) |
| | | for (ByteString v : pwAttr) |
| | | { |
| | | if (pwPolicyState.passwordIsPreEncoded(v.getValue())) |
| | | if (pwPolicyState.passwordIsPreEncoded(v)) |
| | | { |
| | | if ((!isInternalOperation()) && selfChange) |
| | | { |
| | |
| | | boolean found = false; |
| | | for (Attribute attr : attrList) |
| | | { |
| | | for (AttributeValue av : attr) |
| | | for (ByteString av : attr) |
| | | { |
| | | if (av.equals(v)) |
| | | { |
| | |
| | | boolean found = false; |
| | | for (Attribute attr : attrList) |
| | | { |
| | | for (AttributeValue av : attr) |
| | | for (ByteString av : attr) |
| | | { |
| | | if (pwPolicyState.getAuthenticationPolicy().isAuthPasswordSyntax()) |
| | | { |
| | | if (AuthPasswordSyntax.isEncoded(av.getValue())) |
| | | if (AuthPasswordSyntax.isEncoded(av)) |
| | | { |
| | | StringBuilder[] components = AuthPasswordSyntax |
| | | .decodeAuthPassword(av.getValue().toString()); |
| | | .decodeAuthPassword(av.toString()); |
| | | PasswordStorageScheme<?> scheme = DirectoryServer |
| | | .getAuthPasswordStorageScheme(components[0].toString()); |
| | | if (scheme != null) |
| | | { |
| | | if (scheme.authPasswordMatches(v.getValue(), components[1] |
| | | .toString(), components[2].toString())) |
| | | if (scheme.authPasswordMatches(v, |
| | | components[1].toString(), components[2].toString())) |
| | | { |
| | | builder.add(av); |
| | | found = true; |
| | |
| | | } |
| | | else |
| | | { |
| | | if (UserPasswordSyntax.isEncoded(av.getValue())) |
| | | if (UserPasswordSyntax.isEncoded(av)) |
| | | { |
| | | String[] components = UserPasswordSyntax.decodeUserPassword(av |
| | | .getValue().toString()); |
| | | String[] components = UserPasswordSyntax.decodeUserPassword(av.toString()); |
| | | PasswordStorageScheme<?> scheme = DirectoryServer |
| | | .getPasswordStorageScheme(toLowerCase(components[0])); |
| | | if (scheme != null) |
| | | { |
| | | if (scheme.passwordMatches(v.getValue(), ByteString.valueOf( |
| | | components[1]))) |
| | | if (scheme != null |
| | | && scheme.passwordMatches(v, ByteString.valueOf(components[1]))) |
| | | { |
| | | builder.add(av); |
| | | found = true; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (av.equals(v)) |
| | |
| | | { |
| | | if (currentPasswords == null) |
| | | { |
| | | currentPasswords = new LinkedList<AttributeValue>(); |
| | | currentPasswords = new LinkedList<ByteString>(); |
| | | } |
| | | currentPasswords.add(v); |
| | | numPasswords--; |
| | |
| | | if (syntaxPolicy == AcceptRejectWarn.REJECT) |
| | | { |
| | | LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder(); |
| | | for (AttributeValue v : attr) |
| | | for (ByteString v : attr) |
| | | { |
| | | if (!syntax.valueIsAcceptable(v.getValue(), invalidReason)) |
| | | if (!syntax.valueIsAcceptable(v, invalidReason)) |
| | | { |
| | | if (!syntax.isHumanReadable() || syntax.isBEREncodingRequired()) |
| | | { |
| | |
| | | throw newDirectoryException(currentEntry, |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | ERR_MODIFY_ADD_INVALID_SYNTAX.get( |
| | | entryDN, attr.getName(), v.getValue(), invalidReason)); |
| | | entryDN, attr.getName(), v, invalidReason)); |
| | | } |
| | | } |
| | | } |
| | |
| | | else if (syntaxPolicy == AcceptRejectWarn.WARN) |
| | | { |
| | | LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder(); |
| | | for (AttributeValue v : attr) |
| | | for (ByteString v : attr) |
| | | { |
| | | if (!syntax.valueIsAcceptable(v.getValue(), invalidReason)) |
| | | if (!syntax.valueIsAcceptable(v, invalidReason)) |
| | | { |
| | | // FIXME remove next line of code. According to Matt, since this is |
| | | // just a warning, the code should not set the resultCode |
| | |
| | | else |
| | | { |
| | | logger.error(ERR_MODIFY_ADD_INVALID_SYNTAX, |
| | | entryDN, attr.getName(), v.getValue(), invalidReason); |
| | | entryDN, attr.getName(), v, invalidReason); |
| | | } |
| | | invalidReason = new LocalizableMessageBuilder(); |
| | | } |
| | |
| | | // Add the provided attribute or merge an existing attribute with |
| | | // the values of the new attribute. If there are any duplicates, |
| | | // then fail. |
| | | List<AttributeValue> duplicateValues = new LinkedList<AttributeValue>(); |
| | | List<ByteString> duplicateValues = new LinkedList<ByteString>(); |
| | | modifiedEntry.addAttribute(attr, duplicateValues); |
| | | if (!duplicateValues.isEmpty() && !permissiveModify) |
| | | { |
| | |
| | | Reject.ifFalse(attrType.isObjectClass()); |
| | | final MatchingRule eqRule = attrType.getEqualityMatchingRule(); |
| | | |
| | | for (AttributeValue v : attr) |
| | | for (ByteString v : attr) |
| | | { |
| | | String name = v.getValue().toString(); |
| | | String name = v.toString(); |
| | | |
| | | String lowerName; |
| | | try |
| | | { |
| | | lowerName = eqRule.normalizeAttributeValue(v.getValue()).toString(); |
| | | lowerName = eqRule.normalizeAttributeValue(v).toString(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | // Remove the specified attribute values or the entire attribute from the |
| | | // value. If there are any specified values that were not present, then |
| | | // fail. If the RDN attribute value would be removed, then fail. |
| | | List<AttributeValue> missingValues = new LinkedList<AttributeValue>(); |
| | | List<ByteString> missingValues = new LinkedList<ByteString>(); |
| | | boolean attrExists = modifiedEntry.removeAttribute(attr, missingValues); |
| | | |
| | | if (attrExists) |
| | |
| | | if (syntaxPolicy == AcceptRejectWarn.REJECT) |
| | | { |
| | | LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder(); |
| | | for (AttributeValue v : attr) |
| | | for (ByteString v : attr) |
| | | { |
| | | if (!syntax.valueIsAcceptable(v.getValue(), invalidReason)) |
| | | if (!syntax.valueIsAcceptable(v, invalidReason)) |
| | | { |
| | | if (!syntax.isHumanReadable() || syntax.isBEREncodingRequired()) |
| | | { |
| | |
| | | throw newDirectoryException(currentEntry, |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | ERR_MODIFY_REPLACE_INVALID_SYNTAX.get( |
| | | entryDN, attr.getName(), v.getValue(), invalidReason)); |
| | | entryDN, attr.getName(), v, invalidReason)); |
| | | } |
| | | } |
| | | } |
| | |
| | | else if (syntaxPolicy == AcceptRejectWarn.WARN) |
| | | { |
| | | LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder(); |
| | | for (AttributeValue v : attr) |
| | | for (ByteString v : attr) |
| | | { |
| | | if (!syntax.valueIsAcceptable(v.getValue(), invalidReason)) |
| | | if (!syntax.valueIsAcceptable(v, invalidReason)) |
| | | { |
| | | setResultCode(ResultCode.INVALID_ATTRIBUTE_SYNTAX); |
| | | if (!syntax.isHumanReadable() || syntax.isBEREncodingRequired()) |
| | |
| | | else |
| | | { |
| | | logger.error(ERR_MODIFY_REPLACE_INVALID_SYNTAX, |
| | | entryDN, attr.getName(), v.getValue(), invalidReason); |
| | | entryDN, attr.getName(), v, invalidReason); |
| | | } |
| | | invalidReason = new LocalizableMessageBuilder(); |
| | | } |
| | |
| | | } |
| | | |
| | | MatchingRule eqRule = attr.getAttributeType().getEqualityMatchingRule(); |
| | | AttributeValue v = attr.iterator().next(); |
| | | ByteString v = attr.iterator().next(); |
| | | |
| | | long incrementValue; |
| | | try |
| | | { |
| | | String nv = eqRule.normalizeAttributeValue(v.getValue()).toString(); |
| | | String nv = eqRule.normalizeAttributeValue(v).toString(); |
| | | incrementValue = Long.parseLong(nv); |
| | | } |
| | | catch (Exception e) |
| | |
| | | logger.traceException(e); |
| | | |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | ERR_MODIFY_INCREMENT_PROVIDED_VALUE_NOT_INTEGER.get(entryDN, attr.getName(), v.getValue()), e); |
| | | ERR_MODIFY_INCREMENT_PROVIDED_VALUE_NOT_INTEGER.get(entryDN, attr.getName(), v), e); |
| | | } |
| | | |
| | | // Get the attribute that is to be incremented. |
| | |
| | | |
| | | // Increment each attribute value by the specified amount. |
| | | AttributeBuilder builder = new AttributeBuilder(a, true); |
| | | for (AttributeValue existingValue : a) |
| | | for (ByteString existingValue : a) |
| | | { |
| | | String s = existingValue.getValue().toString(); |
| | | long currentValue; |
| | | try |
| | | { |
| | | currentValue = Long.parseLong(s); |
| | | currentValue = Long.parseLong(existingValue.toString()); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | ERR_MODIFY_INCREMENT_REQUIRES_INTEGER_VALUE.get( |
| | | entryDN, a.getName(), existingValue.getValue()), |
| | | ERR_MODIFY_INCREMENT_REQUIRES_INTEGER_VALUE.get(entryDN, a.getName(), existingValue), |
| | | e); |
| | | } |
| | | |
| | | long newValue = currentValue + incrementValue; |
| | | builder.add(AttributeValues.create(t, String.valueOf(newValue))); |
| | | builder.add(String.valueOf(newValue)); |
| | | } |
| | | |
| | | // Replace the existing attribute with the incremented version. |
| | |
| | | { |
| | | if (clearPasswords.isEmpty()) |
| | | { |
| | | for (AttributeValue v : currentPasswords) |
| | | { |
| | | clearPasswords.add(v.getValue()); |
| | | } |
| | | clearPasswords.addAll(currentPasswords); |
| | | } |
| | | else |
| | | { |
| | |
| | | // (like 0x04 for a standard universal octet string type versus 0x80 |
| | | // for a simple password in a bind operation). So we have to |
| | | // manually check for duplicates. |
| | | for (AttributeValue v : currentPasswords) |
| | | for (ByteString pw : currentPasswords) |
| | | { |
| | | ByteString pw = v.getValue(); |
| | | |
| | | boolean found = false; |
| | | for (ByteString s : clearPasswords) |
| | | { |
| | | if (s.equals(pw)) |
| | | { |
| | | found = true; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (! found) |
| | | if (!clearPasswords.contains(pw)) |
| | | { |
| | | clearPasswords.add(pw); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | for (AttributeValue v : newPasswords) |
| | | for (ByteString v : newPasswords) |
| | | { |
| | | LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder(); |
| | | if (! pwPolicyState.passwordIsAcceptable(this, modifiedEntry, |
| | | v.getValue(), clearPasswords, invalidReason)) |
| | | v, clearPasswords, invalidReason)) |
| | | { |
| | | pwpErrorType = |
| | | PasswordPolicyErrorType.INSUFFICIENT_PASSWORD_QUALITY; |
| | |
| | | { |
| | | if (newPasswords != null) |
| | | { |
| | | for (AttributeValue v : newPasswords) |
| | | for (ByteString v : newPasswords) |
| | | { |
| | | if (pwPolicyState.isPasswordInHistory(v.getValue())) |
| | | if (pwPolicyState.isPasswordInHistory(v)) |
| | | { |
| | | if (selfChange || (! pwPolicyState.getAuthenticationPolicy(). |
| | | isSkipValidationForAdministrators())) |
| | |
| | | import java.util.logging.Logger; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.io.ASN1; |
| | | import org.forgerock.opendj.io.ASN1Reader; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.admin.client.ManagementContext; |
| | | import org.opends.server.admin.client.ldap.JNDIDirContextAdaptor; |
| | | import org.opends.server.admin.client.ldap.LDAPConnection; |
| | |
| | | import org.opends.server.admin.std.client.RootCfgClient; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.api.WorkQueue; |
| | | import org.opends.server.api.plugin.PluginType; |
| | | import org.opends.server.backends.MemoryBackend; |
| | | import org.opends.server.backends.jeb.*; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.DeleteOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.extensions.ConfigFileHandler; |
| | | import org.opends.server.loggers.*; |
| | | import org.opends.server.plugins.InvocationCounterPlugin; |
| | | import org.forgerock.opendj.io.ASN1; |
| | | import org.forgerock.opendj.io.ASN1Reader; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.opends.server.protocols.ldap.BindRequestProtocolOp; |
| | | import org.opends.server.protocols.ldap.BindResponseProtocolOp; |
| | | import org.opends.server.protocols.ldap.LDAPMessage; |
| | |
| | | import org.opends.server.tools.LDAPModify; |
| | | import org.opends.server.tools.dsconfig.DSConfig; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.FilePermission; |
| | | import org.opends.server.util.BuildVersion; |
| | | import org.opends.server.util.EmbeddedUtils; |
| | |
| | | return new ArrayList<T>(Arrays.asList(elems)); |
| | | } |
| | | |
| | | public static HashSet<PluginType> getPluginTypes(Entry e) |
| | | { |
| | | HashSet<PluginType> pluginTypes = new HashSet<PluginType>(); |
| | | List<Attribute> attrList = e.getAttribute("ds-cfg-plugin-type"); |
| | | if (attrList != null) |
| | | { |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (ByteString v : a) |
| | | { |
| | | pluginTypes.add(PluginType.forName(v.toString().toLowerCase())); |
| | | } |
| | | } |
| | | } |
| | | return pluginTypes; |
| | | } |
| | | |
| | | } |
| | |
| | | import javax.naming.directory.BasicAttributes; |
| | | import javax.naming.ldap.LdapName; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void createEntry(LdapName dn, Attributes attributes) |
| | | throws NamingException { |
| | | throw new UnsupportedOperationException("createEntry"); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void deleteSubtree(LdapName dn) throws NamingException { |
| | | throw new UnsupportedOperationException("deleteSubtree"); |
| | | } |
| | |
| | | @Override |
| | | public Collection<LdapName> listEntries(LdapName dn, String filter) throws NamingException { |
| | | MockEntry entry = getEntry(dn); |
| | | |
| | | if (entry == null) { |
| | | throw new NameNotFoundException("could not find entry " + dn); |
| | | } else { |
| | | } |
| | | |
| | | LinkedList<LdapName> names = new LinkedList<LdapName>(); |
| | | for (MockEntry child : entry.children) { |
| | | for (MockEntry child : entry.children) |
| | | { |
| | | names.add(new LdapName(child.getDN().toString())); |
| | | } |
| | | return names; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void modifyEntry(LdapName dn, Attributes mods) throws NamingException { |
| | | throw new UnsupportedOperationException("modifyEntry"); |
| | | } |
| | |
| | | Attributes attributes = new BasicAttributes(); |
| | | for (org.opends.server.types.Attribute attribute : entry.getAttributes()) { |
| | | BasicAttribute ba = new BasicAttribute(attribute.getName()); |
| | | for (AttributeValue value : attribute) { |
| | | ba.add(value.getValue().toString()); |
| | | for (ByteString value : attribute) { |
| | | ba.add(value.toString()); |
| | | } |
| | | attributes.put(ba); |
| | | } |
| | |
| | | */ |
| | | public TestChildCfg getChild(String expectedName) { |
| | | Assert.assertNotNull(child); |
| | | Assert.assertEquals(child.dn().rdn().getAttributeValue(0) |
| | | .getValue().toString(), expectedName); |
| | | Assert.assertEquals(child.dn().rdn().getAttributeValue(0).toString(), expectedName); |
| | | return child; |
| | | } |
| | | |
| | |
| | | */ |
| | | public TestChildCfg getChild(String expectedName) { |
| | | Assert.assertNotNull(child); |
| | | Assert.assertEquals(child.dn().rdn().getAttributeValue(0) |
| | | .getValue().toString(), expectedName); |
| | | Assert.assertEquals(child.dn().rdn().getAttributeValue(0).toString(), expectedName); |
| | | return child; |
| | | } |
| | | |
| | |
| | | import java.io.File; |
| | | import java.util.Map; |
| | | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.*; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | |
| | | assertTrue(schemaEntry.hasAttribute(mnType)); |
| | | assertTrue(schemaEntry.hasAttribute(mtType)); |
| | | |
| | | AttributeValue oldMTValue = |
| | | ByteString oldMTValue = |
| | | schemaEntry.getAttribute(mtType).get(0).iterator().next(); |
| | | |
| | | String path = TestCaseUtils.createTempFile( |
| | |
| | | assertTrue(schemaEntry.hasAttribute(mnType)); |
| | | assertTrue(schemaEntry.hasAttribute(mtType)); |
| | | |
| | | AttributeValue newMTValue = |
| | | ByteString newMTValue = |
| | | schemaEntry.getAttribute(mtType).get(0).iterator().next(); |
| | | assertFalse(oldMTValue.equals(newMTValue)); |
| | | } |
| | |
| | | DN.valueOf("uid=user.0,ou=People,dc=test,dc=com"), LockMode.DEFAULT); |
| | | |
| | | assertNotNull(entry); |
| | | for (AttributeValue value : entry.getAttribute("cn").get(0)) { |
| | | assertEquals(value.getValue().toString(), "Testing Test"); |
| | | for (ByteString value : entry.getAttribute("cn").get(0)) { |
| | | assertEquals(value.toString(), "Testing Test"); |
| | | } |
| | | for (AttributeValue value : entry.getAttribute("sn").get(0)) { |
| | | assertEquals(value.getValue().toString(), "Test"); |
| | | for (ByteString value : entry.getAttribute("sn").get(0)) { |
| | | assertEquals(value.toString(), "Test"); |
| | | } |
| | | for (AttributeValue value : entry.getAttribute("givenname").get(0)) { |
| | | assertEquals(value.getValue().toString(), "Testing"); |
| | | for (ByteString value : entry.getAttribute("givenname").get(0)) { |
| | | assertEquals(value.toString(), "Testing"); |
| | | } |
| | | for (AttributeValue value : entry.getAttribute("employeenumber").get(0)) { |
| | | assertEquals(value.getValue().toString(), "777"); |
| | | for (ByteString value : entry.getAttribute("employeenumber").get(0)) { |
| | | assertEquals(value.toString(), "777"); |
| | | } |
| | | |
| | | AttributeType attribute = |
| | |
| | | Attributes.create("title", "debugger"))); |
| | | |
| | | final Attribute cnAttr = entry.getAttribute("cn").get(0); |
| | | assertTrue(cnAttr.contains(AttributeValues.create( |
| | | cnAttr.getAttributeType(), "Aaren Rigor"))); |
| | | assertTrue(cnAttr.contains(AttributeValues.create( |
| | | cnAttr.getAttributeType(), "Aarenister Rigor"))); |
| | | assertFalse(cnAttr.contains(AttributeValues.create( |
| | | cnAttr.getAttributeType(), "Aaren Atp"))); |
| | | assertTrue(cnAttr.contains(ByteString.valueOf("Aaren Rigor"))); |
| | | assertTrue(cnAttr.contains(ByteString.valueOf("Aarenister Rigor"))); |
| | | assertFalse(cnAttr.contains(ByteString.valueOf("Aaren Atp"))); |
| | | |
| | | Set<String> options = Collections.singleton("lang-de"); |
| | | assertTrue(entry.getAttribute("givenname", options).get(0).contains( |
| | | AttributeValues.create(entry.getAttribute("givenname", options).get(0) |
| | | .getAttributeType(), "test"))); |
| | | ByteString.valueOf("test"))); |
| | | options = Collections.singleton("lang-cn"); |
| | | assertNull(entry.getAttribute("givenname", options)); |
| | | options = Collections.singleton("lang-es"); |
| | | assertTrue(entry.getAttribute("givenname", options).get(0).contains( |
| | | AttributeValues.create(entry.getAttribute("givenname", options).get(0) |
| | | .getAttributeType(), "newtest3"))); |
| | | ByteString.valueOf("newtest3"))); |
| | | options = Collections.singleton("lang-fr"); |
| | | assertTrue(entry.getAttribute("givenname", options).get(0).contains( |
| | | AttributeValues.create(entry.getAttribute("givenname", options).get(0) |
| | | .getAttributeType(), "test2"))); |
| | | ByteString.valueOf("test2"))); |
| | | |
| | | assertTrue(entry.getAttribute("employeenumber").contains( |
| | | Attributes.create("employeenumber", "222"))); |
| | |
| | | //No indexes should be used. |
| | | String debugString = |
| | | result.get(0).getAttribute("debugsearchindex").get(0).toString(); |
| | | assertTrue(debugString.contains("NOT-INDEXED")); |
| | | assertThat(debugString).contains("not-indexed"); |
| | | |
| | | resultCode = TestCaseUtils.applyModifications(true, |
| | | "dn: ds-cfg-attribute=givenName,cn=Index," + |
| | |
| | | //No indexes should be used. |
| | | String debugString = |
| | | result.get(0).getAttribute("debugsearchindex").get(0).toString(); |
| | | assertThat(debugString).contains("NOT-INDEXED"); |
| | | assertThat(debugString).contains("not-indexed"); |
| | | } |
| | | |
| | | @Test(dependsOnMethods = "testSearchNotIndexed") |
| | |
| | | */ |
| | | package org.opends.server.backends.jeb; |
| | | |
| | | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.tasks.TaskUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.util.*; |
| | | |
| | | |
| | | |
| | | @SuppressWarnings("javadoc") |
| | | public class TestImportJob extends JebTestCase |
| | | { |
| | | private String beID = "importRoot"; |
| | |
| | | AttributeType attribute = entry.getAttribute("cn").get(0) |
| | | .getAttributeType(); |
| | | |
| | | assertTrue(entry.hasValue(attribute, null, |
| | | AttributeValues.create(attribute, "Annalee Bogard"))); |
| | | assertTrue(entry.hasValue(attribute, null, ByteString.valueOf("Annalee Bogard"))); |
| | | |
| | | VerifyConfig verifyConfig = new VerifyConfig(); |
| | | verifyConfig.setBaseDN(DN.valueOf("dc=importtest1,dc=com")); |
| | |
| | | if (attrType == null) |
| | | attrType = DirectoryServer.getDefaultAttributeType(type); |
| | | List<Attribute> attrList = e.getAttribute(attrType, null); |
| | | AttributeValue v = attrList.get(0).iterator().next(); |
| | | long retVal = Long.parseLong(v.getValue().toString()); |
| | | return (retVal); |
| | | ByteString v = attrList.get(0).iterator().next(); |
| | | return Long.parseLong(v.toString()); |
| | | } |
| | | } |
| | |
| | | // Encoded one-to-five byte number of attributes |
| | | buffer.appendBERLength(numAttributes); |
| | | |
| | | |
| | | // The attributes will be encoded as a sequence of: |
| | | // - A UTF-8 byte representation of the attribute name. |
| | | // - A zero delimiter |
| | | // - A one-to-five byte number of values for the attribute |
| | | // - A sequence of: |
| | | // - A one-to-five byte length for the value |
| | | // - A UTF-8 byte representation for the value |
| | | for (List<Attribute> attrList : attributes.values()) |
| | | { |
| | | for (Attribute a : attrList) |
| | | { |
| | | byte[] nameBytes = getBytes(a.getNameWithOptions()); |
| | | buffer.append(nameBytes); |
| | | buffer.append((byte)0x00); |
| | | |
| | | buffer.appendBERLength(a.size()); |
| | | for(AttributeValue v : a) |
| | | { |
| | | buffer.appendBERLength(v.getValue().length()); |
| | | buffer.append(v.getValue()); |
| | | } |
| | | } |
| | | } |
| | | append(buffer, attributes); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | else |
| | | { |
| | | // The attributes will be encoded as a sequence of: |
| | | // - A UTF-8 byte representation of the attribute name. |
| | | // - A zero delimiter |
| | | // - A one-to-five byte number of values for the attribute |
| | | // - A sequence of: |
| | | // - A one-to-five byte length for the value |
| | | // - A UTF-8 byte representation for the value |
| | | append(buffer, attributes); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * The attributes will be encoded as a sequence of: |
| | | * - A UTF-8 byte representation of the attribute name. |
| | | * - A zero delimiter |
| | | * - A one-to-five byte number of values for the attribute |
| | | * - A sequence of: |
| | | * - A one-to-five byte length for the value |
| | | * - A UTF-8 byte representation for the value |
| | | */ |
| | | private void append(ByteStringBuilder buffer, |
| | | Map<AttributeType, List<Attribute>> attributes) |
| | | { |
| | | for (List<Attribute> attrList : attributes.values()) |
| | | { |
| | | for (Attribute a : attrList) |
| | |
| | | buffer.append((byte)0x00); |
| | | |
| | | buffer.appendBERLength(a.size()); |
| | | for(AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | buffer.appendBERLength(v.getValue().length()); |
| | | buffer.append(v.getValue()); |
| | | } |
| | | buffer.appendBERLength(v.length()); |
| | | buffer.append(v); |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.backends.jeb; |
| | | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.AfterClass; |
| | | import org.testng.annotations.Test; |
| | | import static org.testng.Assert.*; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.backends.jeb.RebuildConfig.RebuildMode; |
| | | import org.opends.server.tasks.TaskUtils; |
| | | import static org.opends.server.util.ServerConstants.OC_TOP; |
| | | import static org.opends.server.util.ServerConstants.OC_EXTENSIBLE_OBJECT; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import java.util.List; |
| | | import java.util.HashMap; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.backends.jeb.RebuildConfig.RebuildMode; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.tasks.TaskUtils; |
| | | import org.opends.server.types.*; |
| | | import org.testng.annotations.AfterClass; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | @SuppressWarnings("javadoc") |
| | | public class TestRebuildJob extends JebTestCase |
| | | { |
| | | private String beID="rebuildRoot"; |
| | |
| | | if (attrType == null) |
| | | attrType = DirectoryServer.getDefaultAttributeType(type); |
| | | List<Attribute> attrList = e.getAttribute(attrType, null); |
| | | AttributeValue v = attrList.get(0).iterator().next(); |
| | | long retVal = Long.parseLong(v.getValue().toString()); |
| | | return (retVal); |
| | | ByteString v = attrList.get(0).iterator().next(); |
| | | return Long.parseLong(v.toString()); |
| | | } |
| | | } |
| | |
| | | int i = 0; |
| | | for(SortValues values : expectedSortedValues) |
| | | { |
| | | AttributeValue[] attrValues = values.getValues(); |
| | | ByteString[] attrValues = values.getValues(); |
| | | AttributeType[] attrTypes = values.getTypes(); |
| | | for(int j = 0; j < attrValues.length; j++) |
| | | { |
| | |
| | | if(attrValues[j] != null) |
| | | { |
| | | MatchingRule eqRule = attrTypes[j].getEqualityMatchingRule(); |
| | | oValue = eqRule.normalizeAttributeValue(attrValues[j].getValue()); |
| | | oValue = eqRule.normalizeAttributeValue(attrValues[j]); |
| | | } |
| | | assertEquals(value, oValue); |
| | | } |
| | |
| | | |
| | | // Add an incorrectly ordered values. |
| | | SortValuesSet svs = |
| | | vlvIndex.getSortValuesSet(null, 0, new AttributeValue[3], new AttributeType[3]); |
| | | vlvIndex.getSortValuesSet(null, 0, new ByteString[3], new AttributeType[3]); |
| | | long id = svs.getEntryIDs()[0]; |
| | | Entry entry = eContainer.getID2Entry().get(null, new EntryID(id), LockMode.DEFAULT); |
| | | |
| | |
| | | // Muck up the values of another ID |
| | | id = svs.getEntryIDs()[0]; |
| | | entry = eContainer.getID2Entry().get(null, new EntryID(id), LockMode.DEFAULT); |
| | | AttributeValue[] values = vlvIndex.getSortValues(entry); |
| | | AttributeValue[] badValues = new AttributeValue[values.length]; |
| | | ByteString[] values = vlvIndex.getSortValues(entry); |
| | | ByteString[] badValues = new ByteString[values.length]; |
| | | System.arraycopy(values, 1, badValues, 0, values.length - 1); |
| | | badValues[badValues.length-1] = values[0]; |
| | | svs.remove(id, values, types); |
| | |
| | | AttributeType[] types = vlvIndex.getSortTypes(); |
| | | |
| | | // Remove an ID |
| | | SortValuesSet svs = |
| | | vlvIndex.getSortValuesSet(null, 0, new AttributeValue[3], types); |
| | | SortValuesSet svs = vlvIndex.getSortValuesSet(null, 0, new ByteString[3], types); |
| | | long id = svs.getEntryIDs()[0]; |
| | | Entry entry = eContainer.getID2Entry().get(null, new EntryID(id), LockMode.DEFAULT); |
| | | svs.remove(id, vlvIndex.getSortValues(entry), types); |
| | |
| | | // Muck up the values of another ID |
| | | id = svs.getEntryIDs()[0]; |
| | | entry = eContainer.getID2Entry().get(null, new EntryID(id), LockMode.DEFAULT); |
| | | AttributeValue[] values = vlvIndex.getSortValues(entry); |
| | | AttributeValue[] badValues = new AttributeValue[values.length]; |
| | | ByteString[] values = vlvIndex.getSortValues(entry); |
| | | ByteString[] badValues = new ByteString[values.length]; |
| | | System.arraycopy(values, 1, badValues, 0, values.length - 1); |
| | | badValues[badValues.length-1] = values[0]; |
| | | svs.remove(id, values, types); |
| | |
| | | if (attrType == null) |
| | | attrType = DirectoryServer.getDefaultAttributeType(type); |
| | | List<Attribute> attrList = e.getAttribute(attrType, null); |
| | | AttributeValue v = attrList.get(0).iterator().next(); |
| | | long retVal = Long.parseLong(v.getValue().toString()); |
| | | return (retVal); |
| | | ByteString v = attrList.get(0).iterator().next(); |
| | | return Long.parseLong(v.toString()); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | // |
| | | // ( AttributeType attributeType, AttributeValue assertionValue |
| | | // ( AttributeType attributeType, ByteString assertionValue |
| | | // |
| | | AttributeType attType = DirectoryServer.getAttributeType(type); |
| | | AttributeValue attVal = null; |
| | | ByteString attVal = null; |
| | | if (attType != null) |
| | | { |
| | | attVal = AttributeValues.create(attType, value); |
| | | attVal = ByteString.valueOf(value); |
| | | } |
| | | |
| | | // Check null, null |
| | | try |
| | | { |
| | | mvf = MatchedValuesFilter.createEqualityFilter((AttributeType) null, |
| | | (AttributeValue) null); |
| | | mvf = MatchedValuesFilter.createEqualityFilter((AttributeType) null, null); |
| | | assertTrue(false, "Expected NullPointerException"); |
| | | } |
| | | catch (NullPointerException e) |
| | |
| | | // Check type, null |
| | | try |
| | | { |
| | | mvf = MatchedValuesFilter.createEqualityFilter(attType, |
| | | (AttributeValue) null); |
| | | mvf = MatchedValuesFilter.createEqualityFilter(attType, null); |
| | | assertTrue(false, "Expected NullPointerException"); |
| | | } |
| | | catch (NullPointerException e) |
| | |
| | | } |
| | | |
| | | // |
| | | // ( AttributeType attributeType, AttributeValue assertionValue |
| | | // ( AttributeType attributeType, ByteString assertionValue |
| | | // |
| | | AttributeType attType = DirectoryServer.getAttributeType(type); |
| | | AttributeValue attVal = null; |
| | | ByteString attVal = null; |
| | | if (attType != null) |
| | | { |
| | | attVal = AttributeValues.create(attType, value); |
| | | attVal = ByteString.valueOf(value); |
| | | } |
| | | |
| | | // Check null, null |
| | | try |
| | | { |
| | | mvf = MatchedValuesFilter.createGreaterOrEqualFilter( |
| | | (AttributeType) null, (AttributeValue) null); |
| | | mvf = MatchedValuesFilter.createGreaterOrEqualFilter((AttributeType) null, null); |
| | | assertTrue(false, "Expected NullPointerException"); |
| | | } |
| | | catch (NullPointerException e) |
| | |
| | | // Check type, null |
| | | try |
| | | { |
| | | mvf = MatchedValuesFilter.createGreaterOrEqualFilter(attType, |
| | | (AttributeValue) null); |
| | | mvf = MatchedValuesFilter.createGreaterOrEqualFilter(attType, null); |
| | | assertTrue(false, "Expected NullPointerException"); |
| | | } |
| | | catch (NullPointerException e) |
| | |
| | | ; |
| | | |
| | | // |
| | | // ( AttributeType attributeType, AttributeValue assertionValue |
| | | // ( AttributeType attributeType, ByteString assertionValue |
| | | // |
| | | AttributeType attType = DirectoryServer.getAttributeType(type); |
| | | AttributeValue attVal = null ; |
| | | ByteString attVal = null ; |
| | | if (attType != null) |
| | | { |
| | | attVal = AttributeValues.create(attType, value); |
| | | attVal = ByteString.valueOf(value); |
| | | } |
| | | |
| | | // Check null, null |
| | | try |
| | | { |
| | | mvf = MatchedValuesFilter.createLessOrEqualFilter((AttributeType) null, |
| | | (AttributeValue) null); |
| | | mvf = MatchedValuesFilter.createLessOrEqualFilter((AttributeType) null, null); |
| | | } |
| | | catch (NullPointerException e) |
| | | { |
| | |
| | | // Check type, null |
| | | try |
| | | { |
| | | mvf = MatchedValuesFilter.createLessOrEqualFilter(attType, |
| | | (AttributeValue) null); |
| | | mvf = MatchedValuesFilter.createLessOrEqualFilter(attType, null); |
| | | } |
| | | catch (NullPointerException e) |
| | | { |
| | |
| | | } |
| | | |
| | | // |
| | | // ( AttributeType attributeType, AttributeValue assertionValue |
| | | // ( AttributeType attributeType, ByteString assertionValue |
| | | // |
| | | AttributeType attType = DirectoryServer.getAttributeType(type); |
| | | AttributeValue attVal = null ; |
| | | ByteString attVal = null ; |
| | | if (attType != null) |
| | | { |
| | | attVal = AttributeValues.create(attType, value); |
| | | attVal = ByteString.valueOf(value); |
| | | } |
| | | |
| | | // Check null, null |
| | | try |
| | | { |
| | | mvf = MatchedValuesFilter.createApproximateFilter((AttributeType) null, |
| | | (AttributeValue) null); |
| | | mvf = MatchedValuesFilter.createApproximateFilter((AttributeType) null, null); |
| | | assertTrue(false, "Expected NullPointerException"); |
| | | } |
| | | catch (NullPointerException e) |
| | |
| | | // Check type, null |
| | | try |
| | | { |
| | | mvf = MatchedValuesFilter.createApproximateFilter(attType, |
| | | (AttributeValue) null); |
| | | mvf = MatchedValuesFilter.createApproximateFilter(attType, null); |
| | | assertTrue(false, "Expected NullPointerException"); |
| | | } |
| | | catch (NullPointerException e) |
| | |
| | | String rawAttTypeTest = type ; |
| | | AttributeType attTypeTest = DirectoryServer.getAttributeType(type) ; |
| | | String matchingRuleIdTest = matchingRule.getOID() ; |
| | | ByteString rawAttValueTest = (attTypeTest == null) ? null : ByteString.valueOf(value); |
| | | AttributeValue attValueTest = (attTypeTest == null) ? null : AttributeValues.create(attTypeTest, value); |
| | | ByteString attValueTest = (attTypeTest == null) ? null : ByteString.valueOf(value); |
| | | // |
| | | // parameter used for the test. |
| | | String rawAttTypeTestCurrent; |
| | | AttributeType attTypeTestCurrent ; |
| | | String rawMatchingRuleidTestCurrent ; |
| | | MatchingRule matchingRuleidTestCurrent ; |
| | | ByteString rawAttValueTestCurrent; |
| | | AttributeValue attValueTestCurrent; |
| | | ByteString attValueTestCurrent; |
| | | |
| | | |
| | | for (int i= 0 ; i <= 7 ; i++) |
| | |
| | | rawAttTypeTestCurrent = null; |
| | | rawMatchingRuleidTestCurrent = null; |
| | | matchingRuleidTestCurrent = null ; |
| | | rawAttValueTestCurrent = null; |
| | | attTypeTestCurrent = null; |
| | | attValueTestCurrent = null ; |
| | | |
| | |
| | | if ((i & 0x4) != 0) rawAttTypeTestCurrent = rawAttTypeTest; |
| | | if ((i & 0x2) != 0) rawMatchingRuleidTestCurrent = matchingRuleIdTest; |
| | | if ((i & 0x2) != 0) matchingRuleidTestCurrent = matchingRule ; |
| | | if ((i & 0x1) != 0) rawAttValueTestCurrent = rawAttValueTest; |
| | | if ((i & 0x1) != 0) attValueTestCurrent = attValueTest; |
| | | |
| | | boolean exceptionExpected = (attTypeTestCurrent == null) |
| | |
| | | { |
| | | // Create filter with raw value |
| | | mvf = MatchedValuesFilter.createExtensibleMatchFilter(rawAttTypeTestCurrent, |
| | | rawMatchingRuleidTestCurrent, rawAttValueTestCurrent); |
| | | rawMatchingRuleidTestCurrent, attValueTestCurrent); |
| | | if ( exceptionExpected) |
| | | { |
| | | assertTrue(false, "Expected NullPointerException"); |
| | |
| | | assertEquals(mvf.getMatchType(), |
| | | MatchedValuesFilter.EXTENSIBLE_MATCH_TYPE); |
| | | assertEquals(rawMatchingRuleidTestCurrent, mvf.getMatchingRuleID()); |
| | | assertEquals(rawAttValueTestCurrent, mvf.getRawAssertionValue()); |
| | | assertEquals(attValueTestCurrent, mvf.getRawAssertionValue()); |
| | | |
| | | mvf = MatchedValuesFilter.createExtensibleMatchFilter( |
| | | attTypeTestCurrent, matchingRuleidTestCurrent, attValueTestCurrent); |
| | |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | if ( ! exceptionExpected) |
| | | { |
| | | assertTrue(false, "Exception not excepted" + t.getMessage()); |
| | | } |
| | | assertTrue(exceptionExpected, "Exception not excepted" + t.getMessage()); |
| | | } |
| | | } |
| | | } |
| | |
| | | /** |
| | | * Check encode/decode method |
| | | */ |
| | | private void checkEncodeDecode(MatchedValuesFilter mvf) |
| | | private void checkEncodeDecode(MatchedValuesFilter mvf) throws Exception |
| | | { |
| | | ByteStringBuilder bsb = new ByteStringBuilder(); |
| | | ASN1Writer writer = ASN1.getWriter(bsb); |
| | | try |
| | | { |
| | | mvf.encode(writer); |
| | | MatchedValuesFilter newMvf = MatchedValuesFilter.decode(ASN1 |
| | | .getReader(bsb)); |
| | | assertEquals(newMvf.toString(), mvf.toString()); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assertTrue(false, "Unexpected LDAPException ; msg=" + e.getMessage()); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | @DataProvider(name = "differentNormalization") |
| | | public Object[][] differentNormalizationData() throws ParseException |
| | | { |
| | |
| | | CERT_EXACT_ASSERTION}}; |
| | | } |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | @Test(dataProvider = "differentNormalization") |
| | | public void testDifferentNormalization(String type, ByteString value, |
| | | String assertion) |
| | | { |
| | | MatchedValuesFilter mvf; |
| | | AttributeType attrType = DirectoryServer.getAttributeType("usercertificate"); |
| | | AttributeValue attrValue = AttributeValues.create(attrType, value); |
| | | |
| | | mvf = MatchedValuesFilter.createEqualityFilter(type, ByteString.valueOf(assertion)); |
| | | assertTrue(mvf.valueMatches(attrType, attrValue)); |
| | | MatchedValuesFilter mvf = MatchedValuesFilter.createEqualityFilter(type, ByteString.valueOf(assertion)); |
| | | assertTrue(mvf.valueMatches(attrType, value)); |
| | | } |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.net.Socket; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | |
| | | import java.util.concurrent.locks.Lock; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.plugins.DisconnectClientPlugin; |
| | |
| | | import org.opends.server.tools.LDAPReader; |
| | | import org.opends.server.tools.LDAPWriter; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.testng.annotations.AfterMethod; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * A set of test cases for add operations |
| | | */ |
| | |
| | | boolean foundBar = false; |
| | | for (Attribute attr : attrList) |
| | | { |
| | | if (attr.contains(AttributeValues.create(a.getAttributeType(), |
| | | ByteString.valueOf("foo")))) |
| | | if (attr.contains(ByteString.valueOf("foo"))) |
| | | { |
| | | foundFoo = true; |
| | | } |
| | | |
| | | if (attr.contains(AttributeValues.create(a.getAttributeType(), |
| | | ByteString.valueOf("bar")))) |
| | | if (attr.contains(ByteString.valueOf("bar"))) |
| | | { |
| | | foundBar = true; |
| | | } |
| | |
| | | boolean found = false; |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | if (v.getValue().toString().equalsIgnoreCase("top")) |
| | | if (v.toString().equalsIgnoreCase("top")) |
| | | { |
| | | found = true; |
| | | break; |
| | |
| | | boolean found = false; |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | assertEquals(Integer.parseInt(v.getValue().toString()), expectedValue); |
| | | assertEquals(Integer.parseInt(v.toString()), expectedValue); |
| | | found = true; |
| | | } |
| | | } |
| | |
| | | String passwd = null; |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | passwd = v.toString(); |
| | | } |
| | |
| | | Attribute a = attrList.get(0); |
| | | assertTrue(a.hasOption("binary")); |
| | | assertEquals(a.size(), 1); |
| | | assertEquals(Base64.encode(a.iterator().next().getValue()), certificateValue); |
| | | assertEquals(Base64.encode(a.iterator().next()), certificateValue); |
| | | } |
| | | |
| | | |
| | |
| | | expectedOrder.append(expectedNameOrder[i]); |
| | | |
| | | DN dn = pluginArray[i].getPluginEntryDN(); |
| | | String name = |
| | | dn.rdn().getAttributeValue(0).getValue().toString().toLowerCase(); |
| | | String name = dn.rdn().getAttributeValue(0).toString().toLowerCase(); |
| | | actualOrder.append(name); |
| | | |
| | | if (! name.equals(expectedNameOrder[i])) |
| | |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | Entry entry = DirectoryServer.getEntry(testEntry.getName()); |
| | | AttributeType attrType = DirectoryServer.getAttributeType( |
| | | "c-l"); |
| | | AttributeType attrType = DirectoryServer.getAttributeType("c-l"); |
| | | assertTrue(entry.hasAttribute(attrType)); |
| | | assertTrue(entry.hasValue(attrType, null, |
| | | AttributeValues.create(attrType, "Savoie"))); |
| | | assertTrue(entry.hasValue(attrType, null, ByteString.valueOf("Savoie"))); |
| | | |
| | | attrType = DirectoryServer.getAttributeType( |
| | | "preferredlanguage"); |
| | | attrType = DirectoryServer.getAttributeType("preferredlanguage"); |
| | | assertTrue(entry.hasAttribute(attrType)); |
| | | assertTrue(entry.hasValue(attrType, null, |
| | | AttributeValues.create(attrType, "fr"))); |
| | | assertTrue(entry.hasValue(attrType, null, ByteString.valueOf("fr"))); |
| | | } |
| | | |
| | | |
| | |
| | | Attribute attribute = description.get(0); |
| | | assertEquals(attribute.size(), 1); |
| | | assertFalse(attribute.hasOptions()); |
| | | assertTrue(attribute.contains(AttributeValues.create( |
| | | attribute.getAttributeType(), "inherited description"))); |
| | | assertTrue(attribute.contains(ByteString.valueOf("inherited description"))); |
| | | } |
| | | finally |
| | | { |
| | |
| | | |
| | | // Test Inherited Collective Attributes on test entry. |
| | | Entry entry = DirectoryServer.getEntry(testEntry.getName()); |
| | | AttributeType attrType = DirectoryServer.getAttributeType( |
| | | "postaladdress"); |
| | | AttributeType attrType = DirectoryServer.getAttributeType("postaladdress"); |
| | | assertTrue(entry.hasAttribute(attrType)); |
| | | assertTrue(entry.hasValue(attrType, null, |
| | | AttributeValues.create(attrType, |
| | | "Sub City, Collective Street, AK 47"))); |
| | | ByteString.valueOf("Sub City, Collective Street, AK 47"))); |
| | | |
| | | attrType = DirectoryServer.getAttributeType( |
| | | "telephonenumber"); |
| | | attrType = DirectoryServer.getAttributeType("telephonenumber"); |
| | | assertTrue(entry.hasAttribute(attrType)); |
| | | assertTrue(entry.hasValue(attrType, null, |
| | | AttributeValues.create(attrType, |
| | | "+1 999 999 9999"))); |
| | | ByteString.valueOf("+1 999 999 9999"))); |
| | | |
| | | // Cleanup. |
| | | TestCaseUtils.deleteEntry(collectiveRDNInheritedSubentry.getName()); |
| | |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | Entry entry = DirectoryServer.getEntry(testEntry.getName()); |
| | | AttributeType attrType = DirectoryServer.getAttributeType( |
| | | "preferredlanguage"); |
| | | AttributeType attrType = DirectoryServer.getAttributeType("preferredlanguage"); |
| | | assertTrue(entry.hasAttribute(attrType)); |
| | | assertTrue(entry.hasValue(attrType, null, |
| | | AttributeValues.create(attrType, "ja"))); |
| | | assertFalse(entry.hasValue(attrType, null, |
| | | AttributeValues.create(attrType, "fr"))); |
| | | assertTrue(entry.hasValue(attrType, null, ByteString.valueOf("ja"))); |
| | | assertFalse(entry.hasValue(attrType, null, ByteString.valueOf("fr"))); |
| | | |
| | | // virtual-overrides-real. |
| | | values = new ArrayList<ByteString>(); |
| | |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | entry = DirectoryServer.getEntry(testEntry.getName()); |
| | | attrType = DirectoryServer.getAttributeType( |
| | | "preferredlanguage"); |
| | | attrType = DirectoryServer.getAttributeType("preferredlanguage"); |
| | | assertTrue(entry.hasAttribute(attrType)); |
| | | assertTrue(entry.hasValue(attrType, null, |
| | | AttributeValues.create(attrType, "fr"))); |
| | | assertFalse(entry.hasValue(attrType, null, |
| | | AttributeValues.create(attrType, "ja"))); |
| | | assertTrue(entry.hasValue(attrType, null, ByteString.valueOf("fr"))); |
| | | assertFalse(entry.hasValue(attrType, null, ByteString.valueOf("ja"))); |
| | | |
| | | // merge-real-and-virtual. |
| | | values = new ArrayList<ByteString>(); |
| | |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | entry = DirectoryServer.getEntry(testEntry.getName()); |
| | | attrType = DirectoryServer.getAttributeType( |
| | | "preferredlanguage"); |
| | | attrType = DirectoryServer.getAttributeType("preferredlanguage"); |
| | | assertTrue(entry.hasAttribute(attrType)); |
| | | assertTrue(entry.hasValue(attrType, null, |
| | | AttributeValues.create(attrType, "ja"))); |
| | | assertTrue(entry.hasValue(attrType, null, |
| | | AttributeValues.create(attrType, "fr"))); |
| | | assertTrue(entry.hasValue(attrType, null, ByteString.valueOf("ja"))); |
| | | assertTrue(entry.hasValue(attrType, null, ByteString.valueOf("fr"))); |
| | | |
| | | // cleanup. |
| | | values = new ArrayList<ByteString>(); |
| | |
| | | searchOperation.run(); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertEquals(searchOperation.getEntriesSent(), 1); |
| | | AttributeType attrType = DirectoryServer.getAttributeType( |
| | | "collectiveattributesubentries"); |
| | | AttributeType attrType = DirectoryServer.getAttributeType("collectiveattributesubentries"); |
| | | assertTrue(searchOperation.getSearchEntries().getFirst().hasValue( |
| | | attrType, null, AttributeValues.create(attrType, |
| | | collectiveSubentry.getName().toNormalizedString()))); |
| | | attrType, null, ByteString.valueOf(collectiveSubentry.getName()))); |
| | | } |
| | | |
| | | @Test |
| | |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | Entry entry = DirectoryServer.getEntry(testEntry.getName()); |
| | | AttributeType attrType = DirectoryServer.getAttributeType( |
| | | "c-l"); |
| | | AttributeType attrType = DirectoryServer.getAttributeType("c-l"); |
| | | assertFalse(entry.hasAttribute(attrType)); |
| | | attrType = DirectoryServer.getAttributeType( |
| | | "preferredlanguage"); |
| | | attrType = DirectoryServer.getAttributeType("preferredlanguage"); |
| | | assertTrue(entry.hasAttribute(attrType)); |
| | | assertTrue(entry.hasValue(attrType, null, |
| | | AttributeValues.create(attrType, "fr"))); |
| | | assertTrue(entry.hasValue(attrType, null, ByteString.valueOf("fr"))); |
| | | |
| | | values = new ArrayList<ByteString>(); |
| | | values.add(ByteString.valueOf("preferredLanguage")); |
| | |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | entry = DirectoryServer.getEntry(testEntry.getName()); |
| | | attrType = DirectoryServer.getAttributeType( |
| | | "preferredlanguage"); |
| | | attrType = DirectoryServer.getAttributeType("preferredlanguage"); |
| | | assertFalse(entry.hasAttribute(attrType)); |
| | | attrType = DirectoryServer.getAttributeType( |
| | | "c-l"); |
| | | attrType = DirectoryServer.getAttributeType("c-l"); |
| | | assertTrue(entry.hasAttribute(attrType)); |
| | | assertTrue(entry.hasValue(attrType, null, |
| | | AttributeValues.create(attrType, "Savoie"))); |
| | | assertTrue(entry.hasValue(attrType, null, ByteString.valueOf("Savoie"))); |
| | | |
| | | values = new ArrayList<ByteString>(); |
| | | values.add(ByteString.valueOf("excludeAllCollectiveAttributes")); |
| | |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | entry = DirectoryServer.getEntry(testEntry.getName()); |
| | | attrType = DirectoryServer.getAttributeType( |
| | | "preferredlanguage"); |
| | | attrType = DirectoryServer.getAttributeType("preferredlanguage"); |
| | | assertFalse(entry.hasAttribute(attrType)); |
| | | attrType = DirectoryServer.getAttributeType( |
| | | "c-l"); |
| | | attrType = DirectoryServer.getAttributeType("c-l"); |
| | | assertFalse(entry.hasAttribute(attrType)); |
| | | |
| | | // cleanup. |
| | |
| | | import org.opends.server.api.AuthenticationPolicy; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValues; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.testng.annotations.AfterClass; |
| | |
| | | // for the user entry. |
| | | assertTrue(testEntry.hasAttribute(attrType)); |
| | | assertTrue(testEntry.hasValue(attrType, null, |
| | | AttributeValues.create(attrType, |
| | | defaultPolicy.getDN( |
| | | ).toString()))); |
| | | ByteString.valueOf(defaultPolicy.getDN().toString()))); |
| | | |
| | | // Add new subentry policy with the |
| | | // scope to apply to the user entry. |
| | |
| | | |
| | | assertTrue(testEntry.hasAttribute(attrType)); |
| | | assertTrue(testEntry.hasValue(attrType, null, |
| | | AttributeValues.create(attrType, |
| | | "cn=Temp Policy," + SUFFIX))); |
| | | ByteString.valueOf("cn=Temp Policy," + SUFFIX))); |
| | | |
| | | // Remove subentry policy and make sure |
| | | // default policy is in effect again. |
| | |
| | | |
| | | assertTrue(testEntry.hasAttribute(attrType)); |
| | | assertTrue(testEntry.hasValue(attrType, null, |
| | | AttributeValues.create(attrType, |
| | | defaultPolicy.getDN( |
| | | ).toString()))); |
| | | ByteString.valueOf(defaultPolicy.getDN().toString()))); |
| | | } |
| | | } |
| | |
| | | for (int i = 0; i < rdn.getNumValues(); i++) |
| | | { |
| | | AttributeType attribute = rdn.getAttributeType(i); |
| | | assertEquals(newEntry.hasValue(attribute, null, AttributeValues.create( |
| | | attribute, "user.0")), user0Exists); |
| | | assertEquals(newEntry.hasValue(attribute, null, AttributeValues.create( |
| | | attribute, "user.test0")), userTest0Exists); |
| | | assertEquals(newEntry.hasValue(attribute, null, ByteString.valueOf("user.0")), user0Exists); |
| | | assertEquals(newEntry.hasValue(attribute, null, ByteString.valueOf("user.test0")), userTest0Exists); |
| | | } |
| | | } |
| | | |
| | |
| | | assertEquals(attrList.size(),1); |
| | | |
| | | // Because deleteOldRDN is true, the values from RDN and the entry have to be identical |
| | | ByteString valueFromEntry = attrList.get(0).iterator().next().getValue(); |
| | | ByteString valueFromRDN = newEntry.getName().rdn().getAttributeValue(at).getValue(); |
| | | ByteString valueFromEntry = attrList.get(0).iterator().next(); |
| | | ByteString valueFromRDN = newEntry.getName().rdn().getAttributeValue(at); |
| | | assertEquals(valueFromEntry,valueFromRDN); |
| | | |
| | | examineCompletedOperation(modifyDNOperation); |
| | |
| | | assertEquals(attrList.size(),1); |
| | | |
| | | // Even though the value of the RDN changed, the representation of the entry's value should be preserved |
| | | ByteString valueFromEntry = attrList.get(0).iterator().next().getValue(); |
| | | ByteString valueFromRDN = newEntry.getName().rdn().getAttributeValue(at).getValue(); |
| | | assertEquals(valueFromEntry,ByteString.valueOf("userid.0")); |
| | | ByteString valueFromEntry = attrList.get(0).iterator().next(); |
| | | ByteString valueFromRDN = newEntry.getName().rdn().getAttributeValue(at); |
| | | assertEquals(valueFromEntry, valueFromRDN); |
| | | assertEquals(valueFromEntry, ByteString.valueOf("UserID.0")); |
| | | |
| | | examineCompletedOperation(modifyDNOperation); |
| | | TestCaseUtils.deleteEntry(DN.valueOf("uid=UserID.0+cn=Test,ou=People,dc=example,dc=com")); |
| | |
| | | |
| | | // Even though the representation of the sn value differs in the RDN, |
| | | // the representation of the entry's value should be preserved |
| | | ByteString valueFromEntry = attrList.get(0).iterator().next().getValue(); |
| | | ByteString valueFromRDN = newEntry.getName().rdn().getAttributeValue(at).getValue(); |
| | | assertEquals(valueFromEntry,ByteString.valueOf("Jensen")); |
| | | ByteString valueFromEntry = attrList.get(0).iterator().next(); |
| | | ByteString valueFromRDN = newEntry.getName().rdn().getAttributeValue(at); |
| | | assertEquals(valueFromEntry, valueFromRDN); |
| | | assertEquals(valueFromEntry, ByteString.valueOf("JENSEN")); |
| | | |
| | | examineCompletedOperation(modifyDNOperation); |
| | | TestCaseUtils.deleteEntry(DN.valueOf("uid=userid.0+sn=Jensen,ou=People,dc=example,dc=com")); |
| | |
| | | |
| | | for(Attribute attribute : newEntry.getAttribute("cn")) |
| | | { |
| | | assertTrue(attribute.contains(AttributeValues.create(attribute.getAttributeType(), "Aaccf Amar Test"))); |
| | | assertTrue(attribute.contains(AttributeValues.create(attribute.getAttributeType(), "Aaccf Amar"))); |
| | | assertTrue(attribute.contains(ByteString.valueOf("Aaccf Amar Test"))); |
| | | assertTrue(attribute.contains(ByteString.valueOf("Aaccf Amar"))); |
| | | } |
| | | |
| | | examineCompletedOPNoExtraPluginCounts(modifyDNOperation); |
| | |
| | | assertNull(DirectoryServer.getEntry(DN.valueOf("cn=Aaccf Amar Test,dc=example,dc=com"))); |
| | | for(Attribute attribute : newOldEntry.getAttribute("cn")) |
| | | { |
| | | assertTrue(attribute.contains(AttributeValues.create(attribute.getAttributeType(), "Aaccf Amar Test"))); |
| | | assertTrue(attribute.contains(AttributeValues.create(attribute.getAttributeType(), "Aaccf Amar"))); |
| | | assertTrue(attribute.contains(ByteString.valueOf("Aaccf Amar Test"))); |
| | | assertTrue(attribute.contains(ByteString.valueOf("Aaccf Amar"))); |
| | | } |
| | | for(Attribute attribute : newOldEntry.getAttribute("uid")) |
| | | { |
| | | assertTrue(attribute.contains(AttributeValues.create(attribute.getAttributeType(), "user.0"))); |
| | | assertTrue(attribute.contains(ByteString.valueOf("user.0"))); |
| | | } |
| | | examineCompletedOPNoExtraPluginCounts(modifyDNOperation); |
| | | } |
| | |
| | | import java.util.Collections; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.SortedSet; |
| | | import java.util.TreeSet; |
| | | |
| | |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.ldap.LDAPFilter; |
| | | import org.opends.server.protocols.ldap.LDAPModification; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.AttributeValues; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | |
| | | private static final String DESCRIPTION = "description"; |
| | | private static final String ETAG = "etag"; |
| | | |
| | | private final AttributeValue dummyValue = AttributeValues.create( |
| | | ByteString.valueOf("dummy"), ByteString.valueOf("dummy")); |
| | | private final ByteString dummyValue = ByteString.valueOf("dummy"); |
| | | private final EntityTagVirtualAttributeProvider provider = new EntityTagVirtualAttributeProvider(); |
| | | private boolean changeListenerRemoved = false; |
| | | private boolean changeListenerAdded = false; |
| | |
| | | { |
| | | final Entry e = TestCaseUtils.makeEntry("dn: dc=example,dc=com", |
| | | "objectClass: top", "objectClass: domain", "dc: example"); |
| | | getEntityTag(e); |
| | | getEntityTag(e, getRule()); |
| | | } |
| | | |
| | | |
| | |
| | | "objectClass: top", "objectClass: domain", "dc: example1"); |
| | | final Entry e2 = TestCaseUtils.makeEntry("dn: dc=example2,dc=com", |
| | | "objectClass: top", "objectClass: domain", "dc: example2"); |
| | | assertFalse(getEntityTag(e1).equals(getEntityTag(e2))); |
| | | VirtualAttributeRule rule = getRule(); |
| | | assertFalse(getEntityTag(e1, rule).equals(getEntityTag(e2, rule))); |
| | | } |
| | | |
| | | |
| | |
| | | final Entry e2 = TestCaseUtils.makeEntry("dn: dc=example,dc=com", |
| | | "objectClass: top", "objectClass: domain", "dc: example", |
| | | "modifyTimestamp: 20120222232918Z"); |
| | | assertEquals(getEntityTag(e1), getEntityTag(e2)); |
| | | VirtualAttributeRule rule = getRule(); |
| | | assertEquals(getEntityTag(e1, rule), getEntityTag(e2, rule)); |
| | | } |
| | | |
| | | |
| | |
| | | final Entry e2 = TestCaseUtils.makeEntry("dn: dc=example,dc=com", |
| | | "objectClass: top", "objectClass: domain", "dc: example", |
| | | "description: two", "description: one"); |
| | | assertEquals(getEntityTag(e1), getEntityTag(e2)); |
| | | VirtualAttributeRule rule = getRule(); |
| | | assertEquals(getEntityTag(e1, rule), getEntityTag(e2, rule)); |
| | | } |
| | | |
| | | |
| | |
| | | "objectClass: top", "objectClass: domain", "dc: example"); |
| | | final Entry e2 = TestCaseUtils.makeEntry("dn: dc=example,dc=com", |
| | | "objectClass: top", "objectClass: domain", "dc: example"); |
| | | assertEquals(getEntityTag(e1), getEntityTag(e2)); |
| | | VirtualAttributeRule rule = getRule(); |
| | | assertEquals(getEntityTag(e1, rule), getEntityTag(e2, rule)); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | final Entry e = TestCaseUtils.makeEntry("dn: dc=example,dc=com", |
| | | "objectClass: top", "objectClass: domain", "dc: example"); |
| | | final AttributeValue value = getEntityTag(e); |
| | | assertTrue(provider.hasAllValues(e, null, |
| | | Collections.<AttributeValue> emptySet())); |
| | | assertTrue(provider.hasAllValues(e, null, Collections.singleton(value))); |
| | | assertFalse(provider.hasAllValues(e, null, |
| | | Collections.singleton(dummyValue))); |
| | | assertFalse(provider |
| | | .hasAllValues(e, null, Arrays.asList(value, dummyValue))); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests hasAnyValues() membership. |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected exception occurred. |
| | | */ |
| | | @Test |
| | | public void testHasAnyValue() throws Exception |
| | | { |
| | | final Entry e = TestCaseUtils.makeEntry("dn: dc=example,dc=com", |
| | | "objectClass: top", "objectClass: domain", "dc: example"); |
| | | final AttributeValue value = getEntityTag(e); |
| | | assertTrue(provider.hasAnyValue(e, null, Collections.singleton(value))); |
| | | assertFalse(provider |
| | | .hasAnyValue(e, null, Collections.singleton(dummyValue))); |
| | | assertTrue(provider.hasAnyValue(e, null, Arrays.asList(value, dummyValue))); |
| | | VirtualAttributeRule rule = getRule(); |
| | | final ByteString value = getEntityTag(e, rule); |
| | | assertTrue(provider.hasAllValues(e, rule, Collections.<ByteString> emptySet())); |
| | | assertTrue(provider.hasAllValues(e, rule, Collections.singleton(value))); |
| | | assertFalse(provider.hasAllValues(e, rule, Collections.singleton(dummyValue))); |
| | | assertFalse(provider.hasAllValues(e, rule, Arrays.asList(value, dummyValue))); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | final Entry e = TestCaseUtils.makeEntry("dn: dc=example,dc=com", |
| | | "objectClass: top", "objectClass: domain", "dc: example"); |
| | | final AttributeValue value = getEntityTag(e); |
| | | assertTrue(provider.hasValue(e, null, value)); |
| | | assertFalse(provider.hasValue(e, null, dummyValue)); |
| | | VirtualAttributeRule rule = getRule(); |
| | | final ByteString value = getEntityTag(e, rule); |
| | | assertTrue(provider.hasValue(e, rule, value)); |
| | | assertFalse(provider.hasValue(e, rule, dummyValue)); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | |
| | | |
| | | private AttributeValue getEntityTag(final Entry e) |
| | | private ByteString getEntityTag(final Entry e, VirtualAttributeRule rule) |
| | | { |
| | | final Set<AttributeValue> values = provider.getValues(e, null); |
| | | final Attribute values = provider.getValues(e, rule); |
| | | assertEquals(values.size(), 1); |
| | | final AttributeValue value = values.iterator().next(); |
| | | final ByteString bs = value.getValue(); |
| | | assertEquals(bs.length(), 16); |
| | | final ByteString value = values.iterator().next(); |
| | | assertEquals(value.length(), 16); |
| | | boolean gotNonZeroByte = false; |
| | | for (int i = 0; i < 16; i++) |
| | | { |
| | | assertTrue(StaticUtils.isHexDigit(bs.byteAt(i))); |
| | | if (bs.byteAt(i) != 0x30) |
| | | assertTrue(StaticUtils.isHexDigit(value.byteAt(i))); |
| | | if (value.byteAt(i) != 0x30) |
| | | { |
| | | gotNonZeroByte = true; |
| | | } |
| | |
| | | return value; |
| | | } |
| | | |
| | | private VirtualAttributeRule getRule() |
| | | { |
| | | AttributeType type = DirectoryServer.getAttributeType("etag", false); |
| | | return new VirtualAttributeRule(type, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior.VIRTUAL_OVERRIDES_REAL); |
| | | } |
| | | |
| | | } |
| | |
| | | import java.util.LinkedHashSet; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.std.meta.VirtualAttributeCfgDefn; |
| | | import org.opends.server.api.VirtualAttributeProvider; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | |
| | | { |
| | | assertTrue(!a.isEmpty()); |
| | | assertEquals(a.size(), 1); |
| | | assertTrue(a.contains(AttributeValues.create(entryDNType, |
| | | entryDN.toNormalizedString()))); |
| | | assertTrue(a.contains(ByteString.valueOf(entryDN.toNormalizedString()))); |
| | | } |
| | | } |
| | | |
| | |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(entryDNType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | Set<AttributeValue> values = provider.getValues(entry, rule); |
| | | Attribute values = provider.getValues(entry, getRule(provider)); |
| | | assertNotNull(values); |
| | | assertEquals(values.size(), 1); |
| | | assertTrue(values.contains(AttributeValues.create(entryDNType, "o=test"))); |
| | | assertTrue(values.contains(ByteString.valueOf("o=test"))); |
| | | } |
| | | |
| | | |
| | |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(entryDNType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | assertTrue(provider.hasValue(entry, rule)); |
| | | assertTrue(provider.hasValue(entry, getRule(provider))); |
| | | } |
| | | |
| | | |
| | |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(entryDNType, provider, |
| | | assertTrue(provider.hasValue(entry, getRule(provider), ByteString.valueOf("o=test"))); |
| | | } |
| | | |
| | | |
| | | |
| | | private VirtualAttributeRule getRule(VirtualAttributeProvider<?> provider) |
| | | { |
| | | return new VirtualAttributeRule(entryDNType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | assertTrue(provider.hasValue(entry, rule, |
| | | AttributeValues.create(entryDNType, "o=test"))); |
| | | VirtualAttributeCfgDefn.ConflictBehavior.VIRTUAL_OVERRIDES_REAL); |
| | | } |
| | | |
| | | |
| | |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(entryDNType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | assertFalse(provider.hasValue(entry, rule, |
| | | AttributeValues.create(entryDNType, "o=not test"))); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code hasAnyValue} method with an empty set of values. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testHasAnyValueEmptySet() |
| | | throws Exception |
| | | { |
| | | EntryDNVirtualAttributeProvider provider = |
| | | new EntryDNVirtualAttributeProvider(); |
| | | |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: o=test", |
| | | "objectClass: top", |
| | | "objectClass: organization", |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(entryDNType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | assertFalse(provider.hasAnyValue(entry, rule, |
| | | Collections.<AttributeValue>emptySet())); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code hasAnyValue} method with a set of values containing only |
| | | * the correct value. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testHasAnyValueOnlyCorrect() |
| | | throws Exception |
| | | { |
| | | EntryDNVirtualAttributeProvider provider = |
| | | new EntryDNVirtualAttributeProvider(); |
| | | |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: o=test", |
| | | "objectClass: top", |
| | | "objectClass: organization", |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(entryDNType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(1); |
| | | values.add(AttributeValues.create(entryDNType, "o=test")); |
| | | |
| | | assertTrue(provider.hasAnyValue(entry, rule, values)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code hasAnyValue} method with a set of values containing only |
| | | * an incorrect value. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testHasAnyValueOnlyIncorrect() |
| | | throws Exception |
| | | { |
| | | EntryDNVirtualAttributeProvider provider = |
| | | new EntryDNVirtualAttributeProvider(); |
| | | |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: o=test", |
| | | "objectClass: top", |
| | | "objectClass: organization", |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(entryDNType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(1); |
| | | values.add(AttributeValues.create(entryDNType, "o=not test")); |
| | | |
| | | assertFalse(provider.hasAnyValue(entry, rule, values)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code hasAnyValue} method with a set of values containing the |
| | | * correct value as well as multiple incorrect values. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testHasAnyValueIncludesCorrect() |
| | | throws Exception |
| | | { |
| | | EntryDNVirtualAttributeProvider provider = |
| | | new EntryDNVirtualAttributeProvider(); |
| | | |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: o=test", |
| | | "objectClass: top", |
| | | "objectClass: organization", |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(entryDNType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(3); |
| | | values.add(AttributeValues.create(entryDNType, "o=test")); |
| | | values.add(AttributeValues.create(entryDNType, "o=not test")); |
| | | values.add(AttributeValues.create(entryDNType, "o=not test either")); |
| | | |
| | | assertTrue(provider.hasAnyValue(entry, rule, values)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code hasAnyValue} method with a set of multiple values, none of |
| | | * which are correct. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testHasAnyValueMissingCorrect() |
| | | throws Exception |
| | | { |
| | | EntryDNVirtualAttributeProvider provider = |
| | | new EntryDNVirtualAttributeProvider(); |
| | | |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: o=test", |
| | | "objectClass: top", |
| | | "objectClass: organization", |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(entryDNType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(3); |
| | | values.add(AttributeValues.create(entryDNType, "o=not test")); |
| | | values.add(AttributeValues.create(entryDNType, "o=not test either")); |
| | | values.add(AttributeValues.create(entryDNType, "o=still not test")); |
| | | |
| | | assertFalse(provider.hasAnyValue(entry, rule, values)); |
| | | assertFalse(provider.hasValue(entry, getRule(provider), ByteString.valueOf("o=not test"))); |
| | | } |
| | | |
| | | |
| | |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(entryDNType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | LinkedList<ByteString> subAny = new LinkedList<ByteString>(); |
| | | subAny.add(ByteString.valueOf("=")); |
| | | |
| | | assertEquals(provider.matchesSubstring(entry, rule, null, subAny, null), |
| | | assertEquals(provider.matchesSubstring(entry, getRule(provider), null, subAny, null), |
| | | ConditionResult.UNDEFINED); |
| | | } |
| | | |
| | |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(entryDNType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | AttributeValue value = AttributeValues.create(entryDNType, "o=test2"); |
| | | assertEquals(provider.greaterThanOrEqualTo(entry, rule, value), |
| | | ByteString value = ByteString.valueOf("o=test2"); |
| | | assertEquals(provider.greaterThanOrEqualTo(entry, getRule(provider), value), |
| | | ConditionResult.UNDEFINED); |
| | | } |
| | | |
| | |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(entryDNType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | AttributeValue value = AttributeValues.create(entryDNType, "o=test2"); |
| | | assertEquals(provider.lessThanOrEqualTo(entry, rule, value), |
| | | ByteString value = ByteString.valueOf("o=test2"); |
| | | assertEquals(provider.lessThanOrEqualTo(entry, getRule(provider), value), |
| | | ConditionResult.UNDEFINED); |
| | | } |
| | | |
| | |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(entryDNType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | AttributeValue value = AttributeValues.create(entryDNType, "o=test2"); |
| | | assertEquals(provider.approximatelyEqualTo(entry, rule, value), |
| | | ByteString value = ByteString.valueOf("o=test2"); |
| | | assertEquals(provider.approximatelyEqualTo(entry, getRule(provider), value), |
| | | ConditionResult.UNDEFINED); |
| | | } |
| | | |
| | |
| | | EntryDNVirtualAttributeProvider provider = |
| | | new EntryDNVirtualAttributeProvider(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(entryDNType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | VirtualAttributeRule rule = getRule(provider); |
| | | |
| | | SearchFilter filter = SearchFilter.createFilterFromString(filterString); |
| | | |
| | |
| | | EntryDNVirtualAttributeProvider provider = |
| | | new EntryDNVirtualAttributeProvider(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(entryDNType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | VirtualAttributeRule rule = getRule(provider); |
| | | |
| | | SearchFilter filter = SearchFilter.createFilterFromString(filterString); |
| | | |
| | |
| | | import java.util.LinkedHashSet; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.UUID; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.std.meta.VirtualAttributeCfgDefn; |
| | |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | |
| | | { |
| | | assertTrue(!a.isEmpty()); |
| | | assertEquals(a.size(), 1); |
| | | assertTrue(a.contains(AttributeValues.create(entryUUIDType, uuidString))); |
| | | assertTrue(a.contains(ByteString.valueOf(uuidString))); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | assertTrue(!a.isEmpty()); |
| | | assertEquals(a.size(), 1); |
| | | assertFalse(a.contains(AttributeValues.create(entryUUIDType, uuidString))); |
| | | assertFalse(a.contains(ByteString.valueOf(uuidString))); |
| | | } |
| | | } |
| | | |
| | |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | Set<AttributeValue> values = provider.getValues(entry, rule); |
| | | Attribute values = provider.getValues(entry, rule); |
| | | assertNotNull(values); |
| | | assertEquals(values.size(), 1); |
| | | assertTrue(values.contains(AttributeValues.create(entryUUIDType, uuidString))); |
| | | assertTrue(values.contains(ByteString.valueOf(uuidString))); |
| | | } |
| | | |
| | | |
| | |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | assertTrue(provider.hasValue(entry, rule, |
| | | AttributeValues.create(entryUUIDType, |
| | | uuidString))); |
| | | assertTrue(provider.hasValue(entry, rule, ByteString.valueOf(uuidString))); |
| | | } |
| | | |
| | | |
| | |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | assertFalse(provider.hasValue(entry, rule, |
| | | AttributeValues.create(entryUUIDType, "wrong"))); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code hasAnyValue} method with an empty set of values. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testHasAnyValueEmptySet() |
| | | throws Exception |
| | | { |
| | | EntryUUIDVirtualAttributeProvider provider = |
| | | new EntryUUIDVirtualAttributeProvider(); |
| | | |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: o=test", |
| | | "objectClass: top", |
| | | "objectClass: organization", |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(entryUUIDType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | assertFalse(provider.hasAnyValue(entry, rule, |
| | | Collections.<AttributeValue>emptySet())); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code hasAnyValue} method with a set of values containing only |
| | | * the correct value. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testHasAnyValueOnlyCorrect() |
| | | throws Exception |
| | | { |
| | | String uuidString = UUID.nameUUIDFromBytes(getBytes("o=test")).toString(); |
| | | |
| | | EntryUUIDVirtualAttributeProvider provider = |
| | | new EntryUUIDVirtualAttributeProvider(); |
| | | |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: o=test", |
| | | "objectClass: top", |
| | | "objectClass: organization", |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(entryUUIDType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(1); |
| | | values.add(AttributeValues.create(entryUUIDType, uuidString)); |
| | | |
| | | assertTrue(provider.hasAnyValue(entry, rule, values)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code hasAnyValue} method with a set of values containing only |
| | | * an incorrect value. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testHasAnyValueOnlyIncorrect() |
| | | throws Exception |
| | | { |
| | | EntryUUIDVirtualAttributeProvider provider = |
| | | new EntryUUIDVirtualAttributeProvider(); |
| | | |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: o=test", |
| | | "objectClass: top", |
| | | "objectClass: organization", |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(entryUUIDType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(1); |
| | | values.add(AttributeValues.create(entryUUIDType, "wrong")); |
| | | |
| | | assertFalse(provider.hasAnyValue(entry, rule, values)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code hasAnyValue} method with a set of values containing the |
| | | * correct value as well as multiple incorrect values. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testHasAnyValueIncludesCorrect() |
| | | throws Exception |
| | | { |
| | | String uuidString = UUID.nameUUIDFromBytes(getBytes("o=test")).toString(); |
| | | |
| | | EntryUUIDVirtualAttributeProvider provider = |
| | | new EntryUUIDVirtualAttributeProvider(); |
| | | |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: o=test", |
| | | "objectClass: top", |
| | | "objectClass: organization", |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(entryUUIDType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(3); |
| | | values.add(AttributeValues.create(entryUUIDType, uuidString)); |
| | | values.add(AttributeValues.create(entryUUIDType, "wrong")); |
| | | values.add(AttributeValues.create(entryUUIDType, "also wrong")); |
| | | |
| | | assertTrue(provider.hasAnyValue(entry, rule, values)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code hasAnyValue} method with a set of multiple values, none of |
| | | * which are correct. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testHasAnyValueMissingCorrect() |
| | | throws Exception |
| | | { |
| | | EntryUUIDVirtualAttributeProvider provider = |
| | | new EntryUUIDVirtualAttributeProvider(); |
| | | |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: o=test", |
| | | "objectClass: top", |
| | | "objectClass: organization", |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(entryUUIDType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(3); |
| | | values.add(AttributeValues.create(entryUUIDType, "wrong")); |
| | | values.add(AttributeValues.create(entryUUIDType, "also wrong")); |
| | | values.add(AttributeValues.create(entryUUIDType, "still wrong")); |
| | | |
| | | assertFalse(provider.hasAnyValue(entry, rule, values)); |
| | | assertFalse(provider.hasValue(entry, rule, ByteString.valueOf("wrong"))); |
| | | } |
| | | } |
| | | |
| | |
| | | "ds-cfg-match-attribute: uid"); |
| | | |
| | | AttributeType t = DirectoryServer.getAttributeType("ds-cfg-match-base-dn"); |
| | | e.addAttribute(Attributes.empty(t), new ArrayList<AttributeValue>()); |
| | | e.addAttribute(Attributes.empty(t), new ArrayList<ByteString>()); |
| | | entries.add(e); |
| | | |
| | | |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | |
| | | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | import java.util.LinkedHashSet; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.std.meta.VirtualAttributeCfgDefn; |
| | | import org.opends.server.api.VirtualAttributeProvider; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.AttributeValues; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DN; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | |
| | | |
| | | /** |
| | | * A set of test cases for the governing structure rule virtual attribute |
| | | * provider. |
| | |
| | | { |
| | | assertTrue(!a.isEmpty()); |
| | | assertEquals(a.size(), 1); |
| | | assertTrue(a.contains(AttributeValues.create(governingStructureRuleType, |
| | | ruleId))); |
| | | assertTrue(a.contains(ByteString.valueOf(ruleId))); |
| | | } |
| | | } |
| | | |
| | |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(governingStructureRuleType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | Set<AttributeValue> values = provider.getValues(entry, rule); |
| | | Attribute values = provider.getValues(entry, getRule(provider)); |
| | | assertNotNull(values); |
| | | assertEquals(values.size(), 1); |
| | | assertTrue(values.contains(AttributeValues.create(governingStructureRuleType, |
| | | "22"))); |
| | | assertTrue(values.contains(ByteString.valueOf("22"))); |
| | | } |
| | | |
| | | |
| | |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(governingStructureRuleType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | assertTrue(provider.hasValue(entry, rule)); |
| | | assertTrue(provider.hasValue(entry, getRule(provider))); |
| | | } |
| | | |
| | | |
| | |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(governingStructureRuleType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | assertTrue(provider.hasValue(entry, rule, |
| | | AttributeValues.create(governingStructureRuleType,"22"))); |
| | | assertTrue(provider.hasValue(entry, getRule(provider), ByteString.valueOf("22"))); |
| | | } |
| | | |
| | | |
| | |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(governingStructureRuleType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | assertFalse(provider.hasValue(entry, rule, |
| | | AttributeValues.create(governingStructureRuleType, |
| | | "1"))); |
| | | assertFalse(provider.hasValue(entry, getRule(provider), ByteString.valueOf("1"))); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code hasAnyValue} method with an empty set of values. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testHasAnyValueEmptySet() |
| | | throws Exception |
| | | private VirtualAttributeRule getRule(VirtualAttributeProvider<?> provider) |
| | | { |
| | | GoverningStructureRuleVirtualAttributeProvider provider = |
| | | new GoverningStructureRuleVirtualAttributeProvider(); |
| | | |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: o=test", |
| | | "objectClass: top", |
| | | "objectclass: organization", |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(governingStructureRuleType, provider, |
| | | return new VirtualAttributeRule(governingStructureRuleType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | assertFalse(provider.hasAnyValue(entry, rule, |
| | | Collections.<AttributeValue>emptySet())); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code hasAnyValue} method with a set of values containing only |
| | | * the correct value. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testHasAnyValueOnlyCorrect() |
| | | throws Exception |
| | | { |
| | | GoverningStructureRuleVirtualAttributeProvider provider = |
| | | new GoverningStructureRuleVirtualAttributeProvider(); |
| | | |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: o=test", |
| | | "objectClass: top", |
| | | "objectClass: organization", |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(governingStructureRuleType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(1); |
| | | values.add(AttributeValues.create(governingStructureRuleType, "22")); |
| | | |
| | | assertTrue(provider.hasAnyValue(entry, rule, values)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code hasAnyValue} method with a set of values containing only |
| | | * an incorrect value. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testHasAnyValueOnlyIncorrect() |
| | | throws Exception |
| | | { |
| | | GoverningStructureRuleVirtualAttributeProvider provider = |
| | | new GoverningStructureRuleVirtualAttributeProvider(); |
| | | |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: o=test", |
| | | "objectClass: top", |
| | | "objectclass: organization", |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(governingStructureRuleType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(1); |
| | | values.add(AttributeValues.create(governingStructureRuleType, "1")); |
| | | |
| | | assertFalse(provider.hasAnyValue(entry, rule, values)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code hasAnyValue} method with a set of values containing the |
| | | * correct value as well as multiple incorrect values. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testHasAnyValueIncludesCorrect() |
| | | throws Exception |
| | | { |
| | | GoverningStructureRuleVirtualAttributeProvider provider = |
| | | new GoverningStructureRuleVirtualAttributeProvider(); |
| | | |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: o=test", |
| | | "objectClass: top", |
| | | "objectClass: organization", |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(governingStructureRuleType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(3); |
| | | values.add(AttributeValues.create(governingStructureRuleType, "22")); |
| | | values.add(AttributeValues.create(governingStructureRuleType, "1")); |
| | | values.add(AttributeValues.create(governingStructureRuleType,"2")); |
| | | |
| | | assertTrue(provider.hasAnyValue(entry, rule, values)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code hasAnyValue} method with a set of multiple values, none of |
| | | * which are correct. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testHasAnyValueMissingCorrect() |
| | | throws Exception |
| | | { |
| | | GoverningStructureRuleVirtualAttributeProvider provider = |
| | | new GoverningStructureRuleVirtualAttributeProvider(); |
| | | |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: o=test", |
| | | "objectClass: top", |
| | | "objectclass: organization", |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(governingStructureRuleType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(3); |
| | | values.add(AttributeValues.create(governingStructureRuleType, "1")); |
| | | values.add(AttributeValues.create(governingStructureRuleType, "2")); |
| | | values.add(AttributeValues.create(governingStructureRuleType,"3")); |
| | | |
| | | assertFalse(provider.hasAnyValue(entry, rule, values)); |
| | | VirtualAttributeCfgDefn.ConflictBehavior.VIRTUAL_OVERRIDES_REAL); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | assertTrue(!a.isEmpty()); |
| | | assertEquals(a.size(), 1); |
| | | assertTrue(a.contains(AttributeValues.create( |
| | | ByteString.valueOf(toUpperCase(String.valueOf(hasSubs))), |
| | | ByteString.valueOf(toUpperCase(String.valueOf(hasSubs)))))); |
| | | assertTrue(a.contains(AttributeValues.create(hasSubordinatesType, |
| | | toUpperCase(String.valueOf(hasSubs))))); |
| | | assertTrue(a.contains(ByteString.valueOf(toUpperCase(String.valueOf(hasSubs))))); |
| | | } |
| | | } |
| | | |
| | |
| | | import org.opends.server.protocols.ldap.LDAPFilter; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.AttributeValues; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DN; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | |
| | | assertEquals(a.size(), 1); |
| | | |
| | | assertTrue(!a.isEmpty()); |
| | | assertTrue(a.contains(AttributeValues.create(isMemberOfType, |
| | | "cn=test static group,ou=groups,o=test"))); |
| | | assertFalse(a.contains(AttributeValues.create(isMemberOfType, |
| | | "cn=not a group,ou=groups,o=test"))); |
| | | assertFalse(a.contains(AttributeValues.create(isMemberOfType, "invalid"))); |
| | | assertTrue(a.contains(ByteString.valueOf("cn=test static group,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOf("cn=not a group,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOf("invalid"))); |
| | | } |
| | | |
| | | InternalClientConnection conn = |
| | |
| | | assertEquals(a.size(), 1); |
| | | |
| | | assertTrue(!a.isEmpty()); |
| | | assertTrue(a.contains(AttributeValues.create(isMemberOfType, |
| | | "cn=test static group,ou=groups,o=test"))); |
| | | assertFalse(a.contains(AttributeValues.create(isMemberOfType, |
| | | "cn=not a group,ou=groups,o=test"))); |
| | | assertFalse(a.contains(AttributeValues.create(isMemberOfType, "invalid"))); |
| | | assertTrue(a.contains(ByteString.valueOf("cn=test static group,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOf("cn=not a group,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOf("invalid"))); |
| | | } |
| | | |
| | | InternalClientConnection conn = |
| | |
| | | assertEquals(a.size(), 1); |
| | | |
| | | assertTrue(!a.isEmpty()); |
| | | assertTrue(a.contains(AttributeValues.create(isMemberOfType, |
| | | "cn=test dynamic group,ou=groups,o=test"))); |
| | | assertFalse(a.contains(AttributeValues.create(isMemberOfType, |
| | | "cn=not a group,ou=groups,o=test"))); |
| | | assertFalse(a.contains(AttributeValues.create(isMemberOfType, "invalid"))); |
| | | assertTrue(a.contains(ByteString.valueOf("cn=test dynamic group,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOf("cn=not a group,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOf("invalid"))); |
| | | } |
| | | |
| | | InternalClientConnection conn = |
| | |
| | | assertEquals(a.size(), 2); |
| | | |
| | | assertTrue(!a.isEmpty()); |
| | | assertTrue(a.contains(AttributeValues.create(isMemberOfType, |
| | | "cn=test group 1,ou=groups,o=test"))); |
| | | assertFalse(a.contains(AttributeValues.create(isMemberOfType, |
| | | "cn=test group 2,ou=groups,o=test"))); |
| | | assertTrue(a.contains(AttributeValues.create(isMemberOfType, |
| | | "cn=test group 3,ou=groups,o=test"))); |
| | | assertFalse(a.contains(AttributeValues.create(isMemberOfType, |
| | | "cn=not a group,ou=groups,o=test"))); |
| | | assertFalse(a.contains(AttributeValues.create(isMemberOfType, "invalid"))); |
| | | assertTrue(a.contains(ByteString.valueOf("cn=test group 1,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOf("cn=test group 2,ou=groups,o=test"))); |
| | | assertTrue(a.contains(ByteString.valueOf("cn=test group 3,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOf("cn=not a group,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOf("invalid"))); |
| | | } |
| | | |
| | | InternalClientConnection conn = |
| | |
| | | assertEquals(a.size(), 4); |
| | | |
| | | assertTrue(!a.isEmpty()); |
| | | assertTrue(a.contains(AttributeValues.create(isMemberOfType, |
| | | "cn=test group 1,ou=groups,o=test"))); |
| | | assertFalse(a.contains(AttributeValues.create(isMemberOfType, |
| | | "cn=test group 2,ou=groups,o=test"))); |
| | | assertTrue(a.contains(AttributeValues.create(isMemberOfType, |
| | | "cn=test group 3,ou=groups,o=test"))); |
| | | assertTrue(a.contains(AttributeValues.create(isMemberOfType, |
| | | "cn=test group 4,ou=groups,o=test"))); |
| | | assertFalse(a.contains(AttributeValues.create(isMemberOfType, |
| | | "cn=test group 5,ou=groups,o=test"))); |
| | | assertTrue(a.contains(AttributeValues.create(isMemberOfType, |
| | | "cn=test group 6,ou=groups,o=test"))); |
| | | assertFalse(a.contains(AttributeValues.create(isMemberOfType, |
| | | "cn=not a group,ou=groups,o=test"))); |
| | | assertFalse(a.contains(AttributeValues.create(isMemberOfType, "invalid"))); |
| | | assertTrue(a.contains(ByteString.valueOf("cn=test group 1,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOf("cn=test group 2,ou=groups,o=test"))); |
| | | assertTrue(a.contains(ByteString.valueOf("cn=test group 3,ou=groups,o=test"))); |
| | | assertTrue(a.contains(ByteString.valueOf("cn=test group 4,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOf("cn=test group 5,ou=groups,o=test"))); |
| | | assertTrue(a.contains(ByteString.valueOf("cn=test group 6,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOf("cn=not a group,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOf("invalid"))); |
| | | } |
| | | |
| | | InternalClientConnection conn = |
| | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code hasAnyValue} method with an empty set of values. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testHasAnyValueEmptySet() |
| | | throws Exception |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | TestCaseUtils.addEntries( |
| | | "dn: ou=People,o=test", |
| | | "objectClass: top", |
| | | "objectClass: organizationalUnit", |
| | | "ou: People", |
| | | "", |
| | | "dn: uid=test.user,ou=People,o=test", |
| | | "objectClass: top", |
| | | "objectClass: person", |
| | | "objectClass: organizationalPerson", |
| | | "objectClass: inetOrgPerson", |
| | | "uid: test.user", |
| | | "givenName: Test", |
| | | "sn: User", |
| | | "cn: Test User", |
| | | "userPassword: password", |
| | | "", |
| | | "dn: ou=Groups,o=test", |
| | | "objectClass: top", |
| | | "objectClass: organizationalUnit", |
| | | "ou: Groups", |
| | | "", |
| | | "dn: cn=Test Static Group,ou=Groups,o=test", |
| | | "objectClass: top", |
| | | "objectClass: groupOfNames", |
| | | "cn: Test Static Group", |
| | | "member: uid=test.user,ou=People,o=test"); |
| | | |
| | | Entry e = |
| | | DirectoryServer.getEntry(DN.valueOf("uid=test.user,ou=People,o=test")); |
| | | |
| | | IsMemberOfVirtualAttributeProvider provider = |
| | | new IsMemberOfVirtualAttributeProvider(); |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(isMemberOfType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | assertFalse(provider.hasAnyValue(e, rule, |
| | | Collections.<AttributeValue>emptySet())); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | DeleteOperation deleteOperation = |
| | | conn.processDelete(DN.valueOf("cn=test static group,ou=groups,o=test")); |
| | | assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code hasAnyValue} method with a set of values containing only |
| | | * the correct value. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testHasAnyValueOnlyCorrect() |
| | | throws Exception |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | TestCaseUtils.addEntries( |
| | | "dn: ou=People,o=test", |
| | | "objectClass: top", |
| | | "objectClass: organizationalUnit", |
| | | "ou: People", |
| | | "", |
| | | "dn: uid=test.user,ou=People,o=test", |
| | | "objectClass: top", |
| | | "objectClass: person", |
| | | "objectClass: organizationalPerson", |
| | | "objectClass: inetOrgPerson", |
| | | "uid: test.user", |
| | | "givenName: Test", |
| | | "sn: User", |
| | | "cn: Test User", |
| | | "userPassword: password", |
| | | "", |
| | | "dn: ou=Groups,o=test", |
| | | "objectClass: top", |
| | | "objectClass: organizationalUnit", |
| | | "ou: Groups", |
| | | "", |
| | | "dn: cn=Test Static Group,ou=Groups,o=test", |
| | | "objectClass: top", |
| | | "objectClass: groupOfNames", |
| | | "cn: Test Static Group", |
| | | "member: uid=test.user,ou=People,o=test"); |
| | | |
| | | Entry e = |
| | | DirectoryServer.getEntry(DN.valueOf("uid=test.user,ou=People,o=test")); |
| | | |
| | | IsMemberOfVirtualAttributeProvider provider = |
| | | new IsMemberOfVirtualAttributeProvider(); |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(isMemberOfType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(); |
| | | values.add(AttributeValues.create(isMemberOfType, |
| | | "cn=test static group,ou=groups,o=test")); |
| | | |
| | | assertTrue(provider.hasAnyValue(e, rule, values)); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | DeleteOperation deleteOperation = |
| | | conn.processDelete(DN.valueOf("cn=test static group,ou=groups,o=test")); |
| | | assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code hasAnyValue} method with a set of values containing only |
| | | * an incorrect value. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testHasAnyValueOnlyIncorrect() |
| | | throws Exception |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | TestCaseUtils.addEntries( |
| | | "dn: ou=People,o=test", |
| | | "objectClass: top", |
| | | "objectClass: organizationalUnit", |
| | | "ou: People", |
| | | "", |
| | | "dn: uid=test.user,ou=People,o=test", |
| | | "objectClass: top", |
| | | "objectClass: person", |
| | | "objectClass: organizationalPerson", |
| | | "objectClass: inetOrgPerson", |
| | | "uid: test.user", |
| | | "givenName: Test", |
| | | "sn: User", |
| | | "cn: Test User", |
| | | "userPassword: password", |
| | | "", |
| | | "dn: ou=Groups,o=test", |
| | | "objectClass: top", |
| | | "objectClass: organizationalUnit", |
| | | "ou: Groups", |
| | | "", |
| | | "dn: cn=Test Static Group,ou=Groups,o=test", |
| | | "objectClass: top", |
| | | "objectClass: groupOfNames", |
| | | "cn: Test Static Group", |
| | | "member: uid=test.user,ou=People,o=test"); |
| | | |
| | | Entry e = |
| | | DirectoryServer.getEntry(DN.valueOf("uid=test.user,ou=People,o=test")); |
| | | |
| | | IsMemberOfVirtualAttributeProvider provider = |
| | | new IsMemberOfVirtualAttributeProvider(); |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(isMemberOfType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(); |
| | | values.add(AttributeValues.create(isMemberOfType, |
| | | "cn=test dynamic group,ou=groups,o=test")); |
| | | |
| | | assertFalse(provider.hasAnyValue(e, rule, values)); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | DeleteOperation deleteOperation = |
| | | conn.processDelete(DN.valueOf("cn=test static group,ou=groups,o=test")); |
| | | assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code hasAnyValue} method with a set of values containing the |
| | | * correct value as well as multiple incorrect values. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testHasAnyValueIncludesCorrect() |
| | | throws Exception |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | TestCaseUtils.addEntries( |
| | | "dn: ou=People,o=test", |
| | | "objectClass: top", |
| | | "objectClass: organizationalUnit", |
| | | "ou: People", |
| | | "", |
| | | "dn: uid=test.user,ou=People,o=test", |
| | | "objectClass: top", |
| | | "objectClass: person", |
| | | "objectClass: organizationalPerson", |
| | | "objectClass: inetOrgPerson", |
| | | "uid: test.user", |
| | | "givenName: Test", |
| | | "sn: User", |
| | | "cn: Test User", |
| | | "userPassword: password", |
| | | "", |
| | | "dn: ou=Groups,o=test", |
| | | "objectClass: top", |
| | | "objectClass: organizationalUnit", |
| | | "ou: Groups", |
| | | "", |
| | | "dn: cn=Test Static Group,ou=Groups,o=test", |
| | | "objectClass: top", |
| | | "objectClass: groupOfNames", |
| | | "cn: Test Static Group", |
| | | "member: uid=test.user,ou=People,o=test"); |
| | | |
| | | Entry e = |
| | | DirectoryServer.getEntry(DN.valueOf("uid=test.user,ou=People,o=test")); |
| | | |
| | | IsMemberOfVirtualAttributeProvider provider = |
| | | new IsMemberOfVirtualAttributeProvider(); |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(isMemberOfType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(); |
| | | values.add(AttributeValues.create(isMemberOfType, |
| | | "cn=test static group,ou=groups,o=test")); |
| | | values.add(AttributeValues.create(isMemberOfType, |
| | | "cn=test dynamic group,ou=groups,o=test")); |
| | | |
| | | assertTrue(provider.hasAnyValue(e, rule, values)); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | DeleteOperation deleteOperation = |
| | | conn.processDelete(DN.valueOf("cn=test static group,ou=groups,o=test")); |
| | | assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code hasAnyValue} method with a set of multiple values, none of |
| | | * which are correct. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testHasAnyValueMissingCorrect() |
| | | throws Exception |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | TestCaseUtils.addEntries( |
| | | "dn: ou=People,o=test", |
| | | "objectClass: top", |
| | | "objectClass: organizationalUnit", |
| | | "ou: People", |
| | | "", |
| | | "dn: uid=test.user,ou=People,o=test", |
| | | "objectClass: top", |
| | | "objectClass: person", |
| | | "objectClass: organizationalPerson", |
| | | "objectClass: inetOrgPerson", |
| | | "uid: test.user", |
| | | "givenName: Test", |
| | | "sn: User", |
| | | "cn: Test User", |
| | | "userPassword: password", |
| | | "", |
| | | "dn: ou=Groups,o=test", |
| | | "objectClass: top", |
| | | "objectClass: organizationalUnit", |
| | | "ou: Groups", |
| | | "", |
| | | "dn: cn=Test Static Group,ou=Groups,o=test", |
| | | "objectClass: top", |
| | | "objectClass: groupOfNames", |
| | | "cn: Test Static Group", |
| | | "member: uid=test.user,ou=People,o=test"); |
| | | |
| | | Entry e = |
| | | DirectoryServer.getEntry(DN.valueOf("uid=test.user,ou=People,o=test")); |
| | | |
| | | IsMemberOfVirtualAttributeProvider provider = |
| | | new IsMemberOfVirtualAttributeProvider(); |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(isMemberOfType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(); |
| | | values.add(AttributeValues.create(isMemberOfType, |
| | | "cn=test nonstatic group,ou=groups,o=test")); |
| | | values.add(AttributeValues.create(isMemberOfType, |
| | | "cn=test dynamic group,ou=groups,o=test")); |
| | | |
| | | assertFalse(provider.hasAnyValue(e, rule, values)); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | DeleteOperation deleteOperation = |
| | | conn.processDelete(DN.valueOf("cn=test static group,ou=groups,o=test")); |
| | | assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code matchesSubstring} method to ensure that it returns a |
| | | * result of "undefined". |
| | | * |
| | |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | AttributeValue value = AttributeValues.create(isMemberOfType, "o=test2"); |
| | | ByteString value = ByteString.valueOf("o=test2"); |
| | | assertEquals(provider.greaterThanOrEqualTo(entry, rule, value), |
| | | ConditionResult.UNDEFINED); |
| | | } |
| | |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | AttributeValue value = AttributeValues.create(isMemberOfType, "o=test2"); |
| | | ByteString value = ByteString.valueOf("o=test2"); |
| | | assertEquals(provider.lessThanOrEqualTo(entry, rule, value), |
| | | ConditionResult.UNDEFINED); |
| | | } |
| | |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | AttributeValue value = AttributeValues.create(isMemberOfType, "o=test2"); |
| | | ByteString value = ByteString.valueOf("o=test2"); |
| | | assertEquals(provider.approximatelyEqualTo(entry, rule, value), |
| | | ConditionResult.UNDEFINED); |
| | | } |
| | |
| | | { |
| | | assertTrue(!a.isEmpty()); |
| | | assertEquals(a.size(), 1); |
| | | assertTrue(a.contains(AttributeValues.create( |
| | | ByteString.valueOf(String.valueOf(count)), |
| | | ByteString.valueOf(String.valueOf(count))))); |
| | | assertTrue(a.contains(AttributeValues.create(numSubordinatesType, |
| | | String.valueOf(count)))); |
| | | assertTrue(a.contains(ByteString.valueOf(String.valueOf(count)))); |
| | | } |
| | | } |
| | | |
| | |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.TestCaseUtils; |
| | |
| | | Attribute attr = attrs.get(0); |
| | | assertNotNull(attr); |
| | | |
| | | Iterator<AttributeValue> it = attr.iterator(); |
| | | Iterator<ByteString> it = attr.iterator(); |
| | | assertTrue(it.hasNext()); |
| | | |
| | | AttributeValue val = it.next(); |
| | | ByteString val = it.next(); |
| | | |
| | | conn.disconnect(DisconnectReason.UNBIND, true, LocalizableMessage.EMPTY); |
| | | |
| | | return |
| | | GeneralizedTimeSyntax.decodeGeneralizedTimeValue(val.getValue()); |
| | | return GeneralizedTimeSyntax.decodeGeneralizedTimeValue(val); |
| | | } |
| | | |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | |
| | | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | import java.util.LinkedHashSet; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.std.meta.VirtualAttributeCfgDefn; |
| | |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.AttributeValues; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DN; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | |
| | | |
| | | /** |
| | | * A set of test cases for the structural object class virtual attribute |
| | | * provider. |
| | |
| | | { |
| | | assertTrue(!a.isEmpty()); |
| | | assertEquals(a.size(), 1); |
| | | assertTrue(a.contains(AttributeValues.create(structuralObjectClassType, |
| | | e.getStructuralObjectClass().getNameOrOID()))); |
| | | assertTrue(a.contains(ByteString.valueOf(e.getStructuralObjectClass().getNameOrOID()))); |
| | | } |
| | | } |
| | | |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testGetValues() |
| | | throws Exception |
| | | public void testGetValues() throws Exception |
| | | { |
| | | StructuralObjectClassVirtualAttributeProvider provider = |
| | | new StructuralObjectClassVirtualAttributeProvider(); |
| | |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | Set<AttributeValue> values = provider.getValues(entry, rule); |
| | | Attribute values = provider.getValues(entry, rule); |
| | | assertNotNull(values); |
| | | assertEquals(values.size(), 1); |
| | | assertTrue(values.contains(AttributeValues.create(structuralObjectClassType, |
| | | entry.getStructuralObjectClass().getNameOrOID()))); |
| | | assertTrue(values.contains(ByteString.valueOf(entry.getStructuralObjectClass().getNameOrOID()))); |
| | | } |
| | | |
| | | |
| | |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | assertTrue(provider.hasValue(entry, rule, |
| | | AttributeValues.create(structuralObjectClassType, |
| | | entry.getStructuralObjectClass().getNameOrOID()))); |
| | | ByteString.valueOf(entry.getStructuralObjectClass().getNameOrOID()))); |
| | | } |
| | | |
| | | |
| | |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | assertFalse(provider.hasValue(entry, rule, |
| | | AttributeValues.create(structuralObjectClassType, |
| | | "inetorgperson"))); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code hasAnyValue} method with an empty set of values. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testHasAnyValueEmptySet() |
| | | throws Exception |
| | | { |
| | | StructuralObjectClassVirtualAttributeProvider provider = |
| | | new StructuralObjectClassVirtualAttributeProvider(); |
| | | |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: o=test", |
| | | "objectClass: top", |
| | | "objectClass: organization", |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(structuralObjectClassType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | assertFalse(provider.hasAnyValue(entry, rule, |
| | | Collections.<AttributeValue>emptySet())); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code hasAnyValue} method with a set of values containing only |
| | | * the correct value. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testHasAnyValueOnlyCorrect() |
| | | throws Exception |
| | | { |
| | | StructuralObjectClassVirtualAttributeProvider provider = |
| | | new StructuralObjectClassVirtualAttributeProvider(); |
| | | |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: o=test", |
| | | "objectClass: top", |
| | | "objectClass: organization", |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(structuralObjectClassType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(1); |
| | | values.add(AttributeValues.create(structuralObjectClassType, "organization")); |
| | | |
| | | assertTrue(provider.hasAnyValue(entry, rule, values)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code hasAnyValue} method with a set of values containing only |
| | | * an incorrect value. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testHasAnyValueOnlyIncorrect() |
| | | throws Exception |
| | | { |
| | | StructuralObjectClassVirtualAttributeProvider provider = |
| | | new StructuralObjectClassVirtualAttributeProvider(); |
| | | |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: o=test", |
| | | "objectClass: top", |
| | | "objectClass: organization", |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(structuralObjectClassType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(1); |
| | | values.add(AttributeValues.create(structuralObjectClassType, "inetorgperson")); |
| | | |
| | | assertFalse(provider.hasAnyValue(entry, rule, values)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code hasAnyValue} method with a set of values containing the |
| | | * correct value as well as multiple incorrect values. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testHasAnyValueIncludesCorrect() |
| | | throws Exception |
| | | { |
| | | StructuralObjectClassVirtualAttributeProvider provider = |
| | | new StructuralObjectClassVirtualAttributeProvider(); |
| | | |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: o=test", |
| | | "objectClass: top", |
| | | "objectClass: organization", |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(structuralObjectClassType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(3); |
| | | values.add(AttributeValues.create(structuralObjectClassType, "organization")); |
| | | values.add(AttributeValues.create(structuralObjectClassType, "inetorgperson")); |
| | | values.add(AttributeValues.create(structuralObjectClassType, |
| | | "top")); |
| | | |
| | | assertTrue(provider.hasAnyValue(entry, rule, values)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code hasAnyValue} method with a set of multiple values, none of |
| | | * which are correct. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testHasAnyValueMissingCorrect() |
| | | throws Exception |
| | | { |
| | | StructuralObjectClassVirtualAttributeProvider provider = |
| | | new StructuralObjectClassVirtualAttributeProvider(); |
| | | |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: o=test", |
| | | "objectClass: top", |
| | | "objectClass: organization", |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(structuralObjectClassType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(3); |
| | | values.add(AttributeValues.create(structuralObjectClassType, "inetorgperson")); |
| | | values.add(AttributeValues.create(structuralObjectClassType, |
| | | "top")); |
| | | values.add(AttributeValues.create(structuralObjectClassType, |
| | | "domain")); |
| | | |
| | | assertFalse(provider.hasAnyValue(entry, rule, values)); |
| | | assertFalse(provider.hasValue(entry, rule, ByteString.valueOf("inetorgperson"))); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | |
| | | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | import java.util.LinkedHashSet; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.std.meta.VirtualAttributeCfgDefn; |
| | |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.AttributeValues; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DN; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | |
| | | |
| | | /** |
| | | * A set of test cases for the subschemaSubentry virtual attribute provider. |
| | | */ |
| | |
| | | { |
| | | assertTrue(!a.isEmpty()); |
| | | assertEquals(a.size(), 1); |
| | | assertTrue(a.contains(AttributeValues.create(subschemaSubentryType, |
| | | "cn=schema"))); |
| | | assertTrue(a.contains(ByteString.valueOf("cn=schema"))); |
| | | } |
| | | } |
| | | |
| | |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | Set<AttributeValue> values = provider.getValues(entry, rule); |
| | | Attribute values = provider.getValues(entry, rule); |
| | | assertNotNull(values); |
| | | assertEquals(values.size(), 1); |
| | | assertTrue(values.contains(AttributeValues.create(subschemaSubentryType, |
| | | "cn=schema"))); |
| | | assertTrue(values.contains(ByteString.valueOf("cn=schema"))); |
| | | } |
| | | |
| | | |
| | |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | assertTrue(provider.hasValue(entry, rule, |
| | | AttributeValues.create(subschemaSubentryType, |
| | | "cn=schema"))); |
| | | assertTrue(provider.hasValue(entry, rule, ByteString.valueOf("cn=schema"))); |
| | | } |
| | | |
| | | |
| | |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | assertFalse(provider.hasValue(entry, rule, |
| | | AttributeValues.create(subschemaSubentryType, |
| | | "cn=not schema"))); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code hasAnyValue} method with an empty set of values. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testHasAnyValueEmptySet() |
| | | throws Exception |
| | | { |
| | | SubschemaSubentryVirtualAttributeProvider provider = |
| | | new SubschemaSubentryVirtualAttributeProvider(); |
| | | |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: o=test", |
| | | "objectClass: top", |
| | | "objectClass: organization", |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(subschemaSubentryType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | assertFalse(provider.hasAnyValue(entry, rule, |
| | | Collections.<AttributeValue>emptySet())); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code hasAnyValue} method with a set of values containing only |
| | | * the correct value. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testHasAnyValueOnlyCorrect() |
| | | throws Exception |
| | | { |
| | | SubschemaSubentryVirtualAttributeProvider provider = |
| | | new SubschemaSubentryVirtualAttributeProvider(); |
| | | |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: o=test", |
| | | "objectClass: top", |
| | | "objectClass: organization", |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(subschemaSubentryType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(1); |
| | | values.add(AttributeValues.create(subschemaSubentryType, "cn=schema")); |
| | | |
| | | assertTrue(provider.hasAnyValue(entry, rule, values)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code hasAnyValue} method with a set of values containing only |
| | | * an incorrect value. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testHasAnyValueOnlyIncorrect() |
| | | throws Exception |
| | | { |
| | | SubschemaSubentryVirtualAttributeProvider provider = |
| | | new SubschemaSubentryVirtualAttributeProvider(); |
| | | |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: o=test", |
| | | "objectClass: top", |
| | | "objectClass: organization", |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(subschemaSubentryType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(1); |
| | | values.add(AttributeValues.create(subschemaSubentryType, "cn=not schema")); |
| | | |
| | | assertFalse(provider.hasAnyValue(entry, rule, values)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code hasAnyValue} method with a set of values containing the |
| | | * correct value as well as multiple incorrect values. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testHasAnyValueIncludesCorrect() |
| | | throws Exception |
| | | { |
| | | SubschemaSubentryVirtualAttributeProvider provider = |
| | | new SubschemaSubentryVirtualAttributeProvider(); |
| | | |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: o=test", |
| | | "objectClass: top", |
| | | "objectClass: organization", |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(subschemaSubentryType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(3); |
| | | values.add(AttributeValues.create(subschemaSubentryType, "cn=schema")); |
| | | values.add(AttributeValues.create(subschemaSubentryType, "cn=not schema")); |
| | | values.add(AttributeValues.create(subschemaSubentryType, |
| | | "cn=not schema either")); |
| | | |
| | | assertTrue(provider.hasAnyValue(entry, rule, values)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code hasAnyValue} method with a set of multiple values, none of |
| | | * which are correct. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testHasAnyValueMissingCorrect() |
| | | throws Exception |
| | | { |
| | | SubschemaSubentryVirtualAttributeProvider provider = |
| | | new SubschemaSubentryVirtualAttributeProvider(); |
| | | |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: o=test", |
| | | "objectClass: top", |
| | | "objectClass: organization", |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(subschemaSubentryType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(3); |
| | | values.add(AttributeValues.create(subschemaSubentryType, "cn=not schema")); |
| | | values.add(AttributeValues.create(subschemaSubentryType, |
| | | "cn=not schema either")); |
| | | values.add(AttributeValues.create(subschemaSubentryType, |
| | | "cn=still not schema")); |
| | | |
| | | assertFalse(provider.hasAnyValue(entry, rule, values)); |
| | | assertFalse(provider.hasValue(entry, rule, ByteString.valueOf("cn=not schema"))); |
| | | } |
| | | } |
| | | |
| | |
| | | import java.util.LinkedHashSet; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | |
| | | |
| | | Attribute attr = attrList.get(0); |
| | | assertEquals(attr.size(), 1); |
| | | assertTrue(attr.contains(AttributeValues.create(descriptionType, |
| | | value))); |
| | | assertTrue(attr.contains(ByteString.valueOf(value))); |
| | | } |
| | | finally |
| | | { |
| | |
| | | |
| | | Attribute attr = attrList.get(0); |
| | | assertEquals(attr.size(), 2); |
| | | assertTrue(attr.contains(AttributeValues.create(descriptionType, |
| | | value1))); |
| | | assertTrue(attr.contains(AttributeValues.create(descriptionType, |
| | | value2))); |
| | | assertTrue(attr.contains(ByteString.valueOf(value1))); |
| | | assertTrue(attr.contains(ByteString.valueOf(value2))); |
| | | } |
| | | finally |
| | | { |
| | |
| | | |
| | | Attribute attr = attrList.get(0); |
| | | assertEquals(attr.size(), 1); |
| | | assertTrue(attr.contains(AttributeValues.create(descriptionType, |
| | | realValue))); |
| | | assertTrue(attr.contains(ByteString.valueOf(realValue))); |
| | | } |
| | | finally |
| | | { |
| | |
| | | |
| | | Attribute attr = attrList.get(0); |
| | | assertEquals(attr.size(), 1); |
| | | assertTrue(attr.contains(AttributeValues.create(descriptionType, |
| | | virtualValue))); |
| | | assertTrue(attr.contains(ByteString.valueOf(virtualValue))); |
| | | } |
| | | finally |
| | | { |
| | |
| | | Attribute a = attrList.get(0); |
| | | assertEquals(a.size(), 2); |
| | | |
| | | assertTrue(a.contains(AttributeValues.create( |
| | | descriptionType, realValue))); |
| | | assertTrue(a.contains(AttributeValues.create( |
| | | descriptionType, virtualValue))); |
| | | assertTrue(a.contains(ByteString.valueOf(realValue))); |
| | | assertTrue(a.contains(ByteString.valueOf(virtualValue))); |
| | | |
| | | } |
| | | finally |
| | |
| | | Attribute a = attrList.get(0); |
| | | assertEquals(a.size(), 2); |
| | | |
| | | assertTrue(a.contains(AttributeValues.create( |
| | | descriptionType, realValue))); |
| | | assertTrue(a.contains(AttributeValues.create( |
| | | descriptionType, virtualValue))); |
| | | assertTrue(a.contains(ByteString.valueOf(realValue))); |
| | | assertTrue(a.contains(ByteString.valueOf(virtualValue))); |
| | | } |
| | | finally |
| | | { |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | |
| | | |
| | | assertTrue(provider.isMultiValued()); |
| | | |
| | | Set<AttributeValue> values = provider.getValues(entry, rule); |
| | | Attribute values = provider.getValues(entry, rule); |
| | | assertNotNull(values); |
| | | assertFalse(values.isEmpty()); |
| | | assertTrue(provider.hasValue(entry, rule)); |
| | | assertTrue(provider.hasValue(entry, rule, |
| | | AttributeValues.create(memberType, u1.toString()))); |
| | | assertFalse(provider.hasValue(entry, rule, |
| | | AttributeValues.create(memberType, ne.toString()))); |
| | | assertTrue(provider.hasAnyValue(entry, rule, values)); |
| | | assertFalse(provider.hasAnyValue(entry, rule, |
| | | Collections.<AttributeValue>emptySet())); |
| | | assertTrue(provider.hasValue(entry, rule, ByteString.valueOf(u1.toString()))); |
| | | assertFalse(provider.hasValue(entry, rule, ByteString.valueOf(ne.toString()))); |
| | | assertEquals(provider.matchesSubstring(entry, rule, null, null, null), |
| | | ConditionResult.UNDEFINED); |
| | | assertEquals(provider.greaterThanOrEqualTo(entry, rule, null), |
| | |
| | | |
| | | assertTrue(provider.isMultiValued()); |
| | | |
| | | Set<AttributeValue> values = provider.getValues(entry, rule); |
| | | Attribute values = provider.getValues(entry, rule); |
| | | assertNotNull(values); |
| | | assertTrue(values.isEmpty()); |
| | | assertFalse(provider.hasValue(entry, rule)); |
| | | assertFalse(provider.hasValue(entry, rule, |
| | | AttributeValues.create(memberType, u1.toString()))); |
| | | assertFalse(provider.hasValue(entry, rule, |
| | | AttributeValues.create(memberType, ne.toString()))); |
| | | assertFalse(provider.hasAnyValue(entry, rule, values)); |
| | | assertFalse(provider.hasAnyValue(entry, rule, |
| | | Collections.<AttributeValue>emptySet())); |
| | | assertFalse(provider.hasValue(entry, rule, ByteString.valueOf(u1.toString()))); |
| | | assertFalse(provider.hasValue(entry, rule, ByteString.valueOf(ne.toString()))); |
| | | assertEquals(provider.matchesSubstring(entry, rule, null, null, null), |
| | | ConditionResult.UNDEFINED); |
| | | assertEquals(provider.greaterThanOrEqualTo(entry, rule, null), |
| | |
| | | |
| | | Attribute a = e.getAttribute(memberType).get(0); |
| | | assertEquals(a.size(), 4); |
| | | |
| | | AttributeValue v = AttributeValues.create(memberType, u1.toString()); |
| | | assertTrue(a.contains(v)); |
| | | assertTrue(a.contains(ByteString.valueOf(u1.toString()))); |
| | | |
| | | cleanUp(); |
| | | } |
| | |
| | | Attribute a = e.getAttribute(memberType).get(0); |
| | | assertEquals(a.size(), 1); |
| | | |
| | | AttributeValue v = AttributeValues.create(memberType, u4.toString()); |
| | | ByteString v = ByteString.valueOf(u4.toString()); |
| | | assertTrue(a.contains(v)); |
| | | |
| | | InternalClientConnection conn = |
| | |
| | | Attribute a = e.getAttribute(memberType).get(0); |
| | | assertEquals(a.size(), 1); |
| | | |
| | | AttributeValue v = AttributeValues.create(memberType, u4.toString()); |
| | | ByteString v = ByteString.valueOf(u4.toString()); |
| | | assertTrue(a.contains(v)); |
| | | |
| | | |
| | |
| | | a = e.getAttribute(memberType).get(0); |
| | | assertEquals(a.size(), 0); |
| | | |
| | | v = AttributeValues.create(memberType, u4.toString()); |
| | | v = ByteString.valueOf(u4.toString()); |
| | | assertTrue(a.contains(v)); |
| | | |
| | | |
| | |
| | | package org.opends.server.plugins; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.server.AdminTestCaseUtils; |
| | | import org.opends.server.admin.std.meta.AttributeCleanupPluginCfgDefn; |
| | | import org.opends.server.admin.std.server.AttributeCleanupPluginCfg; |
| | | import org.opends.server.api.plugin.PluginResult; |
| | | import org.opends.server.api.plugin.PluginType; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.AddOperationBasis; |
| | | import org.opends.server.core.ModifyOperationBasis; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | public void testInitializeWithInvalidConfigs(Entry e) |
| | | throws ConfigException, InitializationException |
| | | { |
| | | Set<PluginType> pluginTypes = new HashSet<PluginType>(); |
| | | List<Attribute> attrList = e.getAttribute("ds-cfg-plugin-type"); |
| | | |
| | | assertNotNull(attrList); |
| | | |
| | | for (Attribute attr : attrList) |
| | | { |
| | | for (AttributeValue value : attr) |
| | | { |
| | | pluginTypes.add( |
| | | PluginType.forName( |
| | | value.getValue().toString().toLowerCase())); |
| | | } |
| | | } |
| | | |
| | | Set<PluginType> pluginTypes = getPluginTypes(e); |
| | | assertTrue(!pluginTypes.isEmpty()); |
| | | |
| | | AttributeCleanupPluginCfg config = |
| | |
| | | fail(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Helper method to get the plugin types from the configuration entry. |
| | | * |
| | | * @param e Configuration entry. |
| | | * @return Set of plugin types. |
| | | */ |
| | | private Set<PluginType> getPluginTypes(Entry e) |
| | | { |
| | | Set<PluginType> pluginTypes = new HashSet<PluginType>(); |
| | | List<Attribute> attrList = e.getAttribute("ds-cfg-plugin-type"); |
| | | |
| | | for(Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | { |
| | | pluginTypes.add( |
| | | PluginType.forName(v.getValue().toString().toLowerCase())); |
| | | } |
| | | } |
| | | |
| | | return pluginTypes; |
| | | } |
| | | |
| | | } |
| | |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryConfig; |
| | | import org.opends.server.types.Entry; |
| | |
| | | /** |
| | | * Tests the process of initializing the server with valid configurations. |
| | | * |
| | | * @param entry The configuration entry to use for the initialization. |
| | | * @param e The configuration entry to use for the initialization. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | |
| | | public void testInitializeWithValidConfigs(Entry e) |
| | | throws Exception |
| | | { |
| | | HashSet<PluginType> pluginTypes = new HashSet<PluginType>(); |
| | | List<Attribute> attrList = e.getAttribute("ds-cfg-plugin-type"); |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | { |
| | | pluginTypes.add(PluginType.forName( |
| | | v.getValue().toString().toLowerCase())); |
| | | } |
| | | } |
| | | |
| | | HashSet<PluginType> pluginTypes = TestCaseUtils.getPluginTypes(e); |
| | | |
| | | EntryUUIDPluginCfg configuration = |
| | | AdminTestCaseUtils.getConfiguration( |
| | |
| | | * Tests the process of initializing the server with valid configurations but |
| | | * without the entryUUID attribute type defined in the server. |
| | | * |
| | | * @param entry The configuration entry to use for the initialization. |
| | | * @param e The configuration entry to use for the initialization. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | |
| | | false); |
| | | DirectoryServer.deregisterAttributeType(entryUUIDType); |
| | | |
| | | |
| | | HashSet<PluginType> pluginTypes = new HashSet<PluginType>(); |
| | | List<Attribute> attrList = e.getAttribute("ds-cfg-plugin-type"); |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | { |
| | | pluginTypes.add(PluginType.forName( |
| | | v.getValue().toString().toLowerCase())); |
| | | } |
| | | } |
| | | |
| | | HashSet<PluginType> pluginTypes = TestCaseUtils.getPluginTypes(e); |
| | | |
| | | EntryUUIDPluginCfg configuration = |
| | | AdminTestCaseUtils.getConfiguration( |
| | |
| | | /** |
| | | * Tests the process of initializing the server with valid configurations. |
| | | * |
| | | * @param entry The configuration entry to use for the initialization. |
| | | * @param e The configuration entry to use for the initialization. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | |
| | | public void testInitializeWithInvalidConfigs(Entry e) |
| | | throws Exception |
| | | { |
| | | HashSet<PluginType> pluginTypes = new HashSet<PluginType>(); |
| | | List<Attribute> attrList = e.getAttribute("ds-cfg-plugin-type"); |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | { |
| | | pluginTypes.add(PluginType.forName( |
| | | v.getValue().toString().toLowerCase())); |
| | | } |
| | | } |
| | | |
| | | HashSet<PluginType> pluginTypes = TestCaseUtils.getPluginTypes(e); |
| | | |
| | | EntryUUIDPluginCfg configuration = |
| | | AdminTestCaseUtils.getConfiguration( |
| | |
| | | */ |
| | | package org.opends.server.plugins; |
| | | |
| | | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashSet; |
| | | import java.util.LinkedHashSet; |
| | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines a set of tests for the |
| | | * org.opends.server.plugins.LDAPADListPlugin class. |
| | |
| | | /** |
| | | * Tests the process of initializing the server with valid configurations. |
| | | * |
| | | * @param entry The configuration entry to use for the initialization. |
| | | * @param e The configuration entry to use for the initialization. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | |
| | | public void testInitializeWithValidConfigs(Entry e) |
| | | throws Exception |
| | | { |
| | | HashSet<PluginType> pluginTypes = new HashSet<PluginType>(); |
| | | List<Attribute> attrList = e.getAttribute("ds-cfg-plugin-type"); |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | { |
| | | pluginTypes.add(PluginType.forName(v.getValue().toString().toLowerCase())); |
| | | } |
| | | } |
| | | |
| | | HashSet<PluginType> pluginTypes = TestCaseUtils.getPluginTypes(e); |
| | | |
| | | LDAPAttributeDescriptionListPluginCfg configuration = |
| | | AdminTestCaseUtils.getConfiguration( |
| | |
| | | /** |
| | | * Tests the process of initializing the server with valid configurations. |
| | | * |
| | | * @param entry The configuration entry to use for the initialization. |
| | | * @param e The configuration entry to use for the initialization. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | |
| | | public void testInitializeWithInvalidConfigs(Entry e) |
| | | throws Exception |
| | | { |
| | | HashSet<PluginType> pluginTypes = new HashSet<PluginType>(); |
| | | List<Attribute> attrList = e.getAttribute("ds-cfg-plugin-type"); |
| | | if (attrList != null) |
| | | { |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | { |
| | | pluginTypes.add(PluginType.forName( |
| | | v.getValue().toString().toLowerCase())); |
| | | } |
| | | } |
| | | } |
| | | |
| | | HashSet<PluginType> pluginTypes = TestCaseUtils.getPluginTypes(e); |
| | | |
| | | LDAPAttributeDescriptionListPluginCfg configuration = |
| | | AdminTestCaseUtils.getConfiguration( |
| | |
| | | import org.opends.server.core.ModifyDNOperation; |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.DirectoryConfig; |
| | | import org.opends.server.types.DN; |
| | |
| | | /** |
| | | * Tests the process of initializing the server with valid configurations. |
| | | * |
| | | * @param entry The configuration entry to use for the initialization. |
| | | * @param e The configuration entry to use for the initialization. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | |
| | | public void testInitializeWithValidConfigs(Entry e) |
| | | throws Exception |
| | | { |
| | | HashSet<PluginType> pluginTypes = new HashSet<PluginType>(); |
| | | List<Attribute> attrList = e.getAttribute("ds-cfg-plugin-type"); |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | { |
| | | pluginTypes.add(PluginType.forName( |
| | | v.getValue().toString().toLowerCase())); |
| | | } |
| | | } |
| | | |
| | | HashSet<PluginType> pluginTypes = TestCaseUtils.getPluginTypes(e); |
| | | |
| | | LastModPluginCfg configuration = |
| | | AdminTestCaseUtils.getConfiguration( |
| | |
| | | * Tests the process of initializing the server with valid configurations but |
| | | * without the lastmod schema defined in the server. |
| | | * |
| | | * @param entry The configuration entry to use for the initialization. |
| | | * @param e The configuration entry to use for the initialization. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | |
| | | public void testInitializeWithValidConfigsWithoutSchema(Entry e) |
| | | throws Exception |
| | | { |
| | | AttributeType ctType = DirectoryConfig.getAttributeType("createtimestamp", |
| | | false); |
| | | AttributeType cnType = DirectoryConfig.getAttributeType("creatorsname", |
| | | false); |
| | | AttributeType mtType = DirectoryConfig.getAttributeType("modifytimestamp", |
| | | false); |
| | | AttributeType mnType = DirectoryConfig.getAttributeType("modifiersname", |
| | | false); |
| | | AttributeType ctType = DirectoryConfig.getAttributeType("createtimestamp", false); |
| | | AttributeType cnType = DirectoryConfig.getAttributeType("creatorsname", false); |
| | | AttributeType mtType = DirectoryConfig.getAttributeType("modifytimestamp", false); |
| | | AttributeType mnType = DirectoryConfig.getAttributeType("modifiersname", false); |
| | | |
| | | DirectoryServer.deregisterAttributeType(ctType); |
| | | DirectoryServer.deregisterAttributeType(cnType); |
| | |
| | | DirectoryServer.deregisterAttributeType(mnType); |
| | | |
| | | |
| | | HashSet<PluginType> pluginTypes = new HashSet<PluginType>(); |
| | | List<Attribute> attrList = e.getAttribute("ds-cfg-plugin-type"); |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | { |
| | | pluginTypes.add(PluginType.forName( |
| | | v.getValue().toString().toLowerCase())); |
| | | } |
| | | } |
| | | |
| | | HashSet<PluginType> pluginTypes = TestCaseUtils.getPluginTypes(e); |
| | | |
| | | LastModPluginCfg configuration = |
| | | AdminTestCaseUtils.getConfiguration( |
| | |
| | | /** |
| | | * Tests the process of initializing the server with valid configurations. |
| | | * |
| | | * @param entry The configuration entry to use for the initialization. |
| | | * @param e The configuration entry to use for the initialization. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | |
| | | public void testInitializeWithInvalidConfigs(Entry e) |
| | | throws Exception |
| | | { |
| | | HashSet<PluginType> pluginTypes = new HashSet<PluginType>(); |
| | | List<Attribute> attrList = e.getAttribute("ds-cfg-plugin-type"); |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | { |
| | | pluginTypes.add(PluginType.forName( |
| | | v.getValue().toString().toLowerCase())); |
| | | } |
| | | } |
| | | |
| | | HashSet<PluginType> pluginTypes = TestCaseUtils.getPluginTypes(e); |
| | | |
| | | LastModPluginCfg configuration = |
| | | AdminTestCaseUtils.getConfiguration( |
| | |
| | | */ |
| | | package org.opends.server.plugins; |
| | | |
| | | |
| | | |
| | | import java.io.ByteArrayInputStream; |
| | | import java.util.ArrayList; |
| | | import java.util.HashSet; |
| | |
| | | import org.opends.server.api.plugin.PluginType; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines a set of tests for the |
| | | * org.opends.server.plugins.PasswordPolicyImportPluginTestCase class. |
| | |
| | | /** |
| | | * Tests the process of initializing the server with valid configurations. |
| | | * |
| | | * @param entry The configuration entry to use for the initialization. |
| | | * @param e The configuration entry to use for the initialization. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | |
| | | public void testInitializeWithValidConfigs(Entry e) |
| | | throws Exception |
| | | { |
| | | HashSet<PluginType> pluginTypes = new HashSet<PluginType>(); |
| | | List<Attribute> attrList = e.getAttribute("ds-cfg-plugin-type"); |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | { |
| | | pluginTypes.add(PluginType.forName( |
| | | v.getValue().toString().toLowerCase())); |
| | | } |
| | | } |
| | | HashSet<PluginType> pluginTypes = TestCaseUtils.getPluginTypes(e); |
| | | |
| | | PasswordPolicyImportPluginCfg configuration = |
| | | AdminTestCaseUtils.getConfiguration( |
| | |
| | | public void testInitializeWithInvalidConfigs(Entry e) |
| | | throws Exception |
| | | { |
| | | HashSet<PluginType> pluginTypes = new HashSet<PluginType>(); |
| | | List<Attribute> attrList = e.getAttribute("ds-cfg-plugin-type"); |
| | | if (attrList != null) |
| | | { |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | { |
| | | pluginTypes.add(PluginType.forName( |
| | | v.getValue().toString().toLowerCase())); |
| | | } |
| | | } |
| | | } |
| | | |
| | | HashSet<PluginType> pluginTypes = TestCaseUtils.getPluginTypes(e); |
| | | |
| | | PasswordPolicyImportPluginCfg configuration = |
| | | AdminTestCaseUtils.getConfiguration( |
| | |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.server.AdminTestCaseUtils; |
| | |
| | | import org.opends.server.admin.std.server.ReferentialIntegrityPluginCfg; |
| | | import org.opends.server.api.Group; |
| | | import org.opends.server.api.plugin.PluginType; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.controls.SubtreeDeleteControl; |
| | | import org.opends.server.core.*; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.RDN; |
| | | import org.testng.annotations.*; |
| | | |
| | | import static org.testng.Assert.*; |
| | |
| | | public void testInitializeWithValidConfigs(Entry e) |
| | | throws Exception |
| | | { |
| | | HashSet<PluginType> pluginTypes = new HashSet<PluginType>(); |
| | | List<Attribute> attrList = e.getAttribute("ds-cfg-plugin-type"); |
| | | for (Attribute a : attrList){ |
| | | for (AttributeValue v : a) |
| | | pluginTypes.add(PluginType.forName( |
| | | v.getValue().toString().toLowerCase())); |
| | | } |
| | | HashSet<PluginType> pluginTypes = TestCaseUtils.getPluginTypes(e); |
| | | ReferentialIntegrityPluginCfg configuration = |
| | | AdminTestCaseUtils.getConfiguration( |
| | | ReferentialIntegrityPluginCfgDefn.getInstance(), e); |
| | |
| | | public void testInitializeWithInValidConfigs(Entry e) |
| | | throws Exception |
| | | { |
| | | HashSet<PluginType> pluginTypes = new HashSet<PluginType>(); |
| | | List<Attribute> attrList = e.getAttribute("ds-cfg-plugin-type"); |
| | | for (Attribute a : attrList){ |
| | | for (AttributeValue v : a) |
| | | pluginTypes.add(PluginType.forName( |
| | | v.getValue().toString().toLowerCase())); |
| | | } |
| | | HashSet<PluginType> pluginTypes = TestCaseUtils.getPluginTypes(e); |
| | | ReferentialIntegrityPluginCfg configuration = |
| | | AdminTestCaseUtils.getConfiguration( |
| | | ReferentialIntegrityPluginCfgDefn.getInstance(), e); |
| | |
| | | * Ensures that the Directory Server is running. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | * |
| | | */ |
| | | @BeforeClass() |
| | | public void startServer() |
| | |
| | | null); |
| | | for (SearchResultEntry entry : operation.getSearchEntries()) { |
| | | for(String dn : dns) { |
| | | AttributeValue value = AttributeValues.create(type, dn); |
| | | ByteString value = ByteString.valueOf(dn); |
| | | assertEquals(entry.hasValue(type, null, value), expected); |
| | | } |
| | | } |
| | |
| | | * Copyright 2011-2012 profiq s.r.o. |
| | | * Portions Copyright 2011-2014 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.opends.server.plugins; |
| | | |
| | | import java.util.LinkedList; |
| | |
| | | |
| | | import org.forgerock.opendj.io.ASN1; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ExtendedOperation; |
| | |
| | | import org.opends.server.plugins.SambaPasswordPlugin.TimeStampProvider; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.util.ServerConstants; |
| | | import org.testng.annotations.*; |
| | | |
| | |
| | | boolean foundNTPassword = false; |
| | | for (Attribute a : sambaAttribute) |
| | | { |
| | | for (AttributeValue val : a) |
| | | for (ByteString val : a) |
| | | { |
| | | foundNTPassword = true; |
| | | assertEquals(val.toString(), ntPassword); |
| | |
| | | boolean foundLMPassword = false; |
| | | for (Attribute a : sambaAttribute) |
| | | { |
| | | for (AttributeValue val : a) |
| | | for (ByteString val : a) |
| | | { |
| | | foundLMPassword = true; |
| | | assertEquals(val.toString(), lmPassword); |
| | |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.server.AdminTestCaseUtils; |
| | | import org.opends.server.admin.std.meta.UniqueAttributePluginCfgDefn; |
| | | import org.opends.server.admin.std.server.UniqueAttributePluginCfg; |
| | | import org.opends.server.api.plugin.PluginType; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ModifyDNOperation; |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.testng.annotations.*; |
| | | |
| | | import static org.testng.Assert.*; |
| | |
| | | public void testInitializeWithValidConfigs(Entry e) |
| | | throws Exception |
| | | { |
| | | HashSet<PluginType> pluginTypes = new HashSet<PluginType>(); |
| | | List<Attribute> attrList = e.getAttribute("ds-cfg-plugin-type"); |
| | | for (Attribute a : attrList){ |
| | | for (AttributeValue v : a) |
| | | pluginTypes.add(PluginType.forName( |
| | | v.getValue().toString().toLowerCase())); |
| | | } |
| | | HashSet<PluginType> pluginTypes = TestCaseUtils.getPluginTypes(e); |
| | | UniqueAttributePluginCfg configuration = |
| | | AdminTestCaseUtils.getConfiguration( |
| | | UniqueAttributePluginCfgDefn.getInstance(), e); |
| | |
| | | public void testInitializeWithInvalidConfigs(Entry e) |
| | | throws Exception |
| | | { |
| | | HashSet<PluginType> pluginTypes = new HashSet<PluginType>(); |
| | | List<Attribute> attrList = e.getAttribute("ds-cfg-plugin-type"); |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | pluginTypes.add(PluginType.forName( |
| | | v.getValue().toString().toLowerCase())); |
| | | } |
| | | HashSet<PluginType> pluginTypes = TestCaseUtils.getPluginTypes(e); |
| | | UniqueAttributePluginCfg configuration = |
| | | AdminTestCaseUtils.getConfiguration( |
| | | UniqueAttributePluginCfgDefn.getInstance(), e); |
| | |
| | | AttributeType attrType = getAttrType(attrTypeString); |
| | | AttributeBuilder builder = new AttributeBuilder(attrType, attrTypeString); |
| | | for(String valString : attrValStrings) { |
| | | builder.add(AttributeValues.create(attrType, valString)); |
| | | builder.add(valString); |
| | | } |
| | | mods.add(new Modification(ModificationType.REPLACE, builder.toAttribute())); |
| | | InternalClientConnection conn = |
| | |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | | import org.forgerock.opendj.io.*; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import static org.opends.server.util.ServerConstants.EOL; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | |
| | | |
| | | AttributeType attribute = |
| | | DirectoryServer.getDefaultAttributeType("testAttribute"); |
| | | |
| | | AttributeValue attributeValue = AttributeValues.create(attribute, "testValue"); |
| | | |
| | | RDN[] rdns = new RDN[1]; |
| | | rdns[0] = RDN.create(attribute, attributeValue); |
| | | |
| | | dn = new DN(rdns); |
| | | ByteString attributeValue = ByteString.valueOf("testValue"); |
| | | dn = new DN(new RDN[] { RDN.create(attribute, attributeValue) }); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.io.*; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import static org.opends.server.util.ServerConstants.EOL; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | import static org.testng.Assert.assertEquals; |
| | | import static org.testng.Assert.assertTrue; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Iterator; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.io.ASN1; |
| | | import org.forgerock.opendj.io.ASN1Reader; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * This class defines a set of tests for the |
| | | * org.opends.server.protocol.ldap.CompareRequestProtocolOp class. |
| | |
| | | |
| | | AttributeType attribute = |
| | | DirectoryServer.getDefaultAttributeType("testAttribute"); |
| | | |
| | | AttributeValue attributeValue = AttributeValues.create(attribute, "testValue"); |
| | | |
| | | RDN[] rdns = new RDN[1]; |
| | | rdns[0] = RDN.create(attribute, attributeValue); |
| | | dn = new DN(rdns); |
| | | ByteString attributeValue = ByteString.valueOf("testValue"); |
| | | dn = new DN(new RDN[] { RDN.create(attribute, attributeValue) }); |
| | | } |
| | | |
| | | /** |
| | |
| | | public void testConstructors() throws Exception |
| | | { |
| | | CompareResponseProtocolOp compareResponse; |
| | | ArrayList<LDAPAttribute> attributes; |
| | | |
| | | //Test to make sure the constructor with result code param works. |
| | | compareResponse = new CompareResponseProtocolOp(resultCode); |
| | | assertEquals(compareResponse.getResultCode(), resultCode); |
| | |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | | import static org.testng.Assert.*; |
| | | import org.testng.annotations.*; |
| | | import org.forgerock.opendj.io.*; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import static org.opends.server.util.ServerConstants.EOL; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Iterator; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.io.ASN1; |
| | | import org.forgerock.opendj.io.ASN1Reader; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * This class defines a set of tests for the |
| | | * org.opends.server.protocol.ldap.DeleteResponseProtocolOp class. |
| | |
| | | public void setupDN() |
| | | { |
| | | //Setup the DN to use in the response tests. |
| | | |
| | | AttributeType attribute = |
| | | DirectoryServer.getDefaultAttributeType("testAttribute"); |
| | | |
| | | AttributeValue attributeValue = AttributeValues.create(attribute, "testValue"); |
| | | |
| | | RDN[] rdns = new RDN[1]; |
| | | rdns[0] = RDN.create(attribute, attributeValue); |
| | | dn = new DN(rdns); |
| | | ByteString attributeValue = ByteString.valueOf("testValue"); |
| | | dn = new DN(new RDN[] { RDN.create(attribute, attributeValue) }); |
| | | } |
| | | |
| | | /** |
| | |
| | | public void testConstructors() throws Exception |
| | | { |
| | | DeleteResponseProtocolOp deleteResponse; |
| | | ArrayList<LDAPAttribute> attributes; |
| | | |
| | | //Test to make sure the constructor with result code param works. |
| | | deleteResponse = new DeleteResponseProtocolOp(resultCode); |
| | | assertEquals(deleteResponse.getResultCode(), resultCode); |
| | |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.io.*; |
| | | import static org.opends.server.util.ServerConstants.EOL; |
| | | import org.opends.server.DirectoryServerTestCase; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | import static org.testng.Assert.assertEquals; |
| | | import static org.testng.Assert.assertTrue; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Iterator; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.io.ASN1; |
| | | import org.forgerock.opendj.io.ASN1Reader; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.opends.server.DirectoryServerTestCase; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * This class defines a set of tests for the |
| | | * org.opends.server.protocol.ldap.ModifyDNResponseProtocolOp class. |
| | |
| | | public void setupDN() |
| | | { |
| | | //Setup the DN to use in the response tests. |
| | | |
| | | AttributeType attribute = |
| | | DirectoryServer.getDefaultAttributeType("testAttribute"); |
| | | |
| | | AttributeValue attributeValue = AttributeValues.create(attribute, "testValue"); |
| | | |
| | | RDN[] rdns = new RDN[1]; |
| | | rdns[0] = RDN.create(attribute, attributeValue); |
| | | dn = new DN(rdns); |
| | | ByteString attributeValue = ByteString.valueOf("testValue"); |
| | | dn = new DN(new RDN[] { RDN.create(attribute, attributeValue) }); |
| | | } |
| | | |
| | | /** |
| | |
| | | public void testConstructors() throws Exception |
| | | { |
| | | ModifyDNResponseProtocolOp modifyResponse; |
| | | ArrayList<LDAPAttribute> attributes; |
| | | |
| | | //Test to make sure the constructor with result code param works. |
| | | modifyResponse = new ModifyDNResponseProtocolOp(resultCode); |
| | | assertEquals(modifyResponse.getResultCode(), resultCode); |
| | |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.io.*; |
| | | import static org.opends.server.util.ServerConstants.EOL; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | import static org.testng.Assert.assertEquals; |
| | | import static org.testng.Assert.assertTrue; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Iterator; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.io.ASN1; |
| | | import org.forgerock.opendj.io.ASN1Reader; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * This class defines a set of tests for the |
| | | * org.opends.server.protocol.ldap.ModifyResponseProtocolOp class. |
| | |
| | | |
| | | AttributeType attribute = |
| | | DirectoryServer.getDefaultAttributeType("testAttribute"); |
| | | |
| | | AttributeValue attributeValue = AttributeValues.create(attribute, "testValue"); |
| | | |
| | | RDN[] rdns = new RDN[1]; |
| | | rdns[0] = RDN.create(attribute, attributeValue); |
| | | dn = new DN(rdns); |
| | | ByteString attributeValue = ByteString.valueOf("testValue"); |
| | | dn = new DN(new RDN[] { RDN.create(attribute, attributeValue) }); |
| | | } |
| | | |
| | | /** |
| | |
| | | public void testConstructors() throws Exception |
| | | { |
| | | ModifyResponseProtocolOp modifyResponse; |
| | | ArrayList<LDAPAttribute> attributes; |
| | | |
| | | //Test to make sure the constructor with result code param works. |
| | | modifyResponse = new ModifyResponseProtocolOp(resultCode); |
| | | assertEquals(modifyResponse.getResultCode(), resultCode); |
| | |
| | | import java.util.SortedSet; |
| | | import java.util.TreeSet; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.backends.MemoryBackend; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | import org.opends.server.replication.server.ReplServerFakeConfiguration; |
| | | import org.opends.server.replication.server.ReplicationServer; |
| | | import org.opends.server.replication.service.ReplicationBroker; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | |
| | | { |
| | | entry.removeAttribute(uidType); |
| | | entry.addAttribute(Attributes.create("entryuuid", stringUID(sequence+1)), |
| | | new LinkedList<AttributeValue>()); |
| | | new LinkedList<ByteString>()); |
| | | addDN = DN.valueOf("dc=dependency" + sequence + "," + addDN); |
| | | AddMsg addMsg = |
| | | new AddMsg(gen.newCSN(), addDN, stringUID(sequence+1), |
| | |
| | | entry.removeAttribute(uidType); |
| | | entry.addAttribute(Attributes.create("entryuuid", |
| | | stringUID(renamedEntryUuid)), |
| | | new LinkedList<AttributeValue>()); |
| | | new LinkedList<ByteString>()); |
| | | DN addDN = DN.valueOf("dc=moddndel" + "," + TEST_ROOT_DN_STRING); |
| | | AddMsg addMsg = |
| | | new AddMsg(gen.newCSN(), addDN, stringUID(renamedEntryUuid), |
| | |
| | | // add the entry a first time |
| | | entry.removeAttribute(uidType); |
| | | entry.addAttribute(Attributes.create("entryuuid", stringUID(sequence+1)), |
| | | new LinkedList<AttributeValue>()); |
| | | new LinkedList<ByteString>()); |
| | | DN addDN = DN.valueOf("dc=dependency" + sequence + "," + TEST_ROOT_DN_STRING); |
| | | AddMsg addMsg = |
| | | new AddMsg(gen.newCSN(), addDN, stringUID(sequence+1), |
| | |
| | | // add again the entry with a new entryuuid. |
| | | entry.removeAttribute(uidType); |
| | | entry.addAttribute(Attributes.create("entryuuid", stringUID(sequence+1025)), |
| | | new LinkedList<AttributeValue>()); |
| | | new LinkedList<ByteString>()); |
| | | addMsg = |
| | | new AddMsg(gen.newCSN(), addDN, stringUID(sequence+1025), |
| | | stringUID(1), |
| | |
| | | // add the entry |
| | | entry.removeAttribute(uidType); |
| | | entry.addAttribute(Attributes.create("entryuuid", stringUID(sequence+1)), |
| | | new LinkedList<AttributeValue>()); |
| | | new LinkedList<ByteString>()); |
| | | addDN = DN.valueOf("dc=dependency" + sequence + "," + TEST_ROOT_DN_STRING); |
| | | AddMsg addMsg = |
| | | new AddMsg(gen.newCSN(), addDN, stringUID(sequence+1), |
| | |
| | | Attribute attr = attrs.get(0); |
| | | if (attr.size() == 1) |
| | | { |
| | | return Long.decode(attr.iterator().next().getValue().toString()); |
| | | return Long.decode(attr.iterator().next().toString()); |
| | | } |
| | | } |
| | | } |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | |
| | | if ((tmpAttrList != null) && (!tmpAttrList.isEmpty())) |
| | | { |
| | | Attribute tmpAttr = tmpAttrList.get(0); |
| | | |
| | | AttributeType attrType = |
| | | DirectoryServer.getAttributeType(attrTypeStr, true); |
| | | found = tmpAttr.contains(AttributeValues.create(attrType, valueString)); |
| | | found = tmpAttr.contains(ByteString.valueOf(valueString)); |
| | | } |
| | | } |
| | | } |
| | |
| | | if (newEntry != null) |
| | | { |
| | | Attribute attribute = newEntry.getAttribute("entryuuid").get(0); |
| | | for (AttributeValue val : attribute) |
| | | for (ByteString val : attribute) |
| | | { |
| | | found = val.getValue().toString(); |
| | | found = val.toString(); |
| | | break; |
| | | } |
| | | } |
| | |
| | | // Read the entry back to get its UUID. |
| | | Entry entry = DirectoryServer.getEntry(dn1); |
| | | List<Attribute> attrs = entry.getAttribute(entryuuidType); |
| | | String entryuuid = |
| | | attrs.get(0).iterator().next().getValue().toString(); |
| | | String entryuuid = attrs.get(0).iterator().next().toString(); |
| | | |
| | | // A change on a first server. |
| | | long changeTime = TimeThread.getTime(); |
| | |
| | | // Read the entry to see how the conflict was resolved. |
| | | entry = DirectoryServer.getEntry(dn1); |
| | | attrs = entry.getAttribute(attrType); |
| | | String attrValue1 = |
| | | attrs.get(0).iterator().next().getValue().toString(); |
| | | String attrValue1 = attrs.get(0).iterator().next().toString(); |
| | | |
| | | // the value should be the last (time t2) value added |
| | | assertEquals(attrValue1, "B"); |
| | |
| | | import org.assertj.core.data.MapEntry; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.AddOperation; |
| | |
| | | |
| | | // Parse and store values |
| | | Map<Integer,Integer> resultMap = new HashMap<Integer,Integer>(); |
| | | for (AttributeValue val : attrs.get(0)) |
| | | for (ByteString val : attrs.get(0)) |
| | | { |
| | | StringTokenizer strtok = new StringTokenizer(val.toString(), ":"); |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013 ForgeRock AS. |
| | | * Portions Copyright 2013-2014 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | |
| | | import org.opends.server.replication.ReplicationTestCase; |
| | | import org.opends.server.replication.common.CSN; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.AttributeValues; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.util.TimeThread; |
| | | import org.testng.annotations.DataProvider; |
| | |
| | | @DataProvider(name = "attrInfo") |
| | | public Object[][] createData() |
| | | { |
| | | AttributeType type = DirectoryServer.getAttributeType("description"); |
| | | |
| | | AttributeValue att1 = AttributeValues.create(type, "string"); |
| | | AttributeValue att2 = AttributeValues.create(type, "value"); |
| | | AttributeValue att3 = AttributeValues.create(type, "again"); |
| | | ByteString att1 = ByteString.valueOf("string"); |
| | | ByteString att2 = ByteString.valueOf("value"); |
| | | ByteString att3 = ByteString.valueOf("again"); |
| | | |
| | | CSN del1 = new CSN(1, 0, 1); |
| | | CSN del2 = new CSN(1, 1, 1); |
| | |
| | | * Create a AttrInfo and check the methods |
| | | */ |
| | | @Test(dataProvider = "attrInfo") |
| | | public void attrInfo( |
| | | AttributeValue att, CSN deleteTime, CSN updateTime) |
| | | throws Exception |
| | | public void attrInfo(ByteString att, CSN deleteTime, CSN updateTime) throws Exception |
| | | { |
| | | // Create an empty AttrInfo |
| | | AttrHistoricalMultiple attrInfo1 = new AttrHistoricalMultiple(); |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.backends.task.Task; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.replication.ReplicationTestCase; |
| | | import org.opends.server.replication.common.CSNGenerator; |
| | |
| | | import org.opends.server.replication.server.ReplicationServer; |
| | | import org.opends.server.replication.service.ReplicationDomain; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | |
| | | Attribute attr = attrs.get(0); |
| | | if (attr.size() == 1) |
| | | { |
| | | return Long.decode(attr.iterator().next().getValue().toString()); |
| | | return Long.decode(attr.iterator().next().toString()); |
| | | } |
| | | } |
| | | } |
| | |
| | | assertEquals(attrs.size(), 1); |
| | | Attribute attr = attrs.get(0); |
| | | assertNotNull(attr); |
| | | Iterator<AttributeValue> attrValues = attr.iterator(); |
| | | Iterator<ByteString> attrValues = attr.iterator(); |
| | | assertNotNull(attrValues); |
| | | assertTrue(attrValues.hasNext()); |
| | | AttributeValue attrValue = attrValues.next(); |
| | | ByteString attrValue = attrValues.next(); |
| | | assertNotNull(attrValue); |
| | | assertFalse(attrValues.hasNext()); |
| | | assertEquals(attrValue.toString(), attributeValue, "Was expecting attribute " + |
| | |
| | | import org.assertj.core.api.Assertions; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.std.meta.ReplicationDomainCfgDefn.AssuredType; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.replication.ReplicationTestCase; |
| | | import org.opends.server.replication.common.CSN; |
| | |
| | | List<Attribute> attrs1 = entry.getAttribute(histType); |
| | | Assertions.assertThat(attrs1).isNotEmpty(); |
| | | |
| | | String histValue = |
| | | attrs1.get(0).iterator().next().getValue().toString(); |
| | | String histValue = attrs1.get(0).iterator().next().toString(); |
| | | |
| | | logger.error(LocalizableMessage.raw("First historical value:" + histValue)); |
| | | |
| | |
| | | List<Attribute> attrs2 = entry2.getAttribute(histType); |
| | | Assertions.assertThat(attrs2).isNotEmpty(); |
| | | |
| | | for (AttributeValue av : attrs2.get(0)) { |
| | | logger.error(LocalizableMessage.raw("Second historical value:" + av.getValue())); |
| | | for (ByteString av : attrs2.get(0)) { |
| | | logger.error(LocalizableMessage.raw("Second historical value: %s", av)); |
| | | } |
| | | |
| | | LinkedList<ReplicationMsg> opList = new LinkedList<ReplicationMsg>(); |
| | |
| | | |
| | | import org.assertj.core.api.Assertions; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | import org.opends.server.replication.service.ReplicationBroker; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | |
| | | { |
| | | Entry entry = DirectoryServer.getEntry(dn); |
| | | List<Attribute> attrs = entry.getAttribute(attrType); |
| | | return attrs.get(0).iterator().next().getValue().toString(); |
| | | return attrs.get(0).iterator().next().toString(); |
| | | } |
| | | |
| | | private static void publishModify(ReplicationBroker broker, CSN changeNum, |
| | |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.opends.server.core.AddOperationBasis; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | builder.add("value1"); |
| | | builder.add("value2"); |
| | | |
| | | List<AttributeValue> duplicateValues = new LinkedList<AttributeValue>(); |
| | | List<ByteString> duplicateValues = new LinkedList<ByteString>(); |
| | | entry.addAttribute(builder.toAttribute(), duplicateValues); |
| | | |
| | | |
| | |
| | | builder.add("value3"); |
| | | builder.add("value4"); |
| | | |
| | | List<AttributeValue> duplicateValues = new LinkedList<AttributeValue>(); |
| | | List<ByteString> duplicateValues = new LinkedList<ByteString>(); |
| | | entry.addAttribute(builder.toAttribute(), duplicateValues); |
| | | |
| | | |
| | |
| | | |
| | | // Create a single valued attribute with value : "value1" |
| | | // add this attribute to the entry. |
| | | List<AttributeValue> duplicateValues = new LinkedList<AttributeValue>(); |
| | | List<ByteString> duplicateValues = new LinkedList<ByteString>(); |
| | | Attribute attribute = Attributes.create(EMPLOYEENUMBER, "value1"); |
| | | entry.addAttribute(attribute, duplicateValues); |
| | | |
| | |
| | | |
| | | // Create a single valued attribute with value : "value1" |
| | | // add this attribute to the entry. |
| | | List<AttributeValue> duplicateValues = new LinkedList<AttributeValue>(); |
| | | List<ByteString> duplicateValues = new LinkedList<ByteString>(); |
| | | Attribute attribute = Attributes.create(EMPLOYEENUMBER, "value1"); |
| | | entry.addAttribute(attribute, duplicateValues); |
| | | |
| | |
| | | builder.add("value1"); |
| | | builder.add("value2"); |
| | | |
| | | List<AttributeValue> duplicateValues = new LinkedList<AttributeValue>(); |
| | | List<ByteString> duplicateValues = new LinkedList<ByteString>(); |
| | | entry.addAttribute(builder.toAttribute(), duplicateValues); |
| | | |
| | | // load historical from the entry |
| | |
| | | |
| | | // Create a single valued attribute with value : "value1" |
| | | // add this attribute to the entry. |
| | | List<AttributeValue> duplicateValues = new LinkedList<AttributeValue>(); |
| | | List<ByteString> duplicateValues = new LinkedList<ByteString>(); |
| | | Attribute attribute = Attributes.create(DISPLAYNAME, "value1"); |
| | | entry.addAttribute(attribute, duplicateValues); |
| | | Attribute attrDel = buildSyncHist(DISPLAYNAME, |
| | |
| | | builder.add("value3"); |
| | | builder.add("value4"); |
| | | |
| | | List<AttributeValue> duplicateValues = new LinkedList<AttributeValue>(); |
| | | List<ByteString> duplicateValues = new LinkedList<ByteString>(); |
| | | entry.addAttribute(builder.toAttribute(), duplicateValues); |
| | | |
| | | // load historical from the entry |
| | |
| | | builder.add("value3"); |
| | | builder.add("value4"); |
| | | |
| | | List<AttributeValue> duplicateValues = new LinkedList<AttributeValue>(); |
| | | List<ByteString> duplicateValues = new LinkedList<ByteString>(); |
| | | entry.addAttribute(builder.toAttribute(), duplicateValues); |
| | | |
| | | // load historical from the entry |
| | |
| | | |
| | | // Create a single valued attribute with value : "value1" |
| | | // add this attribute to the entry. |
| | | List<AttributeValue> duplicateValues = new LinkedList<AttributeValue>(); |
| | | List<ByteString> duplicateValues = new LinkedList<ByteString>(); |
| | | Attribute attribute = Attributes.create(DISPLAYNAME, "value1"); |
| | | entry.addAttribute(attribute, duplicateValues); |
| | | |
| | |
| | | EntryHistorical hist = EntryHistorical.newInstanceFromEntry(entry); |
| | | |
| | | // simulate a add of the description attribute done at time t10 |
| | | testModify(entry, hist, 10, true, buildMod(DESCRIPTION, ModificationType.ADD, "init value")); |
| | | testModify(entry, hist, 10, true, buildMod(DESCRIPTION, ModificationType.ADD, "Init Value")); |
| | | Attribute attr = buildSyncHist(DESCRIPTION, |
| | | ":000000000000000a000000000000:add:init value"); |
| | | ":000000000000000a000000000000:add:Init Value"); |
| | | assertEquals(hist.encodeAndPurge(), attr); |
| | | |
| | | // Now simulate a del and a add in the same operation |
| | | attr = Attributes.create(DESCRIPTION, "init value"); |
| | | attr = Attributes.create(DESCRIPTION, "Init Value"); |
| | | Modification mod1 = new Modification(ModificationType.DELETE, attr); |
| | | |
| | | attr = Attributes.create(DESCRIPTION, "Init Value"); |
| | |
| | | EntryHistorical hist = EntryHistorical.newInstanceFromEntry(entry); |
| | | |
| | | // Now simulate a del and a add in the same operation |
| | | Attribute attr = Attributes.create(DESCRIPTION, "init value"); |
| | | Attribute attr = Attributes.create(DESCRIPTION, "Init Value"); |
| | | Modification mod1 = new Modification(ModificationType.ADD, attr); |
| | | |
| | | attr = Attributes.create(DESCRIPTION, "Init Value"); |
| | |
| | | assertEquals(size, mods.size()); |
| | | Modification newMod = mods.get(0); |
| | | assertTrue(newMod.getModificationType().equals(modType)); |
| | | AttributeValue val = newMod.getAttribute().iterator().next(); |
| | | assertEquals(val.getValue().toString(), value); |
| | | ByteString val = newMod.getAttribute().iterator().next(); |
| | | assertEquals(val.toString(), value); |
| | | } |
| | | |
| | | /** |
| | |
| | | assertEquals(expectedValues.length, attr.size()); |
| | | for (String value : expectedValues) |
| | | { |
| | | attr.contains(AttributeValues.create(attr.getAttributeType(), value)); |
| | | attr.contains(ByteString.valueOf(value)); |
| | | } |
| | | } |
| | | |
| | |
| | | builder.add("value1"); |
| | | builder.add("value2"); |
| | | |
| | | List<AttributeValue> duplicateValues = new LinkedList<AttributeValue>(); |
| | | List<ByteString> duplicateValues = new LinkedList<ByteString>(); |
| | | entry.addAttribute(builder.toAttribute(), duplicateValues); |
| | | |
| | | // load historical from the entry |
| | |
| | | builder.add("value2"); |
| | | builder.add("value3"); |
| | | |
| | | List<AttributeValue> duplicateValues = new LinkedList<AttributeValue>(); |
| | | List<ByteString> duplicateValues = new LinkedList<ByteString>(); |
| | | entry.addAttribute(builder.toAttribute(), duplicateValues); |
| | | |
| | | // load historical from the entry |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013 ForgeRock AS |
| | | * Portions Copyright 2013-2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.replication.ReplicationTestCase; |
| | | import org.opends.server.replication.common.CSN; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.AttributeValues; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.util.TimeThread; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | |
| | | */ |
| | | @DataProvider(name = "valueInfo") |
| | | public Object[][] createData() { |
| | | AttributeType type = DirectoryServer.getAttributeType("description"); |
| | | |
| | | AttributeValue att1 = AttributeValues.create(type, "string"); |
| | | AttributeValue att2 = AttributeValues.create(type, "value"); |
| | | AttributeValue att3 = AttributeValues.create(type, "again"); |
| | | ByteString att1 = ByteString.valueOf("string"); |
| | | ByteString att2 = ByteString.valueOf("value"); |
| | | ByteString att3 = ByteString.valueOf("again"); |
| | | |
| | | CSN del1 = new CSN(1, 0, 1); |
| | | CSN del2 = new CSN(1, 1, 1); |
| | |
| | | * Create a ValueInfo and check the methods |
| | | */ |
| | | @Test(dataProvider = "valueInfo") |
| | | public void valueInfo(AttributeValue value, CSN csnUpdate, CSN csnDelete) throws Exception |
| | | public void valueInfo(ByteString value, CSN csnUpdate, CSN csnDelete) throws Exception |
| | | { |
| | | AttributeType type = DirectoryServer.getAttributeType("description"); |
| | | AttrValueHistorical valInfo1 = new AttrValueHistorical(value, csnUpdate, csnDelete); |
| | | AttrValueHistorical valInfo2 = new AttrValueHistorical(value, csnUpdate, csnUpdate); |
| | | AttrValueHistorical valInfo3 = new AttrValueHistorical(AttributeValues.create(type,"Test"), |
| | | AttrValueHistorical valInfo3 = new AttrValueHistorical(ByteString.valueOf("Test"), |
| | | csnUpdate, csnUpdate); |
| | | |
| | | // Check equals |
| | |
| | | return null; |
| | | } |
| | | Attribute a = attrs.iterator().next(); |
| | | AttributeValue av = a.iterator().next(); |
| | | return av.toString(); |
| | | return a.iterator().next().toString(); |
| | | } |
| | | |
| | | private static void checkValues(Entry entry, String attrName, |
| | |
| | | { |
| | | for (Attribute a : entry.getAttribute(attrName)) |
| | | { |
| | | for (AttributeValue av : a) |
| | | for (ByteString av : a) |
| | | { |
| | | assertThat(expectedValues) |
| | | .as("In entry " + entry + " incorrect value for attr '" + attrName + "'") |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | | import org.opends.server.types.NameForm; |
| | |
| | | |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | AttributeType at = AttributeTypeSyntax.decodeAttributeType( |
| | | v.getValue(), DirectoryServer.getSchema(), |
| | | true); |
| | | v, DirectoryServer.getSchema(),true); |
| | | if (! isNumericOID(at.getOID())) |
| | | { |
| | | invalidOIDs.add(at.getNameOrOID()); |
| | |
| | | |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | ObjectClass oc = ObjectClassSyntax.decodeObjectClass( |
| | | v.getValue(), DirectoryServer.getSchema(), |
| | | true); |
| | | v, DirectoryServer.getSchema(), true); |
| | | if (! isNumericOID(oc.getOID())) |
| | | { |
| | | invalidOIDs.add(oc.getNameOrOID()); |
| | |
| | | |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | NameForm nf = NameFormSyntax.decodeNameForm(v.getValue(), |
| | | DirectoryServer.getSchema(), true); |
| | | NameForm nf = NameFormSyntax.decodeNameForm( |
| | | v, DirectoryServer.getSchema(), true); |
| | | if (! isNumericOID(nf.getOID())) |
| | | { |
| | | invalidOIDs.add(nf.getNameOrOID()); |
| | |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.ldap.LDAPFilter; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DN; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | |
| | | //An entry must be returned. |
| | | assertNotNull(e); |
| | | Attribute attr = e.getAttribute("ldapsyntaxes").get(0); |
| | | Iterator<AttributeValue> iter = attr.iterator(); |
| | | Iterator<ByteString> iter = attr.iterator(); |
| | | |
| | | //There are other ways of doing it but we will extract the OID |
| | | //from the attribute values and then check to see if our |
| | |
| | | List<String> syntaxList = new ArrayList<String>(); |
| | | while(iter.hasNext()) |
| | | { |
| | | AttributeValue val = iter.next(); |
| | | //parse the OIDs. |
| | | syntaxList.add(getOIDFromLdapSyntax(val.toString())); |
| | | syntaxList.add(getOIDFromLdapSyntax(iter.next().toString())); |
| | | } |
| | | |
| | | //Check if we find our OID. |
| | |
| | | import java.util.Date; |
| | | import java.util.TimeZone; |
| | | |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | |
| | | throws Exception |
| | | { |
| | | Date d = new Date(); |
| | | AttributeValue timeValue = UTCTimeSyntax.createUTCTimeValue(d); |
| | | Date decodedDate = UTCTimeSyntax.decodeUTCTimeValue(timeValue.getValue()); |
| | | ByteString timeValue = UTCTimeSyntax.createUTCTimeValue(d); |
| | | Date decodedDate = UTCTimeSyntax.decodeUTCTimeValue(timeValue); |
| | | |
| | | // UTCTime does not have support for sub-second values, so we need to make |
| | | // sure that the decoded value is within 1000 milliseconds. |
| | |
| | | |
| | | // values from 50 through 99 inclusive shall have 1900 added to it |
| | | for (int yy = 50; yy <= 99; yy++) { |
| | | String utcString = String.format("%02d0819120000Z", new Integer(yy)); |
| | | String utcString = String.format("%02d0819120000Z", yy); |
| | | Date decodedDate = UTCTimeSyntax.decodeUTCTimeValue(ByteString.valueOf(utcString)); |
| | | cal.clear(); |
| | | cal.setTime(decodedDate); |
| | |
| | | import org.opends.server.backends.task.Task; |
| | | import org.opends.server.backends.task.TaskState; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | |
| | |
| | | { |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (AttributeValue v : a) |
| | | for (ByteString v : a) |
| | | { |
| | | sleepTime = Long.parseLong(v.getValue().toString()); |
| | | sleepTime = Long.parseLong(v.toString()); |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | |
| | | /** CN attribute type used in all tests. */ |
| | | private AttributeType cnType = null; |
| | | private AttributeType cnType; |
| | | |
| | | /** CN attribute value used in all tests. */ |
| | | private AttributeValue cnValue = null; |
| | | private ByteString cnValue; |
| | | |
| | | private final String[] noOptions = new String[] {}; |
| | | |
| | | private final String[] noValues = new String[] {}; |
| | | |
| | | private final String[] oneOption = new String[] |
| | | { |
| | | "option1" |
| | | }; |
| | | |
| | | private final String[] oneValue = new String[] |
| | | { |
| | | "value1" |
| | | }; |
| | | |
| | | private final String[] replaceValues = new String[] |
| | | { |
| | | "value2", "value4" |
| | | }; |
| | | |
| | | private final String[] threeOptions = new String[] |
| | | { |
| | | "option1", "option2", "option3" |
| | | }; |
| | | |
| | | private final String[] threeValues = new String[] |
| | | { |
| | | "value1", "value2", "value3" |
| | | }; |
| | | |
| | | private final String[] twoOptions = new String[] |
| | | { |
| | | "option1", "option2" |
| | | }; |
| | | |
| | | private final String[] twoValues = new String[] |
| | | { |
| | | "value1", "value2" |
| | | }; |
| | | |
| | | |
| | | private final String[] oneOption = new String[] { "option1" }; |
| | | private final String[] oneValue = new String[] { "value1" }; |
| | | private final String[] replaceValues = new String[] { "value2", "value4" }; |
| | | private final String[] threeOptions = new String[] { "option1", "option2", "option3" }; |
| | | private final String[] threeValues = new String[] { "value1", "value2", "value3" }; |
| | | private final String[] twoOptions = new String[] { "option1", "option2" }; |
| | | private final String[] twoValues = new String[] { "value1", "value2" }; |
| | | |
| | | /** |
| | | * Attribute data provider. |
| | |
| | | cnType, |
| | | "cn", |
| | | noOptions, |
| | | new String[] |
| | | { |
| | | cnValue.getValue().toString() |
| | | } |
| | | new String[] { cnValue.toString() } |
| | | }, |
| | | { |
| | | 8, |
| | |
| | | cnType, |
| | | "cn", |
| | | noOptions, |
| | | new String[] |
| | | { |
| | | cnValue.getValue().toString() |
| | | } |
| | | new String[] { cnValue.toString() } |
| | | }, |
| | | { |
| | | 9, |
| | |
| | | cnType, |
| | | "cn", |
| | | noOptions, |
| | | new String[] |
| | | { |
| | | cnValue.getValue().toString() |
| | | } |
| | | new String[] { cnValue.toString() } |
| | | }, |
| | | { |
| | | 10, |
| | |
| | | cnType, |
| | | "CN", |
| | | noOptions, |
| | | new String[] |
| | | { |
| | | cnValue.getValue().toString() |
| | | } |
| | | new String[] { cnValue.toString() } |
| | | }, |
| | | { |
| | | 11, |
| | |
| | | cnType, |
| | | "CN", |
| | | noOptions, |
| | | new String[] |
| | | { |
| | | cnValue.getValue().toString() |
| | | } |
| | | new String[] { cnValue.toString() } |
| | | }, |
| | | { |
| | | 12, |
| | |
| | | cnType, |
| | | "CN", |
| | | noOptions, |
| | | new String[] |
| | | { |
| | | cnValue.getValue().toString() |
| | | } |
| | | new String[] { cnValue.toString() } |
| | | }, |
| | | { |
| | | 13, |
| | |
| | | cnType = DirectoryServer.getAttributeType("cn"); |
| | | Assert.assertNotNull(cnType); |
| | | |
| | | cnValue = AttributeValues.create(cnType, "john doe"); |
| | | cnValue = ByteString.valueOf("john doe"); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | Assert.assertEquals(a.size(), 2); |
| | | Assert.assertTrue(a.contains(AttributeValues.create(cnType, "value1"))); |
| | | Assert.assertTrue(a.contains(AttributeValues.create(cnType, "value2"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("value1"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("value2"))); |
| | | } |
| | | |
| | | |
| | |
| | | AttributeBuilder builder = new AttributeBuilder(cnType); |
| | | |
| | | // Note duplicate values. |
| | | Assert.assertTrue(builder.addAll(Arrays.asList(AttributeValues.create(cnType, |
| | | "value1"), AttributeValues.create(cnType, "value1"), AttributeValues.create( |
| | | cnType, "value2")))); |
| | | Assert.assertTrue(builder.addAll(Arrays.asList(ByteString.valueOf("value1"), ByteString.valueOf("value1"), ByteString.valueOf("value2")))); |
| | | Assert.assertEquals(builder.size(), 2); |
| | | |
| | | // Add same values. |
| | | Assert.assertFalse(builder.addAll(Arrays.asList(AttributeValues.create(cnType, |
| | | "value1"), AttributeValues.create(cnType, "value1"), AttributeValues.create( |
| | | cnType, "value2")))); |
| | | Assert.assertFalse(builder.addAll(Arrays.asList(ByteString.valueOf("value1"), ByteString.valueOf("value1"), ByteString.valueOf("value2")))); |
| | | Assert.assertEquals(builder.size(), 2); |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | Assert.assertEquals(a.size(), 2); |
| | | Assert.assertTrue(a.contains(AttributeValues.create(cnType, "value1"))); |
| | | Assert.assertTrue(a.contains(AttributeValues.create(cnType, "value2"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("value1"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("value2"))); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests {@link AttributeBuilder#add(AttributeValue)}. |
| | | * Tests {@link AttributeBuilder#add(ByteString)}. |
| | | */ |
| | | @Test |
| | | public void testAttributeBuilderAddAttributeValue() throws Exception |
| | |
| | | Assert.assertFalse(builder.add(cnValue)); |
| | | Assert.assertEquals(builder.size(), 1); |
| | | |
| | | Assert.assertTrue(builder.add(AttributeValues.create(cnType, "jane doe"))); |
| | | Assert.assertTrue(builder.add(ByteString.valueOf("jane doe"))); |
| | | Assert.assertEquals(builder.size(), 2); |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | Assert.assertEquals(a.size(), 2); |
| | | Assert.assertTrue(a.contains(cnValue)); |
| | | Assert.assertTrue(a.contains(AttributeValues.create(cnType, "jane doe"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("jane doe"))); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | Assert.assertEquals(a.size(), 2); |
| | | Assert.assertTrue(a.contains(AttributeValues.create(cnType, "value1"))); |
| | | Assert.assertTrue(a.contains(AttributeValues.create(cnType, "value2"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("value1"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("value2"))); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | assertEquals(a.size(), 2); |
| | | assertTrue(a.contains(AttributeValues.create(cnType, "value1"))); |
| | | assertTrue(a.contains(AttributeValues.create(cnType, "value2"))); |
| | | assertTrue(a.contains(ByteString.valueOf("value1"))); |
| | | assertTrue(a.contains(ByteString.valueOf("value2"))); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | |
| | | /** |
| | | * Tests {@link AttributeBuilder#contains(AttributeValue)}. |
| | | * Tests {@link AttributeBuilder#contains(ByteString)}. |
| | | */ |
| | | @Test |
| | | public void testAttributeBuilderContains() throws Exception |
| | |
| | | |
| | | builder.addAll(createAttribute(cnType, "cn", noOptions, twoValues)); |
| | | |
| | | Assert.assertTrue(builder.contains(AttributeValues.create(cnType, "value1"))); |
| | | Assert.assertTrue(builder.contains(AttributeValues.create(cnType, "value2"))); |
| | | Assert.assertFalse(builder.contains(AttributeValues.create(cnType, "value3"))); |
| | | Assert.assertTrue(builder.contains(ByteString.valueOf("value1"))); |
| | | Assert.assertTrue(builder.contains(ByteString.valueOf("value2"))); |
| | | Assert.assertFalse(builder.contains(ByteString.valueOf("value3"))); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | builder.addAll(createAttribute(cnType, "cn", noOptions, twoValues)); |
| | | |
| | | AttributeValue av1 = AttributeValues.create(cnType, "value1"); |
| | | AttributeValue av2 = AttributeValues.create(cnType, "value2"); |
| | | AttributeValue av3 = AttributeValues.create(cnType, "value3"); |
| | | ByteString av1 = ByteString.valueOf("value1"); |
| | | ByteString av2 = ByteString.valueOf("value2"); |
| | | ByteString av3 = ByteString.valueOf("value3"); |
| | | |
| | | Assert.assertTrue(builder.containsAll(Collections |
| | | .<AttributeValue> emptySet())); |
| | | Assert.assertTrue(builder.containsAll(Collections.<ByteString> emptySet())); |
| | | |
| | | Assert.assertTrue(builder.containsAll(Collections.singleton(av1))); |
| | | Assert.assertTrue(builder.containsAll(Collections.singleton(av2))); |
| | |
| | | |
| | | builder.add("value1"); |
| | | Assert.assertTrue(builder.iterator().hasNext()); |
| | | Assert.assertEquals(builder.iterator().next(), AttributeValues.create(cnType, |
| | | "value1")); |
| | | Assert.assertEquals(builder.iterator().next(), ByteString.valueOf("value1")); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | Assert.assertEquals(a.size(), 1); |
| | | Assert.assertTrue(a.contains(AttributeValues.create(cnType, "value3"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("value3"))); |
| | | } |
| | | |
| | | |
| | |
| | | builder.addAll(createAttribute(cnType, "cn", noOptions, threeValues)); |
| | | |
| | | // Remove existing values. |
| | | Assert.assertTrue(builder.removeAll(Arrays.asList(AttributeValues.create( |
| | | cnType, "value1"), AttributeValues.create(cnType, "value2")))); |
| | | Assert.assertTrue(builder.removeAll(Arrays.asList(ByteString.valueOf("value1"), ByteString.valueOf("value2")))); |
| | | Assert.assertEquals(builder.size(), 1); |
| | | |
| | | // Remove removed values. |
| | | Assert.assertFalse(builder.removeAll(Arrays.asList(AttributeValues.create( |
| | | cnType, "value1"), AttributeValues.create(cnType, "value2")))); |
| | | Assert.assertFalse(builder.removeAll(Arrays.asList(ByteString.valueOf("value1"), ByteString.valueOf("value2")))); |
| | | Assert.assertEquals(builder.size(), 1); |
| | | |
| | | // Remove nothing. |
| | | Assert.assertFalse(builder.removeAll(Collections |
| | | .<AttributeValue> emptySet())); |
| | | Assert.assertFalse(builder.removeAll(Collections.<ByteString> emptySet())); |
| | | Assert.assertEquals(builder.size(), 1); |
| | | |
| | | // Remove non existent value. |
| | | Assert.assertFalse(builder.removeAll(Collections |
| | | .singleton(AttributeValues.create(cnType, "value4")))); |
| | | .singleton(ByteString.valueOf("value4")))); |
| | | Assert.assertEquals(builder.size(), 1); |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | Assert.assertEquals(a.size(), 1); |
| | | Assert.assertTrue(a.contains(AttributeValues.create(cnType, "value3"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("value3"))); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests {@link AttributeBuilder#remove(AttributeValue)}. |
| | | * Tests {@link AttributeBuilder#remove(ByteString)}. |
| | | */ |
| | | @Test |
| | | public void testAttributeBuilderRemoveAttributeValue() throws Exception |
| | |
| | | |
| | | builder.addAll(createAttribute(cnType, "cn", noOptions, threeValues)); |
| | | |
| | | Assert.assertTrue(builder.remove(AttributeValues.create(cnType, "value1"))); |
| | | Assert.assertTrue(builder.remove(ByteString.valueOf("value1"))); |
| | | Assert.assertEquals(builder.size(), 2); |
| | | |
| | | // Already removed. |
| | | Assert.assertFalse(builder.remove(AttributeValues.create(cnType, "value1"))); |
| | | Assert.assertFalse(builder.remove(ByteString.valueOf("value1"))); |
| | | Assert.assertEquals(builder.size(), 2); |
| | | |
| | | // Non existent. |
| | | Assert.assertFalse(builder.remove(AttributeValues.create(cnType, "value4"))); |
| | | Assert.assertFalse(builder.remove(ByteString.valueOf("value4"))); |
| | | Assert.assertEquals(builder.size(), 2); |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | Assert.assertEquals(a.size(), 2); |
| | | Assert.assertTrue(a.contains(AttributeValues.create(cnType, "value2"))); |
| | | Assert.assertTrue(a.contains(AttributeValues.create(cnType, "value3"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("value2"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("value3"))); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | Assert.assertEquals(a.size(), 2); |
| | | Assert.assertTrue(a.contains(AttributeValues.create(cnType, "value2"))); |
| | | Assert.assertTrue(a.contains(AttributeValues.create(cnType, "value3"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("value2"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("value3"))); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | Assert.assertEquals(a.size(), 2); |
| | | Assert.assertTrue(a.contains(AttributeValues.create(cnType, "value2"))); |
| | | Assert.assertTrue(a.contains(AttributeValues.create(cnType, "value4"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("value2"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("value4"))); |
| | | } |
| | | |
| | | |
| | |
| | | builder.addAll(createAttribute(cnType, "cn", noOptions, threeValues)); |
| | | |
| | | // Note duplicate values. |
| | | builder.replaceAll(Arrays.asList(AttributeValues.create(cnType, "value2"), |
| | | AttributeValues.create(cnType, "value2"), AttributeValues.create(cnType, |
| | | "value4"))); |
| | | builder.replaceAll(Arrays.asList(ByteString.valueOf("value2"), |
| | | ByteString.valueOf("value2"), ByteString.valueOf("value4"))); |
| | | Assert.assertEquals(builder.size(), 2); |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | Assert.assertEquals(a.size(), 2); |
| | | Assert.assertTrue(a.contains(AttributeValues.create(cnType, "value2"))); |
| | | Assert.assertTrue(a.contains(AttributeValues.create(cnType, "value4"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("value2"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("value4"))); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests {@link AttributeBuilder#replace(AttributeValue)}. |
| | | * Tests {@link AttributeBuilder#replace(ByteString)}. |
| | | */ |
| | | @Test |
| | | public void testAttributeBuilderReplaceAttributeValue() throws Exception |
| | |
| | | AttributeBuilder builder = new AttributeBuilder(cnType); |
| | | builder.addAll(createAttribute(cnType, "cn", noOptions, threeValues)); |
| | | |
| | | builder.replace(AttributeValues.create(cnType, "value4")); |
| | | builder.replace(ByteString.valueOf("value4")); |
| | | Assert.assertEquals(builder.size(), 1); |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | Assert.assertEquals(a.size(), 1); |
| | | Assert.assertTrue(a.contains(AttributeValues.create(cnType, "value4"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("value4"))); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | Assert.assertEquals(a.size(), 1); |
| | | Assert.assertTrue(a.contains(AttributeValues.create(cnType, "value4"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("value4"))); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | |
| | | /** |
| | | * Tests {@link Attribute#contains(AttributeValue)}. |
| | | * Tests {@link Attribute#contains(ByteString)}. |
| | | * |
| | | * @param testCase |
| | | * Test case index (useful for debugging). |
| | |
| | | // Check contains(). |
| | | for (String value : values) |
| | | { |
| | | Assert.assertTrue(a.contains(AttributeValues.create(type, value))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf(value))); |
| | | |
| | | // Assumes internal normalization to lower-case. |
| | | Assert.assertTrue(a |
| | | .contains(AttributeValues.create(type, value.toUpperCase()))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf(value.toUpperCase()))); |
| | | } |
| | | |
| | | Assert.assertFalse(a.contains(AttributeValues.create(type, "xxxx"))); |
| | | Assert.assertFalse(a.contains(ByteString.valueOf("xxxx"))); |
| | | } |
| | | |
| | | |
| | |
| | | throws Exception |
| | | { |
| | | // Check containsAll(). |
| | | Set<AttributeValue> expectedValues = new HashSet<AttributeValue>(); |
| | | Set<ByteString> expectedValues = new HashSet<ByteString>(); |
| | | for (String value : values) |
| | | { |
| | | expectedValues.add(AttributeValues.create(type, value)); |
| | | expectedValues.add(ByteString.valueOf(value)); |
| | | } |
| | | |
| | | Assert.assertTrue(a.containsAll(Collections.<AttributeValue> emptySet())); |
| | | Assert.assertTrue(a.containsAll(Collections.<ByteString> emptySet())); |
| | | Assert.assertTrue(a.containsAll(expectedValues)); |
| | | |
| | | if (values.length > 1) |
| | | { |
| | | Set<AttributeValue> subSet = new HashSet<AttributeValue>(expectedValues); |
| | | Set<ByteString> subSet = new HashSet<ByteString>(expectedValues); |
| | | subSet.remove(subSet.iterator()); |
| | | Assert.assertTrue(a.containsAll(subSet)); |
| | | } |
| | | |
| | | Set<AttributeValue> bigSet = new HashSet<AttributeValue>(expectedValues); |
| | | bigSet.add(AttributeValues.create(type, "xxxx")); |
| | | Set<ByteString> bigSet = new HashSet<ByteString>(expectedValues); |
| | | bigSet.add(ByteString.valueOf("xxxx")); |
| | | Assert.assertFalse(a.containsAll(bigSet)); |
| | | |
| | | expectedValues.clear(); |
| | | for (String value : values) |
| | | { |
| | | // Assumes internal normalization to lower-case. |
| | | expectedValues.add(AttributeValues.create(type, value.toUpperCase())); |
| | | expectedValues.add(ByteString.valueOf(value.toUpperCase())); |
| | | } |
| | | Assert.assertTrue(a.containsAll(expectedValues)); |
| | | } |
| | |
| | | else |
| | | { |
| | | // Values must be returned in the correct order. |
| | | Iterator<AttributeValue> i = a.iterator(); |
| | | Iterator<ByteString> i = a.iterator(); |
| | | for (String value : values) |
| | | { |
| | | Assert.assertTrue(i.hasNext()); |
| | | |
| | | AttributeValue v = i.next(); |
| | | Assert.assertEquals(v, AttributeValues.create(type, value)); |
| | | ByteString v = i.next(); |
| | | ByteString nv = a.getAttributeType().getEqualityMatchingRule().normalizeAttributeValue(v); |
| | | Assert.assertEquals(nv, ByteString.valueOf(value)); |
| | | |
| | | try |
| | | { |
| | |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.testng.Assert; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines a set of tests for the |
| | | * org.opends.server.core.Attributes class. |
| | |
| | | public void testMergeWithDuplicates(int testCase, Attribute a1, Attribute a2, |
| | | Attribute e, Attribute d) throws Exception |
| | | { |
| | | List<AttributeValue> duplicates = new LinkedList<AttributeValue>(); |
| | | List<ByteString> duplicates = new LinkedList<ByteString>(); |
| | | Attribute actual = Attributes.merge(a1, a2, duplicates); |
| | | Assert.assertEquals(actual, e); |
| | | |
| | |
| | | public void testSubtractWithMissingValues(int testCase, Attribute a1, |
| | | Attribute a2, Attribute e, Attribute m) throws Exception |
| | | { |
| | | List<AttributeValue> missingValues = new LinkedList<AttributeValue>(); |
| | | List<ByteString> missingValues = new LinkedList<ByteString>(); |
| | | Attribute actual = Attributes.subtract(a1, a2, missingValues); |
| | | Assert.assertEquals(actual, e); |
| | | |
| | |
| | | import java.util.LinkedList; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import org.testng.annotations.Test; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class provides a set of test cases that cover the schema validation |
| | | * processing that should be performed on entries during add, modify, and |
| | |
| | | "objectClass: domain", |
| | | "dc: example"); |
| | | |
| | | e.addAttribute(Attributes.create("dc", "foo"), |
| | | new LinkedList<AttributeValue>()); |
| | | e.addAttribute(Attributes.create("dc", "foo"), new LinkedList<ByteString>()); |
| | | |
| | | assertFalse(e.conformsToSchema(null, false, true, true, new LocalizableMessageBuilder())); |
| | | } |
| | |
| | | "creatorsName"); |
| | | builder.add("cn=Directory Manager"); |
| | | builder.add("cn=Another User"); |
| | | e.addAttribute(builder.toAttribute(), new LinkedList<AttributeValue>()); |
| | | e.addAttribute(builder.toAttribute(), new LinkedList<ByteString>()); |
| | | |
| | | assertFalse(e.conformsToSchema(null, false, true, true, new LocalizableMessageBuilder())); |
| | | } |
| | |
| | | "sn: User", |
| | | "cn: Test User"); |
| | | |
| | | e.addAttribute(Attributes.create("name", "foo"), |
| | | new LinkedList<AttributeValue>()); |
| | | e.addAttribute(Attributes.create("name", "foo"), new LinkedList<ByteString>()); |
| | | |
| | | assertFalse(e.conformsToSchema(null, false, true, true, new LocalizableMessageBuilder())); |
| | | } |
| | |
| | | * that is not reachable because it's in exception handling code that |
| | | * is not exercisable externally. |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | public class SearchFilterTests extends DirectoryServerTestCase { |
| | | |
| | | @BeforeClass |
| | |
| | | char lowNibble = CHAR_NIBBLES[j]; |
| | | byte lowByteNibble = BYTE_NIBBLES[j]; |
| | | String inputChar = "\\" + highNibble + lowNibble; |
| | | byte byteValue = (byte)((((int)highByteNibble) << 4) | lowByteNibble); |
| | | byte byteValue = (byte)((highByteNibble << 4) | lowByteNibble); |
| | | String outputChar = getFilterValueForChar(byteValue); |
| | | |
| | | // Exact match |
| | |
| | | } |
| | | } |
| | | |
| | | return (Object[][]) allParameters.toArray(new String[][]{}); |
| | | return allParameters.toArray(new String[][]{}); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | List<String> invalidEscapeSequences = new ArrayList<String>(); |
| | | |
| | | for (int i = 0; i < VALID_NIBBLES.length; i++) { |
| | | char validNibble = VALID_NIBBLES[i]; |
| | | for (int j = 0; j < INVALID_NIBBBLES.length; j++) { |
| | | char invalidNibble = INVALID_NIBBBLES[j]; |
| | | |
| | | for (char validNibble : VALID_NIBBLES) |
| | | { |
| | | for (char invalidNibble : INVALID_NIBBBLES) |
| | | { |
| | | invalidEscapeSequences.add("\\" + validNibble + invalidNibble); |
| | | invalidEscapeSequences.add("\\" + invalidNibble + validNibble); |
| | | } |
| | |
| | | allParameters.add(new String[]{"(sn:caseExactMatch:=" + invalidEscape}); |
| | | } |
| | | |
| | | return (Object[][]) allParameters.toArray(new String[][]{}); |
| | | return allParameters.toArray(new String[][]{}); |
| | | } |
| | | |
| | | |
| | |
| | | (value == 0x7F)) // Delete character |
| | | { |
| | | return "\\" + StaticUtils.byteToHex(value); |
| | | } else { |
| | | return "" + ((char)value); |
| | | } |
| | | return String.valueOf((char) value); |
| | | } |
| | | |
| | | @Test(dataProvider = "escapeSequenceFilters") |
| | |
| | | //////////////////////////////////////////////////////////////////////////// |
| | | |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | private static final String makeSimpleLdif(String givenname, String sn) { |
| | | String cn = givenname + " " + sn; |
| | | return TestCaseUtils.makeLdif( |
| | |
| | | JOE_AUSTIN_LDIF)); |
| | | |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | private List<String> getEntriesExcluding(List<String> matchedEntries) { |
| | | List<String> unmatched = new ArrayList<String>(ALL_ENTRIES_LDIF); |
| | | unmatched.removeAll(matchedEntries); |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | private static class FilterDescription { |
| | | private SearchFilter searchFilter; |
| | | |
| | |
| | | private FilterType filterType; |
| | | private LinkedHashSet<SearchFilter> filterComponents = new LinkedHashSet<SearchFilter>(); |
| | | private SearchFilter notComponent; |
| | | private AttributeValue assertionValue; |
| | | private ByteString assertionValue; |
| | | private AttributeType attributeType; |
| | | private ByteString subInitialElement; |
| | | private List<ByteString> subAnyElements = new ArrayList<ByteString>(); |
| | |
| | | private boolean dnAttributes; |
| | | |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | public void validateFilterFields() throws AssertionError { |
| | | if (!searchFilter.getFilterType().equals(filterType)) { |
| | | throwUnequalError("filterTypes"); |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | private void throwUnequalError(String message) throws AssertionError { |
| | | throw new AssertionError("Filter differs from what is expected '" + message + "' differ.\n" + toString()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | @Override |
| | | public String toString() { |
| | | return "FilterDescription: \n" + |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | private FilterDescription negate() { |
| | | FilterDescription negation = new FilterDescription(); |
| | | negation.searchFilter = SearchFilter.createNOTFilter(searchFilter); |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | @Override |
| | | public FilterDescription clone() { |
| | | FilterDescription that = new FilterDescription(); |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | private FilterDescription assertionFilterDescription(FilterType filterType, |
| | | String attributeType, |
| | | String attributeValue, |
| | |
| | | |
| | | description.filterType = filterType; |
| | | description.attributeType = DirectoryServer.getAttributeType(attributeType); |
| | | description.assertionValue = AttributeValues.create(description.attributeType, attributeValue); |
| | | description.assertionValue = ByteString.valueOf(attributeValue); |
| | | |
| | | if (filterType == FilterType.EQUALITY) { |
| | | description.searchFilter = SearchFilter.createEqualityFilter(description.attributeType, |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | private FilterDescription equalityFilterDescription(String attributeType, |
| | | String attributeValue, |
| | | List<String> matchedEntries) { |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | private FilterDescription lessEqualFilterDescription(String attributeType, |
| | | String attributeValue, |
| | | List<String> matchedEntries) { |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | private FilterDescription greaterEqualFilterDescription(String attributeType, |
| | | String attributeValue, |
| | | List<String> matchedEntries) { |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | private FilterDescription approximateFilterDescription(String attributeType, |
| | | String attributeValue, |
| | | List<String> matchedEntries) { |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | private FilterDescription substringFilterDescription(String attributeType, |
| | | String subInitial, |
| | | List<String> subAny, |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | private List<FilterDescription> getNotFilters(List<FilterDescription> filters) { |
| | | List<FilterDescription> notFilters = new ArrayList<FilterDescription>(); |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | private FilterDescription getAndFilter(List<FilterDescription> filters) { |
| | | FilterDescription andFilter = new FilterDescription(); |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | private List<FilterDescription> getAndFilters(List<FilterDescription> filters) { |
| | | List<FilterDescription> andFilters = new ArrayList<FilterDescription>(); |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | private FilterDescription getOrFilter(List<FilterDescription> filters) { |
| | | FilterDescription orFilter = new FilterDescription(); |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | private List<FilterDescription> getOrFilters(List<FilterDescription> filters) { |
| | | List<FilterDescription> orFilters = new ArrayList<FilterDescription>(); |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | private List<FilterDescription> getEqualityFilters() throws Exception { |
| | | List<FilterDescription> descriptions = new ArrayList<FilterDescription>(); |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | private List<FilterDescription> getApproximateFilters() throws Exception { |
| | | List<FilterDescription> descriptions = new ArrayList<FilterDescription>(); |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | private List<FilterDescription> getSubstringFilters() throws Exception { |
| | | List<FilterDescription> descriptions = new ArrayList<FilterDescription>(); |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | private List<FilterDescription> getInequalityFilters() throws Exception { |
| | | List<FilterDescription> descriptions = new ArrayList<FilterDescription>(); |
| | | |
| | | descriptions.add(lessEqualFilterDescription("sn", "Aus", |
| | | (List<String>)(new ArrayList<String>()))); |
| | | new ArrayList<String>())); |
| | | |
| | | descriptions.add(greaterEqualFilterDescription("sn", "Aus", |
| | | asList(JANE_AUSTIN_LDIF, JOE_AUSTIN_LDIF, |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | protected List<FilterDescription> getMinimalFilterDescriptionList() throws Exception { |
| | | List<FilterDescription> baseDescriptions = new ArrayList<FilterDescription>(); |
| | | List<FilterDescription> allDescriptions = new ArrayList<FilterDescription>(); |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | @DataProvider(name = "filterDescriptions") |
| | | public Object[][] getFilterDescriptions() throws Exception { |
| | | List<FilterDescription> allDescriptions = getFilterDescriptionList(); |
| | |
| | | }; |
| | | |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | @DataProvider(name = "equalsTest") |
| | | public Object[][] getEqualsTests() throws Exception { |
| | | return TEST_EQUALS_PARAMS; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | @Test(dataProvider = "equalsTest") |
| | | public void testEquals(String stringFilter1, String stringFilter2, boolean expectEquals, boolean expectStringEquals) throws Exception { |
| | | SearchFilter filter1 = SearchFilter.createFilterFromString(stringFilter1); |
| | |
| | | } |
| | | |
| | | @Test(dataProvider = "differentNormalization") |
| | | public void testdifferentNormalization(String ldifEntry, String filterStr, |
| | | public void testDifferentNormalization(String ldifEntry, String filterStr, |
| | | boolean expectMatch) throws Exception |
| | | { |
| | | Entry entry = TestCaseUtils.entryFromLdifString(ldifEntry); |
| | | boolean matches = SearchFilter.createFilterFromString(filterStr).matchesEntry(entry); |
| | | Assert.assertEquals(matches, expectMatch, "Filter=" + filterStr + "\nEntry=" + entry); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/TestAttributeValue.java (deleted)
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/TestEntry.java
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/TestRDN.java
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/VirtualAttributeTestCase.java
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/util/TestLDIFReader.java |