| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.guitools.controlpanel.task; |
| | | |
| | |
| | | import javax.swing.tree.TreePath; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.AVA; |
| | | import org.forgerock.opendj.ldap.AttributeDescription; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.guitools.controlpanel.browser.BrowserController; |
| | | import org.opends.guitools.controlpanel.datamodel.BackendDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.BaseDNDescriptor; |
| | |
| | | } |
| | | mustRename = !newDn.equals(oldDn); |
| | | } |
| | | catch (OpenDsException ode) |
| | | catch (OpenDsException e) |
| | | { |
| | | throw new RuntimeException("Could not parse DN: " + oldEntry.getDN(), ode); |
| | | throw new RuntimeException("Could not parse DN: " + oldEntry.getDN(), e); |
| | | } |
| | | modifications = getModifications(newEntry, oldEntry, getInfo()); |
| | | // Find password modifications |
| | |
| | | |
| | | private boolean rdnTypeChanged(RDN oldRDN, RDN newRDN) |
| | | { |
| | | if (newRDN.getNumValues() != oldRDN.getNumValues()) |
| | | if (newRDN.size() != oldRDN.size()) |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | for (int i = 0; i < newRDN.getNumValues(); i++) |
| | | for (AVA ava : newRDN) |
| | | { |
| | | if (!find(oldRDN, newRDN.getAttributeName(i))) |
| | | if (!find(oldRDN, ava.getAttributeType())) |
| | | { |
| | | return true; |
| | | } |
| | |
| | | return false; |
| | | } |
| | | |
| | | private boolean find(RDN rdn, String attrName) |
| | | private boolean find(RDN rdn, AttributeType attrType) |
| | | { |
| | | for (int j = 0; j < rdn.getNumValues(); j++) |
| | | for (AVA ava : rdn) |
| | | { |
| | | if (attrName.equalsIgnoreCase(rdn.getAttributeName(j))) |
| | | if (attrType.equals(ava.getAttributeType())) |
| | | { |
| | | return true; |
| | | } |
| | |
| | | |
| | | private boolean entryContainsRdnTypes(CustomSearchResult entry, RDN rdn) |
| | | { |
| | | for (int i = 0; i < rdn.getNumValues(); i++) |
| | | for (AVA ava : rdn) |
| | | { |
| | | List<Object> values = entry.getAttributeValues(rdn.getAttributeName(i)); |
| | | List<Object> values = entry.getAttributeValues(ava.getAttributeName()); |
| | | if (values.isEmpty()) |
| | | { |
| | | return false; |
| | |
| | | newAttrs.add(newEntry.getObjectClassAttribute()); |
| | | for (org.opends.server.types.Attribute attr : newAttrs) |
| | | { |
| | | String attrName = attr.getNameWithOptions(); |
| | | AttributeDescription attrDesc = attr.getAttributeDescription(); |
| | | String attrName = attrDesc.toString(); |
| | | if (!ViewEntryPanel.isEditable(attrName, schema)) |
| | | { |
| | | continue; |
| | |
| | | } |
| | | List<Object> oldValues = oldEntry.getAttributeValues(attrName); |
| | | |
| | | boolean isAttributeInNewRdn = false; |
| | | ByteString rdnValue = null; |
| | | RDN rdn = newEntry.getName().rdn(); |
| | | for (int i=0; i<rdn.getNumValues() && !isAttributeInNewRdn; i++) |
| | | for (AVA ava : newEntry.getName().rdn()) |
| | | { |
| | | isAttributeInNewRdn = |
| | | rdn.getAttributeName(i).equalsIgnoreCase(attrName); |
| | | if (isAttributeInNewRdn) |
| | | if (ava.getAttributeType().equals(attrDesc.getAttributeType())) |
| | | { |
| | | rdnValue = rdn.getAttributeValue(i); |
| | | rdnValue = ava.getAttributeValue(); |
| | | } |
| | | } |
| | | boolean isAttributeInNewRdn = rdnValue != null; |
| | | |
| | | /* Check the attributes of the old DN. If we are renaming them they |
| | | * will be deleted. Check that they are on the new entry but not in |
| | |
| | | { |
| | | oldRDN = DN.valueOf(oldEntry.getDN()).rdn(); |
| | | } |
| | | catch (DirectoryException de) |
| | | catch (DirectoryException unexpected) |
| | | { |
| | | throw new RuntimeException("Unexpected error parsing DN: "+ |
| | | oldEntry.getDN(), de); |
| | | throw new RuntimeException("Unexpected error parsing DN: " + oldEntry.getDN(), unexpected); |
| | | } |
| | | for (int i=0; i<oldRDN.getNumValues(); i++) |
| | | for (AVA ava : oldRDN) |
| | | { |
| | | if (oldRDN.getAttributeName(i).equalsIgnoreCase(attrName)) |
| | | if (ava.getAttributeType().equals(attrDesc.getAttributeType())) |
| | | { |
| | | ByteString value = oldRDN.getAttributeValue(i); |
| | | ByteString value = ava.getAttributeValue(); |
| | | if (attr.contains(value)) |
| | | { |
| | | if (rdnValue == null || !rdnValue.equals(value)) |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | * Portions Copyright 2012-2016 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.ui; |
| | |
| | | else |
| | | { |
| | | aParentDN = nodeDN.parent(); |
| | | aRdn = nodeDN.rdn().getAttributeValue(0) + "-1"; |
| | | aRdn = nodeDN.rdn().getFirstAVA().getAttributeValue() + "-1"; |
| | | } |
| | | } |
| | | catch (DirectoryException de) |
| | |
| | | try |
| | | { |
| | | DN theDN = DN.valueOf(dn); |
| | | newValue = theDN.rdn().getAttributeValue(0).toString(); |
| | | newValue = theDN.rdn().getFirstAVA().getAttributeValue().toString(); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | |
| | | try |
| | | { |
| | | DN oldDN = DN.valueOf(entryToDuplicate.getDN()); |
| | | oldValue = oldDN.rdn().getAttributeValue(0).toString(); |
| | | oldValue = oldDN.rdn().getFirstAVA().getAttributeValue().toString(); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | |
| | | try |
| | | { |
| | | DN dn = DN.valueOf(sr.getDN()); |
| | | rdnAttribute = dn.rdn().getAttributeType(0).getNameOrOID(); |
| | | rdnAttribute = dn.rdn().getFirstAVA().getAttributeType().getNameOrOID(); |
| | | |
| | | updateDNValue(); |
| | | Boolean hasPassword = !sr.getAttributeValues( |
| | |
| | | import java.io.StringReader; |
| | | import java.text.ParseException; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Collection; |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.ldap.AVA; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.guitools.controlpanel.datamodel.BinaryValue; |
| | |
| | | import org.opends.guitools.controlpanel.ui.nodes.DndBrowserNodes; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.server.schema.SchemaConstants; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.OpenDsException; |
| | | import org.opends.server.types.RDN; |
| | | import org.opends.server.types.Schema; |
| | | import org.opends.server.util.Base64; |
| | | import org.opends.server.util.LDIFReader; |
| | | import org.opends.server.util.ServerConstants; |
| | | |
| | | /** |
| | | * The panel displaying a simplified view of an entry. |
| | | */ |
| | | /** The panel displaying a simplified view of an entry. */ |
| | | public class SimplifiedViewEntryPanel extends ViewEntryPanel |
| | | { |
| | | private static final long serialVersionUID = 2775960608128921072L; |
| | |
| | | basicAttrName = attrName.substring(0, index); |
| | | subType = attrName.substring(index + 1); |
| | | } |
| | | if (subType != null && subType.equalsIgnoreCase("binary")) |
| | | if ("binary".equalsIgnoreCase(subType)) |
| | | { |
| | | // TODO: use message |
| | | subType = "binary"; |
| | |
| | | Schema schema = getInfo().getServerDescriptor().getSchema(); |
| | | if (isRootEntry) |
| | | { |
| | | String[] attrsNotToAdd = {"entryuuid", "hassubordinates", |
| | | "numsubordinates", "subschemasubentry", "entrydn", |
| | | "hassubordinates"}; |
| | | List<String> attrsNotToAdd = Arrays.asList("entryuuid", "hassubordinates", |
| | | "numsubordinates", "subschemasubentry", "entrydn", "hassubordinates"); |
| | | for (String attr : sr.getAttributeNames()) |
| | | { |
| | | boolean found = false; |
| | | for (String addedAttr : attrNames) |
| | | { |
| | | found = addedAttr.equalsIgnoreCase(attr); |
| | | if (found) |
| | | { |
| | | break; |
| | | } |
| | | } |
| | | if (!found) |
| | | { |
| | | for (String notToAddAttr : attrsNotToAdd) |
| | | { |
| | | found = notToAddAttr.equalsIgnoreCase(attr); |
| | | if (found) |
| | | { |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | if (!found) |
| | | if (!find(attrNames, attr) && !find(attrsNotToAdd, attr)) |
| | | { |
| | | attrNames.add(attr); |
| | | } |
| | |
| | | |
| | | for (String attr : attributes) |
| | | { |
| | | boolean add = isEditable(attr, schema); |
| | | |
| | | if (add) |
| | | boolean canAdd = isEditable(attr, schema); |
| | | if (canAdd && !find(attrNames, attr)) |
| | | { |
| | | boolean found = false; |
| | | for (String addedAttr : attrNames) |
| | | { |
| | | found = addedAttr.equalsIgnoreCase(attr); |
| | | if (found) |
| | | { |
| | | break; |
| | | } |
| | | } |
| | | if (!found) |
| | | { |
| | | attrNames.add(attr); |
| | | } |
| | | attrNames.add(attr); |
| | | } |
| | | } |
| | | } |
| | | return attrNames; |
| | | } |
| | | |
| | | private boolean find(Collection<String> attrNames, String attrNameToFind) |
| | | { |
| | | for (String attrName : attrNames) |
| | | { |
| | | if (attrName.equalsIgnoreCase(attrNameToFind)) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | private void updateAttributes( |
| | | Collection<String> attributes, |
| | | Set<String> newAttributes, |
| | |
| | | |
| | | private boolean hasBinaryValue(List<Object> values) |
| | | { |
| | | if (!values.isEmpty()) |
| | | { |
| | | return values.iterator().next() instanceof byte[]; |
| | | } |
| | | return false; |
| | | return !values.isEmpty() && values.iterator().next() instanceof byte[]; |
| | | } |
| | | |
| | | private boolean mustAddBrowseButton(String attrName) |
| | |
| | | if (oldDN.size() > 0) |
| | | { |
| | | RDN rdn = oldDN.rdn(); |
| | | List<AttributeType> attributeTypes = new ArrayList<>(); |
| | | List<String> attributeNames = new ArrayList<>(); |
| | | List<ByteString> attributeValues = new ArrayList<>(); |
| | | for (int i=0; i<rdn.getNumValues(); i++) |
| | | List<AVA> avas = new ArrayList<>(); |
| | | for (AVA ava : rdn) |
| | | { |
| | | String attrName = rdn.getAttributeName(i); |
| | | ByteString value = rdn.getAttributeValue(i); |
| | | AttributeType attrType = ava.getAttributeType(); |
| | | String attrName = ava.getAttributeName(); |
| | | ByteString value = ava.getAttributeValue(); |
| | | |
| | | List<String> values = getDisplayedStringValues(attrName); |
| | | if (!values.contains(value.toString())) |
| | |
| | | String firstNonEmpty = getFirstNonEmpty(values); |
| | | if (firstNonEmpty != null) |
| | | { |
| | | attributeTypes.add(rdn.getAttributeType(i)); |
| | | attributeNames.add(rdn.getAttributeName(i)); |
| | | attributeValues.add(ByteString.valueOfUtf8(firstNonEmpty)); |
| | | avas.add(new AVA(attrType, attrName, ByteString.valueOfUtf8(firstNonEmpty))); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | attributeTypes.add(rdn.getAttributeType(i)); |
| | | attributeNames.add(rdn.getAttributeName(i)); |
| | | attributeValues.add(value); |
| | | avas.add(new AVA(attrType, attrName, value)); |
| | | } |
| | | } |
| | | if (attributeTypes.isEmpty()) |
| | | if (avas.isEmpty()) |
| | | { |
| | | // Check the attributes in the order that we display them and use |
| | | // the first one. |
| | |
| | | String aName = Utilities.getAttributeNameWithoutOptions(attrName); |
| | | if (schema.hasAttributeType(aName)) |
| | | { |
| | | attributeTypes.add(schema.getAttributeType(aName)); |
| | | attributeNames.add(attrName); |
| | | attributeValues.add(ByteString.valueOfUtf8((String) o)); |
| | | avas.add(new AVA(schema.getAttributeType(aName), aName, o)); |
| | | } |
| | | break; |
| | | } |
| | |
| | | } |
| | | } |
| | | DN parent = oldDN.parent(); |
| | | if (!attributeTypes.isEmpty()) |
| | | if (!avas.isEmpty()) |
| | | { |
| | | RDN newRDN = new RDN(attributeTypes, attributeNames, attributeValues); |
| | | RDN newRDN = new RDN(avas); |
| | | |
| | | DN newDN; |
| | | if (parent == null) |
| | |
| | | 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.AVA; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | |
| | | if (oldDN.size() > 0) |
| | | { |
| | | RDN rdn = oldDN.rdn(); |
| | | List<AttributeType> attributeTypes = new ArrayList<>(); |
| | | List<String> attributeNames = new ArrayList<>(); |
| | | List<ByteString> attributeValues = new ArrayList<>(); |
| | | for (int i=0; i<rdn.getNumValues(); i++) |
| | | List<AVA> avas = new ArrayList<>(); |
| | | for (AVA ava : rdn) |
| | | { |
| | | String attrName = rdn.getAttributeName(i); |
| | | ByteString value = rdn.getAttributeValue(i); |
| | | AttributeType attrType = ava.getAttributeType(); |
| | | String attrName = ava.getAttributeName(); |
| | | ByteString value = ava.getAttributeValue(); |
| | | |
| | | Set<String> values = getDisplayedStringValues(attrName); |
| | | if (!values.contains(value.toString())) |
| | |
| | | String firstNonEmpty = getFirstNonEmpty(values); |
| | | if (firstNonEmpty != null) |
| | | { |
| | | attributeTypes.add(rdn.getAttributeType(i)); |
| | | attributeNames.add(rdn.getAttributeName(i)); |
| | | attributeValues.add(ByteString.valueOfUtf8(firstNonEmpty)); |
| | | avas.add(new AVA(attrType, attrName, ByteString.valueOfUtf8(firstNonEmpty))); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | attributeTypes.add(rdn.getAttributeType(i)); |
| | | attributeNames.add(rdn.getAttributeName(i)); |
| | | attributeValues.add(value); |
| | | avas.add(new AVA(attrType, attrName, value)); |
| | | } |
| | | } |
| | | if (attributeTypes.isEmpty()) |
| | | if (avas.isEmpty()) |
| | | { |
| | | // Check the attributes in the order that we display them and use |
| | | // the first one. |
| | |
| | | String aName = Utilities.getAttributeNameWithoutOptions(attrName); |
| | | if (schema.hasAttributeType(aName)) |
| | | { |
| | | attributeTypes.add(schema.getAttributeType(aName)); |
| | | attributeNames.add(attrName); |
| | | attributeValues.add(ByteString.valueOfUtf8((String) o)); |
| | | avas.add(new AVA(schema.getAttributeType(aName), attrName, o)); |
| | | } |
| | | break; |
| | | } |
| | |
| | | } |
| | | } |
| | | DN parent = oldDN.parent(); |
| | | if (!attributeTypes.isEmpty()) |
| | | if (!avas.isEmpty()) |
| | | { |
| | | RDN newRDN = new RDN(attributeTypes, attributeNames, attributeValues); |
| | | RDN newRDN = new RDN(avas); |
| | | |
| | | DN newDN; |
| | | if (parent == null) |
| | |
| | | import javax.swing.tree.TreePath; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.AVA; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClassType; |
| | |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.OpenDsException; |
| | | import org.opends.server.types.RDN; |
| | | import org.opends.server.types.Schema; |
| | | import org.opends.server.util.Base64; |
| | | import org.opends.server.util.ServerConstants; |
| | |
| | | protected void addValuesInRDN(Entry entry) |
| | | { |
| | | // Add the values in the RDN if they are not there |
| | | RDN rdn = entry.getName().rdn(); |
| | | for (int i=0; i<rdn.getNumValues(); i++) |
| | | for (AVA ava : entry.getName().rdn()) |
| | | { |
| | | String attrName = rdn.getAttributeName(i); |
| | | ByteString value = rdn.getAttributeValue(i); |
| | | String attrName = ava.getAttributeName(); |
| | | ByteString value = ava.getAttributeValue(); |
| | | boolean done = false; |
| | | for (org.opends.server.types.Attribute attr : entry.getAttribute(attrName.toLowerCase())) |
| | | { |
| | |
| | | } |
| | | if (!done) |
| | | { |
| | | entry.addAttribute(Attributes.create(rdn.getAttributeType(i), value), newArrayList(value)); |
| | | entry.addAttribute(Attributes.create(ava.getAttributeType(), value), newArrayList(value)); |
| | | } |
| | | } |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.ui.nodes; |
| | | |
| | | import javax.swing.Icon; |
| | |
| | | import org.opends.server.types.LDAPURL; |
| | | import org.opends.server.types.RDN; |
| | | |
| | | /** |
| | | * The basic node used to render entries in the 'Manage Entries' tree. |
| | | * |
| | | */ |
| | | /** The basic node used to render entries in the 'Manage Entries' tree. */ |
| | | public class BasicNode extends DefaultMutableTreeNode { |
| | | |
| | | private static final long serialVersionUID = 5441658731908509872L; |
| | |
| | | * @return <CODE>true</CODE> if the node is a leaf and <CODE>false</CODE> |
| | | * otherwise. |
| | | */ |
| | | @Override |
| | | public boolean isLeaf() { |
| | | return isLeaf; |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Rendering |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | // |
| | | // Rendering |
| | | // |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return getDisplayName(); |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | result = rdn.getAttributeValue(0).toString(); |
| | | result = rdn.getFirstAVA().getAttributeValue().toString(); |
| | | } |
| | | } |
| | | else { |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.admin; |
| | | |
| | | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.RDN; |
| | | import org.opends.server.util.StaticUtils; |
| | | |
| | | |
| | | |
| | | /** |
| | | * A reference to another managed object. |
| | | * |
| | |
| | | + s + "\""); |
| | | } |
| | | |
| | | ByteString av = rdn.getAttributeValue(0); |
| | | ByteString av = rdn.getFirstAVA().getAttributeValue(); |
| | | if (av == null) { |
| | | throw new IllegalArgumentException("Unabled to decode the DN string: \"" |
| | | + s + "\""); |
| | |
| | | return path.toDN(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | return name; |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2007-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.admin.server; |
| | | |
| | |
| | | this.cachedManagedObject = null; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationAdd(ConfigEntry configEntry) { |
| | | if (optionalRelation != null) { |
| | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean configAddIsAcceptable(ConfigEntry configEntry, |
| | | LocalizableMessageBuilder unacceptableReason) { |
| | | DN dn = configEntry.getDN(); |
| | | ByteString av = dn.rdn().getAttributeValue(0); |
| | | ByteString av = dn.rdn().getFirstAVA().getAttributeValue(); |
| | | String name = av.toString().trim(); |
| | | |
| | | try { |
| | |
| | | * |
| | | * |
| | | * Copyright 2007-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.admin.server; |
| | | |
| | | |
| | | |
| | | import static org.opends.messages.AdminMessages.*; |
| | | |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.admin.Configuration; |
| | | import org.opends.server.admin.Constraint; |
| | | import org.opends.server.admin.DecodingException; |
| | | import org.opends.server.admin.DefinitionDecodingException; |
| | | import org.opends.server.admin.DefinitionDecodingException.Reason; |
| | | import org.opends.server.admin.InstantiableRelationDefinition; |
| | | import org.opends.server.admin.ManagedObjectDefinition; |
| | | import org.opends.server.admin.ManagedObjectPath; |
| | | import org.opends.server.admin.OptionalRelationDefinition; |
| | | import org.opends.server.admin.SetRelationDefinition; |
| | | import org.opends.server.admin.DefinitionDecodingException.Reason; |
| | | import org.opends.server.api.ConfigDeleteListener; |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.opends.server.types.DN; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | |
| | | |
| | | /** |
| | | * An adaptor class which converts {@link ConfigDeleteListener} |
| | |
| | | this.cachedManagedObject = null; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationDelete(ConfigEntry configEntry) { |
| | | if (optionalRelation != null) { |
| | | // Optional managed objects are located directly beneath the |
| | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean configDeleteIsAcceptable(ConfigEntry configEntry, |
| | | LocalizableMessageBuilder unacceptableReason) { |
| | | DN dn = configEntry.getDN(); |
| | | ByteString av = dn.rdn().getAttributeValue(0); |
| | | ByteString av = dn.rdn().getFirstAVA().getAttributeValue(); |
| | | String name = av.toString().trim(); |
| | | |
| | | try { |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.admin.AbsoluteInheritedDefaultBehaviorProvider; |
| | | import org.opends.server.admin.AbstractManagedObjectDefinition; |
| | | import org.opends.server.admin.AggregationPropertyDefinition; |
| | |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | |
| | | /** |
| | |
| | | ArrayList<String> names = new ArrayList<>(children.size()); |
| | | for (DN child : children) { |
| | | // Assume that RDNs are single-valued and can be trimmed. |
| | | ByteString av = child.rdn().getAttributeValue(0); |
| | | ByteString av = child.rdn().getFirstAVA().getAttributeValue(); |
| | | names.add(av.toString().trim()); |
| | | } |
| | | |
| | |
| | | ArrayList<String> names = new ArrayList<>(children.size()); |
| | | for (DN child : children) { |
| | | // Assume that RDNs are single-valued and can be trimmed. |
| | | ByteString av = child.rdn().getAttributeValue(0); |
| | | ByteString av = child.rdn().getFirstAVA().getAttributeValue(); |
| | | names.add(av.toString().trim()); |
| | | } |
| | | |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.AttributeDescription; |
| | | import org.forgerock.opendj.ldap.AVA; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | |
| | | private boolean checkRDN(int right, RDN rdn, AciContainer container) |
| | | { |
| | | container.setRights(right); |
| | | final int numAVAs = rdn.getNumValues(); |
| | | for (int i = 0; i < numAVAs; i++) |
| | | for (AVA ava : rdn) |
| | | { |
| | | container.setCurrentAttributeType(rdn.getAttributeType(i)); |
| | | container.setCurrentAttributeValue(rdn.getAttributeValue(i)); |
| | | container.setCurrentAttributeType(ava.getAttributeType()); |
| | | container.setCurrentAttributeValue(ava.getAttributeValue()); |
| | | if (!accessAllowed(container)) |
| | | { |
| | | return false; |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.AVA; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | |
| | | return true; |
| | | } |
| | | |
| | | if (rdn.getNumValues() != 1) |
| | | if (rdn.size() != 1) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | AttributeType thatType = rdn.getAttributeType(0); |
| | | AVA firstAVA = rdn.getFirstAVA(); |
| | | AttributeType thatType = firstAVA.getAttributeType(); |
| | | if (!typePatterns[0].equals("*")) |
| | | { |
| | | AttributeType thisType = DirectoryServer.getAttributeType(typePatterns[0]); |
| | |
| | | } |
| | | } |
| | | |
| | | return matchValuePattern(valuePatterns.get(0), thatType, rdn.getAttributeValue(0)); |
| | | return matchValuePattern(valuePatterns.get(0), thatType, firstAVA.getAttributeValue()); |
| | | } |
| | | |
| | | if (hasTypeWildcard) |
| | |
| | | return false; |
| | | } |
| | | |
| | | if (numValues != rdn.getNumValues()) |
| | | if (numValues != rdn.size()) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | TreeMap<String,ArrayList<ByteString>> patternMap = new TreeMap<>(); |
| | | TreeMap<String, ByteString> rdnMap = new TreeMap<>(); |
| | | |
| | | for (int i = 0; i < rdn.getNumValues(); i++) |
| | | for (AVA ava : rdn) |
| | | { |
| | | rdnMap.put(rdn.getAttributeType(i).getNameOrOID(), |
| | | rdn.getAttributeValue(i)); |
| | | rdnMap.put(ava.getAttributeType().getNameOrOID(), ava.getAttributeValue()); |
| | | } |
| | | |
| | | for (int i = 0; i < numValues; i++) |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.AVA; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | |
| | | LinkedHashMap<AttributeType,List<Attribute>> opAttrs = new LinkedHashMap<>(0); |
| | | LinkedHashMap<AttributeType,List<Attribute>> userAttrs = new LinkedHashMap<>(1); |
| | | |
| | | RDN rdn = backupBaseDN.rdn(); |
| | | int numAVAs = rdn.getNumValues(); |
| | | for (int i=0; i < numAVAs; i++) |
| | | for (AVA ava : backupBaseDN.rdn()) |
| | | { |
| | | AttributeType attrType = rdn.getAttributeType(i); |
| | | userAttrs.put(attrType, Attributes.createAsList(attrType, rdn.getAttributeValue(i))); |
| | | AttributeType attrType = ava.getAttributeType(); |
| | | userAttrs.put(attrType, Attributes.createAsList(attrType, ava.getAttributeValue())); |
| | | } |
| | | |
| | | backupBaseEntry = new Entry(backupBaseDN, objectClasses, userAttrs, opAttrs); |
| | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.util.*; |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.HashMap; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.NavigableMap; |
| | | import java.util.Set; |
| | | import java.util.TreeMap; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.AVA; |
| | | 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.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.util.Reject; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.MonitorBackendCfg; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.api.MonitorProvider; |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.opends.server.core.*; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.DeleteOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ModifyDNOperation; |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.BackupConfig; |
| | | import org.opends.server.types.BackupDirectory; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.IndexType; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.LDIFExportConfig; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | | import org.opends.server.types.LDIFImportResult; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.RDN; |
| | | import org.opends.server.types.RestoreConfig; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.opends.server.util.DynamicConstants; |
| | | import org.opends.server.util.LDIFWriter; |
| | | import org.opends.server.util.TimeThread; |
| | |
| | | final RDN rdn = dn.rdn(); |
| | | if (rdn != null) |
| | | { |
| | | // Add the RDN values |
| | | for (int i = 0; i < rdn.getNumValues(); i++) |
| | | for (AVA ava : rdn) |
| | | { |
| | | final AttributeType attributeType = rdn.getAttributeType(i); |
| | | final ByteString value = rdn.getAttributeValue(attributeType); |
| | | final AttributeType attributeType = ava.getAttributeType(); |
| | | final ByteString value = ava.getAttributeValue(); |
| | | monitorUserAttrs.put(attributeType, Attributes.createAsList(attributeType, value)); |
| | | } |
| | | } |
| | |
| | | final HashMap<AttributeType, List<Attribute>> attrMap = new LinkedHashMap<>(monitorAttrs.size() + 1); |
| | | |
| | | // Make sure to include the RDN attribute. |
| | | final RDN entryRDN = entryDN.rdn(); |
| | | final AttributeType rdnType = entryRDN.getAttributeType(0); |
| | | final ByteString rdnValue = entryRDN.getAttributeValue(0); |
| | | final AVA ava = entryDN.rdn().getFirstAVA(); |
| | | final AttributeType rdnType = ava.getAttributeType(); |
| | | final ByteString rdnValue = ava.getAttributeValue(); |
| | | |
| | | attrMap.put(rdnType, Attributes.createAsList(rdnType, rdnValue)); |
| | | |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.AVA; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | |
| | | import org.opends.server.schema.NameFormSyntax; |
| | | import org.opends.server.schema.ObjectClassSyntax; |
| | | import org.opends.server.schema.SomeSchemaElement; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.BackupConfig; |
| | | import org.opends.server.types.BackupDirectory; |
| | | import org.opends.server.types.CommonSchemaElements; |
| | | import org.opends.server.types.DITContentRule; |
| | | import org.opends.server.types.DITStructureRule; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.ExistingFileBehavior; |
| | | import org.opends.server.types.IndexType; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.LDAPSyntaxDescription; |
| | | import org.opends.server.types.LDIFExportConfig; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | | import org.opends.server.types.LDIFImportResult; |
| | | import org.opends.server.types.MatchingRuleUse; |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.NameForm; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.Privilege; |
| | | import org.opends.server.types.RDN; |
| | | import org.opends.server.types.RestoreConfig; |
| | | import org.opends.server.types.Schema; |
| | | import org.opends.server.types.SchemaFileElement; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.opends.server.util.BackupManager; |
| | | import org.opends.server.util.DynamicConstants; |
| | | import org.opends.server.util.LDIFException; |
| | |
| | | RDN rdn = entryDN.rdn(); |
| | | if (rdn != null) |
| | | { |
| | | int numAVAs = rdn.getNumValues(); |
| | | for (int i = 0; i < numAVAs; i++) |
| | | for (AVA ava : rdn) |
| | | { |
| | | AttributeType attrType = rdn.getAttributeType(i); |
| | | Attribute attribute = Attributes.create(attrType, rdn.getAttributeValue(i)); |
| | | AttributeType attrType = ava.getAttributeType(); |
| | | Attribute attribute = Attributes.create(attrType, ava.getAttributeValue()); |
| | | addAttributeToSchemaEntry(attribute, userAttrs, operationalAttrs); |
| | | } |
| | | } |
| | |
| | | Map<AttributeType,List<Attribute>> operationalAttributes = new LinkedHashMap<>(); |
| | | |
| | | DN dn = DirectoryServer.getSchemaDN(); |
| | | RDN rdn = dn.rdn(); |
| | | for (int i=0; i < rdn.getNumValues(); i++) |
| | | for (AVA ava : dn.rdn()) |
| | | { |
| | | AttributeType type = rdn.getAttributeType(i); |
| | | List<Attribute> attrList = newLinkedList(Attributes.create(type, rdn.getAttributeValue(i))); |
| | | if (type.isOperational()) |
| | | { |
| | | operationalAttributes.put(type, attrList); |
| | | } |
| | | else |
| | | { |
| | | userAttributes.put(type, attrList); |
| | | } |
| | | AttributeType type = ava.getAttributeType(); |
| | | Map<AttributeType, List<Attribute>> attrs = type.isOperational() ? operationalAttributes : userAttributes; |
| | | attrs.put(type, newLinkedList(Attributes.create(type, ava.getAttributeValue()))); |
| | | } |
| | | |
| | | return new Entry(dn, objectClasses, userAttributes, operationalAttributes); |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.AVA; |
| | | 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.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.util.Reject; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.TrustStoreBackendCfg; |
| | |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.BackupConfig; |
| | | import org.opends.server.types.BackupDirectory; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.FilePermission; |
| | | import org.opends.server.types.IndexType; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.LDIFExportConfig; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | | import org.opends.server.types.LDIFImportResult; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.RDN; |
| | | import org.opends.server.types.RestoreConfig; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.opends.server.util.CertificateManager; |
| | | import org.opends.server.util.Platform.KeyType; |
| | | import org.opends.server.util.SetupUtils; |
| | |
| | | DirectoryServer.getObjectClass("ds-cfg-branch", true); |
| | | objectClasses.put(branchOC, "ds-cfg-branch"); |
| | | |
| | | LinkedHashMap<AttributeType,List<Attribute>> opAttrs = new LinkedHashMap<>(0); |
| | | LinkedHashMap<AttributeType,List<Attribute>> userAttrs = new LinkedHashMap<>(1); |
| | | |
| | | RDN rdn = baseDN.rdn(); |
| | | int numAVAs = rdn.getNumValues(); |
| | | for (int i=0; i < numAVAs; i++) |
| | | for (AVA ava : baseDN.rdn()) |
| | | { |
| | | AttributeType attrType = rdn.getAttributeType(i); |
| | | userAttrs.put(attrType, Attributes.createAsList(attrType, rdn.getAttributeValue(i))); |
| | | AttributeType attrType = ava.getAttributeType(); |
| | | userAttrs.put(attrType, Attributes.createAsList(attrType, ava.getAttributeValue())); |
| | | } |
| | | |
| | | baseEntry = new Entry(baseDN, objectClasses, userAttrs, opAttrs); |
| | | baseEntry = new Entry(baseDN, objectClasses, userAttrs, null); |
| | | |
| | | // Register this as a change listener. |
| | | configuration.addTrustStoreChangeListener(this); |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2010-2015 ForgeRock AS. |
| | | * Portions Copyright 2010-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.backends.jeb; |
| | | |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.MemoryQuota; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.util.Platform; |
| | | |
| | | import com.sleepycat.je.Durability; |
| | | import com.sleepycat.je.EnvironmentConfig; |
| | | import com.sleepycat.je.dbi.MemoryBudget; |
| | | import org.opends.server.util.Platform; |
| | | |
| | | /** This class maps JE properties to configuration attributes. */ |
| | | public class ConfigurableEnvironment |
| | |
| | | |
| | | EnvironmentConfig envConfig = defaultConfig(); |
| | | setDurability(envConfig, cfg.isDBTxnNoSync(), cfg.isDBTxnWriteNoSync()); |
| | | setJEProperties(cfg, envConfig, cfg.dn().rdn().getAttributeValue(0)); |
| | | setJEProperties(cfg, envConfig, cfg.dn().rdn().getFirstAVA().getAttributeValue()); |
| | | setDBLoggingLevel(envConfig, cfg.getDBLoggingLevel(), cfg.dn(), cfg.isDBLoggingFileHandlerOn()); |
| | | |
| | | // See if there are any native JE properties specified in the config |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | |
| | | // Install and register the monitor for this cache. |
| | | EntryCacheMonitorProvider monitor = |
| | | new EntryCacheMonitorProvider(configuration.dn(). |
| | | rdn().getAttributeValue(0).toString(), entryCache); |
| | | rdn().getFirstAVA().getAttributeValue().toString(), entryCache); |
| | | try { |
| | | monitor.initializeMonitorProvider((EntryCacheMonitorProviderCfg) |
| | | rootConfiguration.getMonitorProvider( |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | |
| | | import static org.opends.messages.PluginMessages.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.util.*; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.StringTokenizer; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.concurrent.locks.ReentrantLock; |
| | | |
| | |
| | | import org.opends.server.api.plugin.InternalDirectoryServerPlugin; |
| | | import org.opends.server.api.plugin.PluginResult; |
| | | import org.opends.server.api.plugin.PluginType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.operation.*; |
| | | import org.opends.server.types.CanceledOperationException; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DisconnectReason; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.IntermediateResponse; |
| | | import org.opends.server.types.LDIFExportConfig; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.Operation; |
| | | import org.opends.server.types.SearchResultEntry; |
| | | import org.opends.server.types.SearchResultReference; |
| | | import org.opends.server.types.operation.PluginOperation; |
| | | import org.opends.server.types.operation.PostOperationAbandonOperation; |
| | | import org.opends.server.types.operation.PostOperationAddOperation; |
| | | import org.opends.server.types.operation.PostOperationBindOperation; |
| | | import org.opends.server.types.operation.PostOperationCompareOperation; |
| | | import org.opends.server.types.operation.PostOperationDeleteOperation; |
| | | import org.opends.server.types.operation.PostOperationExtendedOperation; |
| | | import org.opends.server.types.operation.PostOperationModifyDNOperation; |
| | | import org.opends.server.types.operation.PostOperationModifyOperation; |
| | | import org.opends.server.types.operation.PostOperationSearchOperation; |
| | | import org.opends.server.types.operation.PostOperationUnbindOperation; |
| | | import org.opends.server.types.operation.PostResponseAddOperation; |
| | | import org.opends.server.types.operation.PostResponseBindOperation; |
| | | import org.opends.server.types.operation.PostResponseCompareOperation; |
| | | import org.opends.server.types.operation.PostResponseDeleteOperation; |
| | | import org.opends.server.types.operation.PostResponseExtendedOperation; |
| | | import org.opends.server.types.operation.PostResponseModifyDNOperation; |
| | | import org.opends.server.types.operation.PostResponseModifyOperation; |
| | | import org.opends.server.types.operation.PostResponseSearchOperation; |
| | | import org.opends.server.types.operation.PostSynchronizationAddOperation; |
| | | import org.opends.server.types.operation.PostSynchronizationDeleteOperation; |
| | | import org.opends.server.types.operation.PostSynchronizationModifyDNOperation; |
| | | import org.opends.server.types.operation.PostSynchronizationModifyOperation; |
| | | import org.opends.server.types.operation.PreOperationAddOperation; |
| | | import org.opends.server.types.operation.PreOperationBindOperation; |
| | | import org.opends.server.types.operation.PreOperationCompareOperation; |
| | | import org.opends.server.types.operation.PreOperationDeleteOperation; |
| | | import org.opends.server.types.operation.PreOperationExtendedOperation; |
| | | import org.opends.server.types.operation.PreOperationModifyDNOperation; |
| | | import org.opends.server.types.operation.PreOperationModifyOperation; |
| | | import org.opends.server.types.operation.PreOperationOperation; |
| | | import org.opends.server.types.operation.PreOperationSearchOperation; |
| | | import org.opends.server.types.operation.PreParseAbandonOperation; |
| | | import org.opends.server.types.operation.PreParseAddOperation; |
| | | import org.opends.server.types.operation.PreParseBindOperation; |
| | | import org.opends.server.types.operation.PreParseCompareOperation; |
| | | import org.opends.server.types.operation.PreParseDeleteOperation; |
| | | import org.opends.server.types.operation.PreParseExtendedOperation; |
| | | import org.opends.server.types.operation.PreParseModifyDNOperation; |
| | | import org.opends.server.types.operation.PreParseModifyOperation; |
| | | import org.opends.server.types.operation.PreParseOperation; |
| | | import org.opends.server.types.operation.PreParseSearchOperation; |
| | | import org.opends.server.types.operation.PreParseUnbindOperation; |
| | | import org.opends.server.types.operation.SearchEntrySearchOperation; |
| | | import org.opends.server.types.operation.SearchReferenceSearchOperation; |
| | | import org.opends.server.types.operation.SubordinateModifyDNOperation; |
| | | |
| | | /** |
| | | * This class defines a utility that will be used to manage the configuration |
| | |
| | | for (DirectoryServerPlugin p : pluginArray) |
| | | { |
| | | DN dn = p.getPluginEntryDN(); |
| | | String lowerName = toLowerCase(dn.rdn().getAttributeValue(0).toString()); |
| | | String lowerName = toLowerCase(dn.rdn().getFirstAVA().getAttributeValue().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).toString()); |
| | | String lowerName = toLowerCase(dn.rdn().getFirstAVA().getAttributeValue().toString()); |
| | | if (initialPluginNames.contains(lowerName)) |
| | | { |
| | | initialPlugins.put(lowerName, plugin); |
| | |
| | | { |
| | | RDN srcRDN = searchEntry.getName().rdn(); |
| | | |
| | | // Only process the entry if it has the expected form of RDN. |
| | | if (!srcRDN.isMultiValued() && |
| | | srcRDN.getAttributeType(0).equals(attrAlias)) |
| | | if (canProcessEntry(srcRDN)) |
| | | { |
| | | DN dstDN = trustStoreRootDN.child(srcRDN); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | /** Only process the entry if it has the expected form of RDN. */ |
| | | private boolean canProcessEntry(RDN rdn) |
| | | { |
| | | return !rdn.isMultiValued() && rdn.getFirstAVA().getAttributeType().equals(attrAlias); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Modify an entry in the local trust store if it differs from an entry in |
| | |
| | | private void handleInstanceKeyAddOperation(Entry entry) |
| | | { |
| | | RDN srcRDN = entry.getName().rdn(); |
| | | |
| | | // Only process the entry if it has the expected form of RDN. |
| | | if (!srcRDN.isMultiValued() && |
| | | srcRDN.getAttributeType(0).equals(attrAlias)) |
| | | if (canProcessEntry(srcRDN)) |
| | | { |
| | | DN dstDN = trustStoreRootDN.child(srcRDN); |
| | | |
| | |
| | | |
| | | RDN srcRDN = op.getEntryToDelete().getName().rdn(); |
| | | |
| | | // Only process the entry if it has the expected form of RDN. |
| | | // FIXME: Technically it is possible to perform a subtree in |
| | | // this case however such subtree delete would essentially be |
| | | // removing configuration branches which should not happen. |
| | | if (!srcRDN.isMultiValued() && |
| | | srcRDN.getAttributeType(0).equals(attrAlias)) |
| | | if (canProcessEntry(srcRDN)) |
| | | { |
| | | DN destDN = trustStoreRootDN.child(srcRDN); |
| | | deleteEntry(destDN); |
| | |
| | | { |
| | | RDN srcRDN = newEntry.getName().rdn(); |
| | | |
| | | // Only process the entry if it has the expected form of RDN. |
| | | if (!srcRDN.isMultiValued() && |
| | | srcRDN.getAttributeType(0).equals(attrAlias)) |
| | | if (canProcessEntry(srcRDN)) |
| | | { |
| | | DN dstDN = trustStoreRootDN.child(srcRDN); |
| | | |
| | |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.AVA; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | 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.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.AcceptRejectWarn; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.DITStructureRule; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.NameForm; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.RDN; |
| | | import org.opends.server.types.VirtualAttributeRule; |
| | | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | |
| | |
| | | } |
| | | |
| | | // Make sure that all attributes in the RDN are allowed. |
| | | int numAVAs = rdn.getNumValues(); |
| | | for (int i = 0; i < numAVAs; i++) |
| | | for (AVA ava : rdn) |
| | | { |
| | | AttributeType t = rdn.getAttributeType(i); |
| | | AttributeType t = ava.getAttributeType(); |
| | | if (!nameForm.isRequiredOrOptional(t) |
| | | && structuralPolicy == AcceptRejectWarn.REJECT) |
| | | { |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.AVA; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.IndexType; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.RDN; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.opends.server.types.SearchResultEntry; |
| | | |
| | |
| | | LinkedList<SearchFilter> filterComps = new LinkedList<>(); |
| | | for (int i=0; i < peerDN.size(); i++) |
| | | { |
| | | RDN rdn = peerDN.getRDN(i); |
| | | for (int j=0; j < rdn.getNumValues(); j++) |
| | | for (AVA ava : peerDN.getRDN(i)) |
| | | { |
| | | String lowerName = toLowerCase(rdn.getAttributeName(j)); |
| | | String lowerName = toLowerCase(ava.getAttributeName()); |
| | | |
| | | // Try to normalize lowerName |
| | | lowerName = normalizeAttributeName(lowerName); |
| | |
| | | AttributeType attrType = theAttributeMap.get(lowerName); |
| | | if (attrType != null) |
| | | { |
| | | filterComps.add(SearchFilter.createEqualityFilter(attrType, rdn.getAttributeValue(j))); |
| | | filterComps.add(SearchFilter.createEqualityFilter(attrType, ava.getAttributeValue())); |
| | | } |
| | | } |
| | | } |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2015 ForgeRock AS. |
| | | * Copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.loggers; |
| | | |
| | |
| | | |
| | | String getName() |
| | | { |
| | | return config.dn().getRDN(0).getAttributeValue(0).toString(); |
| | | return config.dn().getRDN(0).getFirstAVA().getAttributeValue().toString(); |
| | | } |
| | | |
| | | String getCommonAuditTopic() throws ConfigException |
| | |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.AVA; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | 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.admin.std.server.SevenBitCleanPluginCfg; |
| | | 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.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | | import org.opends.server.types.RDN; |
| | | import org.opends.server.types.RawAttribute; |
| | | import org.opends.server.types.RawModification; |
| | | import org.opends.server.types.operation.PreParseAddOperation; |
| | | import org.opends.server.types.operation.PreParseModifyOperation; |
| | | import org.opends.server.types.operation.PreParseModifyDNOperation; |
| | | import org.opends.server.types.operation.PreParseModifyOperation; |
| | | |
| | | /** |
| | | * This class implements a Directory Server plugin that can be used to ensure |
| | |
| | | ERR_PLUGIN_7BIT_CANNOT_DECODE_NEW_RDN.get(de.getMessageObject())); |
| | | } |
| | | |
| | | int numValues = newRDN.getNumValues(); |
| | | for (int i=0; i < numValues; i++) |
| | | for (AVA ava : newRDN) |
| | | { |
| | | if (! config.getAttributeType().contains(newRDN.getAttributeType(i))) |
| | | if (!config.getAttributeType().contains(ava.getAttributeType())) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | if (!is7BitClean(newRDN.getAttributeValue(i))) |
| | | if (!is7BitClean(ava.getAttributeValue())) |
| | | { |
| | | return PluginResult.PreParse.stopProcessing( |
| | | ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_PLUGIN_7BIT_MODIFYDN_ATTR_NOT_CLEAN.get( |
| | | newRDN.getAttributeName(i))); |
| | | ERR_PLUGIN_7BIT_MODIFYDN_ATTR_NOT_CLEAN.get(ava.getAttributeName())); |
| | | } |
| | | } |
| | | } |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.AVA; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.IndexType; |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.RDN; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.opends.server.types.SearchResultEntry; |
| | | import org.opends.server.types.operation.PluginOperation; |
| | |
| | | { |
| | | Attribute a = m.getAttribute(); |
| | | AttributeType t = a.getAttributeDescription().getAttributeType(); |
| | | if (! config.getType().contains(t)) |
| | | if (!isModifyingUniqueAttribute(t, config)) |
| | | { |
| | | // This modification isn't for a unique attribute. |
| | | continue; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | List<ByteString> recordedValues = new LinkedList<>(); |
| | | RDN newRDN = modifyDNOperation.getNewRDN(); |
| | | for (int i=0; i < newRDN.getNumValues(); i++) |
| | | for (AVA ava : modifyDNOperation.getNewRDN()) |
| | | { |
| | | AttributeType t = newRDN.getAttributeType(i); |
| | | if (! config.getType().contains(t)) |
| | | AttributeType t = ava.getAttributeType(); |
| | | if (!isModifyingUniqueAttribute(t, config)) |
| | | { |
| | | // We aren't interested in this attribute type. |
| | | continue; |
| | | } |
| | | |
| | | ByteString v = newRDN.getAttributeValue(i); |
| | | ByteString v = ava.getAttributeValue(); |
| | | DN entryDN = modifyDNOperation.getEntryDN(); |
| | | PreOperation stop = |
| | | checkUniqueness(entryDN, t, v, baseDNs, recordedValues, config); |
| | |
| | | return PluginResult.PreOperation.continueOperationProcessing(); |
| | | } |
| | | |
| | | private boolean isModifyingUniqueAttribute(AttributeType t, UniqueAttributePluginCfg config) |
| | | { |
| | | return config.getType().contains(t); |
| | | } |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final void doPostSynchronization( |
| | | PostSynchronizationAddOperation addOperation) |
| | |
| | | { |
| | | Attribute a = m.getAttribute(); |
| | | AttributeType t = a.getAttributeDescription().getAttributeType(); |
| | | if (! config.getType().contains(t)) |
| | | if (!isModifyingUniqueAttribute(t, config)) |
| | | { |
| | | // This modification isn't for a unique attribute. |
| | | continue; |
| | | } |
| | | |
| | |
| | | |
| | | DN entryDN = modifyDNOperation.getEntryDN(); |
| | | DN updatedEntryDN = modifyDNOperation.getUpdatedEntry().getName(); |
| | | RDN newRDN = modifyDNOperation.getNewRDN(); |
| | | for (int i=0; i < newRDN.getNumValues(); i++) |
| | | for (AVA ava : modifyDNOperation.getNewRDN()) |
| | | { |
| | | AttributeType t = newRDN.getAttributeType(i); |
| | | if (! config.getType().contains(t)) |
| | | AttributeType t = ava.getAttributeType(); |
| | | if (isModifyingUniqueAttribute(t, config)) |
| | | { |
| | | // We aren't interested in this attribute type. |
| | | continue; |
| | | ByteString v = ava.getAttributeValue(); |
| | | sendAlertForUnresolvedConflict(modifyDNOperation, entryDN, updatedEntryDN, t, v, baseDNs, config); |
| | | } |
| | | |
| | | ByteString v = newRDN.getAttributeValue(i); |
| | | sendAlertForUnresolvedConflict(modifyDNOperation, entryDN, |
| | | updatedEntryDN, t, v, baseDNs, config); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | Attribute a = m.getAttribute(); |
| | | AttributeType t = a.getAttributeDescription().getAttributeType(); |
| | | if (! config.getType().contains(t)) |
| | | if (!isModifyingUniqueAttribute(t, config)) |
| | | { |
| | | // This modification isn't for a unique attribute. |
| | | continue; |
| | | } |
| | | |
| | |
| | | return PostOperation.continueOperationProcessing(); |
| | | } |
| | | |
| | | RDN newRDN = modifyDNOperation.getNewRDN(); |
| | | for (int i=0; i < newRDN.getNumValues(); i++) |
| | | for (AVA ava : modifyDNOperation.getNewRDN()) |
| | | { |
| | | AttributeType t = newRDN.getAttributeType(i); |
| | | if (! config.getType().contains(t)) |
| | | AttributeType t = ava.getAttributeType(); |
| | | if (isModifyingUniqueAttribute(t, config)) |
| | | { |
| | | // We aren't interested in this attribute type. |
| | | continue; |
| | | uniqueAttrValue2Dn.remove(ava.getAttributeValue()); |
| | | } |
| | | uniqueAttrValue2Dn.remove(newRDN.getAttributeValue(i)); |
| | | } |
| | | return PostOperation.continueOperationProcessing(); |
| | | } |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2013-2015 ForgeRock AS |
| | | * Copyright 2013-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.protocols.http; |
| | | |
| | |
| | | |
| | | if (friendlyName == null) |
| | | { |
| | | friendlyName = config.dn().rdn().getAttributeValue(0).toString(); |
| | | friendlyName = config.dn().rdn().getFirstAVA().getAttributeValue().toString(); |
| | | } |
| | | |
| | | int listenPort = config.getListenPort(); |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | |
| | | { |
| | | if (friendlyName == null) |
| | | { |
| | | friendlyName = config.dn().rdn().getAttributeValue(0).toString(); |
| | | friendlyName = config.dn().rdn().getFirstAVA().getAttributeValue().toString(); |
| | | } |
| | | |
| | | // Open the selector. |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.admin.server.ConfigurationAddListener; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.server.ConfigurationDeleteListener; |
| | | import org.opends.server.admin.std.server.ExternalChangelogDomainCfg; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.RDN; |
| | | |
| | | /** |
| | | * This class specifies the external changelog feature for a replication |
| | | * domain. |
| | | */ |
| | | /** This class specifies the external changelog feature for a replication domain. */ |
| | | public class ExternalChangelogDomain |
| | | implements ConfigurationAddListener<ExternalChangelogDomainCfg>, |
| | | ConfigurationDeleteListener<ExternalChangelogDomainCfg>, |
| | |
| | | if (domain==null) |
| | | { |
| | | RDN rdn = configuration.dn().parent().rdn(); |
| | | DN rdns = DN.decode(rdn.getAttributeValue(0)); |
| | | DN rdns = DN.decode(rdn.getFirstAVA().getAttributeValue()); |
| | | domain = MultimasterReplication.findDomain(rdns, null); |
| | | } |
| | | return null; |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.AVA; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | |
| | | RDN newRdn = modifyDNOperation.getNewRDN(); |
| | | |
| | | // Go through each attribute of the old RDN |
| | | for (int i=0 ; i<rdn.getNumValues() ; i++) |
| | | for (AVA ava : rdn) |
| | | { |
| | | AttributeType attributeType = rdn.getAttributeType(i); |
| | | AttributeType attributeType = ava.getAttributeType(); |
| | | // Is it present in the fractional attributes established list ? |
| | | boolean foundAttribute = |
| | | fractionalConcernedAttributes.contains(attributeType); |
| | |
| | | if (! backupDir.getConfigEntryDN().equals(cfg.dn())) |
| | | { |
| | | logger.error(ERR_BACKUPDB_CANNOT_BACKUP_IN_DIRECTORY, b.getBackendID(), backupLocation.getPath(), |
| | | backupDir.getConfigEntryDN().rdn().getAttributeValue(0)); |
| | | backupDir.getConfigEntryDN().rdn().getFirstAVA().getAttributeValue()); |
| | | return false ; |
| | | } |
| | | } |
| | |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.AttributeDescription; |
| | | import org.forgerock.opendj.ldap.AVA; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteSequenceReader; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | |
| | | } |
| | | |
| | | // Make sure that all attributes in the RDN are allowed. |
| | | int numAVAs = rdn.getNumValues(); |
| | | for (int i = 0; i < numAVAs; i++) |
| | | for (AVA ava : rdn) |
| | | { |
| | | AttributeType t = rdn.getAttributeType(i); |
| | | AttributeType t = ava.getAttributeType(); |
| | | if (! nameForm.isRequiredOrOptional(t)) |
| | | { |
| | | LocalizableMessage message = |
| | |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLEncoder; |
| | | import java.nio.CharBuffer; |
| | | import java.nio.charset.Charset; |
| | | import java.nio.charset.CharsetDecoder; |
| | | import java.nio.charset.CodingErrorAction; |
| | | import java.util.*; |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.SortedSet; |
| | | import java.util.TreeSet; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.AVA; |
| | | 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.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.util.Reject; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | mayExtend=false, |
| | | mayInvoke=true) |
| | | public final class RDN |
| | | implements Comparable<RDN> |
| | | implements Comparable<RDN>, Iterable<AVA> |
| | | { |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The set of attribute types for the elements in this RDN. */ |
| | | private AttributeType[] attributeTypes; |
| | | |
| | | /** The set of values for the elements in this RDN. */ |
| | | private ByteString[] attributeValues; |
| | | |
| | | /** The set of user-provided names for the attributes in this RDN. */ |
| | | private String[] attributeNames; |
| | | |
| | | /** The collection of AVAs for the elements in this RDN. */ |
| | | private final List<AVA> avas; |
| | | /** Representation of the normalized form of this RDN. */ |
| | | private ByteString normalizedRDN; |
| | | |
| | |
| | | * @param attributeValue The value for this RDN. It must not be |
| | | * {@code null}. |
| | | */ |
| | | @SuppressWarnings("unchecked") |
| | | public RDN(AttributeType attributeType, ByteString attributeValue) |
| | | { |
| | | Reject.ifNull(attributeType, attributeValue); |
| | | attributeTypes = new AttributeType[] { attributeType }; |
| | | attributeNames = new String[] { attributeType.getNameOrOID() }; |
| | | attributeValues = new ByteString[] { attributeValue }; |
| | | avas = new ArrayList<>(1); |
| | | avas.add(new AVA(attributeType, attributeValue)); |
| | | } |
| | | |
| | | |
| | |
| | | * @param attributeValue The value for this RDN. It must not be |
| | | * {@code null}. |
| | | */ |
| | | @SuppressWarnings("unchecked") |
| | | public RDN(AttributeType attributeType, String attributeName, ByteString attributeValue) |
| | | { |
| | | Reject.ifNull(attributeType, attributeName, attributeValue); |
| | | attributeTypes = new AttributeType[] { attributeType }; |
| | | attributeNames = new String[] { attributeName }; |
| | | attributeValues = new ByteString[] { attributeValue }; |
| | | avas = new ArrayList<>(1); |
| | | avas.add(new AVA(attributeType, attributeName, attributeValue)); |
| | | } |
| | | |
| | | |
| | |
| | | * have the same number of elements as the |
| | | * {@code attributeTypes} argument. |
| | | */ |
| | | @SuppressWarnings("unchecked") |
| | | public RDN(List<AttributeType> attributeTypes, |
| | | List<String> attributeNames, |
| | | List<ByteString> attributeValues) |
| | |
| | | Reject.ifFalse(attributeValues.size() == attributeTypes.size(), |
| | | "attributeValues must have the same number of elements than attributeTypes"); |
| | | |
| | | this.attributeTypes = new AttributeType[attributeTypes.size()]; |
| | | this.attributeNames = new String[attributeNames.size()]; |
| | | this.attributeValues = new ByteString[attributeValues.size()]; |
| | | |
| | | attributeTypes.toArray(this.attributeTypes); |
| | | attributeNames.toArray(this.attributeNames); |
| | | attributeValues.toArray(this.attributeValues); |
| | | avas = new ArrayList<>(attributeTypes.size()); |
| | | for (int i = 0; i < attributeTypes.size(); i++) |
| | | { |
| | | avas.add(new AVA(attributeTypes.get(i), attributeNames.get(i), attributeValues.get(i))); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | * have the same number of elements as the |
| | | * {@code attributeTypes} argument. |
| | | */ |
| | | @SuppressWarnings("unchecked") |
| | | public RDN(AttributeType[] attributeTypes, String[] attributeNames, ByteString[] attributeValues) |
| | | { |
| | | Reject.ifNull(attributeTypes, attributeNames, attributeValues); |
| | |
| | | Reject.ifFalse(attributeValues.length == attributeTypes.length, |
| | | "attributeValues must have the same number of elements than attributeTypes"); |
| | | |
| | | this.attributeTypes = attributeTypes; |
| | | this.attributeNames = attributeNames; |
| | | this.attributeValues = attributeValues; |
| | | avas = new ArrayList<>(attributeTypes.length); |
| | | for (int i = 0; i < attributeTypes.length; i++) |
| | | { |
| | | avas.add(new AVA(attributeTypes[i], attributeNames[i], attributeValues[i])); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Creates a new RDN with the provided collection of {@link AVA}. |
| | | * |
| | | * @param avas |
| | | * The collection of AVA that will define the new RDN |
| | | */ |
| | | public RDN(Collection<AVA> avas) |
| | | { |
| | | Reject.ifNull(avas, "avas must not be null"); |
| | | Reject.ifTrue(avas.isEmpty(), "avas must not be empty"); |
| | | this.avas = new ArrayList<>(avas); |
| | | } |
| | | |
| | | |
| | |
| | | return new RDN(attributeType, attributeValue); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the number of attribute-value pairs contained in this |
| | | * RDN. |
| | | * Retrieves the number of attribute-value pairs contained in this RDN. |
| | | * |
| | | * @return The number of attribute-value pairs contained in this |
| | | * RDN. |
| | | * @return The number of attribute-value pairs contained in this RDN. |
| | | */ |
| | | public int getNumValues() |
| | | public int size() |
| | | { |
| | | return attributeTypes.length; |
| | | return avas.size(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether this RDN includes the specified attribute type. |
| | | * |
| | |
| | | */ |
| | | public boolean hasAttributeType(AttributeType attributeType) |
| | | { |
| | | for (AttributeType t : attributeTypes) |
| | | for (AVA ava : avas) |
| | | { |
| | | if (t.equals(attributeType)) |
| | | if (ava.getAttributeType().equals(attributeType)) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | |
| | | */ |
| | | public boolean hasAttributeType(String lowerName) |
| | | { |
| | | for (AttributeType t : attributeTypes) |
| | | for (AVA ava : avas) |
| | | { |
| | | if (t.hasNameOrOID(lowerName)) |
| | | if (ava.getAttributeType().hasNameOrOID(lowerName)) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | for (String s : attributeNames) |
| | | { |
| | | if (s.equalsIgnoreCase(lowerName)) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the attribute type at the specified position in the set |
| | | * of attribute types for this RDN. |
| | | * |
| | | * @param pos The position of the attribute type to retrieve. |
| | | * |
| | | * @return The attribute type at the specified position in the set |
| | | * of attribute types for this RDN. |
| | | */ |
| | | public AttributeType getAttributeType(int pos) |
| | | { |
| | | return attributeTypes[pos]; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the name for the attribute type at the specified |
| | | * position in the set of attribute types for this RDN. |
| | | * |
| | | * @param pos The position of the attribute type for which to |
| | | * retrieve the name. |
| | | * |
| | | * @return The name for the attribute type at the specified |
| | | * position in the set of attribute types for this RDN. |
| | | */ |
| | | public String getAttributeName(int pos) |
| | | { |
| | | return attributeNames[pos]; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the attribute value that is associated with the |
| | | * specified attribute type. |
| | |
| | | */ |
| | | public ByteString getAttributeValue(AttributeType attributeType) |
| | | { |
| | | for (int i=0; i < attributeTypes.length; i++) |
| | | for (AVA ava : avas) |
| | | { |
| | | if (attributeTypes[i].equals(attributeType)) |
| | | if (ava.getAttributeType().equals(attributeType)) |
| | | { |
| | | return attributeValues[i]; |
| | | return ava.getAttributeValue(); |
| | | } |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the value for the attribute type at the specified |
| | | * position in the set of attribute types for this RDN. |
| | | * |
| | | * @param pos The position of the attribute type for which to |
| | | * retrieve the value. |
| | | * |
| | | * @return The value for the attribute type at the specified |
| | | * position in the set of attribute types for this RDN. |
| | | */ |
| | | public ByteString getAttributeValue(int pos) |
| | | { |
| | | return attributeValues[pos]; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether this RDN is multivalued. |
| | | * |
| | |
| | | */ |
| | | public boolean isMultiValued() |
| | | { |
| | | return attributeTypes.length > 1; |
| | | return avas.size() > 1; |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | public boolean hasValue(AttributeType type, ByteString value) |
| | | { |
| | | for (int i=0; i < attributeTypes.length; i++) |
| | | for (AVA ava : avas) |
| | | { |
| | | if (attributeTypes[i].equals(type) && |
| | | attributeValues[i].equals(value)) |
| | | if (ava.getAttributeType().equals(type) && ava.getAttributeValue().equals(value)) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | |
| | | */ |
| | | boolean addValue(AttributeType type, String name, ByteString value) |
| | | { |
| | | int numValues = attributeTypes.length; |
| | | for (int i=0; i < numValues; i++) |
| | | for (AVA ava : avas) |
| | | { |
| | | if (attributeTypes[i].equals(type) && |
| | | attributeValues[i].equals(value)) |
| | | if (ava.getAttributeType().equals(type) && ava.getAttributeValue().equals(value)) |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | numValues++; |
| | | AttributeType[] newTypes = new AttributeType[numValues]; |
| | | System.arraycopy(attributeTypes, 0, newTypes, 0, attributeTypes.length); |
| | | newTypes[attributeTypes.length] = type; |
| | | attributeTypes = newTypes; |
| | | |
| | | String[] newNames = new String[numValues]; |
| | | System.arraycopy(attributeNames, 0, newNames, 0, attributeNames.length); |
| | | newNames[attributeNames.length] = name; |
| | | attributeNames = newNames; |
| | | |
| | | ByteString[] newValues = new ByteString[numValues]; |
| | | System.arraycopy(attributeValues, 0, newValues, 0, attributeValues.length); |
| | | newValues[attributeValues.length] = value; |
| | | attributeValues = newValues; |
| | | |
| | | avas.add(new AVA(type, name, value)); |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves a version of the provided value in a form that is |
| | | * properly escaped for use in a DN or RDN. |
| | | * |
| | | * @param valueBS The value to be represented in a DN-safe form. |
| | | * |
| | | * @return A version of the provided value in a form that is |
| | | * properly escaped for use in a DN or RDN. |
| | | */ |
| | | private static String getDNValue(ByteString valueBS) { |
| | | final String value = valueBS.toString(); |
| | | if (value == null || value.length() == 0) { |
| | | return ""; |
| | | } |
| | | |
| | | // Only copy the string value if required. |
| | | boolean needsEscaping = false; |
| | | int length = value.length(); |
| | | |
| | | needsEscaping: { |
| | | char c = value.charAt(0); |
| | | if (c == ' ' || c == '#') { |
| | | needsEscaping = true; |
| | | break needsEscaping; |
| | | } |
| | | |
| | | if (value.charAt(length - 1) == ' ') { |
| | | needsEscaping = true; |
| | | break needsEscaping; |
| | | } |
| | | |
| | | for (int i = 0; i < length; i++) { |
| | | c = value.charAt(i); |
| | | if (c < ' ') { |
| | | needsEscaping = true; |
| | | break needsEscaping; |
| | | } else { |
| | | switch (c) { |
| | | case ',': |
| | | case '+': |
| | | case '"': |
| | | case '\\': |
| | | case '<': |
| | | case '>': |
| | | case ';': |
| | | needsEscaping = true; |
| | | break needsEscaping; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (!needsEscaping) { |
| | | return value; |
| | | } |
| | | |
| | | // We need to copy and escape the string (allow for at least one |
| | | // escaped character). |
| | | StringBuilder buffer = new StringBuilder(length + 3); |
| | | |
| | | // If the lead character is a space or a # it must be escaped. |
| | | int start = 0; |
| | | char c = value.charAt(0); |
| | | if (c == ' ' || c == '#') { |
| | | buffer.append('\\'); |
| | | buffer.append(c); |
| | | if (length == 1) { |
| | | return buffer.toString(); |
| | | } |
| | | start = 1; |
| | | } |
| | | |
| | | // Escape remaining characters as necessary. |
| | | for (int i = start; i < length; i++) { |
| | | c = value.charAt(i); |
| | | if (c < ' ') { |
| | | for (byte b : getBytes(String.valueOf(c))) { |
| | | buffer.append('\\'); |
| | | buffer.append(byteToLowerHex(b)); |
| | | } |
| | | } else { |
| | | switch (value.charAt(i)) { |
| | | case ',': |
| | | case '+': |
| | | case '"': |
| | | case '\\': |
| | | case '<': |
| | | case '>': |
| | | case ';': |
| | | buffer.append('\\'); |
| | | buffer.append(c); |
| | | break; |
| | | default: |
| | | buffer.append(c); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | // If the last character is a space it must be escaped. |
| | | if (value.charAt(length - 1) == ' ') { |
| | | length = buffer.length(); |
| | | buffer.insert(length - 1, '\\'); |
| | | } |
| | | |
| | | return buffer.toString(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Decodes the provided string as an RDN. |
| | | * |
| | |
| | | */ |
| | | public RDN duplicate() |
| | | { |
| | | int numValues = attributeTypes.length; |
| | | AttributeType[] newTypes = new AttributeType[numValues]; |
| | | System.arraycopy(attributeTypes, 0, newTypes, 0, numValues); |
| | | |
| | | String[] newNames = new String[numValues]; |
| | | System.arraycopy(attributeNames, 0, newNames, 0, numValues); |
| | | |
| | | ByteString[] newValues = new ByteString[numValues]; |
| | | System.arraycopy(attributeValues, 0, newValues, 0, numValues); |
| | | |
| | | return new RDN(newTypes, newNames, newValues); |
| | | return new RDN(avas); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | /** Returns normalized value for attribute at provided position. */ |
| | | private ByteString getEqualityNormalizedValue(int position) |
| | | private ByteString getEqualityNormalizedValue(AVA ava) |
| | | { |
| | | final MatchingRule matchingRule = attributeTypes[position].getEqualityMatchingRule(); |
| | | ByteString attributeValue = attributeValues[position]; |
| | | final MatchingRule matchingRule = ava.getAttributeType().getEqualityMatchingRule(); |
| | | ByteString attributeValue = ava.getAttributeValue(); |
| | | if (matchingRule != null) |
| | | { |
| | | try |
| | |
| | | catch (final DecodeException de) |
| | | { |
| | | // Unable to normalize, use default |
| | | attributeValue = attributeValues[position]; |
| | | attributeValue = ava.getAttributeValue(); |
| | | } |
| | | } |
| | | return attributeValue; |
| | |
| | | @Override |
| | | public String toString() |
| | | { |
| | | StringBuilder buffer = new StringBuilder(); |
| | | buffer.append(attributeNames[0]); |
| | | buffer.append("="); |
| | | buffer.append(getDNValue(attributeValues[0])); |
| | | for (int i = 1; i < attributeTypes.length; i++) { |
| | | buffer.append("+"); |
| | | buffer.append(attributeNames[i]); |
| | | buffer.append("="); |
| | | buffer.append(getDNValue(attributeValues[i])); |
| | | } |
| | | return buffer.toString(); |
| | | StringBuilder buffer = new StringBuilder(); |
| | | Iterator<AVA> it = avas.iterator(); |
| | | buffer.append(it.next()); |
| | | while (it.hasNext()) |
| | | { |
| | | buffer.append("+"); |
| | | buffer.append(it.next()); |
| | | } |
| | | return buffer.toString(); |
| | | } |
| | | |
| | | /** |
| | |
| | | String toNormalizedUrlSafeString() |
| | | { |
| | | final StringBuilder buffer = new StringBuilder(); |
| | | if (attributeNames.length == 1) |
| | | if (avas.size() == 1) |
| | | { |
| | | normalizeAVAToUrlSafeString(0, buffer); |
| | | normalizeAVAToUrlSafeString(getFirstAVA(), buffer); |
| | | } |
| | | else |
| | | { |
| | | // Normalization sorts RDNs alphabetically |
| | | SortedSet<String> avaStrings = new TreeSet<>(); |
| | | for (int i=0; i < attributeNames.length; i++) |
| | | for (AVA ava : avas) |
| | | { |
| | | StringBuilder builder = new StringBuilder(); |
| | | normalizeAVAToUrlSafeString(i, builder); |
| | | normalizeAVAToUrlSafeString(ava, builder); |
| | | avaStrings.add(builder.toString()); |
| | | } |
| | | |
| | |
| | | { |
| | | final int startPos = builder.length(); |
| | | |
| | | if (attributeNames.length == 1) |
| | | if (avas.size() == 1) |
| | | { |
| | | normalizeAVAToByteString(0, builder); |
| | | normalizeAVAToByteString(getFirstAVA(), builder); |
| | | } |
| | | else |
| | | { |
| | | // Normalization sorts RDNs |
| | | SortedSet<ByteString> avaStrings = new TreeSet<>(); |
| | | for (int i = 0; i < attributeNames.length; i++) |
| | | for (AVA ava : avas) |
| | | { |
| | | ByteStringBuilder b = new ByteStringBuilder(); |
| | | normalizeAVAToByteString(i, b); |
| | | normalizeAVAToByteString(ava, b); |
| | | avaStrings.add(b.toByteString()); |
| | | } |
| | | |
| | |
| | | * Builder to add the representation to. |
| | | * @return the builder |
| | | */ |
| | | private ByteStringBuilder normalizeAVAToByteString(int position, final ByteStringBuilder builder) |
| | | private ByteStringBuilder normalizeAVAToByteString(AVA ava, final ByteStringBuilder builder) |
| | | { |
| | | builder.appendUtf8(attributeTypes[position].getNormalizedNameOrOID()); |
| | | builder.appendUtf8(ava.getAttributeType().getNormalizedNameOrOID()); |
| | | builder.appendUtf8("="); |
| | | final ByteString value = getEqualityNormalizedValue(position); |
| | | final ByteString value = getEqualityNormalizedValue(ava); |
| | | if (value.length() > 0) |
| | | { |
| | | builder.appendBytes(escapeBytes(value)); |
| | |
| | | * @param builder The buffer to which to append the information. |
| | | * @return the builder |
| | | */ |
| | | private StringBuilder normalizeAVAToUrlSafeString(int position, StringBuilder builder) |
| | | private StringBuilder normalizeAVAToUrlSafeString(AVA ava, StringBuilder builder) |
| | | { |
| | | builder.append(attributeTypes[position].getNormalizedNameOrOID()); |
| | | AttributeType attrType = ava.getAttributeType(); |
| | | builder.append(attrType.getNormalizedNameOrOID()); |
| | | builder.append('='); |
| | | |
| | | ByteString value = getEqualityNormalizedValue(position); |
| | | ByteString value = getEqualityNormalizedValue(ava); |
| | | if (value.length() == 0) |
| | | { |
| | | return builder; |
| | | } |
| | | final boolean hasAttributeName = !attributeTypes[position].getNames().isEmpty(); |
| | | final boolean isHumanReadable = attributeTypes[position].getSyntax().isHumanReadable(); |
| | | final boolean hasAttributeName = !attrType.getNames().isEmpty(); |
| | | final boolean isHumanReadable = attrType.getSyntax().isHumanReadable(); |
| | | if (!hasAttributeName || !isHumanReadable) |
| | | { |
| | | builder.append(value.toPercentHexString()); |
| | |
| | | return toNormalizedByteString().compareTo(rdn.toNormalizedByteString()); |
| | | } |
| | | |
| | | /** |
| | | * Returns the first AVA of this {@link RDN}. |
| | | * |
| | | * @return the first AVA of this {@link RDN}. |
| | | */ |
| | | public AVA getFirstAVA() |
| | | { |
| | | return avas.get(0); |
| | | } |
| | | |
| | | @Override |
| | | public Iterator<AVA> iterator() |
| | | { |
| | | return avas.iterator(); |
| | | } |
| | | } |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.AVA; |
| | | import org.forgerock.opendj.ldap.Assertion; |
| | | import org.forgerock.opendj.ldap.AttributeDescription; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | |
| | | int count = entryDN.size(); |
| | | for (int rdnIndex = 0; rdnIndex < count; rdnIndex++) |
| | | { |
| | | RDN rdn = entryDN.getRDN(rdnIndex); |
| | | int numAVAs = rdn.getNumValues(); |
| | | for (int i=0; i < numAVAs; i++) |
| | | for (AVA ava : entryDN.getRDN(rdnIndex)) |
| | | { |
| | | try |
| | | { |
| | | if (attributeType == null || attributeType.equals(rdn.getAttributeType(i))) |
| | | if (attributeType == null || attributeType.equals(ava.getAttributeType())) |
| | | { |
| | | ByteString v = rdn.getAttributeValue(i); |
| | | ByteString v = ava.getAttributeValue(); |
| | | ByteString nv = matchingRule.normalizeAttributeValue(v); |
| | | ConditionResult r = assertion.matches(nv); |
| | | switch (r) |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.AVA; |
| | | import org.forgerock.opendj.ldap.AttributeDescription; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | |
| | | Map<AttributeType,List<Attribute>>userAttributes, |
| | | Map<AttributeType,List<Attribute>> operationalAttributes) |
| | | { |
| | | RDN rdn = entryDN.rdn(); |
| | | int numAVAs = rdn.getNumValues(); |
| | | for (int i=0; i < numAVAs; i++) |
| | | for (AVA ava : entryDN.rdn()) |
| | | { |
| | | AttributeType t = rdn.getAttributeType(i); |
| | | ByteString v = rdn.getAttributeValue(i); |
| | | String n = rdn.getAttributeName(i); |
| | | if (t.isOperational()) |
| | | { |
| | | addRDNAttributesIfNecessary(operationalAttributes, t, v, n); |
| | | } |
| | | else |
| | | { |
| | | addRDNAttributesIfNecessary(userAttributes, t, v, n); |
| | | } |
| | | AttributeType t = ava.getAttributeType(); |
| | | addRDNAttributesIfNecessary(t.isOperational() ? operationalAttributes : userAttributes, ava); |
| | | } |
| | | } |
| | | |
| | | |
| | | private void addRDNAttributesIfNecessary( |
| | | Map<AttributeType, List<Attribute>> attributes, AttributeType t, |
| | | ByteString v, String n) |
| | | private void addRDNAttributesIfNecessary(Map<AttributeType, List<Attribute>> attributes, AVA ava) |
| | | { |
| | | AttributeType t = ava.getAttributeType(); |
| | | String n = ava.getAttributeName(); |
| | | ByteString v = ava.getAttributeValue(); |
| | | final List<Attribute> attrList = attributes.get(t); |
| | | if (attrList == null) |
| | | { |
| | |
| | | import static org.opends.messages.UtilityMessages.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | import java.io.*; |
| | | import java.io.BufferedReader; |
| | | import java.io.Closeable; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.FileOutputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.io.InputStreamReader; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.InetAddress; |
| | | import java.net.InetSocketAddress; |
| | | import java.net.ServerSocket; |
| | |
| | | import java.nio.channels.SocketChannel; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.Date; |
| | | import java.util.HashSet; |
| | | import java.util.Iterator; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.RandomAccess; |
| | | import java.util.TimeZone; |
| | | |
| | | import javax.naming.InitialContext; |
| | | import javax.naming.NamingException; |
| | |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.i18n.LocalizableMessageDescriptor; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.AVA; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.util.Reject; |
| | | import org.opends.messages.ToolMessages; |
| | | import org.opends.server.api.ClientConnection; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.IdentifiedException; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.RDN; |
| | | |
| | | import com.forgerock.opendj.cli.Argument; |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | |
| | | |
| | | // Get the information about the RDN attributes. |
| | | RDN rdn = dn.rdn(); |
| | | int numAVAs = rdn.getNumValues(); |
| | | |
| | | // If there is only one RDN attribute, then see which objectclass we should use. |
| | | ObjectClass structuralClass = DirectoryServer.getObjectClass(getObjectClassName(rdn, numAVAs)); |
| | | ObjectClass structuralClass = DirectoryServer.getObjectClass(getObjectClassName(rdn)); |
| | | |
| | | // Get the top and untypedObject classes to include in the entry. |
| | | LinkedHashMap<ObjectClass,String> objectClasses = new LinkedHashMap<>(3); |
| | |
| | | LinkedHashMap<AttributeType,List<Attribute>> operationalAttributes = new LinkedHashMap<>(); |
| | | |
| | | boolean extensibleObjectAdded = false; |
| | | for (int i=0; i < numAVAs; i++) |
| | | for (AVA ava : rdn) |
| | | { |
| | | AttributeType attrType = rdn.getAttributeType(i); |
| | | ByteString attrValue = rdn.getAttributeValue(i); |
| | | String attrName = rdn.getAttributeName(i); |
| | | AttributeType attrType = ava.getAttributeType(); |
| | | |
| | | // First, see if this type is allowed by the untypedObject class. If not, |
| | | // then we'll need to include the extensibleObject class. |
| | |
| | | |
| | | |
| | | // Create the attribute and add it to the appropriate map. |
| | | if (attrType.isOperational()) |
| | | { |
| | | addAttributeValue(operationalAttributes, attrType, attrName, attrValue); |
| | | } |
| | | else |
| | | { |
| | | addAttributeValue(userAttributes, attrType, attrName, attrValue); |
| | | } |
| | | addAttributeValue(attrType.isOperational() ? operationalAttributes : userAttributes, ava); |
| | | } |
| | | |
| | | |
| | |
| | | return new Entry(dn, objectClasses, userAttributes, operationalAttributes); |
| | | } |
| | | |
| | | private static String getObjectClassName(RDN rdn, int numAVAs) |
| | | private static String getObjectClassName(RDN rdn) |
| | | { |
| | | if (numAVAs == 1) |
| | | if (rdn.size() == 1) |
| | | { |
| | | final AttributeType attrType = rdn.getAttributeType(0); |
| | | final AttributeType attrType = rdn.getFirstAVA().getAttributeType(); |
| | | if (attrType.hasName(ATTR_C)) |
| | | { |
| | | return OC_COUNTRY; |
| | |
| | | return OC_UNTYPED_OBJECT_LC; |
| | | } |
| | | |
| | | private static void addAttributeValue(LinkedHashMap<AttributeType, List<Attribute>> attrs, |
| | | AttributeType attrType, String attrName, ByteString attrValue) |
| | | private static void addAttributeValue(LinkedHashMap<AttributeType, List<Attribute>> attrs, AVA ava) |
| | | { |
| | | AttributeType attrType = ava.getAttributeType(); |
| | | ByteString attrValue = ava.getAttributeValue(); |
| | | List<Attribute> attrList = attrs.get(attrType); |
| | | if (attrList != null && !attrList.isEmpty()) |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | AttributeBuilder builder = new AttributeBuilder(attrType, attrName); |
| | | AttributeBuilder builder = new AttributeBuilder(attrType, ava.getAttributeName()); |
| | | builder.add(attrValue); |
| | | attrs.put(attrType, builder.toAttributeList()); |
| | | } |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.AVA; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | |
| | | import org.opends.server.types.LockManager.DNLock; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.Privilege; |
| | | import org.opends.server.types.RDN; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.opends.server.types.operation.PostOperationAddOperation; |
| | | import org.opends.server.types.operation.PostResponseAddOperation; |
| | |
| | | */ |
| | | private void addRDNAttributesIfNecessary() throws DirectoryException |
| | | { |
| | | RDN rdn = entryDN.rdn(); |
| | | int numAVAs = rdn.getNumValues(); |
| | | for (int i=0; i < numAVAs; i++) |
| | | for (AVA ava : entryDN.rdn()) |
| | | { |
| | | AttributeType t = rdn.getAttributeType(i); |
| | | ByteString v = rdn.getAttributeValue(i); |
| | | String n = rdn.getAttributeName(i); |
| | | if (t.isOperational()) |
| | | { |
| | | addRDNAttributesIfNecessary(operationalAttributes, t, v, n); |
| | | } |
| | | else |
| | | { |
| | | addRDNAttributesIfNecessary(userAttributes, t, v, n); |
| | | } |
| | | AttributeType t = ava.getAttributeType(); |
| | | addRDNAttributesIfNecessary(t.isOperational() ? operationalAttributes : userAttributes, ava); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | private void addRDNAttributesIfNecessary( |
| | | Map<AttributeType, List<Attribute>> attributes, AttributeType t, |
| | | ByteString v, String n) throws DirectoryException |
| | | private void addRDNAttributesIfNecessary(Map<AttributeType, List<Attribute>> attributes, AVA ava) |
| | | throws DirectoryException |
| | | { |
| | | AttributeType t = ava.getAttributeType(); |
| | | String n = ava.getAttributeName(); |
| | | ByteString v = ava.getAttributeValue(); |
| | | final List<Attribute> attrList = attributes.get(t); |
| | | if (attrList == null) |
| | | { |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.AVA; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | |
| | | // If we should delete the old RDN values from the entry, then do so. |
| | | if (deleteOldRDN()) |
| | | { |
| | | RDN currentRDN = entryDN.rdn(); |
| | | int numValues = currentRDN.getNumValues(); |
| | | for (int i=0; i < numValues; i++) |
| | | for (AVA ava : entryDN.rdn()) |
| | | { |
| | | Attribute a = Attributes.create( |
| | | currentRDN.getAttributeType(i), |
| | | currentRDN.getAttributeName(i), |
| | | currentRDN.getAttributeValue(i)); |
| | | ava.getAttributeType(), |
| | | ava.getAttributeName(), |
| | | ava.getAttributeValue()); |
| | | |
| | | // If the associated attribute type is marked NO-USER-MODIFICATION, then |
| | | // refuse the update. |
| | |
| | | |
| | | |
| | | // Add the new RDN values to the entry. |
| | | int newRDNValues = newRDN.getNumValues(); |
| | | for (int i=0; i < newRDNValues; i++) |
| | | for (AVA ava : newRDN) |
| | | { |
| | | Attribute a = Attributes.create( |
| | | newRDN.getAttributeType(i), |
| | | newRDN.getAttributeName(i), |
| | | newRDN.getAttributeValue(i)); |
| | | ava.getAttributeType(), |
| | | ava.getAttributeName(), |
| | | ava.getAttributeValue()); |
| | | |
| | | List<ByteString> duplicateValues = new LinkedList<>(); |
| | | newEntry.addAttribute(a, duplicateValues); |
| | |
| | | ERR_MODDN_VIOLATES_SCHEMA.get(entryDN, invalidReason)); |
| | | } |
| | | |
| | | for (int i=0; i < newRDNValues; i++) |
| | | for (AVA ava : newRDN) |
| | | { |
| | | AttributeType at = newRDN.getAttributeType(i); |
| | | AttributeType at = ava.getAttributeType(); |
| | | if (at.isObsolete()) |
| | | { |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | |
| | | import javax.naming.ldap.LdapName; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.AdminTestCase; |
| | | import org.opends.server.admin.TestCfg; |
| | |
| | | import org.opends.server.admin.TestParentCfg; |
| | | import org.opends.server.admin.client.ldap.JNDIDirContextAdaptor; |
| | | import org.opends.server.admin.std.server.RootCfg; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.opends.server.types.DN; |
| | | import org.testng.Assert; |
| | | import org.testng.annotations.AfterClass; |
| | |
| | | // No implementation required. |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationAdd(TestChildCfg configuration) { |
| | | return new ConfigChangeResult(); |
| | | } |
| | |
| | | */ |
| | | public TestChildCfg getChild(String expectedName) { |
| | | Assert.assertNotNull(child); |
| | | Assert.assertEquals(child.dn().rdn().getAttributeValue(0).toString(), expectedName); |
| | | Assert.assertEquals(child.dn().rdn().getFirstAVA().getAttributeValue().toString(), expectedName); |
| | | return child; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationAddAcceptable(TestChildCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) { |
| | | child = configuration; |
| | | return true; |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | // No implementation required. |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange(TestChildCfg configuration) { |
| | | return new ConfigChangeResult(); |
| | | } |
| | |
| | | */ |
| | | public TestChildCfg getChild(String expectedName) { |
| | | Assert.assertNotNull(child); |
| | | Assert.assertEquals(child.dn().rdn().getAttributeValue(0).toString(), expectedName); |
| | | Assert.assertEquals(child.dn().rdn().getFirstAVA().getAttributeValue().toString(), expectedName); |
| | | return child; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable(TestChildCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) { |
| | | child = configuration; |
| | | return true; |
| | | } |
| | | |
| | | } |
| | | |
| | | /** Test child 1 LDIF. */ |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | | |
| | | |
| | | import java.util.ArrayList; |
| | | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.api.plugin.DirectoryServerPlugin; |
| | | import org.opends.server.api.plugin.PluginType; |
| | | import org.opends.server.types.DN; |
| | | |
| | | import static org.testng.Assert.*; |
| | | 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.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * A set of test cases for the plugin config manager. |
| | | */ |
| | | /** A set of test cases for the plugin config manager. */ |
| | | public class PluginConfigManagerTestCase |
| | | extends CoreTestCase |
| | | { |
| | |
| | | expectedOrder.append(expectedNameOrder[i]); |
| | | |
| | | DN dn = pluginArray[i].getPluginEntryDN(); |
| | | String name = dn.rdn().getAttributeValue(0).toString().toLowerCase(); |
| | | String name = dn.rdn().getFirstAVA().getAttributeValue().toString().toLowerCase(); |
| | | actualOrder.append(name); |
| | | |
| | | if (! name.equals(expectedNameOrder[i])) |
| | |
| | | import javax.naming.directory.InitialDirContext; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.AVA; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | |
| | | final Entry newEntry = DirectoryServer.getEntry(dn(entryDN)); |
| | | assertNotNull(newEntry); |
| | | |
| | | final RDN rdn = newEntry.getName().rdn(); |
| | | for (int i = 0; i < rdn.getNumValues(); i++) |
| | | for (AVA ava : newEntry.getName().rdn()) |
| | | { |
| | | AttributeType attribute = rdn.getAttributeType(i); |
| | | assertEquals(newEntry.hasValue(attribute, b("user.0")), user0Exists); |
| | | assertEquals(newEntry.hasValue(attribute, b("user.test0")), userTest0Exists); |
| | | AttributeType attrType = ava.getAttributeType(); |
| | | assertEquals(newEntry.hasValue(attrType, b("user.0")), user0Exists); |
| | | assertEquals(newEntry.hasValue(attrType, b("user.test0")), userTest0Exists); |
| | | } |
| | | } |
| | | |
| | |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Iterator; |
| | | |
| | | import org.forgerock.opendj.ldap.AVA; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.TestCaseUtils; |
| | |
| | | public void testConstructor() throws Exception { |
| | | RDN rdn = new RDN(AT_DC, AV_DC_ORG); |
| | | |
| | | assertEquals(rdn.getNumValues(), 1); |
| | | assertEquals(rdn.getAttributeType(0), AT_DC); |
| | | assertEquals(rdn.getAttributeName(0), AT_DC.getNameOrOID()); |
| | | assertEquals(rdn.getAttributeValue(0), AV_DC_ORG); |
| | | assertEquals(rdn.size(), 1); |
| | | AVA ava = rdn.getFirstAVA(); |
| | | assertEquals(ava.getAttributeType(), AT_DC); |
| | | assertEquals(ava.getAttributeName(), AT_DC.getNameOrOID()); |
| | | assertEquals(ava.getAttributeValue(), AV_DC_ORG); |
| | | } |
| | | |
| | | |
| | |
| | | public void testConstructorWithName() throws Exception { |
| | | RDN rdn = new RDN(AT_DC, "domainComponent", AV_DC_ORG); |
| | | |
| | | assertEquals(rdn.getNumValues(), 1); |
| | | assertEquals(rdn.getAttributeType(0), AT_DC); |
| | | assertEquals(rdn.getAttributeName(0), "domainComponent"); |
| | | assertEquals(rdn.getAttributeValue(0), AV_DC_ORG); |
| | | assertEquals(rdn.size(), 1); |
| | | AVA ava = rdn.getFirstAVA(); |
| | | assertEquals(ava.getAttributeType(), AT_DC); |
| | | assertEquals(ava.getAttributeName(), "domainComponent"); |
| | | assertEquals(ava.getAttributeValue(), AV_DC_ORG); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | RDN rdn = new RDN(attrTypes, attrNames, attrValues); |
| | | |
| | | assertEquals(rdn.getNumValues(), 2); |
| | | assertEquals(rdn.size(), 2); |
| | | |
| | | assertEquals(rdn.getAttributeType(0), AT_DC); |
| | | assertEquals(rdn.getAttributeName(0), AT_DC.getNameOrOID()); |
| | | assertEquals(rdn.getAttributeValue(0), AV_DC_ORG); |
| | | Iterator<AVA> it = rdn.iterator(); |
| | | AVA ava1 = it.next(); |
| | | AVA ava2 = it.next(); |
| | | |
| | | assertEquals(rdn.getAttributeType(1), AT_CN); |
| | | assertEquals(rdn.getAttributeName(1), AT_CN.getNameOrOID()); |
| | | assertEquals(rdn.getAttributeValue(1), AV_CN); |
| | | assertEquals(ava1.getAttributeType(), AT_DC); |
| | | assertEquals(ava1.getAttributeName(), AT_DC.getNameOrOID()); |
| | | assertEquals(ava1.getAttributeValue(), AV_DC_ORG); |
| | | |
| | | assertEquals(ava2.getAttributeType(), AT_CN); |
| | | assertEquals(ava2.getAttributeName(), AT_CN.getNameOrOID()); |
| | | assertEquals(ava2.getAttributeValue(), AV_CN); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | RDN rdn = new RDN(typeList, nameList, valueList); |
| | | |
| | | assertEquals(rdn.getNumValues(), 2); |
| | | assertEquals(rdn.size(), 2); |
| | | |
| | | assertEquals(rdn.getAttributeType(0), AT_DC); |
| | | assertEquals(rdn.getAttributeName(0), AT_DC.getNameOrOID()); |
| | | assertEquals(rdn.getAttributeValue(0), AV_DC_ORG); |
| | | Iterator<AVA> it = rdn.iterator(); |
| | | AVA ava1 = it.next(); |
| | | AVA ava2 = it.next(); |
| | | |
| | | assertEquals(rdn.getAttributeType(1), AT_CN); |
| | | assertEquals(rdn.getAttributeName(1), AT_CN.getNameOrOID()); |
| | | assertEquals(rdn.getAttributeValue(1), AV_CN); |
| | | assertEquals(ava1.getAttributeType(), AT_DC); |
| | | assertEquals(ava1.getAttributeName(), AT_DC.getNameOrOID()); |
| | | assertEquals(ava1.getAttributeValue(), AV_DC_ORG); |
| | | |
| | | assertEquals(ava2.getAttributeType(), AT_CN); |
| | | assertEquals(ava2.getAttributeName(), AT_CN.getNameOrOID()); |
| | | assertEquals(ava2.getAttributeValue(), AV_CN); |
| | | } |
| | | |
| | | |
| | |
| | | fail("Expected exception for value \"" + rawRDN + "\""); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Test getAttributeName. |
| | | * |
| | |
| | | |
| | | RDN rdn = new RDN(attrTypes, attrNames, attrValues); |
| | | |
| | | assertEquals(rdn.getAttributeName(0), AT_DC.getNameOrOID()); |
| | | assertEquals(rdn.getAttributeName(1), AT_CN.getNameOrOID()); |
| | | } |
| | | Iterator<AVA> it = rdn.iterator(); |
| | | AVA ava1 = it.next(); |
| | | AVA ava2 = it.next(); |
| | | |
| | | assertEquals(ava1.getAttributeName(), AT_DC.getNameOrOID()); |
| | | assertEquals(ava2.getAttributeName(), AT_CN.getNameOrOID()); |
| | | } |
| | | |
| | | @SuppressWarnings("javadoc") |
| | | @Test(expectedExceptions = IllegalArgumentException.class) |
| | |
| | | ByteString[] attrValues = { AV_DC_ORG, AV_CN }; |
| | | |
| | | RDN rdn = new RDN(attrTypes, attrNames, attrValues); |
| | | |
| | | assertEquals(rdn.getAttributeType(0), AT_DC); |
| | | assertEquals(rdn.getAttributeType(1), AT_CN); |
| | | Iterator<AVA> it = rdn.iterator(); |
| | | assertEquals(it.next().getAttributeType(), AT_DC); |
| | | assertEquals(it.next().getAttributeType(), AT_CN); |
| | | } |
| | | |
| | | /** |
| | |
| | | ByteString[] attrValues = { AV_DC_ORG, AV_CN }; |
| | | |
| | | RDN rdn = new RDN(attrTypes, attrNames, attrValues); |
| | | |
| | | assertEquals(rdn.getAttributeValue(0), AV_DC_ORG); |
| | | assertEquals(rdn.getAttributeValue(1), AV_CN); |
| | | Iterator<AVA> it = rdn.iterator(); |
| | | assertEquals(it.next().getAttributeValue(), AV_DC_ORG); |
| | | assertEquals(it.next().getAttributeValue(), AV_CN); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | |
| | | /** |
| | | * Test getNumValues. |
| | | * Test {@link RDN#size()}. |
| | | * |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test |
| | | public void testGetNumValues() throws Exception { |
| | | public void testSize() throws Exception { |
| | | RDN rdn = new RDN(AT_DC, AV_DC_ORG); |
| | | assertEquals(rdn.getNumValues(), 1); |
| | | assertEquals(rdn.size(), 1); |
| | | |
| | | rdn.addValue(AT_CN, AT_CN.getNameOrOID(), AV_CN); |
| | | assertEquals(rdn.getNumValues(), 2); |
| | | assertEquals(rdn.size(), 2); |
| | | } |
| | | |
| | | |
| | |
| | | @Test |
| | | public void testIsMultiValued() throws Exception { |
| | | RDN rdn = new RDN(AT_DC, AV_DC_ORG); |
| | | assertEquals(rdn.getNumValues(), 1); |
| | | assertEquals(rdn.size(), 1); |
| | | assertFalse(rdn.isMultiValued()); |
| | | |
| | | rdn.addValue(AT_CN, AT_CN.getNameOrOID(), AV_CN); |