AutoRefactor'ed simplify expressions
| | |
| | | } |
| | | } else { |
| | | // otherwise if DN or password is null, send back an error |
| | | if (((!authenticationIsID && (bindDN == null)) || bindPassword == null) |
| | | if (((!authenticationIsID && bindDN == null) || bindPassword == null) |
| | | && batchResponses.isEmpty()) { |
| | | batchResponses.add( |
| | | createErrorResponse(objFactory, |
| | |
| | | * Process optional authRequest (i.e. use authz) |
| | | */ |
| | | if (batchRequest.authRequest != null) { |
| | | if (authenticationIsID == true) { |
| | | if (authenticationIsID) { |
| | | // If we are using SASL, then use the bind authz. |
| | | connOptions.addSASLProperty("authzid=" + |
| | | batchRequest.authRequest.getPrincipal()); |
| | |
| | | |
| | | boolean throwException = false; |
| | | |
| | | if ((timeout > 0) && t.isAlive()) |
| | | if (timeout > 0 && t.isAlive()) |
| | | { |
| | | t.interrupt(); |
| | | try |
| | |
| | | throwException = true; |
| | | } |
| | | |
| | | if ((pair[0] == null) && (pair[1] == null)) |
| | | if (pair[0] == null && pair[1] == null) |
| | | { |
| | | throwException = true; |
| | | } |
| | |
| | | if (attrs != null) |
| | | { |
| | | Attribute attr = attrs.get(attrName); |
| | | if ((attr != null) && (attr.size() > 0)) |
| | | if (attr != null && attr.size() > 0) |
| | | { |
| | | Object o = attr.get(); |
| | | if (o instanceof String) |
| | |
| | | if (node instanceof SuffixNode) |
| | | { |
| | | String dn = node.getDN(); |
| | | return (Utilities.areDnsEqual(dn, ADSContext.getAdministrationSuffixDN()) || |
| | | return Utilities.areDnsEqual(dn, ADSContext.getAdministrationSuffixDN()) || |
| | | Utilities.areDnsEqual(dn, ConfigConstants.DN_DEFAULT_SCHEMA_ROOT) || |
| | | Utilities.areDnsEqual(dn, ConfigConstants.DN_TASK_ROOT) || |
| | | Utilities.areDnsEqual(dn, ConfigConstants.DN_CONFIG_ROOT) || |
| | | Utilities.areDnsEqual(dn, ConfigConstants.DN_MONITOR_ROOT) || |
| | | Utilities.areDnsEqual(dn, ConfigConstants.DN_TRUST_STORE_ROOT) || |
| | | Utilities.areDnsEqual(dn, ConfigConstants.DN_BACKUP_ROOT) || |
| | | Utilities.areDnsEqual(dn, DN_EXTERNAL_CHANGELOG_ROOT)); |
| | | Utilities.areDnsEqual(dn, DN_EXTERNAL_CHANGELOG_ROOT); |
| | | } |
| | | else |
| | | { |
| | |
| | | nodeChanged = updateNodeRendering(node, task.getDisplayedEntry()); |
| | | } |
| | | } |
| | | else if ((newState == NodeRefresher.State.CANCELLED) || |
| | | (newState == NodeRefresher.State.INTERRUPTED)) { |
| | | else if (newState == NodeRefresher.State.CANCELLED || |
| | | newState == NodeRefresher.State.INTERRUPTED) { |
| | | |
| | | // Let's collapse task.getNode() |
| | | tree.collapsePath(new TreePath(treeModel.getPathToRoot(node))); |
| | |
| | | do { |
| | | int waitingSize = waitingQueue.size(); |
| | | int i = 0; |
| | | while ((i < waitingSize) && !canBeFetched(i)) { |
| | | while (i < waitingSize && !canBeFetched(i)) { |
| | | i++; |
| | | } |
| | | if (i == waitingSize) { // Nothing found |
| | |
| | | public void setData(Set<BaseDNDescriptor> newData, |
| | | ServerDescriptor.ServerStatus status, boolean isAuthenticated) |
| | | { |
| | | if (!newData.equals(data) || (serverStatus != status) || |
| | | (this.isAuthenticated != isAuthenticated)) |
| | | if (!newData.equals(data) || serverStatus != status || this.isAuthenticated != isAuthenticated) |
| | | { |
| | | serverStatus = status; |
| | | this.isAuthenticated = isAuthenticated; |
| | |
| | | |
| | | private int compareRepl(BaseDNDescriptor desc1, BaseDNDescriptor desc2) |
| | | { |
| | | return (String.valueOf(desc1.getType()).compareTo( |
| | | String.valueOf(desc2.getType()))); |
| | | String val1 = String.valueOf(desc1.getType()); |
| | | String val2 = String.valueOf(desc2.getType()); |
| | | return val1.compareTo(val2); |
| | | } |
| | | |
| | | private int compareMissingChanges(BaseDNDescriptor desc1, |
| | |
| | | { |
| | | String sName = sr.getName(); |
| | | Name name; |
| | | if ((baseDN != null) && (baseDN.length() > 0)) |
| | | if (baseDN != null && baseDN.length() > 0) |
| | | { |
| | | if ((sName != null) && (sName.length() > 0)) |
| | | if (sName != null && sName.length() > 0) |
| | | { |
| | | name = new CompositeName(sName); |
| | | name.add(baseDN); |
| | |
| | | for (int i=0; i<name.size(); i++) |
| | | { |
| | | String n = name.get(i); |
| | | if ((buf.length() != 0) && (n != null) && (n.length() > 0)) |
| | | if (n != null && n.length() > 0) |
| | | { |
| | | buf.append(","); |
| | | } |
| | | if ((n != null) && (n.length() > 0)) |
| | | { |
| | | if (buf.length() != 0) |
| | | { |
| | | buf.append(","); |
| | | } |
| | | buf.append(n); |
| | | } |
| | | } |
| | |
| | | if (path != null && path.trim().length() > 0) |
| | | { |
| | | File f = new File(path); |
| | | while ((f != null) && !f.isDirectory()) |
| | | while (f != null && !f.isDirectory()) |
| | | { |
| | | f = f.getParentFile(); |
| | | } |
| | |
| | | /** {@inheritDoc} */ |
| | | public void focusGained(FocusEvent e) |
| | | { |
| | | if ((tf.getText() == null) || "".equals(tf.getText())) |
| | | if (tf.getText() == null || "".equals(tf.getText())) |
| | | { |
| | | tf.setText(" "); |
| | | tf.selectAll(); |
| | |
| | | controller.getTree().setSelectionPath(pathToSelect); |
| | | } |
| | | else if (!selectedPath.equals(pathToSelect) && |
| | | (pathToSelect.getPathCount() < selectedPath.getPathCount())) |
| | | pathToSelect.getPathCount() < selectedPath.getPathCount()) |
| | | { |
| | | controller.getTree().setSelectionPath(pathToSelect); |
| | | } |
| | |
| | | lastDn = dnToRemove; |
| | | |
| | | long t = System.currentTimeMillis(); |
| | | boolean canDelete = nToDelete > 0 && nToDelete > nDeleted; |
| | | boolean displayProgress = |
| | | (((nDeleted % 20) == 0) || ((t - lastProgressTime) > 5000)) && |
| | | (nToDelete > 0) && (nToDelete > nDeleted); |
| | | canDelete && ((nDeleted % 20) == 0 || t - lastProgressTime > 5000); |
| | | |
| | | if (displayProgress) |
| | | { |
| | |
| | | package org.opends.guitools.controlpanel.task; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | |
| | | import org.opends.guitools.controlpanel.ui.nodes.BasicNode; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.messages.AdminToolMessages; |
| | | import org.opends.server.config.ConfigConstants; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | |
| | |
| | | } |
| | | catch (OpenDsException ode) |
| | | { |
| | | throw new RuntimeException("Could not parse DN: "+oldEntry.getDN(), |
| | | ode); |
| | | throw new RuntimeException("Could not parse DN: " + oldEntry.getDN(), ode); |
| | | } |
| | | modifications = getModifications(newEntry, oldEntry, getInfo()); |
| | | // Find password modifications |
| | |
| | | /** {@inheritDoc} */ |
| | | public void postOperation() |
| | | { |
| | | if ((lastException == null) && (state == State.FINISHED_SUCCESSFULLY) && |
| | | (passwordModification != null)) |
| | | if (lastException == null |
| | | && state == State.FINISHED_SUCCESSFULLY |
| | | && passwordModification != null) |
| | | { |
| | | try |
| | | { |
| | |
| | | RDN oldRDN = oldDN.rdn(); |
| | | RDN newRDN = newEntry.getName().rdn(); |
| | | |
| | | boolean rdnTypeChanged = |
| | | newRDN.getNumValues() != oldRDN.getNumValues(); |
| | | |
| | | for (int i=0; (i<newRDN.getNumValues()) && !rdnTypeChanged; i++) { |
| | | boolean found = false; |
| | | for (int j=0; |
| | | (j<oldRDN.getNumValues()) && !found; j++) { |
| | | found = newRDN.getAttributeName(i).equalsIgnoreCase( |
| | | oldRDN.getAttributeName(j)); |
| | | } |
| | | rdnTypeChanged = !found; |
| | | if (rdnTypeChanged(oldRDN, newRDN) |
| | | && userChangedObjectclass(originalMods) |
| | | /* See if the original entry contains the new naming attribute(s) if it does we will be able |
| | | to perform the renaming and then the modifications without problem */ |
| | | && !entryContainsRdnTypes(originalEntry, newRDN)) |
| | | { |
| | | throw new CannotRenameException(AdminToolMessages.ERR_CANNOT_MODIFY_OBJECTCLASS_AND_RENAME.get()); |
| | | } |
| | | |
| | | if (rdnTypeChanged) { |
| | | /* Check if user changed the objectclass...*/ |
| | | boolean changedOc = false; |
| | | for (ModificationItem mod : originalMods) |
| | | { |
| | | Attribute attr = mod.getAttribute(); |
| | | changedOc = attr.getID().equalsIgnoreCase( |
| | | ConfigConstants.ATTR_OBJECTCLASS); |
| | | if (changedOc) |
| | | { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (changedOc) |
| | | { |
| | | /* See if the original entry contains the new |
| | | naming attribute(s) if it does we will be able |
| | | to perform the renaming and then the |
| | | modifications without problem */ |
| | | boolean entryContainsRdnTypes = true; |
| | | for (int i=0; (i<newRDN.getNumValues()) && entryContainsRdnTypes; i++) |
| | | { |
| | | List<Object> values = originalEntry.getAttributeValues( |
| | | newRDN.getAttributeName(i)); |
| | | entryContainsRdnTypes = !values.isEmpty(); |
| | | } |
| | | |
| | | if (!entryContainsRdnTypes) |
| | | { |
| | | throw new CannotRenameException( |
| | | AdminToolMessages.ERR_CANNOT_MODIFY_OBJECTCLASS_AND_RENAME.get()); |
| | | } |
| | | } |
| | | } |
| | | SwingUtilities.invokeLater(new Runnable() |
| | | { |
| | | public void run() |
| | |
| | | } |
| | | }); |
| | | |
| | | ctx.modifyAttributes(Utilities.getJNDIName(newEntry.getName().toString()), |
| | | mods); |
| | | ctx.modifyAttributes(Utilities.getJNDIName(newEntry.getName().toString()), mods); |
| | | |
| | | SwingUtilities.invokeLater(new Runnable() |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | private boolean rdnTypeChanged(RDN oldRDN, RDN newRDN) |
| | | { |
| | | if (newRDN.getNumValues() != oldRDN.getNumValues()) |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | for (int i = 0; i < newRDN.getNumValues(); i++) |
| | | { |
| | | if (!find(oldRDN, newRDN.getAttributeName(i))) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | private boolean find(RDN rdn, String attrName) |
| | | { |
| | | for (int j = 0; j < rdn.getNumValues(); j++) |
| | | { |
| | | if (attrName.equalsIgnoreCase(rdn.getAttributeName(j))) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | private boolean userChangedObjectclass(final ArrayList<ModificationItem> mods) |
| | | { |
| | | for (ModificationItem mod : mods) |
| | | { |
| | | if (ATTR_OBJECTCLASS.equalsIgnoreCase(mod.getAttribute().getID())) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | private boolean entryContainsRdnTypes(CustomSearchResult entry, RDN rdn) |
| | | { |
| | | for (int i = 0; i < rdn.getNumValues(); i++) |
| | | { |
| | | List<Object> values = entry.getAttributeValues(rdn.getAttributeName(i)); |
| | | if (!!values.isEmpty()) |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * Gets the modifications to apply between two entries. |
| | | * @param newEntry the new entry. |
| | |
| | | { |
| | | continue; |
| | | } |
| | | AttributeType attrType = schema.getAttributeType( |
| | | attr.getName().toLowerCase()); |
| | | AttributeType attrType = schema.getAttributeType(attr.getName().toLowerCase()); |
| | | if (attrType == null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType( |
| | | attr.getName().toLowerCase()); |
| | | attrType = DirectoryServer.getDefaultAttributeType(attr.getName().toLowerCase()); |
| | | } |
| | | List<ByteString> newValues = new ArrayList<>(); |
| | | Iterator<ByteString> it = attr.iterator(); |
| | |
| | | if (oldRDN.getAttributeName(i).equalsIgnoreCase(attrName)) |
| | | { |
| | | ByteString value = oldRDN.getAttributeValue(i); |
| | | boolean containsValue = false; |
| | | it = attr.iterator(); |
| | | while (it.hasNext()) |
| | | if (containsValue(attr, value)) |
| | | { |
| | | if (value.equals(it.next())) |
| | | { |
| | | containsValue = true; |
| | | break; |
| | | } |
| | | } |
| | | if (containsValue) |
| | | { |
| | | if ((rdnValue == null) || !rdnValue.equals(value)) |
| | | if (rdnValue == null || !rdnValue.equals(value)) |
| | | { |
| | | oldRdnValueToAdd = value; |
| | | } |
| | |
| | | { |
| | | toAdd.add(oldRdnValueToAdd); |
| | | } |
| | | if ((toDelete.size() + toAdd.size() >= newValues.size()) && |
| | | if (toDelete.size() + toAdd.size() >= newValues.size() && |
| | | !isAttributeInNewRdn) |
| | | { |
| | | modifications.add(new ModificationItem( |
| | |
| | | String attrNoOptions = |
| | | Utilities.getAttributeNameWithoutOptions(attrName).toLowerCase(); |
| | | |
| | | List<org.opends.server.types.Attribute> attrs = |
| | | newEntry.getAttribute(attrNoOptions); |
| | | boolean found = false; |
| | | if (attrs != null) |
| | | { |
| | | for (org.opends.server.types.Attribute attr : attrs) |
| | | { |
| | | if (attr.getNameWithOptions().equalsIgnoreCase(attrName)) |
| | | { |
| | | found = true; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | if (!found && !oldValues.isEmpty()) |
| | | List<org.opends.server.types.Attribute> attrs = newEntry.getAttribute(attrNoOptions); |
| | | if (!find(attrs, attrName) && !oldValues.isEmpty()) |
| | | { |
| | | modifications.add(new ModificationItem( |
| | | DirContext.REMOVE_ATTRIBUTE, |
| | |
| | | return modifications; |
| | | } |
| | | |
| | | private static boolean find(List<org.opends.server.types.Attribute> attrs, String attrName) |
| | | { |
| | | if (attrs != null) |
| | | { |
| | | for (org.opends.server.types.Attribute attr : attrs) |
| | | { |
| | | if (attr.getNameWithOptions().equalsIgnoreCase(attrName)) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | private static boolean containsValue(org.opends.server.types.Attribute attr, Object value) |
| | | { |
| | | for (Iterator<ByteString> it = attr.iterator(); it.hasNext();) |
| | | { |
| | | if (value.equals(it.next())) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * Creates a JNDI attribute using an attribute name and a set of values. |
| | | * @param attrName the attribute name. |
| | |
| | | { |
| | | InitialLdapContext ctx = |
| | | controller.findConnectionForDisplayedEntry(node); |
| | | if ((ctx != null) && isBoundAs(dn, ctx)) |
| | | if (ctx != null && isBoundAs(dn, ctx)) |
| | | { |
| | | currentPassword = ConnectionUtils.getBindPassword(ctx).toCharArray(); |
| | | } |
| | |
| | | try |
| | | { |
| | | ArrayList<String> arguments = getCommandLineArguments(); |
| | | |
| | | String[] args = new String[arguments.size()]; |
| | | |
| | | arguments.toArray(args); |
| | | |
| | | returnCode = LDAPPasswordModify.mainPasswordModify(args, false, |
| | |
| | | } |
| | | else |
| | | { |
| | | if ((lastException == null) && (currentPassword != null)) |
| | | if (lastException == null && currentPassword != null) |
| | | { |
| | | // The connections must be updated, just update the environment, which |
| | | // is what we use to clone connections and to launch scripts. |
| | |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.Set; |
| | | |
| | | import javax.naming.NamingException; |
| | |
| | | { |
| | | return OBFUSCATED_VALUE; |
| | | } |
| | | else |
| | | else if (o instanceof byte[]) |
| | | { |
| | | if (o instanceof byte[]) |
| | | byte[] bytes = (byte[])o; |
| | | if (displayBase64(attrName)) |
| | | { |
| | | byte[] bytes = (byte[])o; |
| | | if (displayBase64(attrName)) |
| | | if (bytes.length > MAX_BINARY_LENGTH_TO_DISPLAY) |
| | | { |
| | | if (bytes.length > MAX_BINARY_LENGTH_TO_DISPLAY) |
| | | { |
| | | return INFO_CTRL_PANEL_VALUE_IN_BASE64.get().toString(); |
| | | } |
| | | else |
| | | { |
| | | return Base64.encode(bytes); |
| | | } |
| | | return INFO_CTRL_PANEL_VALUE_IN_BASE64.get().toString(); |
| | | } |
| | | else |
| | | { |
| | | if (bytes.length > MAX_BINARY_LENGTH_TO_DISPLAY) |
| | | { |
| | | return INFO_CTRL_PANEL_BINARY_VALUE.get().toString(); |
| | | } |
| | | else |
| | | { |
| | | // Get the String value |
| | | ByteString v = ByteString.wrap(bytes); |
| | | return v.toString(); |
| | | } |
| | | return Base64.encode(bytes); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return String.valueOf(o); |
| | | if (bytes.length > MAX_BINARY_LENGTH_TO_DISPLAY) |
| | | { |
| | | return INFO_CTRL_PANEL_BINARY_VALUE.get().toString(); |
| | | } |
| | | else |
| | | { |
| | | // Get the String value |
| | | ByteString v = ByteString.wrap(bytes); |
| | | return v.toString(); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return String.valueOf(o); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | protected String obfuscateLDIFLine(String line) |
| | | { |
| | | String returnValue; |
| | | int index = line.indexOf(":"); |
| | | if (index != -1) |
| | | { |
| | | String attrName = line.substring(0, index).trim(); |
| | | |
| | | if (Utilities.mustObfuscate(attrName, |
| | | getInfo().getServerDescriptor().getSchema())) |
| | | { |
| | | returnValue = attrName + ": " + OBFUSCATED_VALUE; |
| | | } |
| | | else |
| | | { |
| | | returnValue = line; |
| | | return attrName + ": " + OBFUSCATED_VALUE; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | returnValue = line; |
| | | } |
| | | return returnValue; |
| | | return line; |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param incompatibilityReasons the list of incompatibility reasons that |
| | | * must be updated. |
| | | * @return <CODE>true</CODE> if the task that we are trying to launch can be |
| | | * launched in paralel with this task and <CODE>false</CODE> otherwise. |
| | | * launched in parallel with this task and <CODE>false</CODE> otherwise. |
| | | */ |
| | | public abstract boolean canLaunch(Task taskToBeLaunched, |
| | | Collection<LocalizableMessage> incompatibilityReasons); |
| | |
| | | { |
| | | binDir = f.getAbsolutePath(); |
| | | } |
| | | if (binDir.lastIndexOf(File.separatorChar) != (binDir.length() - 1)) |
| | | if (binDir.lastIndexOf(File.separatorChar) != binDir.length() - 1) |
| | | { |
| | | binDir += File.separatorChar; |
| | | } |
| | |
| | | */ |
| | | protected boolean runningOnSameServer(Task task) |
| | | { |
| | | boolean runningOnSameServer = false; |
| | | if (getServer().isLocal() && task.getServer().isLocal()) |
| | | { |
| | | runningOnSameServer = true; |
| | | return true; |
| | | } |
| | | else |
| | | |
| | | // Compare the host name and the instance path. This is safer than |
| | | // comparing ports: we might be running locally on a stopped instance with |
| | | // the same configuration as a "remote" (though located on the same machine) server. |
| | | String host1 = getServer().getHostname(); |
| | | String host2 = task.getServer().getHostname(); |
| | | boolean runningOnSameServer = host1 == null ? host2 == null : host1.equalsIgnoreCase(host2); |
| | | if (runningOnSameServer) |
| | | { |
| | | // Compare the host name and the instance path. This is safer than |
| | | // comparing ports: we might be running locally on a stopped instance with |
| | | // the same configuration as a "remote" (though located on the same |
| | | // machine) server. |
| | | String f1 = getServer().getInstancePath(); |
| | | String f2 = task.getServer().getInstancePath(); |
| | | |
| | | String host1 = getServer().getHostname(); |
| | | String host2 = task.getServer().getHostname(); |
| | | if (host1 == null) |
| | | { |
| | | runningOnSameServer = host2 == null; |
| | | } |
| | | else |
| | | { |
| | | runningOnSameServer = host1.equalsIgnoreCase(host2); |
| | | } |
| | | if (runningOnSameServer) |
| | | { |
| | | if (f1 == null) |
| | | { |
| | | runningOnSameServer = f2 == null; |
| | | } |
| | | else |
| | | { |
| | | runningOnSameServer = f1.equals(f2); |
| | | } |
| | | } |
| | | return Objects.equals(f1, f2); |
| | | } |
| | | return runningOnSameServer; |
| | | } |
| | |
| | | */ |
| | | protected String getCommandLinePath(String scriptBasicName) |
| | | { |
| | | String cmdLineName; |
| | | if (isWindows()) |
| | | { |
| | | cmdLineName = getBinaryDir()+scriptBasicName+".bat"; |
| | | return getBinaryDir() + scriptBasicName + ".bat"; |
| | | } |
| | | else |
| | | { |
| | | cmdLineName = getBinaryDir()+scriptBasicName; |
| | | } |
| | | return cmdLineName; |
| | | return getBinaryDir() + scriptBasicName; |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param clearArgs the arguments in clear. |
| | | * @return the list of obfuscated command-line arguments. |
| | | */ |
| | | protected List<String> getObfuscatedCommandLineArguments( |
| | | List<String> clearArgs) |
| | | protected List<String> getObfuscatedCommandLineArguments(List<String> clearArgs) |
| | | { |
| | | String[] toObfuscate = {"--bindPassword", "--currentPassword", |
| | | "--newPassword"}; |
| | | String[] toObfuscate = { "--bindPassword", "--currentPassword", "--newPassword" }; |
| | | ArrayList<String> args = new ArrayList<>(clearArgs); |
| | | for (int i=1; i<args.size(); i++) |
| | | { |
| | |
| | | { |
| | | ctx = getInfo().getUserDataDirContext(); |
| | | } |
| | | if (isServerRunning() && (ctx != null)) |
| | | if (isServerRunning() && ctx != null) |
| | | { |
| | | String hostName = localHostName; |
| | | if ((hostName == null) || !getInfo().getServerDescriptor().isLocal()) |
| | | if (hostName == null || !getInfo().getServerDescriptor().isLocal()) |
| | | { |
| | | hostName = ConnectionUtils.getHostName(ctx); |
| | | } |
| | |
| | | args.removeAll(getConfigCommandLineArguments()); |
| | | return getEquivalentCommandLine(cmdLineName, args); |
| | | } |
| | | else |
| | | { |
| | | return null; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | |
| | | ArrayList<String> args = new ArrayList<>(getObfuscatedCommandLineArguments( |
| | | getConnectionCommandLineArguments(useAdminCtx, true))); |
| | | args.add(getNoPropertiesFileArgument()); |
| | | String equiv = getEquivalentCommandLine(getCommandLinePath("ldapmodify"), |
| | | args); |
| | | String equiv = getEquivalentCommandLine(getCommandLinePath("ldapmodify"), args); |
| | | |
| | | StringBuilder sb = new StringBuilder(); |
| | | sb.append(INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_MODIFY.get()).append("<br><b>"); |
| | |
| | | ArrayList<String> args = new ArrayList<>(getObfuscatedCommandLineArguments( |
| | | getConnectionCommandLineArguments(useAdminCtx, true))); |
| | | args.add(getNoPropertiesFileArgument()); |
| | | String equiv = getEquivalentCommandLine(getCommandLinePath("ldapmodify"), |
| | | args); |
| | | String equiv = getEquivalentCommandLine(getCommandLinePath("ldapmodify"), args); |
| | | StringBuilder sb = new StringBuilder(); |
| | | sb.append(INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_RENAME.get()).append("<br><b>"); |
| | | sb.append(equiv); |
| | |
| | | public void mouseReleased(MouseEvent ev) |
| | | { |
| | | int selectedRow = table.getSelectedRow(); |
| | | if ((selectedRow != -1) && (lastRowMouseOver == selectedRow)) |
| | | if (selectedRow != -1 && lastRowMouseOver == selectedRow) |
| | | { |
| | | AbstractIndexDescriptor index = tableModel.getIndexAt(selectedRow); |
| | | final IndexSelectionEvent ise = new IndexSelectionEvent(table, index); |
| | |
| | | /** {@inheritDoc} */ |
| | | public void keyTyped(KeyEvent ev) |
| | | { |
| | | if ((ev.getKeyChar() == KeyEvent.VK_SPACE) || |
| | | (ev.getKeyChar() == KeyEvent.VK_ENTER)) |
| | | if (ev.getKeyChar() == KeyEvent.VK_SPACE || |
| | | ev.getKeyChar() == KeyEvent.VK_ENTER) |
| | | { |
| | | usedBySelected(); |
| | | } |
| | |
| | | } |
| | | |
| | | String parentPath = parentDirectory.getText(); |
| | | if ((parentPath == null) || (parentPath.trim().equals(""))) |
| | | if (parentPath == null || parentPath.trim().equals("")) |
| | | { |
| | | errors.add(ERR_CTRL_PANEL_NO_BACKUP_PATH_PROVIDED.get()); |
| | | setPrimaryInvalid(lPath); |
| | |
| | | } |
| | | } |
| | | String dir = backupID.getText(); |
| | | if ((dir == null) || (dir.trim().equals(""))) |
| | | if (dir == null || dir.trim().equals("")) |
| | | { |
| | | errors.add(ERR_CTRL_PANEL_NO_BACKUP_ID_PROVIDED.get()); |
| | | setPrimaryInvalid(lBackupID); |
| | |
| | | { |
| | | if (isLocal()) |
| | | { |
| | | boolean selected = backupList.isVisible() && |
| | | (getSelectedBackup() != null); |
| | | boolean selected = backupList.isVisible() && getSelectedBackup() != null; |
| | | if (!selected) |
| | | { |
| | | errors.add(ERR_CTRL_PANEL_NO_PARENT_BACKUP_SELECTED.get()); |
| | |
| | | else |
| | | { |
| | | String parentID = parentBackupID.getText(); |
| | | if ((parentID == null) || (parentID.trim().equals(""))) |
| | | if (parentID == null || parentID.trim().equals("")) |
| | | { |
| | | errors.add(ERR_CTRL_PANEL_NO_PARENT_BACKUP_ID_PROVIDED.get()); |
| | | setPrimaryInvalid(lParentID); |
| | |
| | | String f = file.getText(); |
| | | if (f.trim().length() == 0) |
| | | { |
| | | if (hasImageSyntax(attrName.getText()) && (oldValue != null) && |
| | | !updateImage) |
| | | if (hasImageSyntax(attrName.getText()) && oldValue != null && !updateImage) |
| | | { |
| | | // Do nothing. We do not want to regenerate the image and we |
| | | // are on the case where the user simply did not change the image. |
| | |
| | | /** |
| | | * The pane that is displayed when the user clicks on 'Browse Entries...'. |
| | | * It contains its own menu bar with all the actions to edit the entries. |
| | | * |
| | | */ |
| | | public class BrowseEntriesPanel extends AbstractBrowseEntriesPanel |
| | | { |
| | |
| | | } |
| | | ignoreTreeSelectionEvents = false; |
| | | } |
| | | if ((paths != null) && (paths.length == 1)) |
| | | if (paths != null && paths.length == 1) |
| | | { |
| | | path = paths[0]; |
| | | } |
| | | |
| | | // Update menu items |
| | | boolean enableDelete = false; |
| | | if ((paths != null) && (paths.length > 0)) |
| | | { |
| | | enableDelete = true; |
| | | for (TreePath p : paths) |
| | | { |
| | | BasicNode n = (BasicNode)p.getLastPathComponent(); |
| | | enableDelete = entryPane.canDelete(n.getDN()); |
| | | if (!enableDelete) |
| | | { |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | boolean enableDelete = enableDelete(paths); |
| | | popupDeleteMenuItem.setEnabled(enableDelete); |
| | | menuBar.deleteMenuItem.setEnabled(enableDelete); |
| | | |
| | |
| | | menuBar.resetPasswordMenuItem.setEnabled(enableResetPassword); |
| | | |
| | | // Assume that if we cannot delete, we cannot create a new path |
| | | boolean enableNewEntry = (path != null) && enableDelete; |
| | | boolean enableNewEntry = path != null && enableDelete; |
| | | popupNewUserMenuItem.setEnabled(enableNewEntry); |
| | | menuBar.newUserMenuItem.setEnabled(enableNewEntry); |
| | | |
| | |
| | | |
| | | updateRightPane(paths); |
| | | } |
| | | |
| | | private boolean enableDelete(TreePath[] paths) |
| | | { |
| | | if (paths != null && paths.length > 0) |
| | | { |
| | | for (TreePath p : paths) |
| | | { |
| | | BasicNode n = (BasicNode)p.getLastPathComponent(); |
| | | if (!entryPane.canDelete(n.getDN())) |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | }; |
| | | tree.getSelectionModel().addTreeSelectionListener(treeSelectionListener); |
| | | } |
| | |
| | | private void updateRightPane(TreePath[] paths) |
| | | { |
| | | TreePath path = null; |
| | | if ((paths != null) && (paths.length == 1)) |
| | | if (paths != null && paths.length == 1) |
| | | { |
| | | path = paths[0]; |
| | | } |
| | |
| | | else |
| | | { |
| | | stopCurrentReader(); |
| | | if ((paths != null) && (paths.length > 1)) |
| | | if (paths != null && paths.length > 1) |
| | | { |
| | | entryPane.multipleEntriesSelected(); |
| | | } |
| | |
| | | private void startReader(LDAPEntryReader reader) |
| | | { |
| | | entryReader = reader; |
| | | if ((entryReaderThread == null) || !entryReaderThread.isAlive()) |
| | | if (entryReaderThread == null || !entryReaderThread.isAlive()) |
| | | { |
| | | entryReaderThread = new Thread(new Runnable() |
| | | { |
| | |
| | | Utilities.getParentDialog(this)); |
| | | } |
| | | TreePath[] paths = treePane.getTree().getSelectionPaths(); |
| | | if ((paths != null) && (paths.length == 1)) |
| | | if (paths != null && paths.length == 1) |
| | | { |
| | | TreePath path = paths[0]; |
| | | BasicNode node = (BasicNode)path.getLastPathComponent(); |
| | |
| | | } |
| | | TreePath[] paths = treePane.getTree().getSelectionPaths(); |
| | | BasicNode parentNode = null; |
| | | if ((paths != null) && (paths.length == 1)) |
| | | if (paths != null && paths.length == 1) |
| | | { |
| | | TreePath path = paths[0]; |
| | | parentNode = (BasicNode)path.getLastPathComponent(); |
| | |
| | | } |
| | | TreePath[] paths = treePane.getTree().getSelectionPaths(); |
| | | BasicNode parentNode = null; |
| | | if ((paths != null) && (paths.length == 1)) |
| | | if (paths != null && paths.length == 1) |
| | | { |
| | | TreePath path = paths[0]; |
| | | parentNode = (BasicNode)path.getLastPathComponent(); |
| | |
| | | } |
| | | TreePath[] paths = treePane.getTree().getSelectionPaths(); |
| | | BasicNode parentNode = null; |
| | | if ((paths != null) && (paths.length == 1)) |
| | | if (paths != null && paths.length == 1) |
| | | { |
| | | TreePath path = paths[0]; |
| | | parentNode = (BasicNode)path.getLastPathComponent(); |
| | |
| | | } |
| | | TreePath[] paths = treePane.getTree().getSelectionPaths(); |
| | | BasicNode parentNode = null; |
| | | if ((paths != null) && (paths.length == 1)) |
| | | if (paths != null && paths.length == 1) |
| | | { |
| | | TreePath path = paths[0]; |
| | | parentNode = (BasicNode)path.getLastPathComponent(); |
| | |
| | | } |
| | | TreePath[] paths = treePane.getTree().getSelectionPaths(); |
| | | BasicNode parentNode = null; |
| | | if ((paths != null) && (paths.length == 1)) |
| | | if (paths != null && paths.length == 1) |
| | | { |
| | | TreePath path = paths[0]; |
| | | parentNode = (BasicNode)path.getLastPathComponent(); |
| | |
| | | } |
| | | TreePath[] paths = treePane.getTree().getSelectionPaths(); |
| | | BasicNode parentNode = null; |
| | | if ((paths != null) && (paths.length == 1)) |
| | | if (paths != null && paths.length == 1) |
| | | { |
| | | TreePath path = paths[0]; |
| | | parentNode = (BasicNode)path.getLastPathComponent(); |
| | |
| | | } |
| | | TreePath[] paths = treePane.getTree().getSelectionPaths(); |
| | | BasicNode node = null; |
| | | if ((paths != null) && (paths.length == 1)) |
| | | if (paths != null && paths.length == 1) |
| | | { |
| | | TreePath path = paths[0]; |
| | | node = (BasicNode)path.getLastPathComponent(); |
| | |
| | | ArrayList<LocalizableMessage> errors = new ArrayList<>(); |
| | | TreePath[] paths = treePane.getTree().getSelectionPaths(); |
| | | |
| | | if ((paths != null) && (paths.length > 0)) |
| | | if (paths != null && paths.length > 0) |
| | | { |
| | | ProgressDialog dlg = new ProgressDialog( |
| | | Utilities.createFrame(), |
| | |
| | | boolean isInterruptedException = false; |
| | | isInterruptedException = t instanceof java.io.InterruptedIOException || |
| | | t instanceof InterruptedNamingException; |
| | | while ((t != null) && !isInterruptedException) |
| | | while (t != null && !isInterruptedException) |
| | | { |
| | | t = t.getCause(); |
| | | isInterruptedException = t instanceof java.io.InterruptedIOException || |
| | |
| | | { |
| | | TreePath[] paths = treePane.getTree().getSelectionPaths(); |
| | | TreePath path = null; |
| | | if ((paths != null) && (paths.length == 1)) |
| | | if (paths != null && paths.length == 1) |
| | | { |
| | | path = paths[0]; |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | if ((paths != null) && (paths.length > 1)) |
| | | if (paths != null && paths.length > 1) |
| | | { |
| | | entryPane.displayMessage(MULTIPLE_ITEMS_SELECTED); |
| | | } |
| | |
| | | public void itemStateChanged(ItemEvent ev) |
| | | { |
| | | if (!ignoreSelectionEvents && |
| | | (ev.getStateChange() == ItemEvent.SELECTED)) |
| | | ev.getStateChange() == ItemEvent.SELECTED) |
| | | { |
| | | repopulateTree(treePane.getTree()); |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | expand = tree.isExpanded(new TreePath(parent)) || |
| | | (parent.getChildCount() == 0); |
| | | expand = tree.isExpanded(new TreePath(parent)) || parent.getChildCount() == 0; |
| | | parent.removeAllChildren(); |
| | | } |
| | | for (AbstractIndexTreeNode node : nodes.get(i)) |
| | | { |
| | | parent.add(node); |
| | | if ((newSelectionPath == null) && |
| | | ((lastSelectedNode != null) || (lastCreatedIndex != null))) |
| | | if (newSelectionPath == null && |
| | | (lastSelectedNode != null || lastCreatedIndex != null)) |
| | | { |
| | | if (lastCreatedIndex != null) |
| | | { |
| | | if ((node instanceof IndexTreeNode) && |
| | | (lastCreatedIndex instanceof IndexDescriptor)) |
| | | if (node instanceof IndexTreeNode && |
| | | lastCreatedIndex instanceof IndexDescriptor) |
| | | { |
| | | if (node.getName().equals(lastCreatedIndex.getName())) |
| | | { |
| | |
| | | ViewPositions pos = Utilities.getViewPositions(entryPane); |
| | | TreePath[] paths = treePane.getTree().getSelectionPaths(); |
| | | TreePath path = null; |
| | | if ((paths != null) && (paths.length == 1)) |
| | | if (paths != null && paths.length == 1) |
| | | { |
| | | path = paths[0]; |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | if ((paths != null) && (paths.length > 1)) |
| | | if (paths != null && paths.length > 1) |
| | | { |
| | | entryPane.displayMultiple(); |
| | | } |
| | |
| | | Color bg = Color.white; |
| | | try |
| | | { |
| | | if ((foreground.getGreen() + foreground.getRed() + foreground.getBlue()) > |
| | | (200 * 3)) |
| | | if (foreground.getGreen() + foreground.getRed() + foreground.getBlue() > 200 * 3) |
| | | { |
| | | // This is done to avoid problem in high contrast UIs |
| | | bg = UIManager.getColor("TextField.background"); |
| | |
| | | @Override |
| | | public void keyTyped(KeyEvent ev) |
| | | { |
| | | if ((ev.getKeyChar() == KeyEvent.VK_SPACE) || |
| | | (ev.getKeyChar() == KeyEvent.VK_ENTER)) |
| | | if (ev.getKeyChar() == KeyEvent.VK_SPACE || |
| | | ev.getKeyChar() == KeyEvent.VK_ENTER) |
| | | { |
| | | objectClassSelected(list); |
| | | } |
| | |
| | | } |
| | | |
| | | List<Syntax> newSyntaxes = new ArrayList<>(syntaxNameMap.values()); |
| | | updateComboBoxModel(newSyntaxes, |
| | | ((DefaultComboBoxModel)syntax.getModel())); |
| | | updateComboBoxModel(newSyntaxes, (DefaultComboBoxModel) syntax.getModel()); |
| | | |
| | | Map<String, AttributeType> attributeNameMap = new TreeMap<>(lowerCase); |
| | | for (String key : schema.getAttributeTypes().keySet()) |
| | |
| | | List<Object> newParents = new ArrayList<>(); |
| | | newParents.addAll(attributeNameMap.values()); |
| | | newParents.add(0, NO_PARENT); |
| | | updateComboBoxModel(newParents, |
| | | ((DefaultComboBoxModel)parent.getModel())); |
| | | updateComboBoxModel(newParents, (DefaultComboBoxModel) parent.getModel()); |
| | | |
| | | final Map<String, MatchingRule> matchingRuleNameMap = new TreeMap<>(lowerCase); |
| | | for (String key : schema.getMatchingRules().keySet()) |
| | |
| | | ignoreChangeEvents = true; |
| | | |
| | | objectClass = oc; |
| | | if ((oc == null) || (schema == null)) |
| | | if (oc == null || schema == null) |
| | | { |
| | | // Ignore: this is called to get an initial panel size. |
| | | return; |
| | |
| | | public void changedUpdate(DocumentEvent ev) |
| | | { |
| | | String text = file.getText().trim(); |
| | | setEnabledOK((text != null) && (text.length() > 0) && |
| | | !errorPane.isVisible()); |
| | | setEnabledOK(text != null && text.length() > 0 && !errorPane.isVisible()); |
| | | } |
| | | /** {@inheritDoc} */ |
| | | public void removeUpdate(DocumentEvent ev) |
| | |
| | | } |
| | | |
| | | String ldifPath = file.getText(); |
| | | if ((ldifPath == null) || (ldifPath.trim().equals(""))) |
| | | if (ldifPath == null || ldifPath.trim().equals("")) |
| | | { |
| | | errors.add(INFO_NO_LDIF_PATH.get()); |
| | | setPrimaryInvalid(lFile); |
| | |
| | | INFO_CTRL_PANEL_CONFIRMATION_EXPORT_LDIF_DETAILS.get(ldifPath)); |
| | | } |
| | | } |
| | | if ((errors.isEmpty()) && confirmed) |
| | | if (errors.isEmpty() && confirmed) |
| | | { |
| | | launchOperation(newTask, |
| | | INFO_CTRL_PANEL_EXPORTING_LDIF_SUMMARY.get(backends.getSelectedItem()), |
| | |
| | | for (int i=0; i < container.getComponentCount(); i++) |
| | | { |
| | | Component comp = container.getComponent(i); |
| | | if ((comp instanceof AbstractButton) || |
| | | (comp instanceof JTextComponent) || |
| | | (comp instanceof JList) || |
| | | (comp instanceof JComboBox) || |
| | | (comp instanceof JTable)) |
| | | if (comp instanceof AbstractButton || |
| | | comp instanceof JTextComponent || |
| | | comp instanceof JList || |
| | | comp instanceof JComboBox || |
| | | comp instanceof JTable) |
| | | { |
| | | comp.addFocusListener(focusListener); |
| | | } |
| | | else if ((comp instanceof JPanel) || (comp instanceof JScrollPane) |
| | | || (comp instanceof JViewport)) |
| | | else if (comp instanceof JPanel || comp instanceof JScrollPane |
| | | || comp instanceof JViewport) |
| | | { |
| | | addFocusListener(focusListener, (Container)comp); |
| | | } |
| | |
| | | { |
| | | lastComponentWithFocus = panel.getPreferredFocusComponent(); |
| | | } |
| | | if (visible && (lastComponentWithFocus != null) && |
| | | lastComponentWithFocus.isVisible()) |
| | | if (visible && lastComponentWithFocus != null && lastComponentWithFocus.isVisible()) |
| | | { |
| | | if (lastComponentWithFocus == null) |
| | | { |
| | |
| | | for (int i=0; i < container.getComponentCount(); i++) |
| | | { |
| | | Component comp = container.getComponent(i); |
| | | if ((comp instanceof AbstractButton) || |
| | | (comp instanceof JTextComponent) || |
| | | (comp instanceof JList) || |
| | | (comp instanceof JComboBox) || |
| | | (comp instanceof JTable)) |
| | | if (comp instanceof AbstractButton || |
| | | comp instanceof JTextComponent || |
| | | comp instanceof JList || |
| | | comp instanceof JComboBox || |
| | | comp instanceof JTable) |
| | | { |
| | | comp.addFocusListener(focusListener); |
| | | } |
| | | else if ((comp instanceof JPanel) || (comp instanceof JScrollPane) |
| | | || (comp instanceof JViewport)) |
| | | else if (comp instanceof JPanel || comp instanceof JScrollPane |
| | | || comp instanceof JViewport) |
| | | { |
| | | addFocusListener(focusListener, (Container)comp); |
| | | } |
| | |
| | | { |
| | | lastComponentWithFocus = panel.getPreferredFocusComponent(); |
| | | } |
| | | if (visible && (lastComponentWithFocus != null)) |
| | | if (visible && lastComponentWithFocus != null) |
| | | { |
| | | lastComponentWithFocus.requestFocusInWindow(); |
| | | } |
| | |
| | | public void changedUpdate(DocumentEvent ev) |
| | | { |
| | | String text = file.getText().trim(); |
| | | setEnabledOK((text != null) && (text.length() > 0) && |
| | | !errorPane.isVisible()); |
| | | setEnabledOK(text != null && text.length() > 0 && !errorPane.isVisible()); |
| | | } |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | |
| | | } |
| | | |
| | | s = filter.getText(); |
| | | if ((s != null) && (s.trim().length() > 0)) |
| | | if (s != null && s.trim().length() > 0) |
| | | { |
| | | try |
| | | { |
| | |
| | | } |
| | | |
| | | String v = properties.getProperty("overwrite-env-java-home"); |
| | | readUseOpenDSJavaHome = |
| | | (v == null) || ("false".equalsIgnoreCase(v.trim())); |
| | | readUseOpenDSJavaHome = v == null || "false".equalsIgnoreCase(v.trim()); |
| | | v = properties.getProperty("overwrite-env-java-args"); |
| | | readUseOpenDSJavaArgs = |
| | | (v == null) || ("false".equalsIgnoreCase(v.trim())); |
| | | readUseOpenDSJavaArgs = v == null || "false".equalsIgnoreCase(v.trim()); |
| | | |
| | | readJavaHome = properties.getProperty("default.java-home"); |
| | | if (readJavaHome == null) |
| | |
| | | { |
| | | jvms = new String[]{userJVM}; |
| | | } |
| | | else if ((userJVM != null) && (userJVM.trim().length() > 0)) |
| | | else if (userJVM != null && userJVM.trim().length() > 0) |
| | | { |
| | | jvms = new String[]{defaultJVM, userJVM}; |
| | | } |
| | |
| | | while ((line = reader.readLine()) != null) |
| | | { |
| | | String trimmedLine = line.trim(); |
| | | if (trimmedLine.startsWith("#") || (trimmedLine.length() == 0)) |
| | | if (trimmedLine.startsWith("#") || trimmedLine.length() == 0) |
| | | { |
| | | commentLines.add(line); |
| | | } |
| | |
| | | writer.write("overwrite-env-java-args="+overwriteOpenDSJavaArgs); |
| | | writer.newLine(); |
| | | writer.newLine(); |
| | | if ((defaultJavaHome != null) && (defaultJavaHome.length() > 0)) |
| | | if (defaultJavaHome != null && defaultJavaHome.length() > 0) |
| | | { |
| | | writer.write("default.java-home="+defaultJavaHome); |
| | | writer.newLine(); |
| | |
| | | { |
| | | boolean isReadOnly = true; |
| | | boolean canDelete = false; |
| | | if ((searchResult != null) && desc.isAuthenticated()) |
| | | if (searchResult != null && desc.isAuthenticated()) |
| | | { |
| | | isReadOnly = isReadOnly(searchResult.getDN()); |
| | | canDelete = canDelete(searchResult.getDN()); |
| | |
| | | */ |
| | | public boolean mustCheckUnsavedChanges() |
| | | { |
| | | return (displayedEntryPanel != null) && |
| | | return displayedEntryPanel != null && |
| | | saveChanges.isVisible() && saveChanges.isEnabled(); |
| | | } |
| | | |
| | |
| | | if (result == UnsavedChangesDialog.Result.SAVE) |
| | | { |
| | | saveChanges(false); |
| | | if ((newTask == null) || // The user data is not valid |
| | | if (newTask == null || // The user data is not valid |
| | | newTask.getState() != Task.State.FINISHED_SUCCESSFULLY) |
| | | { |
| | | result = UnsavedChangesDialog.Result.CANCEL; |
| | |
| | | public void valueChanged(TreeSelectionEvent ev) |
| | | { |
| | | TreePath[] paths = tree.getSelectionPaths(); |
| | | setEnabledOK((paths != null) && (paths.length > 0)); |
| | | setEnabledOK(paths != null && paths.length > 0); |
| | | } |
| | | }); |
| | | MouseListener mouseListener = new MouseAdapter() { |
| | |
| | | @Override |
| | | public void mousePressed(MouseEvent e) { |
| | | int selRow = tree.getRowForLocation(e.getX(), e.getY()); |
| | | if ((selRow != -1) && (e.getClickCount() == 2)) |
| | | if (selRow != -1 && e.getClickCount() == 2) |
| | | { |
| | | okClicked(); |
| | | } |
| | |
| | | @Override |
| | | public void keyTyped(KeyEvent ev) |
| | | { |
| | | if ((ev.getKeyChar() == KeyEvent.VK_SPACE) || |
| | | (ev.getKeyChar() == KeyEvent.VK_ENTER)) |
| | | if (ev.getKeyChar() == KeyEvent.VK_SPACE || |
| | | ev.getKeyChar() == KeyEvent.VK_ENTER) |
| | | { |
| | | usedBySelected(); |
| | | } |
| | |
| | | catch (Throwable th) |
| | | { |
| | | } |
| | | if ((t <= 0) || (t > MAX_VALUE)) |
| | | if (t <= 0 || t > MAX_VALUE) |
| | | { |
| | | errors.add(INFO_CTRL_PANEL_INVALID_PERIOD_VALUE.get(MAX_VALUE)); |
| | | } |
| | |
| | | public void valueChanged(ListSelectionEvent ev) |
| | | { |
| | | BackupDescriptor backup = getSelectedBackup(); |
| | | setEnabledOK((backup != null) && !errorPane.isVisible()); |
| | | setEnabledOK(backup != null && !errorPane.isVisible()); |
| | | } |
| | | }; |
| | | backupList.getSelectionModel().addListSelectionListener(listener); |
| | |
| | | |
| | | if (isLocal()) |
| | | { |
| | | boolean selected = backupList.isVisible() && (backup != null); |
| | | boolean selected = backupList.isVisible() && backup != null; |
| | | if (!selected) |
| | | { |
| | | if (backupList.getRowCount() == 0) |
| | |
| | | else |
| | | { |
| | | String parentPath = parentDirectory.getText(); |
| | | if ((parentPath == null) || (parentPath.trim().equals(""))) |
| | | if (parentPath == null || parentPath.trim().equals("")) |
| | | { |
| | | errors.add(ERR_CTRL_PANEL_NO_BACKUP_PATH_PROVIDED.get()); |
| | | setPrimaryInvalid(lPath); |
| | | } |
| | | |
| | | String id = backupID.getText(); |
| | | if ((id == null) || (id.trim().equals(""))) |
| | | if (id == null || id.trim().equals("")) |
| | | { |
| | | errors.add(ERR_CTRL_PANEL_NO_BACKUP_ID_PROVIDED.get()); |
| | | setPrimaryInvalid(lBackupID); |
| | |
| | | INFO_CTRL_PANEL_CONFIRM_RESTORE_DETAILS.get()); |
| | | } |
| | | |
| | | if ((errors.isEmpty()) && confirmed) |
| | | if (errors.isEmpty() && confirmed) |
| | | { |
| | | launchOperation(newTask, |
| | | INFO_CTRL_PANEL_RESTORING_SUMMARY.get(backup.getID()), |
| | |
| | | */ |
| | | public boolean mustCheckUnsavedChanges() |
| | | { |
| | | return (schemaElementPanel != null) && |
| | | schemaElementPanel.mustCheckUnsavedChanges(); |
| | | return schemaElementPanel != null && schemaElementPanel.mustCheckUnsavedChanges(); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public UnsavedChangesDialog.Result checkUnsavedChanges() |
| | | { |
| | | if (schemaElementPanel == null) |
| | | { |
| | | return UnsavedChangesDialog.Result.DO_NOT_SAVE; |
| | | } |
| | | else |
| | | if (schemaElementPanel != null) |
| | | { |
| | | return schemaElementPanel.checkUnsavedChanges(); |
| | | } |
| | | return UnsavedChangesDialog.Result.DO_NOT_SAVE; |
| | | } |
| | | } |
| | |
| | | public void update(CustomSearchResult sr, boolean isReadOnly, TreePath path) |
| | | { |
| | | boolean sameEntry = false; |
| | | if ((searchResult != null) && (sr != null)) |
| | | if (searchResult != null && sr != null) |
| | | { |
| | | sameEntry = searchResult.getDN().equals(sr.getDN()); |
| | | } |
| | |
| | | { |
| | | gbc.anchor = GridBagConstraints.WEST; |
| | | } |
| | | else if ((values.size() <= 1) && |
| | | else if (values.size() <= 1 && |
| | | (hasBinaryValue(values) || isBinary(attr))) |
| | | { |
| | | gbc.anchor = GridBagConstraints.WEST; |
| | |
| | | /** {@inheritDoc} */ |
| | | public void run() |
| | | { |
| | | if ((p != null) && (scrollAttributes.getViewport().contains(p))) |
| | | if (p != null && scrollAttributes.getViewport().contains(p)) |
| | | { |
| | | scrollAttributes.getViewport().setViewPosition(p); |
| | | } |
| | |
| | | basicAttrName = attrName.substring(0, index); |
| | | subType = attrName.substring(index + 1); |
| | | } |
| | | if ((subType != null) && (subType.equalsIgnoreCase("binary"))) |
| | | if (subType != null && subType.equalsIgnoreCase("binary")) |
| | | { |
| | | // TODO: use message |
| | | subType = "binary"; |
| | |
| | | Utilities.centerGoldenMean(editOcDlg, |
| | | Utilities.getParentDialog(SimplifiedViewEntryPanel.this)); |
| | | } |
| | | if ((newValue == null) && (ocDescriptor != null)) |
| | | if (newValue == null && ocDescriptor != null) |
| | | { |
| | | editOcPanel.setValue(ocDescriptor); |
| | | } |
| | |
| | | { |
| | | // We use an empty binary array to not breaking the logic: |
| | | // it means that there is no value for the attribute. |
| | | if ((binaryValue != null) && (binaryValue.length > 0)) |
| | | if (binaryValue != null && binaryValue.length > 0) |
| | | { |
| | | newValue = BinaryValue.createBase64(binaryValue); |
| | | editBinaryPanel.setValue(attrName, newValue); |
| | |
| | | |
| | | private boolean isAttrName(String attrName, CustomSearchResult sr) |
| | | { |
| | | boolean isAttrName = false; |
| | | List<Object> values = |
| | | sr.getAttributeValues(ServerConstants.OBJECTCLASS_ATTRIBUTE_TYPE_NAME); |
| | | List<Object> values = sr.getAttributeValues(ServerConstants.OBJECTCLASS_ATTRIBUTE_TYPE_NAME); |
| | | for (Object o : values) |
| | | { |
| | | String ocName = (String)o; |
| | | String attr = hmNameAttrNames.get(ocName.toLowerCase()); |
| | | if ((attr != null) && (attr.equalsIgnoreCase(attrName))) |
| | | if (attr != null && attr.equalsIgnoreCase(attrName)) |
| | | { |
| | | isAttrName = true; |
| | | break; |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | return isAttrName; |
| | | return false; |
| | | } |
| | | |
| | | private boolean hasBinaryValue(List<Object> values) |
| | |
| | | } |
| | | values.addAll(ocDesc.getAuxiliary()); |
| | | Schema schema = getInfo().getServerDescriptor().getSchema(); |
| | | if ((schema != null) && (structural != null)) |
| | | if (schema != null && structural != null) |
| | | { |
| | | ObjectClass oc = schema.getObjectClass(structural.toLowerCase()); |
| | | if (oc != null) |
| | |
| | | /** {@inheritDoc} */ |
| | | public void keyTyped(KeyEvent ev) |
| | | { |
| | | if ((ev.getKeyChar() == KeyEvent.VK_SPACE) || |
| | | (ev.getKeyChar() == KeyEvent.VK_ENTER)) |
| | | if (ev.getKeyChar() == KeyEvent.VK_SPACE || |
| | | ev.getKeyChar() == KeyEvent.VK_ENTER) |
| | | { |
| | | objectClassSelected(list); |
| | | } |
| | |
| | | @Override |
| | | public void keyTyped(KeyEvent ev) |
| | | { |
| | | if ((ev.getKeyChar() == KeyEvent.VK_SPACE) || |
| | | (ev.getKeyChar() == KeyEvent.VK_ENTER)) |
| | | if (ev.getKeyChar() == KeyEvent.VK_SPACE || |
| | | ev.getKeyChar() == KeyEvent.VK_ENTER) |
| | | { |
| | | attrSelected(list); |
| | | } |
| | |
| | | */ |
| | | public void update(ObjectClass oc, Schema schema) |
| | | { |
| | | if ((oc == null) || (schema == null)) |
| | | if (oc == null || schema == null) |
| | | { |
| | | // Ignore: this is called to get an initial panel size. |
| | | return; |
| | |
| | | public void update(CustomSearchResult sr, boolean isReadOnly, TreePath path) |
| | | { |
| | | boolean sameEntry = false; |
| | | if ((searchResult != null) && (sr != null)) |
| | | if (searchResult != null && sr != null) |
| | | { |
| | | sameEntry = searchResult.getDN().equals(sr.getDN()); |
| | | } |
| | |
| | | { |
| | | public void run() |
| | | { |
| | | if ((p != null) && (scroll.getViewport().contains(p))) |
| | | if (p != null && scroll.getViewport().contains(p)) |
| | | { |
| | | scroll.getViewport().setViewPosition(p); |
| | | } |
| | |
| | | addedAttrs.add( |
| | | Utilities.getAttributeNameWithoutOptions(attrName).toLowerCase()); |
| | | } |
| | | if ((ocs != null) && (schema != null)) |
| | | if (ocs != null && schema != null) |
| | | { |
| | | for (Object o : ocs) |
| | | { |
| | |
| | | try |
| | | { |
| | | d = Integer.parseInt(day.getText().trim()); |
| | | if ((d < 0) || (d > 31)) |
| | | if (d < 0 || d > 31) |
| | | { |
| | | errorMessages.add(ERR_CTRL_PANEL_INVALID_DAY.get()); |
| | | setPrimaryInvalid(lDay); |
| | |
| | | // simply to update the dn |
| | | Entry entry = null; |
| | | String dn = getDisplayedDN(); |
| | | if ((dn != null) && !dn.equals(title.getText())) |
| | | if (dn != null && !dn.equals(title.getText())) |
| | | { |
| | | title.setText(dn); |
| | | } |
| | | /* |
| | | Entry entry; |
| | | try |
| | | { |
| | | entry = getEntry(); |
| | | String dn = entry.getDN().toString(); |
| | | if (!dn.equals(title.getText())) |
| | | { |
| | | title.setText(dn); |
| | | } |
| | | } |
| | | catch (OpenDsException de) |
| | | { |
| | | entry = null; |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | entry = null; |
| | | logger.warn(LocalizableMessage.raw("Unexpected error: "+t, t)); |
| | | } |
| | | */ |
| | | LDAPEntryChangedEvent ev = new LDAPEntryChangedEvent(this, entry); |
| | | for (LDAPEntryChangedListener listener : listeners) |
| | | { |
| | |
| | | protected void updateTitle(CustomSearchResult sr, TreePath path) |
| | | { |
| | | String dn = sr.getDN(); |
| | | if ((dn != null) && (dn.length() > 0)) |
| | | if (dn != null && dn.length() > 0) |
| | | { |
| | | title.setText(sr.getDN()); |
| | | } |
| | |
| | | List<Object> ocs = |
| | | sr.getAttributeValues(ServerConstants.OBJECTCLASS_ATTRIBUTE_TYPE_NAME); |
| | | Schema schema = getInfo().getServerDescriptor().getSchema(); |
| | | if (!ocs.isEmpty() && (schema != null)) |
| | | if (!ocs.isEmpty() && schema != null) |
| | | { |
| | | ObjectClassValue ocDesc = getObjectClassDescriptor(ocs, schema); |
| | | StringBuilder sb = new StringBuilder(); |
| | |
| | | isWindowsServiceEnabled = ev.getNewDescriptor().isWindowsServiceEnabled(); |
| | | |
| | | final boolean isLocal = ev.getNewDescriptor().isLocal(); |
| | | if ((isLocal != previousLocal) || |
| | | (isWindowsServiceEnabled != previousValue)) |
| | | if (isLocal != previousLocal || isWindowsServiceEnabled != previousValue) |
| | | { |
| | | previousLocal = isLocal; |
| | | SwingUtilities.invokeLater(new Runnable() |
| | |
| | | { |
| | | if (enableService) |
| | | { |
| | | returnCode = ConfigureWindowsService.enableService(outPrintStream, |
| | | errorPrintStream); |
| | | if ((returnCode != ConfigureWindowsService.SERVICE_ALREADY_ENABLED) && |
| | | (returnCode != ConfigureWindowsService.SERVICE_ENABLE_SUCCESS)) |
| | | returnCode = ConfigureWindowsService.enableService(outPrintStream, errorPrintStream); |
| | | if (returnCode != ConfigureWindowsService.SERVICE_ALREADY_ENABLED && |
| | | returnCode != ConfigureWindowsService.SERVICE_ENABLE_SUCCESS) |
| | | { |
| | | state = State.FINISHED_WITH_ERROR; |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | returnCode = ConfigureWindowsService.disableService(outPrintStream, |
| | | errorPrintStream); |
| | | if ((returnCode != ConfigureWindowsService.SERVICE_ALREADY_DISABLED) |
| | | && |
| | | (returnCode != ConfigureWindowsService.SERVICE_DISABLE_SUCCESS)) |
| | | returnCode = ConfigureWindowsService.disableService(outPrintStream, errorPrintStream); |
| | | if (returnCode != ConfigureWindowsService.SERVICE_ALREADY_DISABLED |
| | | && returnCode != ConfigureWindowsService.SERVICE_DISABLE_SUCCESS) |
| | | { |
| | | state = State.FINISHED_WITH_ERROR; |
| | | } |
| | |
| | | { |
| | | /** {@inheritDoc} */ |
| | | public void mouseClicked(MouseEvent e) { |
| | | if (isEnabled() && (e.getClickCount() == 2)) |
| | | if (isEnabled() && e.getClickCount() == 2) |
| | | { |
| | | if (e.getSource() == availableList) |
| | | { |
| | |
| | | private void updateButtonEnabling() |
| | | { |
| | | int index = availableList.getSelectedIndex(); |
| | | add.setEnabled((index != -1) && |
| | | (index <availableListModel.getSize()) && isEnabled()); |
| | | add.setEnabled(index != -1 && |
| | | index <availableListModel.getSize() && isEnabled()); |
| | | index = selectedList.getSelectedIndex(); |
| | | remove.setEnabled((index != -1) && |
| | | (index <selectedListModel.getSize()) && isEnabled()); |
| | | remove.setEnabled(index != -1 && |
| | | index <selectedListModel.getSize() && isEnabled()); |
| | | |
| | | if (addAll != null) |
| | | { |
| | | addAll.setEnabled((availableListModel.getSize() > 0) && isEnabled()); |
| | | addAll.setEnabled(availableListModel.getSize() > 0 && isEnabled()); |
| | | } |
| | | if (removeAll != null) |
| | | { |
| | | removeAll.setEnabled((selectedListModel.getSize() > 0) && isEnabled()); |
| | | removeAll.setEnabled(selectedListModel.getSize() > 0 && isEnabled()); |
| | | } |
| | | } |
| | | |
| | |
| | | public void setValue(byte[] value, boolean isImage) |
| | | { |
| | | label.setText(getString(value, isImage).toString()); |
| | | deleteButton.setVisible((value != null) && isDisplayDelete()); |
| | | deleteButton.setVisible(value != null && isDisplayDelete()); |
| | | this.value = value; |
| | | if (!isImage) |
| | | { |
| | |
| | | public void setValue(BinaryValue value, boolean isImage) |
| | | { |
| | | label.setText(getMessage(value, isImage).toString()); |
| | | deleteButton.setVisible((value != null) && isDisplayDelete()); |
| | | deleteButton.setVisible(value != null && isDisplayDelete()); |
| | | this.value = value; |
| | | if (!isImage) |
| | | { |
| | |
| | | else |
| | | { |
| | | Icon icon = getIcon(value); |
| | | if ((icon == null) || (icon.getIconHeight() <= 0)) |
| | | if (icon == null || icon.getIconHeight() <= 0) |
| | | { |
| | | Utilities.setWarningLabel(label, ERR_LOADING_IMAGE.get()); |
| | | label.setVisible(true); |
| | |
| | | MouseEvent newEvent = getTranslatedEvent(ev); |
| | | |
| | | if (isMacOS() && ev.isPopupTrigger() && |
| | | (ev.getButton() != MouseEvent.BUTTON1)) |
| | | ev.getButton() != MouseEvent.BUTTON1) |
| | | { |
| | | MouseEvent baseEvent = ev; |
| | | if (newEvent != null) |
| | |
| | | baseEvent = newEvent; |
| | | } |
| | | int mods = baseEvent.getModifiersEx(); |
| | | mods &= (InputEvent.ALT_DOWN_MASK | InputEvent.META_DOWN_MASK | |
| | | InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK); |
| | | mods &= InputEvent.ALT_DOWN_MASK | InputEvent.META_DOWN_MASK | |
| | | InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK; |
| | | mods |= InputEvent.BUTTON1_DOWN_MASK; |
| | | final MouseEvent macEvent = new MouseEvent( |
| | | baseEvent.getComponent(), |
| | |
| | | Rectangle r = getPathBounds(path); |
| | | if (r != null) |
| | | { |
| | | int newX = r.x + (r.width / 2); |
| | | int newY = r.y + (r.height / 2); |
| | | int newX = r.x + r.width / 2; |
| | | int newY = r.y + r.height / 2; |
| | | // Simulate an event |
| | | newEvent = new MouseEvent( |
| | | ev.getComponent(), |
| | |
| | | { |
| | | Rectangle pathBounds = getPathBounds(closestPath); |
| | | if (pathBounds != null && |
| | | x >= pathBounds.x && x < (getX() + getWidth()) && |
| | | y >= pathBounds.y && y < (pathBounds.y + pathBounds.height)) |
| | | x >= pathBounds.x && x < getX() + getWidth() && |
| | | y >= pathBounds.y && y < pathBounds.y + pathBounds.height) |
| | | { |
| | | path = closestPath; |
| | | } |
| | |
| | | private JScrollPane selectedScroll1; |
| | | private JScrollPane selectedScroll2; |
| | | private JList availableList; |
| | | private JList selectedList1; |
| | | private JList selectedList2; |
| | | private JList<T> selectedList1; |
| | | private JList<T> selectedList2; |
| | | private Class<T> theClass; |
| | | private Collection<T> unmovableItems = new ArrayList<>(); |
| | | private boolean ignoreListEvents; |
| | |
| | | { |
| | | /** {@inheritDoc} */ |
| | | public void mouseClicked(MouseEvent e) { |
| | | if (isEnabled() && (e.getClickCount() == 2)) |
| | | if (isEnabled() && e.getClickCount() == 2) |
| | | { |
| | | if (e.getSource() == availableList) |
| | | { |
| | | if (availableList.getSelectedValue() != null) |
| | | { |
| | | add1Clicked(); |
| | | addClicked(selectedListModel1); |
| | | } |
| | | } |
| | | else if (e.getSource() == selectedList1) |
| | |
| | | |
| | | availableListModel = new SortableListModel<>(); |
| | | availableListModel.addListDataListener(listDataListener); |
| | | availableList = new JList(); |
| | | availableList = new JList<>(); |
| | | availableList.setModel(availableListModel); |
| | | availableList.setVisibleRowCount(15); |
| | | availableList.addMouseListener(doubleClickListener); |
| | | |
| | | selectedListModel1 = new SortableListModel<>(); |
| | | selectedListModel1.addListDataListener(listDataListener); |
| | | selectedList1 = new JList(); |
| | | selectedList1 = new JList<>(); |
| | | selectedList1.setModel(selectedListModel1); |
| | | selectedList1.setVisibleRowCount(7); |
| | | selectedList1.addMouseListener(doubleClickListener); |
| | | |
| | | selectedListModel2 = new SortableListModel<>(); |
| | | selectedListModel2.addListDataListener(listDataListener); |
| | | selectedList2 = new JList(); |
| | | selectedList2 = new JList<>(); |
| | | selectedList2.setModel(selectedListModel2); |
| | | selectedList2.setVisibleRowCount(7); |
| | | selectedList2.addMouseListener(doubleClickListener); |
| | |
| | | /** {@inheritDoc} */ |
| | | public void actionPerformed(ActionEvent ev) |
| | | { |
| | | add1Clicked(); |
| | | addClicked(selectedListModel1); |
| | | } |
| | | }); |
| | | gbc.insets = new Insets(5, 5, 0, 5); |
| | |
| | | /** {@inheritDoc} */ |
| | | public void actionPerformed(ActionEvent ev) |
| | | { |
| | | add2Clicked(); |
| | | addClicked(selectedListModel2); |
| | | } |
| | | }); |
| | | gbc.insets = new Insets(5, 5, 0, 5); |
| | |
| | | ignoreListEvents = true; |
| | | |
| | | JList[] lists = {availableList, selectedList1, selectedList2}; |
| | | for (JList list : lists) |
| | | for (JList<T> list : lists) |
| | | { |
| | | for (T element : unmovableItems) |
| | | { |
| | |
| | | } |
| | | |
| | | ignoreListEvents = false; |
| | | int index = availableList.getSelectedIndex(); |
| | | add1.setEnabled((index != -1) && |
| | | (index <availableListModel.getSize()) && isEnabled()); |
| | | add1.setEnabled(isEnabled(availableList, availableListModel)); |
| | | add2.setEnabled(add1.isEnabled()); |
| | | index = selectedList1.getSelectedIndex(); |
| | | remove1.setEnabled((index != -1) && |
| | | (index <selectedListModel1.getSize()) && isEnabled()); |
| | | index = selectedList2.getSelectedIndex(); |
| | | remove2.setEnabled((index != -1) && |
| | | (index <selectedListModel2.getSize()) && isEnabled()); |
| | | remove1.setEnabled(isEnabled(selectedList1, selectedListModel1)); |
| | | remove2.setEnabled(isEnabled(selectedList2, selectedListModel2)); |
| | | |
| | | if (addAll1 != null) |
| | | { |
| | | boolean onlyUnmovable = |
| | | unmovableItems.containsAll(availableListModel.getData()); |
| | | addAll1.setEnabled((availableListModel.getSize() > 0) && isEnabled() && |
| | | !onlyUnmovable); |
| | | addAll1.setEnabled(isEnabled(availableListModel)); |
| | | addAll2.setEnabled(addAll1.isEnabled()); |
| | | } |
| | | if (removeAll1 != null) |
| | | { |
| | | boolean onlyUnmovable = |
| | | unmovableItems.containsAll(selectedListModel1.getData()); |
| | | removeAll1.setEnabled((selectedListModel1.getSize() > 0) && isEnabled() && |
| | | !onlyUnmovable); |
| | | removeAll1.setEnabled(isEnabled(selectedListModel1)); |
| | | } |
| | | if (removeAll2 != null) |
| | | { |
| | | boolean onlyUnmovable = |
| | | unmovableItems.containsAll(selectedListModel2.getData()); |
| | | removeAll2.setEnabled((selectedListModel2.getSize() > 0) && isEnabled() && |
| | | !onlyUnmovable); |
| | | removeAll2.setEnabled(isEnabled(selectedListModel2)); |
| | | } |
| | | } |
| | | |
| | | private boolean isEnabled(JList<T> list, SortableListModel<T> model) |
| | | { |
| | | int index = list.getSelectedIndex(); |
| | | return index != -1 && index < model.getSize() && isEnabled(); |
| | | } |
| | | |
| | | private boolean isEnabled(SortableListModel<T> model) |
| | | { |
| | | boolean onlyUnmovable = unmovableItems.containsAll(model.getData()); |
| | | return model.getSize() > 0 && isEnabled() && !onlyUnmovable; |
| | | } |
| | | |
| | | /** |
| | | * Returns the available list. |
| | | * @return the available list. |
| | |
| | | * Returns the first selected list. |
| | | * @return the first selected list. |
| | | */ |
| | | public JList getSelectedList1() |
| | | public JList<T> getSelectedList1() |
| | | { |
| | | return selectedList1; |
| | | } |
| | |
| | | * Returns the second selected list. |
| | | * @return the second selected list. |
| | | */ |
| | | public JList getSelectedList2() |
| | | public JList<T> getSelectedList2() |
| | | { |
| | | return selectedList2; |
| | | } |
| | | |
| | | private void add1Clicked() |
| | | private void addClicked(SortableListModel<T> selectedListModel) |
| | | { |
| | | @SuppressWarnings("deprecation") |
| | | Object[] selectedObjects = availableList.getSelectedValues(); |
| | | for (int i=0; i<selectedObjects.length; i++) |
| | | for (Object selectedObject : availableList.getSelectedValuesList()) |
| | | { |
| | | T value = DoubleAddRemovePanel.this.theClass.cast(selectedObjects[i]); |
| | | selectedListModel1.add(value); |
| | | T value = DoubleAddRemovePanel.this.theClass.cast(selectedObject); |
| | | selectedListModel.add(value); |
| | | availableListModel.remove(value); |
| | | } |
| | | selectedListModel1.fireContentsChanged(selectedListModel1, 0, |
| | | selectedListModel1.getSize()); |
| | | availableListModel.fireContentsChanged(availableListModel, 0, |
| | | availableListModel.getSize()); |
| | | } |
| | | |
| | | private void add2Clicked() |
| | | { |
| | | @SuppressWarnings("deprecation") |
| | | Object[] selectedObjects = availableList.getSelectedValues(); |
| | | for (int i=0; i<selectedObjects.length; i++) |
| | | { |
| | | T value = DoubleAddRemovePanel.this.theClass.cast(selectedObjects[i]); |
| | | selectedListModel2.add(value); |
| | | availableListModel.remove(value); |
| | | } |
| | | selectedListModel2.fireContentsChanged(selectedListModel2, 0, |
| | | selectedListModel2.getSize()); |
| | | availableListModel.fireContentsChanged(availableListModel, 0, |
| | | availableListModel.getSize()); |
| | | selectedListModel.fireContentsChanged(selectedListModel, 0, selectedListModel.getSize()); |
| | | availableListModel.fireContentsChanged(availableListModel, 0, availableListModel.getSize()); |
| | | } |
| | | |
| | | private void remove1Clicked() |
| | | { |
| | | @SuppressWarnings("deprecation") |
| | | Object[] selectedObjects = selectedList1.getSelectedValues(); |
| | | for (int i=0; i<selectedObjects.length; i++) |
| | | { |
| | | T value = DoubleAddRemovePanel.this.theClass.cast(selectedObjects[i]); |
| | | availableListModel.add(value); |
| | | selectedListModel1.remove(value); |
| | | } |
| | | selectedListModel1.fireContentsChanged(selectedListModel1, 0, |
| | | selectedListModel1.getSize()); |
| | | availableListModel.fireContentsChanged(availableListModel, 0, |
| | | availableListModel.getSize()); |
| | | removeClicked(selectedListModel1, selectedList1); |
| | | } |
| | | |
| | | private void remove2Clicked() |
| | | { |
| | | @SuppressWarnings("deprecation") |
| | | Object[] selectedObjects = selectedList2.getSelectedValues(); |
| | | for (int i=0; i<selectedObjects.length; i++) |
| | | removeClicked(selectedListModel2, selectedList2); |
| | | } |
| | | |
| | | private void removeClicked(SortableListModel<T> selectedListModel, JList<T> selectedList) |
| | | { |
| | | for (T value : selectedList.getSelectedValuesList()) |
| | | { |
| | | T value = DoubleAddRemovePanel.this.theClass.cast(selectedObjects[i]); |
| | | availableListModel.add(value); |
| | | selectedListModel2.remove(value); |
| | | selectedListModel.remove(value); |
| | | } |
| | | selectedListModel2.fireContentsChanged(selectedListModel2, 0, |
| | | selectedListModel2.getSize()); |
| | | availableListModel.fireContentsChanged(availableListModel, 0, |
| | | availableListModel.getSize()); |
| | | selectedListModel.fireContentsChanged(selectedListModel, 0, selectedListModel.getSize()); |
| | | availableListModel.fireContentsChanged(availableListModel, 0, availableListModel.getSize()); |
| | | } |
| | | |
| | | /** |
| | |
| | | throws BadLocationException |
| | | { |
| | | int totalLength = fb.getDocument().getLength(); |
| | | |
| | | int caretPosition = tf.getCaretPosition(); |
| | | |
| | | if ((totalLength >= maxSize) && |
| | | (caretPosition == fb.getDocument().getLength())) |
| | | if (totalLength >= maxSize && |
| | | caretPosition == fb.getDocument().getLength()) |
| | | { |
| | | tf.setCaretPosition(0); |
| | | } |
| | |
| | | { |
| | | return Collections.unmodifiableSet(selectedMultipleSuperiors); |
| | | } |
| | | else |
| | | |
| | | ObjectClass oc = (ObjectClass)singleSuperior.getSelectedItem(); |
| | | if (oc != null) |
| | | { |
| | | ObjectClass oc = (ObjectClass)singleSuperior.getSelectedItem(); |
| | | if (oc == null) |
| | | { |
| | | return Collections.emptySet(); |
| | | } |
| | | else |
| | | { |
| | | return Collections.singleton( |
| | | (ObjectClass)(singleSuperior.getSelectedItem())); |
| | | } |
| | | return Collections.singleton(oc); |
| | | } |
| | | return Collections.emptySet(); |
| | | } |
| | | |
| | | /** |
| | |
| | | String allText = |
| | | fb.getDocument().getText(0, fb.getDocument().getLength()); |
| | | int index = allText.indexOf(':'); |
| | | if ((index != -1) && (newText.length() == 1)) |
| | | if (index != -1 && newText.length() == 1) |
| | | { |
| | | int minuteLength = allText.length() - index - 1; |
| | | int hourLength = index; |
| | | |
| | | if ((minuteLength > 2) || (hourLength > 2)) |
| | | if (minuteLength > 2 || hourLength > 2) |
| | | { |
| | | if (offset < previousLength) |
| | | { |
| | |
| | | int hourLength = index; |
| | | int caretPosition = tf.getCaretPosition(); |
| | | |
| | | if ((minuteLength >= 2) && |
| | | (caretPosition == allText.length())) |
| | | if (minuteLength >= 2 && |
| | | caretPosition == allText.length()) |
| | | { |
| | | tf.setCaretPosition(0); |
| | | } |
| | |
| | | value, isSelected, row, column)); |
| | | return ocPanel; |
| | | } |
| | | else if ((value instanceof byte[]) || (value instanceof BinaryValue)) |
| | | else if (value instanceof byte[] || value instanceof BinaryValue) |
| | | { |
| | | attrName = getAttributeName(table, row); |
| | | boolean isImage = Utilities.hasImageSyntax(attrName, |
| | |
| | | throw new IllegalArgumentException( |
| | | "Unknown class for "+value+": "+" row: "+row+ "column: "+column); |
| | | } |
| | | super.getTableCellRendererComponent(table, s, isSelected, hasFocus, row, |
| | | column); |
| | | if (isFull && (row != 0)) |
| | | super.getTableCellRendererComponent(table, s, isSelected, hasFocus, row, column); |
| | | if (isFull && row != 0) |
| | | { |
| | | setBorder(fullBorder); |
| | | } |
| | |
| | | { |
| | | setBorder(incrementalBorder); |
| | | } |
| | | if (isDate) |
| | | { |
| | | setHorizontalAlignment(SwingConstants.RIGHT); |
| | | } |
| | | else |
| | | { |
| | | setHorizontalAlignment(SwingConstants.LEFT); |
| | | } |
| | | setHorizontalAlignment(isDate ? SwingConstants.RIGHT : SwingConstants.LEFT); |
| | | |
| | | return this; |
| | | } |
| | |
| | | updateComponent(ocPanel, table, row, column, isSelected); |
| | | return ocPanel; |
| | | } |
| | | else if ((value instanceof byte[]) || (value instanceof BinaryValue)) |
| | | else if (value instanceof byte[] || value instanceof BinaryValue) |
| | | { |
| | | if (value instanceof byte[]) |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | if ((column == 1) && !table.isCellEditable(row, column)) |
| | | if (column == 1 && !table.isCellEditable(row, column)) |
| | | { |
| | | lockLabel.setIcon(lockIcon); |
| | | } |
| | |
| | | |
| | | private boolean isPassword(JTable table, int row, int col) |
| | | { |
| | | boolean isPassword = false; |
| | | if (col == 1) |
| | | { |
| | | Object o = table.getValueAt(row, 0); |
| | | if (Utilities.hasPasswordSyntax((String)o, getSchema())) |
| | | { |
| | | isPassword = true; |
| | | return true; |
| | | } |
| | | } |
| | | return isPassword; |
| | | return false; |
| | | } |
| | | |
| | | private boolean isImage(JTable table, int row, int col) |
| | | { |
| | | boolean isImage = false; |
| | | if (col == 1) |
| | | { |
| | | Object o = table.getValueAt(row, 0); |
| | | isImage = Utilities.hasImageSyntax((String)o, schema); |
| | | return Utilities.hasImageSyntax((String)o, schema); |
| | | } |
| | | return isImage; |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | private boolean isRequired(JTable table, int row, int col) |
| | | { |
| | | boolean isRequired = false; |
| | | if (col == 0) |
| | | { |
| | | Object o = table.getValueAt(row, 0); |
| | | isRequired = requiredAttrs.contains( |
| | | return requiredAttrs.contains( |
| | | Utilities.getAttributeNameWithoutOptions((String)o).toLowerCase()); |
| | | } |
| | | return isRequired; |
| | | return false; |
| | | } |
| | | } |
| | |
| | | comp.setBackground(ColorAndFontConstants.treeBackground); |
| | | comp.setForeground(ColorAndFontConstants.treeForeground); |
| | | } |
| | | else if (isBeingPressed && hasMouseOver && (row == lastRowMouseOver)) |
| | | else if (isBeingPressed && hasMouseOver && row == lastRowMouseOver) |
| | | { |
| | | comp.setBackground(pressedBackground); |
| | | comp.setForeground(pressedForeground); |
| | | } |
| | | else if ((hasMouseOver && (row == lastRowMouseOver)) || isSelected) |
| | | else if ((hasMouseOver && row == lastRowMouseOver) || isSelected) |
| | | { |
| | | comp.setBackground(mouseOverBackground); |
| | | comp.setForeground(mouseOverForeground); |
| | |
| | | private Border rootBorder = BorderFactory.createEmptyBorder(0, 5, 0, 0); |
| | | private Border normalBorder = BorderFactory.createEmptyBorder(0, 0, 0, 0); |
| | | |
| | | /** |
| | | * Constructor of the renderer. |
| | | * |
| | | */ |
| | | /** Constructor of the renderer. */ |
| | | public TreeCellRenderer() |
| | | { |
| | | backgroundNonSelectionColor = nonselectionBackground; |
| | |
| | | isLeaf, row, hasFocus); |
| | | setIcon(null); |
| | | |
| | | if ((row == 0) && (tree.isRootVisible())) |
| | | if (row == 0 && tree.isRootVisible()) |
| | | { |
| | | setBorder(rootBorder); |
| | | } |
| | |
| | | String replicaId = ConnectionUtils.getFirstValue(sr, "server-id"); |
| | | String missingChanges = ConnectionUtils.getFirstValue(sr, "missing-changes"); |
| | | |
| | | if ((dn != null) && (replicaId != null) && (missingChanges != null)) |
| | | if (dn != null && replicaId != null && missingChanges != null) |
| | | { |
| | | for (BackendDescriptor backend : backends) |
| | | { |
| | |
| | | String backendID = ConnectionUtils.getFirstValue(sr, "ds-backend-id"); |
| | | String entryCount = ConnectionUtils.getFirstValue(sr, "ds-backend-entry-count"); |
| | | Set<String> baseDnEntries = ConnectionUtils.getValues(sr, "ds-base-dn-entry-count"); |
| | | if ((backendID != null) && ((entryCount != null) || (baseDnEntries != null))) |
| | | if (backendID != null && (entryCount != null || baseDnEntries != null)) |
| | | { |
| | | for (BackendDescriptor backend : backends) |
| | | { |
| | |
| | | { |
| | | // Check if it is the DB monitor entry |
| | | String cn = ConnectionUtils.getFirstValue(sr, "cn"); |
| | | if ((cn != null) && cn.endsWith(DATABASE_ENVIRONMENT_SUFFIX)) |
| | | if (cn != null && cn.endsWith(DATABASE_ENVIRONMENT_SUFFIX)) |
| | | { |
| | | String monitorBackendID = cn.substring(0, cn.length() - DATABASE_ENVIRONMENT_SUFFIX.length()); |
| | | for (BackendDescriptor backend : backends) |
| | |
| | | } |
| | | try |
| | | { |
| | | if ((rootMonitor == null) && isRootMonitor(csr)) |
| | | if (rootMonitor == null && isRootMonitor(csr)) |
| | | { |
| | | rootMonitor = csr; |
| | | } |
| | | else if ((entryCaches == null) && isEntryCaches(csr)) |
| | | else if (entryCaches == null && isEntryCaches(csr)) |
| | | { |
| | | entryCaches = csr; |
| | | } |
| | | else if ((workQueue == null) && isWorkQueue(csr)) |
| | | else if (workQueue == null && isWorkQueue(csr)) |
| | | { |
| | | workQueue = csr; |
| | | } |
| | | else if ((jvmMemoryUsage == null) && isJvmMemoryUsage(csr)) |
| | | else if (jvmMemoryUsage == null && isJvmMemoryUsage(csr)) |
| | | { |
| | | jvmMemoryUsage = csr; |
| | | } |
| | | else if ((systemInformation == null) && isSystemInformation(csr)) |
| | | else if (systemInformation == null && isSystemInformation(csr)) |
| | | { |
| | | systemInformation = csr; |
| | | } |
| | | else if ((versionMonitor == null) && isVersionMonitor(csr)) |
| | | else if (versionMonitor == null && isVersionMonitor(csr)) |
| | | { |
| | | versionMonitor = csr; |
| | | } |
| | |
| | | |
| | | private boolean isConnectionHandler(CustomSearchResult csr) throws OpenDsException |
| | | { |
| | | boolean isConnectionHandler = false; |
| | | DN dn = DN.valueOf(csr.getDN()); |
| | | DN parent = dn.parent(); |
| | | if ((parent != null) && parent.equals(monitorDN)) |
| | | if (parent != null && parent.equals(monitorDN)) |
| | | { |
| | | List<?> vs = csr.getAttributeValues("cn"); |
| | | if ((vs != null) && !vs.isEmpty()) |
| | | if (vs != null && !vs.isEmpty()) |
| | | { |
| | | String cn = (String) vs.iterator().next(); |
| | | String statistics = " Statistics"; |
| | | if (cn.endsWith(statistics)) |
| | | { |
| | | isConnectionHandler = true; |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | return isConnectionHandler; |
| | | return false; |
| | | } |
| | | |
| | | private static boolean isTaskEntry(CustomSearchResult csr) throws OpenDsException |
| | | { |
| | | boolean isTaskEntry = false; |
| | | List<Object> vs = csr.getAttributeValues("objectclass"); |
| | | if ((vs != null) && !vs.isEmpty()) |
| | | if (vs != null && !vs.isEmpty()) |
| | | { |
| | | for (Object oc : vs) |
| | | { |
| | | if (oc.toString().equalsIgnoreCase("ds-task")) |
| | | { |
| | | isTaskEntry = true; |
| | | break; |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | return isTaskEntry; |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | |
| | | // this connection handler is the right one. |
| | | // See org.opends.server.protocols.ldap.LDAPConnectionHandler to see |
| | | // how the DN of the monitoring entry is generated. |
| | | if (key.contains(getKey("port " + ch.getPort()))) |
| | | if (key.contains(getKey("port " + ch.getPort())) |
| | | && hasAllAddresses(ch, key)) |
| | | { |
| | | boolean hasAllAddresses = true; |
| | | for (InetAddress a : ch.getAddresses()) |
| | | { |
| | | if (!key.contains(getKey(a.getHostAddress()))) |
| | | { |
| | | hasAllAddresses = false; |
| | | break; |
| | | } |
| | | } |
| | | if (hasAllAddresses) |
| | | { |
| | | monitorEntries.add(hmConnectionHandlersMonitor.get(key)); |
| | | } |
| | | monitorEntries.add(hmConnectionHandlersMonitor.get(key)); |
| | | } |
| | | } |
| | | } |
| | |
| | | return monitorEntries; |
| | | } |
| | | |
| | | private boolean hasAllAddresses(ConnectionHandlerDescriptor ch, String key) |
| | | { |
| | | for (InetAddress a : ch.getAddresses()) |
| | | { |
| | | if (!key.contains(getKey(a.getHostAddress()))) |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | } |
| | |
| | | * entry and <CODE>false</CODE> otherwise. |
| | | */ |
| | | public boolean contains(LDAPURL url) { |
| | | boolean contains = false; |
| | | if (!isUnreliableEntryListEmpty) { |
| | | boolean isInServer = |
| | | serverHost.equalsIgnoreCase(String.valueOf(url.getHost())) && |
| | | (serverPort == url.getPort()); |
| | | serverPort == url.getPort(); |
| | | if (isInServer) { |
| | | for (DN dn : unreliableEntryList) |
| | | { |
| | |
| | | { |
| | | if (dn.equals(DN.valueOf(url.getRawBaseDN()))) |
| | | { |
| | | contains = true; |
| | | break; |
| | | return true; |
| | | } |
| | | } |
| | | catch (OpenDsException oe) |
| | |
| | | } |
| | | } |
| | | } |
| | | return contains; |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | if (multipleScreen) |
| | | { |
| | | comp.setLocation((screenSize.width / 4) - (width / 2), |
| | | comp.setLocation(screenSize.width / 4 - width / 2, |
| | | (screenSize.height - height) / 2); |
| | | } else |
| | | { |
| | |
| | | { |
| | | if (v2 instanceof Number) |
| | | { |
| | | if ((v1 instanceof Double) || (v2 instanceof Double)) |
| | | if (v1 instanceof Double || v2 instanceof Double) |
| | | { |
| | | double n1 = ((Number) v1).doubleValue(); |
| | | double n2 = ((Number) v2).doubleValue(); |
| | |
| | | while (index1 != -1) { |
| | | int index2 = lowerCaseContents.indexOf(Constants.LINE_SEPARATOR, index1); |
| | | String value; |
| | | if (index2 > (index1 + attrName.length())) { |
| | | if (index2 > index1 + attrName.length()) { |
| | | value = contents.substring(attrName.length() + index1, index2).trim(); |
| | | } else if (lowerCaseContents.length() > (index1 + attrName.length())) { |
| | | } else if (lowerCaseContents.length() > index1 + attrName.length()) { |
| | | // Assume end of file |
| | | value = contents.substring(attrName.length() + index1).trim(); |
| | | } else { |
| | | value = null; |
| | | } |
| | | |
| | | if ((value != null) && (value.length() > 0)) { |
| | | if (value != null && value.length() > 0) { |
| | | set.add(value); |
| | | } |
| | | |
| | |
| | | } |
| | | return set; |
| | | } |
| | | |
| | | } |
| | |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.opends.quicksetup; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | |
| | | * |
| | | * This class assumes that we are running in the case of an offline install. |
| | | */ |
| | | |
| | | public class CurrentInstallStatus |
| | | { |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | private boolean isInstalled; |
| | | |
| | | private boolean canOverwriteCurrentInstall; |
| | | |
| | | private LocalizableMessage installationMsg; |
| | | |
| | | /** |
| | | * The constructor of a CurrentInstallStatus object. |
| | | * |
| | | */ |
| | | /** The constructor of a CurrentInstallStatus object. */ |
| | | public CurrentInstallStatus() |
| | | { |
| | | if (Utils.isWebStart()) |
| | |
| | | |
| | | private int getPort() |
| | | { |
| | | int port = -1; |
| | | try { |
| | | port = Installation.getLocal().getCurrentConfiguration(). |
| | | getPort(); |
| | | return Installation.getLocal().getCurrentConfiguration().getPort(); |
| | | } catch (IOException ioe) { |
| | | logger.info(LocalizableMessage.raw("Failed to get port", ioe)); |
| | | return -1; |
| | | } |
| | | return port; |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | File dbDir = Installation.getLocal().getDatabasesDirectory(); |
| | | File[] children = dbDir.listFiles(); |
| | | return ((children != null) && (children.length > 0)); |
| | | return children != null && children.length > 0; |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | File configDir = Installation.getLocal().getConfigurationDirectory(); |
| | | File[] children = configDir.listFiles(); |
| | | return ((children != null) && (children.length > 0)); |
| | | return children != null && children.length > 0; |
| | | } |
| | | |
| | | } |
| | |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.opends.quicksetup; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | |
| | | * @return boolean where true indicates usage should be printed |
| | | */ |
| | | protected boolean shouldPrintUsage() { |
| | | boolean printUsage = false; |
| | | if ((args != null) && (args.length > 0)) { |
| | | if (args != null && args.length > 0) { |
| | | for (String arg : args) { |
| | | if (arg.equals("-?") || |
| | | arg.equalsIgnoreCase("-H") || |
| | | arg.equalsIgnoreCase("--help")) { |
| | | printUsage = true; |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | return printUsage; |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return boolean where true indicates usage should be printed |
| | | */ |
| | | protected boolean isQuiet() { |
| | | boolean printUsage = false; |
| | | if ((args != null) && (args.length > 0)) { |
| | | if (args != null && args.length > 0) { |
| | | for (String arg : args) { |
| | | if (arg.equals("-?") || |
| | | arg.equalsIgnoreCase("-Q") || |
| | | arg.equalsIgnoreCase("--quiet")) { |
| | | printUsage = true; |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | return printUsage; |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return boolean where true indicates version should be printed |
| | | */ |
| | | protected boolean shouldPrintVersion() { |
| | | boolean printVersion = false; |
| | | if ((args != null) && (args.length > 0)) |
| | | if (args != null && args.length > 0) |
| | | { |
| | | for (String arg : args) |
| | | { |
| | | if (arg.equalsIgnoreCase("--version")) |
| | | { |
| | | printVersion = true; |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | return printVersion; |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | |
| | | * should be launched |
| | | */ |
| | | protected boolean isCli() { |
| | | boolean isCli = false; |
| | | for (String arg : args) { |
| | | if (arg.equalsIgnoreCase("--"+OPTION_LONG_CLI) || |
| | | arg.equalsIgnoreCase("-"+OPTION_SHORT_CLI)) { |
| | | isCli = true; |
| | | break; |
| | | return true; |
| | | } |
| | | } |
| | | return isCli; |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | int defaultJMXPort = -1; |
| | | |
| | | for (int i=0;i<65000 && (defaultJMXPort == -1);i+=1000) |
| | | for (int i=0;i<65000 && defaultJMXPort == -1;i+=1000) |
| | | { |
| | | int port = i + CliConstants.DEFAULT_JMX_PORT; |
| | | boolean isForbidden = false; |
| | |
| | | if (path != null && path.trim().length() > 0) |
| | | { |
| | | File f = new File(path); |
| | | while ((f != null) && !f.isDirectory()) |
| | | while (f != null && !f.isDirectory()) |
| | | { |
| | | f = f.getParentFile(); |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013 ForgeRock AS. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | |
| | | package org.opends.quicksetup.installer; |
| | | |
| | | import org.opends.quicksetup.Constants; |
| | |
| | | /** |
| | | * This class is used to provide a data model for the Data Replication |
| | | * Options panel of the installer. |
| | | * |
| | | */ |
| | | public class DataReplicationOptions |
| | | { |
| | | /** |
| | | * This enumeration is used to know what the user wants to do for the data |
| | | * (import data or not, what use as source of the data...). |
| | | * |
| | | */ |
| | | public enum Type |
| | | { |
| | |
| | | { |
| | | int defaultPort = -1; |
| | | |
| | | for (int i=0;i<10000 && (defaultPort == -1);i+=1000) |
| | | for (int i=0;i<10000 && defaultPort == -1;i+=1000) |
| | | { |
| | | int port = i + Constants.DEFAULT_REPLICATION_PORT; |
| | | if (Utils.canUseAsPort(port)) |
| | |
| | | /** {@inheritDoc} */ |
| | | protected LocalizableMessage getTextForIcon(UIFactory.IconType iconType) |
| | | { |
| | | LocalizableMessage text; |
| | | if ((iconType == UIFactory.IconType.WAIT) && |
| | | if (iconType == UIFactory.IconType.WAIT && |
| | | rbReplicated.isSelected() && cbTopologyExists.isSelected()) |
| | | { |
| | | text = INFO_CONTACTING_SERVER_LABEL.get(); |
| | | return INFO_CONTACTING_SERVER_LABEL.get(); |
| | | } |
| | | else |
| | | { |
| | | text = super.getTextForIcon(iconType); |
| | | return super.getTextForIcon(iconType); |
| | | } |
| | | return text; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | private Object getDefaultValue(FieldName fieldName) |
| | | { |
| | | Object value; |
| | | AuthenticationData auth = |
| | | defaultUserData.getReplicationOptions().getAuthenticationData(); |
| | | switch (fieldName) |
| | | { |
| | | case REPLICATION_PORT: |
| | | value = defaultUserData.getReplicationOptions().getReplicationPort(); |
| | | break; |
| | | |
| | | return defaultUserData.getReplicationOptions().getReplicationPort(); |
| | | case REMOTE_SERVER_DN: |
| | | value = auth.getDn(); |
| | | break; |
| | | |
| | | return auth.getDn(); |
| | | case REMOTE_SERVER_PWD: |
| | | value = auth.getPwd(); |
| | | break; |
| | | |
| | | return auth.getPwd(); |
| | | case REMOTE_SERVER_HOST: |
| | | value = auth.getHostName(); |
| | | break; |
| | | |
| | | return auth.getHostName(); |
| | | case REMOTE_SERVER_PORT: |
| | | value = auth.getPort(); |
| | | break; |
| | | |
| | | return auth.getPort(); |
| | | case REPLICATION_OPTIONS: |
| | | value = defaultUserData.getReplicationOptions().getType(); |
| | | break; |
| | | |
| | | return defaultUserData.getReplicationOptions().getType(); |
| | | default: |
| | | throw new IllegalArgumentException("Unknown field name: " + |
| | | fieldName); |
| | | throw new IllegalArgumentException("Unknown field name: " + fieldName); |
| | | } |
| | | |
| | | return value; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | private String getDefaultStringValue(FieldName fieldName) |
| | | { |
| | | String value = null; |
| | | |
| | | Object v = getDefaultValue(fieldName); |
| | | if (v != null) |
| | | { |
| | | if (v instanceof String) |
| | | { |
| | | value = (String) v; |
| | | } else |
| | | { |
| | | value = String.valueOf(v); |
| | | } |
| | | return String.valueOf(v); |
| | | } |
| | | return value; |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | for (FieldName fieldName : hm.keySet()) |
| | | { |
| | | JTextComponent field; |
| | | LabelFieldDescriptor desc = hm.get(fieldName); |
| | | |
| | | String defaultValue = getDefaultStringValue(fieldName); |
| | | field = UIFactory.makeJTextComponent(desc, defaultValue); |
| | | JTextComponent field = UIFactory.makeJTextComponent(desc, defaultValue); |
| | | |
| | | hmFields.put(fieldName, field); |
| | | |
| | | JLabel l = UIFactory.makeJLabel(desc); |
| | | |
| | | l.setLabelFor(field); |
| | | |
| | | hmLabels.put(fieldName, l); |
| | |
| | | } |
| | | setFieldValue(FieldName.HOST_NAME, userData.getHostName()); |
| | | setFieldValue(FieldName.SERVER_PORT, Integer.toString(userData.getServerPort())); |
| | | setFieldValue(FieldName.ADMIN_CONNECTOR_PORT, Integer.toString((userData.getAdminConnectorPort()))); |
| | | setFieldValue(FieldName.ADMIN_CONNECTOR_PORT, Integer.toString(userData.getAdminConnectorPort())); |
| | | setFieldValue(FieldName.SECURITY_OPTIONS, Utils.getSecurityOptionsString(userData.getSecurityOptions(), false)); |
| | | setFieldValue(FieldName.DIRECTORY_MANAGER_DN, userData.getDirectoryManagerDn()); |
| | | setFieldValue(FieldName.DATA_OPTIONS, Utils.getDataDisplayString(userData)); |
| | |
| | | if (!Utils.isWebStart()) |
| | | { |
| | | String javaHome = System.getProperty("java.home"); |
| | | if ((javaHome == null) || (javaHome.length() == 0)) |
| | | if (javaHome == null || javaHome.length() == 0) |
| | | { |
| | | javaHome = System.getenv(SetupUtils.OPENDJ_JAVA_HOME); |
| | | } |
| | |
| | | |
| | | private boolean displayWebStartWarningIfRequired() |
| | | { |
| | | boolean returnValue = true; |
| | | if (Utils.isWebStart() && !userAgreedWithWebStart) |
| | | { |
| | | JavaArguments args = getJavaArguments(); |
| | | if (!args.equals(javaArguments) && |
| | | ((args.getInitialMemory() != -1) || |
| | | (args.getMaxMemory() != -1) || |
| | | (args.getAdditionalArguments().length > 0))) |
| | | (args.getInitialMemory() != -1 || |
| | | args.getMaxMemory() != -1 || |
| | | args.getAdditionalArguments().length > 0)) |
| | | { |
| | | returnValue = displayConfirmationDialog( |
| | | userAgreedWithWebStart = displayConfirmationDialog( |
| | | INFO_JAVA_ARGUMENTS_CANNOT_BE_CHECKED_IN_WEBSTART.get(), |
| | | INFO_CONFIRMATION_TITLE.get()); |
| | | userAgreedWithWebStart = returnValue; |
| | | return userAgreedWithWebStart; |
| | | } |
| | | } |
| | | return returnValue; |
| | | return true; |
| | | } |
| | | } |
| | |
| | | for (String id : hmLabels.keySet()) |
| | | { |
| | | String sPort = hmFields.get(id).getText(); |
| | | boolean isValid = false; |
| | | try |
| | | { |
| | | int replicationPort = Integer.parseInt(sPort); |
| | | if ((replicationPort >= 1) && |
| | | (replicationPort <= 65535)) |
| | | { |
| | | isValid = true; |
| | | } |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | if (!isValid) |
| | | if (!isValid(sPort)) |
| | | { |
| | | UIFactory.setTextStyle(hmLabels.get(id), |
| | | UIFactory.TextStyle.SECONDARY_FIELD_INVALID); |
| | |
| | | } |
| | | } |
| | | |
| | | private boolean isValid(String sPort) |
| | | { |
| | | try |
| | | { |
| | | int port = Integer.parseInt(sPort); |
| | | if (port >= 1 && port <= 65535) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | protected boolean requiresScroll() |
| | | { |
| | |
| | | */ |
| | | public void display(String[] aliases) |
| | | { |
| | | if ((aliases == null) || (aliases.length ==0)) |
| | | if (aliases == null || aliases.length ==0) |
| | | { |
| | | throw new IllegalArgumentException( |
| | | "The provided aliases are null or empty."); |
| | |
| | | { |
| | | String parent = tfServerLocationParent.getText(); |
| | | String relative = tfServerLocationRelativePath.getText(); |
| | | if ((parent != null) && (parent.length() > 0)) |
| | | if (parent != null && parent.length() > 0) |
| | | { |
| | | value = parent; |
| | | } |
| | | if ((relative != null) && (relative.length() > 0)) |
| | | if (relative != null && relative.length() > 0) |
| | | { |
| | | if (value == null) |
| | | { |
| | |
| | | |
| | | package org.opends.quicksetup.ui; |
| | | |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | |
| | | import java.awt.CardLayout; |
| | | import java.awt.Component; |
| | | import java.awt.Dimension; |
| | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | |
| | | import javax.naming.ldap.LdapName; |
| | | import javax.naming.ldap.Rdn; |
| | | import javax.swing.Box; |
| | |
| | | import javax.swing.event.HyperlinkEvent; |
| | | import javax.swing.event.HyperlinkListener; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.quicksetup.UserDataCertificateException; |
| | | import org.opends.quicksetup.event.MinimumSizeComponentListener; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | |
| | | /** |
| | | * This class is used to present the user a certificate to the user in order |
| | | * it to be accepted. |
| | |
| | | */ |
| | | public enum ReturnType |
| | | { |
| | | /** |
| | | * The user did not accept the certificate. |
| | | */ |
| | | /** The user did not accept the certificate. */ |
| | | NOT_ACCEPTED, |
| | | /** |
| | | * The user accepted the certificate only for this session. |
| | | */ |
| | | /** The user accepted the certificate only for this session. */ |
| | | ACCEPTED_FOR_SESSION, |
| | | /** |
| | | * The user accepted the certificate permanently. |
| | | */ |
| | | /** The user accepted the certificate permanently. */ |
| | | ACCEPTED_PERMANENTLY |
| | | } |
| | | private static final long serialVersionUID = -8989965057591475064L; |
| | |
| | | * |
| | | * @param e the HyperlinkEvent. |
| | | */ |
| | | @Override |
| | | public void hyperlinkUpdate(HyperlinkEvent e) |
| | | { |
| | | if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) |
| | |
| | | explanationPane.setEditable(false); |
| | | explanationPane.addHyperlinkListener(this); |
| | | p.add(explanationPane, gbc); |
| | | if ((ce.getChain() != null) && (ce.getChain().length > 0)) |
| | | if (ce.getChain() != null && ce.getChain().length > 0) |
| | | { |
| | | LocalizableMessageBuilder mb = new LocalizableMessageBuilder(); |
| | | mb.append(text); |
| | |
| | | INFO_CERTIFICATE_DIALOG_ACCEPT_FOR_SESSION_BUTTON_TOOLTIP.get()); |
| | | buttonsPanel.add(acceptSessionButton, gbc); |
| | | acceptSessionButton.addActionListener(new ActionListener() { |
| | | @Override |
| | | public void actionPerformed(ActionEvent ev) { |
| | | acceptForSession(); |
| | | } |
| | |
| | | INFO_CERTIFICATE_DIALOG_ACCEPT_PERMANENTLY_BUTTON_TOOLTIP.get()); |
| | | buttonsPanel.add(acceptPermanentlyButton, gbc); |
| | | acceptPermanentlyButton.addActionListener(new ActionListener() { |
| | | @Override |
| | | public void actionPerformed(ActionEvent ev) { |
| | | acceptPermanently(); |
| | | } |
| | |
| | | buttonsPanel.add(doNotAcceptButton, gbc); |
| | | doNotAcceptButton.addActionListener(new ActionListener() |
| | | { |
| | | @Override |
| | | public void actionPerformed(ActionEvent ev) |
| | | { |
| | | doNotAccept(); |
| | |
| | | { |
| | | JPanel p = UIFactory.makeJPanel(); |
| | | p.setLayout(new GridBagLayout()); |
| | | if ((ce.getChain() != null) && (ce.getChain().length > 0)) |
| | | if (ce.getChain() != null && ce.getChain().length > 0) |
| | | { |
| | | final JComboBox combo = new JComboBox(); |
| | | combo.setToolTipText( |
| | |
| | | |
| | | combo.addActionListener(new ActionListener() |
| | | { |
| | | @Override |
| | | public void actionPerformed(ActionEvent ev) |
| | | { |
| | | String selectedItem = (String)combo.getSelectedItem(); |
| | |
| | | */ |
| | | public static LocalizableMessage getSHA1FingerPrint(X509Certificate cert) |
| | | { |
| | | LocalizableMessage msg = null; |
| | | try { |
| | | MessageDigest md = MessageDigest.getInstance("SHA1"); |
| | | |
| | | byte[] b = md.digest(cert.getEncoded()); |
| | | StringBuilder sb = new StringBuilder(); |
| | | for (int i = 0; i < b.length; i++) |
| | | { |
| | | if (i > 0) |
| | | { |
| | | sb.append(":"); |
| | | } |
| | | sb.append(Integer.toHexString(((int) b[i]) & 0xFF)); |
| | | } |
| | | msg = LocalizableMessage.raw(sb); |
| | | } |
| | | catch (NoSuchAlgorithmException nsae) { |
| | | logger.warn(LocalizableMessage.raw("SHA1 algorithm not supported: "+nsae, nsae)); |
| | | } |
| | | catch (CertificateEncodingException cee) { |
| | | logger.warn(LocalizableMessage.raw("Certificate encoding exception: "+cee, cee)); |
| | | } |
| | | return msg; |
| | | return getFingerPrint(cert, "SHA1"); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static LocalizableMessage getMD5FingerPrint(X509Certificate cert) |
| | | { |
| | | LocalizableMessage msg = null; |
| | | try { |
| | | MessageDigest md = MessageDigest.getInstance("MD5"); |
| | | return getFingerPrint(cert, "MD5"); |
| | | } |
| | | |
| | | private static LocalizableMessage getFingerPrint(X509Certificate cert, String algorithm) |
| | | { |
| | | try { |
| | | MessageDigest md = MessageDigest.getInstance(algorithm); |
| | | byte[] b = md.digest(cert.getEncoded()); |
| | | StringBuilder sb = new StringBuilder(); |
| | | for (int i = 0; i < b.length; i++) |
| | |
| | | { |
| | | sb.append(":"); |
| | | } |
| | | sb.append(Integer.toHexString(((int) b[i]) & 0xFF)); |
| | | sb.append(Integer.toHexString(b[i] & 0xFF)); |
| | | } |
| | | msg = LocalizableMessage.raw(sb); |
| | | return LocalizableMessage.raw(sb); |
| | | } |
| | | catch (NoSuchAlgorithmException nsae) { |
| | | logger.warn(LocalizableMessage.raw("MD5 algorithm not supported: "+nsae, nsae)); |
| | | logger.warn(LocalizableMessage.raw(algorithm + " algorithm not supported: " + nsae, nsae)); |
| | | return null; |
| | | } |
| | | catch (CertificateEncodingException cee) { |
| | | logger.warn(LocalizableMessage.raw("Certificate encoding exception: "+cee, cee)); |
| | | return null; |
| | | } |
| | | return msg; |
| | | } |
| | | |
| | | private JComponent createSHA1FingerprintComponent(X509Certificate cert) |
| | |
| | | { |
| | | LdapName dn = new LdapName(name); |
| | | Rdn rdn = dn.getRdn(0); |
| | | name = rdn.getValue().toString(); |
| | | return rdn.getValue().toString(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | logger.warn(LocalizableMessage.raw("Error parsing subject dn: "+ |
| | | cert.getSubjectX500Principal(), t)); |
| | | return name; |
| | | } |
| | | return name; |
| | | } |
| | | |
| | | /** |
| | | * Method called when user clicks on ok. |
| | | * |
| | | */ |
| | | /** Method called when user clicks on ok. */ |
| | | private void acceptForSession() |
| | | { |
| | | returnValue = ReturnType.ACCEPTED_FOR_SESSION; |
| | | dispose(); |
| | | } |
| | | |
| | | /** |
| | | * Method called when user clicks on cancel. |
| | | * |
| | | */ |
| | | /** Method called when user clicks on cancel. */ |
| | | private void doNotAccept() |
| | | { |
| | | returnValue = ReturnType.NOT_ACCEPTED; |
| | | dispose(); |
| | | } |
| | | |
| | | /** |
| | | * Method called when user clicks on ok. |
| | | * |
| | | */ |
| | | /** Method called when user clicks on ok. */ |
| | | private void acceptPermanently() |
| | | { |
| | | returnValue = ReturnType.ACCEPTED_PERMANENTLY; |
| | | dispose(); |
| | | } |
| | | |
| | | /** |
| | | * Method written for testing purposes. |
| | | * @param args the arguments to be passed to the test program. |
| | | */ |
| | | /* |
| | | public static void main(String[] args) |
| | | { |
| | | try |
| | | { |
| | | // TODO |
| | | } catch (Exception ex) |
| | | { |
| | | ex.printStackTrace(); |
| | | } |
| | | } |
| | | */ |
| | | } |
| | | |
| | |
| | | */ |
| | | public void setDisplayedStep(final WizardStep step, final UserData userData) |
| | | { |
| | | final CardLayout cl = (CardLayout) (getLayout()); |
| | | final CardLayout cl = (CardLayout) getLayout(); |
| | | |
| | | if (getPanel(step).blockingBeginDisplay()) |
| | | { |
| | |
| | | String authType = ce.getAuthType(); |
| | | String host = ce.getHost(); |
| | | |
| | | if ((chain != null) && (authType != null) && (host != null)) |
| | | if (chain != null && authType != null && host != null) |
| | | { |
| | | logger.info(LocalizableMessage.raw("Accepting certificate presented by host "+host)); |
| | | getTrustManager().acceptCertificate(chain, authType, host); |
| | |
| | | int lastPercentage = -1; |
| | | WebStartDownloader.Status lastStatus = |
| | | WebStartDownloader.Status.DOWNLOADING; |
| | | while (!loader.isFinished() && (loader.getException() == null)) |
| | | while (!loader.isFinished() && loader.getException() == null) |
| | | { |
| | | checkAbort(); |
| | | // Pool until is over |
| | | int perc = loader.getDownloadPercentage(); |
| | | WebStartDownloader.Status downloadStatus = loader.getStatus(); |
| | | if ((perc != lastPercentage) || (downloadStatus != lastStatus)) |
| | | if (perc != lastPercentage || downloadStatus != lastStatus) |
| | | { |
| | | lastPercentage = perc; |
| | | int ratio = (perc * maxRatio) / 100; |
| | |
| | | |
| | | if (multipleScreen) |
| | | { |
| | | comp.setLocation((screenSize.width / 4) - (width / 2), |
| | | comp.setLocation(screenSize.width / 4 - width / 2, |
| | | (screenSize.height - height) / 2); |
| | | } else |
| | | { |
| | |
| | | |
| | | if (!destination.exists()) { |
| | | if (Utils.insureParentsExist(destination)) { |
| | | if ((application != null) && application.isVerbose()) { |
| | | if (application != null && application.isVerbose()) { |
| | | application.notifyListeners(application.getFormattedWithPoints( |
| | | INFO_PROGRESS_COPYING_FILE.get( |
| | | objectFile.getAbsolutePath(), |
| | |
| | | Utils.setPermissionsUnix(Utils.getPath(destination), permissions); |
| | | } |
| | | |
| | | if ((application != null) && application.isVerbose()) { |
| | | if (application != null && application.isVerbose()) { |
| | | application.notifyListeners( |
| | | application.getFormattedDoneWithLineBreak()); |
| | | } |
| | |
| | | logger.info(LocalizableMessage.raw("Ignoring file '" + |
| | | objectFile.getAbsolutePath() + "' since '" + |
| | | destination.getAbsolutePath() + "' already exists")); |
| | | if ((application != null) && application.isVerbose()) { |
| | | if (application != null && application.isVerbose()) { |
| | | application.notifyListeners( |
| | | INFO_INFO_IGNORING_FILE.get( |
| | | objectFile.getAbsolutePath(), |
| | |
| | | File file = getObjectFile(); |
| | | boolean isFile = file.isFile(); |
| | | |
| | | if ((application != null) && application.isVerbose()) { |
| | | if (application != null && application.isVerbose()) { |
| | | if (isFile) { |
| | | application.notifyListeners(application.getFormattedWithPoints( |
| | | INFO_PROGRESS_DELETING_FILE.get(file.getAbsolutePath()))); |
| | |
| | | errMsg, null); |
| | | } |
| | | |
| | | if ((application != null) && application.isVerbose()) { |
| | | if (application != null && application.isVerbose()) { |
| | | application.notifyListeners( |
| | | application.getFormattedDoneWithLineBreak()); |
| | | } |
| | |
| | | int ratioBeforeCompleted = minRatio |
| | | + ((nEntries - 1) * (maxRatio - minRatio) / numberZipEntries); |
| | | int ratioWhenCompleted = |
| | | minRatio + (nEntries * (maxRatio - minRatio) / |
| | | numberZipEntries); |
| | | minRatio + (nEntries * (maxRatio - minRatio) / numberZipEntries); |
| | | |
| | | String name = entry.getName(); |
| | | if (name != null && removeFirstPath) { |
| | |
| | | */ |
| | | public final AbstractManagedObjectDefinition<? extends C, ? extends S> |
| | | getChild(String name) throws IllegalArgumentException { |
| | | if ((name == null) || (name.length() == 0)) { |
| | | if (name == null || name.length() == 0) { |
| | | throw new IllegalArgumentException("null or empty managed object name"); |
| | | } |
| | | |
| | |
| | | */ |
| | | public final PropertyDefinition<?> getPropertyDefinition(String name) |
| | | throws IllegalArgumentException { |
| | | if ((name == null) || (name.length() == 0)) { |
| | | if (name == null || name.length() == 0) { |
| | | throw new IllegalArgumentException("null or empty property name"); |
| | | } |
| | | |
| | |
| | | */ |
| | | public final RelationDefinition<?, ?> getRelationDefinition(String name) |
| | | throws IllegalArgumentException { |
| | | if ((name == null) || (name.length() == 0)) { |
| | | if (name == null || name.length() == 0) { |
| | | throw new IllegalArgumentException("null or empty relation name"); |
| | | } |
| | | |
| | |
| | | public final AggregationPropertyDefinition<?, ?> |
| | | getAggregationPropertyDefinition(String name) |
| | | throws IllegalArgumentException { |
| | | if ((name == null) || (name.length() == 0)) { |
| | | if (name == null || name.length() == 0) { |
| | | throw new IllegalArgumentException( |
| | | "null or empty aggregation property name"); |
| | | } |
| | |
| | | * definition is the {@link TopCfgDefn}. |
| | | */ |
| | | public final boolean isTop() { |
| | | return (this instanceof TopCfgDefn); |
| | | return this instanceof TopCfgDefn; |
| | | } |
| | | |
| | | |
| | |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | |
| | | if ((upperLimit != null) && (nvalue > upperLimit)) { |
| | | if (upperLimit != null && nvalue > upperLimit) { |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | } |
| | |
| | | |
| | | // Check the unit is in range - values must not be more granular |
| | | // than the base unit. |
| | | if ((ms % baseUnit.getDuration()) != 0) { |
| | | if (ms % baseUnit.getDuration() != 0) { |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | |
| | |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | |
| | | if ((upperLimit != null) && (value > upperLimit)) { |
| | | if (upperLimit != null && value > upperLimit) { |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | } |
| | |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | |
| | | if ((upperLimit != null) && (value > upperLimit)) { |
| | | if (upperLimit != null && value > upperLimit) { |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | } |
| | |
| | | import org.opends.server.admin.AbsoluteInheritedDefaultBehaviorProvider; |
| | | import org.opends.server.admin.AbstractManagedObjectDefinition; |
| | | import org.opends.server.admin.AdministratorAction.Type; |
| | | import org.opends.server.admin.RelationDefinition; |
| | | import org.opends.server.admin.std.meta.RootCfgDefn; |
| | | import org.opends.server.admin.*; |
| | | import org.opends.server.types.InitializationException; |
| | |
| | | } |
| | | // Create new dir if necessary |
| | | try { |
| | | (new File(generationDir)).mkdir(); |
| | | new File(generationDir).mkdir(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | System.exit(1); |
| | |
| | | for (String catName : list.keySet()) { |
| | | heading3(getFriendlyName(catName)); |
| | | // Get the list of the category |
| | | TreeMap<String, AbstractManagedObjectDefinition> catList = |
| | | list.get(catName); |
| | | TreeMap<String, AbstractManagedObjectDefinition> catList = list.get(catName); |
| | | for (AbstractManagedObjectDefinition mo : catList.values()) { |
| | | if ((relList.get(mo.getName()) != null) && |
| | | (relList.get(mo.getName()).hasOption(RelationOption.HIDDEN))) { |
| | | RelationDefinition relDefn = relList.get(mo.getName()); |
| | | if (relDefn != null && relDefn.hasOption(RelationOption.HIDDEN)) { |
| | | continue; |
| | | } |
| | | paragraph( |
| | |
| | | TreeMap<String, AbstractManagedObjectDefinition> list) { |
| | | |
| | | for (AbstractManagedObjectDefinition mo : list.values()) { |
| | | if ((relList.get(mo.getName()) != null) && |
| | | (relList.get(mo.getName()).hasOption(RelationOption.HIDDEN))) { |
| | | RelationDefinition relDefn = relList.get(mo.getName()); |
| | | if (relDefn != null && relDefn.hasOption(RelationOption.HIDDEN)) { |
| | | continue; |
| | | } |
| | | moList.put(mo.getName(), mo); |
| | |
| | | tableRow("Allowed Values", getSyntaxStr(prop)); |
| | | |
| | | tableRow("Multi-valued", |
| | | (prop.hasOption(PropertyOption.MULTI_VALUED) ? "Yes" : "No")); |
| | | prop.hasOption(PropertyOption.MULTI_VALUED) ? "Yes" : "No"); |
| | | |
| | | if (prop.hasOption(PropertyOption.MANDATORY)) { |
| | | tableRow("Required", "Yes"); |
| | |
| | | } else if (actionType == Type.NONE) { |
| | | actionStr = "None"; |
| | | } |
| | | String dot = (actionStr.equals("") ? "" : ". "); |
| | | String dot = actionStr.equals("") ? "" : ". "; |
| | | action = actionStr + |
| | | ((synopsis != null) ? dot + synopsis : ""); |
| | | } |
| | |
| | | advancedProps.values().toArray(new PropertyDefinition[0]); |
| | | |
| | | for (int ii=0; |
| | | (ii < basicPropsArray.length) || (ii < advancedPropsArray.length); |
| | | ii < basicPropsArray.length || ii < advancedPropsArray.length; |
| | | ii++) { |
| | | String basicPropName = |
| | | ii < basicPropsArray.length ? basicPropsArray[ii].getName() : null; |
| | |
| | | if (basicPropName != null) { |
| | | basicHtmlCell = " <td>↓ <a href=\"#" + basicPropName + "\">" |
| | | + basicPropName + "</a></td>\n"; |
| | | } else if ((basicPropsArray.length == 0) && (ii == 0)) { |
| | | } else if (basicPropsArray.length == 0 && ii == 0) { |
| | | basicHtmlCell = " <td> None</td>\n"; |
| | | } else if (ii >= basicPropsArray.length) { |
| | | // Case of nb of basic props < nb of advanced props |
| | |
| | | if (advancedPropName != null) { |
| | | advancedHtmlCell = " <td>↓ <a href=\"#" + advancedPropName + |
| | | "\">" + advancedPropName + "</a></td>\n"; |
| | | } else if ((advancedPropsArray.length == 0) && (ii == 0)) { |
| | | } else if (advancedPropsArray.length == 0 && ii == 0) { |
| | | advancedHtmlCell = " <td> None</td>\n"; |
| | | } |
| | | |
| | |
| | | |
| | | private final String Now = new Date().toString(); |
| | | private String getHtmlHeader(String pageTitle) { |
| | | return ("<html>\n" + |
| | | return "<html>\n" + |
| | | "<head>\n" + |
| | | "<meta http-equiv=\"content-type\"\n" + |
| | | "content=\"text/html; charset=ISO-8859-1\">\n" + |
| | |
| | | "href=\"" + CSS_FILE + "\">\n" + |
| | | "<link rel=\"shortcut icon\" href=\"" + FAVICON + "\">\n" + |
| | | "<meta name=\"date generated\" content=\"" + Now + "\">\n" + |
| | | "</head>\n"); |
| | | "</head>\n"; |
| | | } |
| | | |
| | | /** Add a Tab Menu, the active tab is the one given as parameter. */ |
| | |
| | | } |
| | | |
| | | private int getIndentPixels() { |
| | | return (ind * 40); |
| | | return ind * 40; |
| | | } |
| | | |
| | | private void startTable() { |
| | |
| | | for(; i > 0; i--) |
| | | { |
| | | wrappedListener = delayListener.getDelayedAddListener(); |
| | | if(wrappedListener != null && |
| | | wrappedListener instanceof DelayedConfigAddListener) |
| | | if(wrappedListener instanceof DelayedConfigAddListener) |
| | | { |
| | | delayListener = (DelayedConfigAddListener) l; |
| | | } |
| | |
| | | ConfigAddListener delayedListener = |
| | | delayListener.getDelayedAddListener(); |
| | | |
| | | if (delayedListener != null && |
| | | delayedListener instanceof ConfigAddListenerAdaptor) { |
| | | if (delayedListener instanceof ConfigAddListenerAdaptor) { |
| | | ConfigAddListenerAdaptor<?> adaptor = |
| | | (ConfigAddListenerAdaptor<?>) delayedListener; |
| | | ServerManagedObjectAddListener<?> l2 = adaptor |
| | |
| | | for(; i > 0; i--) |
| | | { |
| | | wrappedListener = delayListener.getDelayedAddListener(); |
| | | if(wrappedListener != null && |
| | | wrappedListener instanceof DelayedConfigAddListener) |
| | | if(wrappedListener instanceof DelayedConfigAddListener) |
| | | { |
| | | delayListener = (DelayedConfigAddListener) l; |
| | | } |
| | |
| | | ConfigDeleteListener delayedListener = |
| | | delayListener.getDelayedDeleteListener(); |
| | | |
| | | if (delayedListener != null && |
| | | delayedListener instanceof ConfigDeleteListenerAdaptor) { |
| | | if (delayedListener instanceof ConfigDeleteListenerAdaptor) { |
| | | ConfigDeleteListenerAdaptor<?> adaptor = |
| | | (ConfigDeleteListenerAdaptor<?>) delayedListener; |
| | | ServerManagedObjectDeleteListener<?> l2 = adaptor |
| | |
| | | for(; i > 0; i--) |
| | | { |
| | | wrappedListener = delayListener.getDelayedAddListener(); |
| | | if(wrappedListener != null && |
| | | wrappedListener instanceof DelayedConfigAddListener) |
| | | if(wrappedListener instanceof DelayedConfigAddListener) |
| | | { |
| | | delayListener = (DelayedConfigAddListener) l; |
| | | } |
| | |
| | | ConfigAddListener delayedListener = |
| | | delayListener.getDelayedAddListener(); |
| | | |
| | | if (delayedListener != null && |
| | | delayedListener instanceof ConfigAddListenerAdaptor) { |
| | | if (delayedListener instanceof ConfigAddListenerAdaptor) { |
| | | ConfigAddListenerAdaptor<?> adaptor = |
| | | (ConfigAddListenerAdaptor<?>) delayedListener; |
| | | if (adaptor.getServerManagedObjectAddListener() == listener) { |
| | |
| | | for(; i > 0; i--) |
| | | { |
| | | wrappedListener = delayListener.getDelayedAddListener(); |
| | | if(wrappedListener != null && |
| | | wrappedListener instanceof DelayedConfigAddListener) |
| | | if(wrappedListener instanceof DelayedConfigAddListener) |
| | | { |
| | | delayListener = (DelayedConfigAddListener) l; |
| | | } |
| | |
| | | ConfigDeleteListener delayedListener = |
| | | delayListener.getDelayedDeleteListener(); |
| | | |
| | | if (delayedListener != null && |
| | | delayedListener instanceof ConfigDeleteListenerAdaptor) { |
| | | if (delayedListener instanceof ConfigDeleteListenerAdaptor) { |
| | | ConfigDeleteListenerAdaptor<?> adaptor = |
| | | (ConfigDeleteListenerAdaptor<?>) delayedListener; |
| | | if (adaptor.getServerManagedObjectDeleteListener() == listener) { |
| | |
| | | // Get the configuration entry. |
| | | DN targetDN = DNBuilder.create(path); |
| | | try { |
| | | return (getManagedObjectConfigEntry(targetDN) != null); |
| | | return getManagedObjectConfigEntry(targetDN) != null; |
| | | } catch (ConfigException e) { |
| | | // Assume it doesn't exist. |
| | | return false; |
| | |
| | | buffer.append(getOID()); |
| | | |
| | | String description = getDescription(); |
| | | if ((description == null) || (description.length() == 0)) |
| | | if (description != null && description.length() != 0) |
| | | { |
| | | buffer.append(" )"); |
| | | buffer.append(" DESC '").append(description).append("'"); |
| | | } |
| | | else |
| | | { |
| | | buffer.append(" DESC '"); |
| | | buffer.append(description); |
| | | buffer.append("' )"); |
| | | } |
| | | buffer.append(" )"); |
| | | } |
| | | } |
| | | |
| | |
| | | // search for the nearest applicable sub-entry. |
| | | List<SubEntry> pwpSubEntries = DirectoryServer.getSubentryManager() |
| | | .getSubentries(userEntry); |
| | | if ((pwpSubEntries != null) && (!pwpSubEntries.isEmpty())) |
| | | if (pwpSubEntries != null && !pwpSubEntries.isEmpty()) |
| | | { |
| | | for (SubEntry subentry : pwpSubEntries) |
| | | { |
| | |
| | | return false; |
| | | } |
| | | |
| | | final boolean result = isDisabled == ConditionResult.TRUE; |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.trace("User %s is%s administratively disabled.", userEntry.getName(), |
| | | (isDisabled == ConditionResult.TRUE ? "" : " not")); |
| | | result ? "" : " not"); |
| | | } |
| | | |
| | | return isDisabled == ConditionResult.TRUE; |
| | | return result; |
| | | } |
| | | |
| | | |
| | |
| | | for (final byte b : idBytes) |
| | | { |
| | | id <<= 8; |
| | | id |= (b & 0xFF); |
| | | id |= b & 0xFF; |
| | | } |
| | | return id - 1; // Subtract 1 to compensate for old behavior. |
| | | } |
| | |
| | | return; |
| | | } |
| | | boolean lastWasPeriod = false; |
| | | while ((pos < length) && ((c = oidStr.charAt(pos++)) != ' ')) { |
| | | while (pos < length && ((c = oidStr.charAt(pos++)) != ' ')) { |
| | | if (c == '.') { |
| | | if (lastWasPeriod) { |
| | | LocalizableMessage message = WARN_ACI_SYNTAX_DOUBLE_PERIOD_IN_NUMERIC_OID.get( |
| | |
| | | |
| | | import static org.opends.messages.AccessControlMessages.*; |
| | | import static org.opends.server.authorization.dseecompat.Aci.*; |
| | | import static org.opends.server.authorization.dseecompat.EnumEvalResult.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | |
| | | * @return An enumeration result of the evaluation. |
| | | */ |
| | | public EnumEvalResult evaluate(AciEvalContext evalCtx) { |
| | | EnumEvalResult res=EnumEvalResult.FALSE; |
| | | EnumEvalResult res = FALSE; |
| | | List<PermBindRulePair>pairs=getPermBindRulePairs(); |
| | | for(PermBindRulePair p : pairs) { |
| | | if(evalCtx.isDenyEval() && |
| | | (p.hasAccessType(EnumAccessType.ALLOW))) { |
| | | if (evalCtx.isDenyEval() && p.hasAccessType(EnumAccessType.ALLOW)) { |
| | | continue; |
| | | } |
| | | if(!p.hasRights(getEvalRights(evalCtx))) { |
| | |
| | | res=p.getBindRule().evaluate(evalCtx); |
| | | // The evaluation result could be FAIL. Stop processing and return |
| | | //FAIL. Maybe an internal search failed. |
| | | if((res != EnumEvalResult.TRUE) && |
| | | (res != EnumEvalResult.FALSE)) { |
| | | res=EnumEvalResult.FAIL; |
| | | if(res != TRUE && res != FALSE) { |
| | | res = FAIL; |
| | | break; |
| | | //If the access type is DENY and the pair evaluated to TRUE, |
| | | //then stop processing and return TRUE. A deny pair |
| | | //succeeded. |
| | | } else if((p.hasAccessType(EnumAccessType.DENY)) && |
| | | (res == EnumEvalResult.TRUE)) { |
| | | res=EnumEvalResult.TRUE; |
| | | //then stop processing and return TRUE. A deny pair succeeded. |
| | | } else if (p.hasAccessType(EnumAccessType.DENY) && res == TRUE) { |
| | | res = TRUE; |
| | | break; |
| | | //An allow access type evaluated TRUE, stop processing |
| | | //and return TRUE. |
| | | } else if((p.hasAccessType(EnumAccessType.ALLOW) && |
| | | (res == EnumEvalResult.TRUE))) { |
| | | res=EnumEvalResult.TRUE; |
| | | //An allow access type evaluated TRUE, stop processing and return TRUE. |
| | | } else if (p.hasAccessType(EnumAccessType.ALLOW) && res == TRUE) { |
| | | res = TRUE; |
| | | break; |
| | | } |
| | | } |
| | |
| | | * @return The evaluation rights to used in the evaluation. |
| | | */ |
| | | private int getEvalRights(AciEvalContext evalCtx) { |
| | | if(evalCtx.hasRights(ACI_WRITE) && |
| | | evalCtx.hasRights(ACI_SELF)) { |
| | | if(evalCtx.hasRights(ACI_WRITE) && evalCtx.hasRights(ACI_SELF)) { |
| | | return ACI_SELF; |
| | | } else if(evalCtx.hasRights(ACI_COMPARE)) { |
| | | return ACI_COMPARE; |
| | |
| | | buffer.append(pair); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void setEvalUserAttributes(int v) { |
| | | if(operation instanceof SearchOperation && (rightsMask == ACI_READ)) { |
| | | if(operation instanceof SearchOperation && rightsMask == ACI_READ) { |
| | | if(v == ACI_FOUND_USER_ATTR_RULE) { |
| | | evalAllAttributes |= ACI_FOUND_USER_ATTR_RULE; |
| | | evalAllAttributes &= ~ACI_USER_ATTR_STAR_MATCHED; |
| | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void setEvalOpAttributes(int v) { |
| | | if(operation instanceof SearchOperation && (rightsMask == ACI_READ)) { |
| | | if(operation instanceof SearchOperation && rightsMask == ACI_READ) { |
| | | if(v == ACI_FOUND_OP_ATTR_RULE) { |
| | | evalAllAttributes |= ACI_FOUND_OP_ATTR_RULE; |
| | | evalAllAttributes &= ~ACI_OP_ATTR_PLUS_MATCHED; |
| | |
| | | { |
| | | Entry entry = modifyOperation.getCurrentEntry(); |
| | | Entry modEntry = modifyOperation.getModifiedEntry(); |
| | | if ((entry != null) && (modEntry != null)) |
| | | if (entry != null && modEntry != null) |
| | | { |
| | | doPostModify(modifyOperation.getModifications(), entry, modEntry); |
| | | } |
| | |
| | | public static boolean skipRightsHasRights(int rights) { |
| | | //geteffectiverights sets this flag, turn it off before evaluating. |
| | | int tmpRights=rights & ~ACI_SKIP_PROXY_CHECK; |
| | | return ((skipRights & tmpRights) == tmpRights); |
| | | return (skipRights & tmpRights) == tmpRights; |
| | | } |
| | | |
| | | |
| | |
| | | * contains a simple target DN and a equality operator, that |
| | | * simple target DN is used as the target DN. |
| | | */ |
| | | if((targets.getTarget() != null) && |
| | | (!targets.getTarget().isPattern())) { |
| | | if(targets.getTarget() != null && !targets.getTarget().isPattern()) { |
| | | EnumTargetOperator op=targets.getTarget().getOperator(); |
| | | if(op != EnumTargetOperator.NOT_EQUALITY) |
| | | { |
| | |
| | | } |
| | | break; |
| | | case SUBORDINATES: |
| | | if ((entryDN.size() <= targetDN.size()) || |
| | | if (entryDN.size() <= targetDN.size() || |
| | | !entryDN.isDescendantOf(targetDN)) { |
| | | return false; |
| | | } |
| | |
| | | * against the entry containing the ACI. If operator is inequality, |
| | | * check that it doesn't match the target DN. |
| | | */ |
| | | if((targets.getTarget() != null) && |
| | | (!targets.getTarget().isPattern())) { |
| | | if(targets.getTarget() != null && |
| | | !targets.getTarget().isPattern()) { |
| | | EnumTargetOperator op=targets.getTarget().getOperator(); |
| | | if(op == EnumTargetOperator.NOT_EQUALITY) { |
| | | DN tmpDN=targets.getTarget().getDN(); |
| | |
| | | * created when the ACI was decoded. If inequality flip the |
| | | * result. |
| | | */ |
| | | if((targets.getTarget() != null) && |
| | | (targets.getTarget().isPattern())) { |
| | | if(targets.getTarget() != null && |
| | | targets.getTarget().isPattern()) { |
| | | final boolean ret = targets.getTarget().matchesPattern(entryDN); |
| | | EnumTargetOperator op=targets.getTarget().getOperator(); |
| | | if(op == EnumTargetOperator.NOT_EQUALITY) |
| | |
| | | String canonicalName = addr.getCanonicalHostName(); |
| | | if (! hn.equalsIgnoreCase(canonicalName)) |
| | | { |
| | | if (hn.equalsIgnoreCase("localhost") && |
| | | (! dns.contains(canonicalName))) |
| | | if (hn.equalsIgnoreCase("localhost") |
| | | && !dns.contains(canonicalName)) |
| | | { |
| | | dns.add(canonicalName); |
| | | |
| | |
| | | EnumEvalResult matched = EnumEvalResult.FALSE; |
| | | for (DN groupDN : groupDNs) { |
| | | Group<?> group = getGroupManager().getGroupInstance(groupDN); |
| | | if((group != null) && (evalCtx.isMemberOf(group))) { |
| | | if(group != null && evalCtx.isMemberOf(group)) { |
| | | matched = EnumEvalResult.TRUE; |
| | | break; |
| | | } |
| | |
| | | continue; |
| | | } |
| | | Group<?> group = getGroupManager().getGroupInstance(groupDN); |
| | | if((group != null) && (evalCtx.isMemberOf(group))) { |
| | | if(group != null && evalCtx.isMemberOf(group)) { |
| | | matched=EnumEvalResult.TRUE; |
| | | break; |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | if ((subAnyElements != null) && (! subAnyElements.isEmpty())) |
| | | if (subAnyElements != null && ! subAnyElements.isEmpty()) |
| | | { |
| | | for (PatternRDN[] element : subAnyElements) |
| | | { |
| | |
| | | { |
| | | int finalLength = subFinal.length; |
| | | |
| | | if ((valueLength - finalLength) < pos) |
| | | if (valueLength - finalLength < pos) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | { |
| | | pos++; |
| | | } |
| | | else if ((c == ',' || c == ';')) |
| | | else if (c == ',' || c == ';') |
| | | { |
| | | if (name.equals("*")) |
| | | { |
| | |
| | | } |
| | | |
| | | // Skip over any spaces after the equal sign. |
| | | while ((pos < length) && (dnString.charAt(pos) == ' ')) |
| | | while (pos < length && dnString.charAt(pos) == ' ') |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | |
| | | |
| | | // Skip over any spaces that might be after the attribute value. |
| | | while ((pos < length) && ((c = dnString.charAt(pos)) == ' ')) |
| | | while (pos < length && ((c = dnString.charAt(pos)) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | rdnComponents.add(rdn); |
| | | break; |
| | | } |
| | | else if ((c == ',') || (c == ';')) |
| | | else if (c == ',' || c == ';') |
| | | { |
| | | // We're at the end of the RDN component, so add it to the list, |
| | | // skip over the comma/semicolon, and start on the next component. |
| | |
| | | // Skip over the plus sign and any spaces that may follow it |
| | | // before the next attribute name. |
| | | pos++; |
| | | while ((pos < length) && (dnString.charAt(pos) == ' ')) |
| | | while (pos < length && dnString.charAt(pos) == ' ') |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | |
| | | |
| | | // Skip over any spaces after the equal sign. |
| | | while ((pos < length) && ((c = dnString.charAt(pos)) == ' ')) |
| | | while (pos < length && ((c = dnString.charAt(pos)) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | rdn.addValue(name, parsedValue, dnString); |
| | | |
| | | |
| | | // Skip over any spaces that might be after the attribute |
| | | // value. |
| | | while ((pos < length) && ((c = dnString.charAt(pos)) == ' ')) |
| | | // Skip over any spaces that might be after the attribute value. |
| | | while (pos < length && ((c = dnString.charAt(pos)) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | | |
| | | |
| | | // Most likely, we will be at either the end of the RDN |
| | | // component or the end of the DN. If so, then handle that |
| | | // appropriately. |
| | | // component or the end of the DN. If so, then handle that appropriately. |
| | | if (pos >= length) |
| | | { |
| | | // We're at the end of the DN string and should have a valid |
| | |
| | | rdnComponents.add(rdn); |
| | | break; |
| | | } |
| | | else if ((c == ',') || (c == ';')) |
| | | else if (c == ',' || c == ';') |
| | | { |
| | | // We're at the end of the RDN component, so add it to the |
| | | // list, skip over the comma/semicolon, and start on the |
| | | // next component. |
| | | // list, skip over the comma/semicolon, and start on the next component. |
| | | rdnComponents.add(rdn); |
| | | pos++; |
| | | break; |
| | |
| | | // character, so throw an exception. |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_DN_INVALID_CHAR.get(dnString, c, pos); |
| | | throw new DirectoryException(ResultCode.INVALID_DN_SYNTAX, |
| | | message); |
| | | throw new DirectoryException(ResultCode.INVALID_DN_SYNTAX, message); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | while (validOID && (namePos < nameLength)) |
| | | while (validOID && namePos < nameLength) |
| | | { |
| | | char ch = attributeName.charAt(namePos++); |
| | | if (isDigit(ch)) |
| | | { |
| | | while (validOID && (namePos < nameLength) && |
| | | while (validOID && namePos < nameLength && |
| | | isDigit(attributeName.charAt(namePos))) |
| | | { |
| | | namePos++; |
| | | } |
| | | |
| | | if ((namePos < nameLength) && |
| | | (attributeName.charAt(namePos) != '.')) |
| | | if (namePos < nameLength && |
| | | attributeName.charAt(namePos) != '.') |
| | | { |
| | | validOID = false; |
| | | } |
| | | } |
| | | else if (ch == '.') |
| | | { |
| | | if ((namePos == 1) || |
| | | (attributeName.charAt(namePos-2) == '.')) |
| | | if (namePos == 1 || |
| | | attributeName.charAt(namePos-2) == '.') |
| | | { |
| | | validOID = false; |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | if (validOID && (attributeName.charAt(nameLength-1) == '.')) |
| | | if (validOID && attributeName.charAt(nameLength-1) == '.') |
| | | { |
| | | validOID = false; |
| | | } |
| | |
| | | { |
| | | // The first two characters must be hex characters. |
| | | StringBuilder hexString = new StringBuilder(); |
| | | if ((pos+2) > length) |
| | | if (pos+2 > length) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_DN_HEX_VALUE_TOO_SHORT.get(dnString); |
| | | throw new DirectoryException(ResultCode.INVALID_DN_SYNTAX, |
| | |
| | | message); |
| | | } |
| | | } |
| | | else if ((c == ' ') || (c == ',') || (c == ';')) |
| | | else if (c == ' ' || c == ',' || c == ';') |
| | | { |
| | | // This denotes the end of the value. |
| | | pos--; |
| | |
| | | { |
| | | escaped = true; |
| | | } |
| | | else if ((c == ',') || (c == ';')) |
| | | else if (c == ',' || c == ';') |
| | | { |
| | | appendHexChars(dnString, valueString, hexChars); |
| | | pos--; |
| | |
| | | } |
| | | try { |
| | | //Can only have one prefix value and one address string. |
| | | if((numParts < 1) || (numParts > 2) ) { |
| | | if(numParts < 1 || numParts > 2 ) { |
| | | LocalizableMessage message = |
| | | WARN_ACI_SYNTAX_INVALID_PREFIX_FORMAT.get(expr); |
| | | throw new AciException(message); |
| | |
| | | prefix = Integer.parseInt(prefixStr); |
| | | } |
| | | //Must be between 0 to maxprefix. |
| | | if((prefix < 0) || (prefix > maxPrefix)) { |
| | | if(prefix < 0 || prefix > maxPrefix) { |
| | | LocalizableMessage message = |
| | | WARN_ACI_SYNTAX_INVALID_PREFIX_VALUE.get(expr); |
| | | throw new AciException(message); |
| | |
| | | prefixBytes[i] = (byte) 0xff; |
| | | prefix -= 8; |
| | | } |
| | | prefixBytes[i] = (byte) ((0xff) << (8 - prefix)); |
| | | prefixBytes[i] = (byte) (0xff << 8 - prefix); |
| | | return prefixBytes; |
| | | } |
| | | |
| | |
| | | throw new AciException(message); |
| | | } |
| | | //Can only have one netmask value and one address string. |
| | | if((numParts < 1) || (numParts > 2) ) { |
| | | if(numParts < 1 || numParts > 2 ) { |
| | | LocalizableMessage message = WARN_ACI_SYNTAX_INVALID_NETMASK_FORMAT.get(expr); |
| | | throw new AciException(message); |
| | | } |
| | |
| | | else { |
| | | long val=Integer.parseInt(quad); |
| | | //must be between 0-255 |
| | | if((val < 0) || (val > 0xff)) { |
| | | if(val < 0 || val > 0xff) { |
| | | LocalizableMessage message = |
| | | WARN_ACI_SYNTAX_INVALID_IPV4_VALUE.get(expr); |
| | | throw new AciException(message); |
| | |
| | | WARN_ACI_SYNTAX_INVALID_SSF_FORMAT.get(expr, nfe.getMessage()); |
| | | throw new AciException(message); |
| | | } |
| | | if ((valueAsInt <= 0) || (valueAsInt > MAX_KEY_BITS)) { |
| | | if (valueAsInt <= 0 || valueAsInt > MAX_KEY_BITS) { |
| | | LocalizableMessage message = WARN_ACI_SYNTAX_INVALID_SSF_RANGE.get(expr); |
| | | throw new AciException(message); |
| | | } |
| | |
| | | { |
| | | return firstFilterList; |
| | | } |
| | | else if((secondFilterList != null) && |
| | | secondFilterList.hasMask(mask)) |
| | | else if (secondFilterList != null && secondFilterList.hasMask(mask)) |
| | | { |
| | | return secondFilterList; |
| | | } |
| | |
| | | //the attribute types value(s) against the corresponding filter. |
| | | // If the filter list does not contain the attribute type skip the |
| | | // attribute type. |
| | | if((attrType != null) && (filterList.containsKey(attrType))) { |
| | | if(attrType != null && filterList.containsKey(attrType)) { |
| | | ByteString value = matchCtx.getCurrentAttributeValue(); |
| | | SearchFilter filter = filterList.get(attrType); |
| | | attrMatched=matchFilterAttributeValue(attrType, value, filter); |
| | |
| | | WARN_ACI_SYNTAX_INVALID_TIMEOFDAY_FORMAT.get(expr, nfe.getMessage()); |
| | | throw new AciException(message); |
| | | } |
| | | if ((valueAsInt < 0) || (valueAsInt > 2359)) |
| | | if (valueAsInt < 0 || valueAsInt > 2359) |
| | | { |
| | | LocalizableMessage message = WARN_ACI_SYNTAX_INVALID_TIMEOFDAY_RANGE.get(expr); |
| | | throw new AciException(message); |
| | |
| | | case PARENT: |
| | | { |
| | | DN parentDN = resDN.parent(); |
| | | if ((parentDN != null) && |
| | | (parentDN.equals(clientDN))) |
| | | if (parentDN != null && parentDN.equals(clientDN)) |
| | | { |
| | | matched = EnumEvalResult.TRUE; |
| | | } |
| | |
| | | } |
| | | } else if(scope == SearchScope.SINGLE_LEVEL) { |
| | | DN parent=evalCtx.getClientDN().parent(); |
| | | if((parent != null) && !parent.equals(urlDN)) |
| | | if(parent != null && !parent.equals(urlDN)) |
| | | { |
| | | return EnumEvalResult.FALSE; |
| | | } |
| | | } else if(scope == SearchScope.SUBORDINATES) { |
| | | DN userDN = evalCtx.getClientDN(); |
| | | if ((userDN.size() <= urlDN.size()) || |
| | | if (userDN.size() <= urlDN.size() || |
| | | !userDN.isDescendantOf(urlDN)) { |
| | | return EnumEvalResult.FALSE; |
| | | } |
| | |
| | | } |
| | | else if ((newIndexParts.length == 1 && existingIndexParts.length == 1) |
| | | || (newIndexParts.length > 1 && existingIndexParts.length == 1) |
| | | || (newIndexParts[1].equalsIgnoreCase(existingIndexParts[1]))) |
| | | || newIndexParts[1].equalsIgnoreCase(existingIndexParts[1])) |
| | | { |
| | | return; |
| | | } |
| | |
| | | { |
| | | if ((newIndexParts.length == 1 && existingIndexParts.length >= 1) |
| | | || (newIndexParts.length > 1 && existingIndexParts.length == 1) |
| | | || (newIndexParts[1].equalsIgnoreCase(existingIndexParts[1]))) |
| | | || newIndexParts[1].equalsIgnoreCase(existingIndexParts[1])) |
| | | { |
| | | return thatIndex; |
| | | } |
| | |
| | | |
| | | |
| | | long finishTime = System.currentTimeMillis(); |
| | | long totalTime = (finishTime - startTime); |
| | | long totalTime = finishTime - startTime; |
| | | |
| | | float rate = 0; |
| | | if (totalTime > 0) |
| | |
| | | public void run() |
| | | { |
| | | long latestCount = exportedCount; |
| | | long deltaCount = (latestCount - previousCount); |
| | | long deltaCount = latestCount - previousCount; |
| | | long latestTime = System.currentTimeMillis(); |
| | | long deltaTime = latestTime - previousTime; |
| | | |
| | |
| | | } |
| | | else |
| | | { |
| | | bytesToRead = Math.min((end - offset), cache.remaining()); |
| | | bytesToRead = Math.min(end - offset, cache.remaining()); |
| | | } |
| | | int bytesRead = 0; |
| | | while (bytesRead < bytesToRead) |
| | |
| | | for (int i = 0; i < INT_SIZE; i++) { |
| | | byte b = buffer[index + i]; |
| | | answer <<= 8; |
| | | answer |= (b & 0xff); |
| | | answer |= b & 0xff; |
| | | } |
| | | return answer; |
| | | } |
| | |
| | | for (int i = start; i < end; i++) |
| | | { |
| | | v <<= 8; |
| | | v |= (bytes[i] & 0xFF); |
| | | v |= bytes[i] & 0xFF; |
| | | } |
| | | return v; |
| | | } |
| | |
| | | if(bytes.length == 8) |
| | | { |
| | | long v = 0; |
| | | v |= (bytes[0] & 0x7F); |
| | | v |= bytes[0] & 0x7F; |
| | | for (int i = 1; i < 8; i++) |
| | | { |
| | | v <<= 8; |
| | | v |= (bytes[i] & 0xFF); |
| | | v |= bytes[i] & 0xFF; |
| | | } |
| | | return v; |
| | | } |
| | |
| | | v |= (decodedBytes[pos++] & 0xFFL) << 24; |
| | | v |= (decodedBytes[pos++] & 0xFFL) << 16; |
| | | v |= (decodedBytes[pos++] & 0xFFL) << 8; |
| | | v |= (decodedBytes[pos++] & 0xFFL); |
| | | v |= decodedBytes[pos++] & 0xFFL; |
| | | entryIDList[i] = v; |
| | | } |
| | | |
| | |
| | | v |= (decodedBytes[pos++] & 0xFFL) << 24; |
| | | v |= (decodedBytes[pos++] & 0xFFL) << 16; |
| | | v |= (decodedBytes[pos++] & 0xFFL) << 8; |
| | | v |= (decodedBytes[pos++] & 0xFFL); |
| | | v |= decodedBytes[pos++] & 0xFFL; |
| | | entryIDList[i] = v; |
| | | } |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.backends.jeb; |
| | | |
| | |
| | | for (int i = offset; i < offset + 4; i++) |
| | | { |
| | | v <<= 8; |
| | | v |= (bytes[i] & 0xFF); |
| | | v |= bytes[i] & 0xFF; |
| | | } |
| | | return v; |
| | | } |
| | |
| | | break; |
| | | } |
| | | |
| | | ByteString b1Bytes = set.getValue((index * orderingRules.length) + j); |
| | | ByteString b1Bytes = set.getValue(index * orderingRules.length + j); |
| | | ByteString b2Bytes = null; |
| | | |
| | | if(values[j] != null) |
| | |
| | | } |
| | | } |
| | | } |
| | | return (nbSeparator == 1); |
| | | return nbSeparator == 1; |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | |
| | | long finishTime = System.currentTimeMillis(); |
| | | long totalTime = (finishTime - startTime); |
| | | long totalTime = finishTime - startTime; |
| | | |
| | | float rate = 0; |
| | | if (totalTime > 0) |
| | |
| | | public void run() |
| | | { |
| | | long latestCount = exportedCount; |
| | | long deltaCount = (latestCount - previousCount); |
| | | long deltaCount = latestCount - previousCount; |
| | | long latestTime = System.currentTimeMillis(); |
| | | long deltaTime = latestTime - previousTime; |
| | | |
| | |
| | | |
| | | private ByteSequence getShardedKey(EntryID entryID) |
| | | { |
| | | final long bucket = (Thread.currentThread().getId() & (SHARD_COUNT - 1)); |
| | | final long bucket = Thread.currentThread().getId() & (SHARD_COUNT - 1); |
| | | return getKeyFromEntryIDAndBucket(entryID, bucket); |
| | | } |
| | | |
| | |
| | | { |
| | | byte b = buffer[index + i]; |
| | | answer <<= 8; |
| | | answer |= (b & 0xff); |
| | | answer |= b & 0xff; |
| | | } |
| | | return answer; |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | bytesToRead = Math.min((end - offset), cache.remaining()); |
| | | bytesToRead = Math.min(end - offset, cache.remaining()); |
| | | } |
| | | int bytesRead = 0; |
| | | while (bytesRead < bytesToRead) |
| | |
| | | for (int i = 0; i < INT_SIZE; i++) { |
| | | byte b = buffer[index + i]; |
| | | answer <<= 8; |
| | | answer |= (b & 0xff); |
| | | answer |= b & 0xff; |
| | | } |
| | | return answer; |
| | | } |
| | |
| | | private String getAttributeValue(String attributeName, boolean isRequired) |
| | | throws InitializationException |
| | | { |
| | | List<Attribute> attrList = |
| | | taskEntry.getAttribute(attributeName.toLowerCase()); |
| | | if ((attrList == null) || attrList.isEmpty()) |
| | | List<Attribute> attrList = taskEntry.getAttribute(attributeName.toLowerCase()); |
| | | if (attrList == null || attrList.isEmpty()) |
| | | { |
| | | if (isRequired) |
| | | { |
| | | throw new InitializationException(ERR_TASK_MISSING_ATTR.get(taskEntry.getName(), attributeName)); |
| | | } |
| | | else |
| | | { |
| | | return null; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | if (attrList.size() > 1) |
| | |
| | | { |
| | | throw new InitializationException(ERR_TASK_NO_VALUES_FOR_ATTR.get(attributeName, taskEntry.getName())); |
| | | } |
| | | else |
| | | { |
| | | return null; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | ByteString value = iterator.next(); |
| | |
| | | */ |
| | | public boolean isRecurring() |
| | | { |
| | | return (recurringTaskID != null); |
| | | return recurringTaskID != null; |
| | | } |
| | | |
| | | /** |
| | |
| | | // If there is an existing task with the same id |
| | | // and it is in completed state, take its place. |
| | | Task t = tasks.get(task.getTaskID()); |
| | | if ((t != null) && TaskState.isDone(t.getTaskState())) |
| | | if (t != null && TaskState.isDone(t.getTaskState())) |
| | | { |
| | | removeCompletedTask(t.getTaskID()); |
| | | } |
| | |
| | | for (Task t : tasks.values()) |
| | | { |
| | | // Find any existing task iterations and try to cancel them. |
| | | if ((t.getRecurringTaskID() != null) && |
| | | (t.getRecurringTaskID().equals(recurringTaskID))) |
| | | if (t.getRecurringTaskID() != null && |
| | | t.getRecurringTaskID().equals(recurringTaskID)) |
| | | { |
| | | TaskState state = t.getTaskState(); |
| | | if (!TaskState.isDone(state) && !TaskState.isCancelled(state)) |
| | |
| | | } |
| | | else if (TaskState.isDone(state)) |
| | | { |
| | | if ((state == TaskState.CANCELED_BEFORE_STARTING) && |
| | | task.isRecurring()) |
| | | if (state == TaskState.CANCELED_BEFORE_STARTING && task.isRecurring()) |
| | | { |
| | | pendingTasks.add(task); |
| | | } |
| | |
| | | // If there is an existing task with the same id |
| | | // and it is in completed state, take its place. |
| | | Task t = tasks.get(newIteration.getTaskID()); |
| | | if ((t != null) && TaskState.isDone(t.getTaskState())) |
| | | if (t != null && TaskState.isDone(t.getTaskState())) |
| | | { |
| | | removeCompletedTask(t.getTaskID()); |
| | | } |
| | |
| | | } |
| | | // Recurring task iteration has to spawn the next one |
| | | // even if the current iteration has been canceled. |
| | | else if ((state == TaskState.CANCELED_BEFORE_STARTING) && |
| | | t.isRecurring()) |
| | | else if (state == TaskState.CANCELED_BEFORE_STARTING && t.isRecurring()) |
| | | { |
| | | if (t.getScheduledStartTime() > TimeThread.getTime()) { |
| | | // If we're waiting for the start time to arrive, |
| | | // then see if that will come before the next |
| | | // sleep time is up. |
| | | // then see if that will come before the next sleep time is up. |
| | | long waitTime = |
| | | t.getScheduledStartTime() - TimeThread.getTime(); |
| | | sleepTime = Math.min(sleepTime, waitTime); |
| | |
| | | state = null; |
| | | } |
| | | |
| | | if ((state != null) && TaskState.isDone(state)) |
| | | if (state != null && TaskState.isDone(state)) |
| | | { |
| | | return state; |
| | | } |
| | |
| | | // Get the name of the class that implements the task logic. |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_TASK_CLASS.toLowerCase(), ATTR_TASK_CLASS); |
| | | List<Attribute> attrList = entry.getAttribute(attrType); |
| | | if ((attrList == null) || attrList.isEmpty()) |
| | | if (attrList == null || attrList.isEmpty()) |
| | | { |
| | | LocalizableMessage message = ERR_TASKSCHED_NO_CLASS_ATTRIBUTE.get(ATTR_TASK_ID); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | |
| | | public LinkedHashSet<ByteString> stringsToValues(List<String> valueStrings, |
| | | boolean allowFailures) throws ConfigException |
| | | { |
| | | if ((valueStrings == null) || valueStrings.isEmpty()) |
| | | if (valueStrings == null || valueStrings.isEmpty()) |
| | | { |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_IS_REQUIRED.get(getName()); |
| | | throw new ConfigException(message); |
| | |
| | | { |
| | | attributeList.add(new javax.management.Attribute(getName(), activeValue)); |
| | | |
| | | if (requiresAdminAction() && (pendingValue != activeValue)) |
| | | if (requiresAdminAction() && pendingValue != activeValue) |
| | | { |
| | | String name = getName() + ";" + OPTION_PENDING_VALUES; |
| | | attributeList.add(new javax.management.Attribute(name, pendingValue)); |
| | |
| | | { |
| | | // If no values are provided, then check to see if this is a required |
| | | // attribute. If it is, then reject the change. |
| | | if ((values == null) || values.isEmpty()) |
| | | if (values == null || values.isEmpty()) |
| | | { |
| | | if (isRequired) |
| | | { |
| | |
| | | |
| | | // If this is not a multivalued attribute but there were more values |
| | | // provided, then reject it. |
| | | if ((! isMultiValued) && iterator.hasNext()) |
| | | if (! isMultiValued && iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(name); |
| | | throw new ConfigException(message); |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011-2013 ForgeRock AS |
| | | * Portions copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.config; |
| | | |
| | | |
| | | |
| | | import java.io.File; |
| | | |
| | | import org.opends.server.types.SSLClientAuthPolicy; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines a number of constants used by the Directory Server |
| | | * configuration, including configuration attribute and objectclass names, |
| | |
| | | * The default maximum request size that should be used if none is specified |
| | | * in the configuration. |
| | | */ |
| | | public static final int DEFAULT_MAX_REQUEST_SIZE = (5 * 1024 * 1024); // 5 MB |
| | | public static final int DEFAULT_MAX_REQUEST_SIZE = 5 * 1024 * 1024; // 5 MB |
| | | |
| | | |
| | | |
| | |
| | | public DN activeValue() |
| | | throws ConfigException |
| | | { |
| | | if ((activeValues == null) || activeValues.isEmpty()) |
| | | if (activeValues == null || activeValues.isEmpty()) |
| | | { |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_NO_STRING_VALUE.get(getName()); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_NO_STRING_VALUE.get(getName())); |
| | | } |
| | | |
| | | if (activeValues.size() > 1) |
| | | { |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_MULTIPLE_STRING_VALUES.get(getName()); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_MULTIPLE_STRING_VALUES.get(getName())); |
| | | } |
| | | |
| | | return activeValues.get(0); |
| | |
| | | return activeValue(); |
| | | } |
| | | |
| | | if ((pendingValues == null) || pendingValues.isEmpty()) |
| | | if (pendingValues == null || pendingValues.isEmpty()) |
| | | { |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_NO_STRING_VALUE.get(getName()); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_NO_STRING_VALUE.get(getName())); |
| | | } |
| | | |
| | | if (pendingValues.size() > 1) |
| | | { |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_MULTIPLE_STRING_VALUES.get(getName()); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_MULTIPLE_STRING_VALUES.get(getName())); |
| | | } |
| | | |
| | | return pendingValues.get(0); |
| | |
| | | throws ConfigException |
| | | { |
| | | // First check if the set is empty and if that is allowed. |
| | | if ((values == null) || (values.isEmpty())) |
| | | if (values == null || values.isEmpty()) |
| | | { |
| | | if (isRequired()) |
| | | { |
| | |
| | | |
| | | // Next check if the set contains multiple values and if that is allowed. |
| | | int numValues = values.size(); |
| | | if (!isMultiValued() && (numValues > 1)) |
| | | if (!isMultiValued() && numValues > 1) |
| | | { |
| | | throw new ConfigException(ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(getName())); |
| | | } |
| | |
| | | public LinkedHashSet<ByteString> stringsToValues(List<String> valueStrings, boolean allowFailures) |
| | | throws ConfigException |
| | | { |
| | | if ((valueStrings == null) || valueStrings.isEmpty()) |
| | | if (valueStrings == null || valueStrings.isEmpty()) |
| | | { |
| | | if (isRequired()) |
| | | { |
| | |
| | | |
| | | |
| | | int numValues = valueStrings.size(); |
| | | if ((! isMultiValued()) && (numValues > 1)) |
| | | if (!isMultiValued() && numValues > 1) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(getName()); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(getName())); |
| | | } |
| | | |
| | | |
| | |
| | | // If this method was configured to continue on error, then it is possible |
| | | // that we ended up with an empty list. Check to see if this is a required |
| | | // attribute and if so deal with it accordingly. |
| | | if ((isRequired()) && valueSet.isEmpty()) |
| | | if (isRequired() && valueSet.isEmpty()) |
| | | { |
| | | throw new ConfigException(ERR_CONFIG_ATTR_IS_REQUIRED.get(getName())); |
| | | } |
| | |
| | | else |
| | | { |
| | | int numValues = a.size(); |
| | | if (numValues > 1 && (!isMultiValued())) |
| | | if (numValues > 1 && !isMultiValued()) |
| | | { |
| | | // This is illegal -- the attribute is single-valued. |
| | | throw new ConfigException(ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(a.getName())); |
| | |
| | | } |
| | | |
| | | |
| | | if (requiresAdminAction() && (pendingValues != null) && |
| | | (pendingValues != activeValues)) |
| | | if (requiresAdminAction() && pendingValues != null && pendingValues != activeValues) |
| | | { |
| | | String name = getName() + ";" + OPTION_PENDING_VALUES; |
| | | |
| | |
| | | public void setValue(long intValue, String unit) |
| | | throws ConfigException |
| | | { |
| | | if ((unit == null) || (! units.containsKey(unit))) |
| | | if (unit == null || !units.containsKey(unit)) |
| | | { |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_INVALID_UNIT.get(unit, getName()); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_INVALID_UNIT.get(unit, getName())); |
| | | } |
| | | |
| | | |
| | | long calculatedValue = (long) (intValue * units.get(unit)); |
| | | if (hasLowerBound && (calculatedValue < lowerBound)) |
| | | if (hasLowerBound && calculatedValue < lowerBound) |
| | | { |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_INT_BELOW_LOWER_BOUND.get( |
| | | getName(), calculatedValue, lowerBound); |
| | | throw new ConfigException(message); |
| | | } |
| | | |
| | | if (hasUpperBound && (calculatedValue > upperBound)) |
| | | if (hasUpperBound && calculatedValue > upperBound) |
| | | { |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_INT_ABOVE_UPPER_BOUND.get( |
| | | getName(), calculatedValue, upperBound); |
| | |
| | | // The rest of the value should be the unit. See if it is in the set of |
| | | // available units. |
| | | String unit = lowerValue.substring(spacePos+1); |
| | | double multiplier; |
| | | if (! units.containsKey(unit)) |
| | | if (!units.containsKey(unit)) |
| | | { |
| | | rejectReason.append(ERR_CONFIG_ATTR_INVALID_UNIT.get(unit, getName())); |
| | | return false; |
| | | } |
| | | else |
| | | { |
| | | multiplier = units.get(unit); |
| | | } |
| | | |
| | | |
| | | // Multiply the int value by the unit multiplier and see if that is within |
| | | // the specified bounds. |
| | | double multiplier = units.get(unit); |
| | | long calculatedValue = (long) (longValue * multiplier); |
| | | if (hasLowerBound && (calculatedValue < lowerBound)) |
| | | if (hasLowerBound && calculatedValue < lowerBound) |
| | | { |
| | | rejectReason.append(ERR_CONFIG_ATTR_INT_BELOW_LOWER_BOUND.get( |
| | | getName(), calculatedValue, lowerBound)); |
| | | return false; |
| | | } |
| | | |
| | | if (hasUpperBound && (calculatedValue > upperBound)) |
| | | if (hasUpperBound && calculatedValue > upperBound) |
| | | { |
| | | rejectReason.append(ERR_CONFIG_ATTR_INT_ABOVE_UPPER_BOUND.get( |
| | | getName(), calculatedValue, upperBound)); |
| | |
| | | stringsToValues(List<String> valueStrings, boolean allowFailures) |
| | | throws ConfigException |
| | | { |
| | | if ((valueStrings == null) || valueStrings.isEmpty()) |
| | | if (valueStrings == null || valueStrings.isEmpty()) |
| | | { |
| | | if (isRequired()) |
| | | { |
| | |
| | | |
| | | |
| | | int numValues = valueStrings.size(); |
| | | if ((! isMultiValued()) && (numValues > 1)) |
| | | if (!isMultiValued() && numValues > 1) |
| | | { |
| | | throw new ConfigException(ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(getName())); |
| | | } |
| | |
| | | // If this method was configured to continue on error, then it is possible |
| | | // that we ended up with an empty list. Check to see if this is a required |
| | | // attribute and if so deal with it accordingly. |
| | | if ((isRequired()) && valueSet.isEmpty()) |
| | | if (isRequired() && valueSet.isEmpty()) |
| | | { |
| | | throw new ConfigException(ERR_CONFIG_ATTR_IS_REQUIRED.get(getName())); |
| | | } |
| | |
| | | String activeValue = activeIntValue + " " + activeUnit; |
| | | attributeList.add(new javax.management.Attribute(getName(), activeValue)); |
| | | |
| | | if (requiresAdminAction() && |
| | | (pendingCalculatedValue != activeCalculatedValue)) |
| | | if (requiresAdminAction() && pendingCalculatedValue != activeCalculatedValue) |
| | | { |
| | | String name = getName() + ";" + OPTION_PENDING_VALUES; |
| | | String pendingValue = pendingIntValue + " " + pendingUnit; |
| | |
| | | * @throws ConfigException If this attribute does not have exactly one |
| | | * active value. |
| | | */ |
| | | public String activeValue() |
| | | throws ConfigException |
| | | public String activeValue() throws ConfigException |
| | | { |
| | | if ((activeValues == null) || activeValues.isEmpty()) |
| | | if (activeValues == null || activeValues.isEmpty()) |
| | | { |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_NO_STRING_VALUE.get(getName()); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_NO_STRING_VALUE.get(getName())); |
| | | } |
| | | |
| | | if (activeValues.size() > 1) |
| | | { |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_MULTIPLE_STRING_VALUES.get(getName()); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_MULTIPLE_STRING_VALUES.get(getName())); |
| | | } |
| | | |
| | | return activeValues.get(0); |
| | |
| | | return activeValue(); |
| | | } |
| | | |
| | | if ((pendingValues == null) || pendingValues.isEmpty()) |
| | | if (pendingValues == null || pendingValues.isEmpty()) |
| | | { |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_NO_STRING_VALUE.get(getName()); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_NO_STRING_VALUE.get(getName())); |
| | | } |
| | | |
| | | if (pendingValues.size() > 1) |
| | | { |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_MULTIPLE_STRING_VALUES.get(getName()); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_MULTIPLE_STRING_VALUES.get(getName())); |
| | | } |
| | | |
| | | return pendingValues.get(0); |
| | |
| | | public void setValue(String value) |
| | | throws ConfigException |
| | | { |
| | | if ((value == null) || (value.length() == 0)) |
| | | if (value == null || value.length() == 0) |
| | | { |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_EMPTY_STRING_VALUE.get(getName()); |
| | | throw new ConfigException(message); |
| | |
| | | |
| | | // Next check if the set contains multiple values and if that is allowed. |
| | | int numValues = values.size(); |
| | | if ((! isMultiValued()) && (numValues > 1)) |
| | | if (!isMultiValued() && numValues > 1) |
| | | { |
| | | throw new ConfigException(ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(getName())); |
| | | } |
| | |
| | | { |
| | | // Make sure that the value is non-empty. |
| | | String stringValue; |
| | | if (value == null || ((stringValue = value.toString()).length() == 0)) |
| | | if (value == null || (stringValue = value.toString()).length() == 0) |
| | | { |
| | | rejectReason.append(ERR_CONFIG_ATTR_EMPTY_STRING_VALUE.get(getName())); |
| | | return false; |
| | |
| | | // Make sure that the value is in the allowed value set. |
| | | if (! allowedValues.contains(stringValue.toLowerCase())) |
| | | { |
| | | rejectReason.append(ERR_CONFIG_ATTR_VALUE_NOT_ALLOWED.get( |
| | | stringValue, getName())); |
| | | rejectReason.append(ERR_CONFIG_ATTR_VALUE_NOT_ALLOWED.get(stringValue, getName())); |
| | | return false; |
| | | } |
| | | |
| | |
| | | else |
| | | { |
| | | int numValues = a.size(); |
| | | if ((numValues > 1) && (! isMultiValued())) |
| | | if (numValues > 1 && !isMultiValued()) |
| | | { |
| | | // This is illegal -- the attribute is single-valued. |
| | | LocalizableMessage message = |
| | |
| | | if (! allowedValues.contains(lowerValue)) |
| | | { |
| | | // This is illegal -- the value is not allowed. |
| | | throw new ConfigException(ERR_CONFIG_ATTR_VALUE_NOT_ALLOWED.get( |
| | | v, a.getName())); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_VALUE_NOT_ALLOWED.get(v, a.getName())); |
| | | } |
| | | |
| | | pendingValues.add(v.toString()); |
| | |
| | | else |
| | | { |
| | | int numValues = a.size(); |
| | | if ((numValues > 1) && (! isMultiValued())) |
| | | if (numValues > 1 && ! isMultiValued()) |
| | | { |
| | | // This is illegal -- the attribute is single-valued. |
| | | LocalizableMessage message = |
| | |
| | | if (! allowedValues.contains(lowerValue)) |
| | | { |
| | | // This is illegal -- the value is not allowed. |
| | | throw new ConfigException(ERR_CONFIG_ATTR_VALUE_NOT_ALLOWED.get( |
| | | v, a.getName())); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_VALUE_NOT_ALLOWED.get(v, a.getName())); |
| | | } |
| | | |
| | | activeValues.add(v.toString()); |
| | |
| | | } |
| | | |
| | | |
| | | if (requiresAdminAction() && (pendingValues != null) && |
| | | (pendingValues != activeValues)) |
| | | if (requiresAdminAction() && pendingValues != null && pendingValues != activeValues) |
| | | { |
| | | String name = getName() + ";" + OPTION_PENDING_VALUES; |
| | | |
| | |
| | | } |
| | | else if (! pendingValues.isEmpty()) |
| | | { |
| | | attributeList.add(new javax.management.Attribute(name, |
| | | pendingValues.get(0))); |
| | | attributeList.add(new javax.management.Attribute(name, pendingValues.get(0))); |
| | | } |
| | | } |
| | | } |
| | |
| | | public String activeValue() |
| | | throws ConfigException |
| | | { |
| | | if ((values == null) || values.isEmpty()) |
| | | if (values == null || values.isEmpty()) |
| | | { |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_NO_STRING_VALUE.get(getName()); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_NO_STRING_VALUE.get(getName())); |
| | | } |
| | | |
| | | if (values.size() > 1) |
| | | { |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_MULTIPLE_STRING_VALUES.get(getName()); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_MULTIPLE_STRING_VALUES.get(getName())); |
| | | } |
| | | |
| | | return values.get(0); |
| | |
| | | public String activeValue() |
| | | throws org.forgerock.opendj.config.server.ConfigException |
| | | { |
| | | if ((activeValues == null) || activeValues.isEmpty()) |
| | | if (activeValues == null || activeValues.isEmpty()) |
| | | { |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_NO_STRING_VALUE.get(getName()); |
| | | throw new org.forgerock.opendj.config.server.ConfigException(message); |
| | |
| | | return activeValue(); |
| | | } |
| | | |
| | | if ((pendingValues == null) || pendingValues.isEmpty()) |
| | | if (pendingValues == null || pendingValues.isEmpty()) |
| | | { |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_NO_STRING_VALUE.get(getName()); |
| | | throw new org.forgerock.opendj.config.server.ConfigException(message); |
| | |
| | | |
| | | // Next check if the set contains multiple values and if that is allowed. |
| | | int numValues = values.size(); |
| | | if ((! isMultiValued()) && (numValues > 1)) |
| | | if (!isMultiValued() && numValues > 1) |
| | | { |
| | | throw new ConfigException(ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(getName())); |
| | | } |
| | |
| | | LinkedHashSet<ByteString> valueSet = new LinkedHashSet<>(numValues); |
| | | for (String value : values) |
| | | { |
| | | if ((value == null) || (value.length() == 0)) |
| | | if (value == null || value.length() == 0) |
| | | { |
| | | throw new ConfigException(ERR_CONFIG_ATTR_EMPTY_STRING_VALUE.get(getName())); |
| | | } |
| | |
| | | } |
| | | |
| | | int numValues = valueStrings.size(); |
| | | if ((! isMultiValued()) && (numValues > 1)) |
| | | if (!isMultiValued() && numValues > 1) |
| | | { |
| | | throw new ConfigException(ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(getName())); |
| | | } |
| | |
| | | else |
| | | { |
| | | int numValues = a.size(); |
| | | if ((numValues > 1) && (! isMultiValued())) |
| | | if (numValues > 1 && !isMultiValued()) |
| | | { |
| | | // This is illegal -- the attribute is single-valued. |
| | | LocalizableMessage message = |
| | |
| | | else |
| | | { |
| | | int numValues = a.size(); |
| | | if ((numValues > 1) && (! isMultiValued())) |
| | | if (numValues > 1 && !isMultiValued()) |
| | | { |
| | | // This is illegal -- the attribute is single-valued. |
| | | LocalizableMessage message = |
| | |
| | | } |
| | | |
| | | |
| | | if (requiresAdminAction() && (pendingValues != null) && |
| | | (pendingValues != activeValues)) |
| | | if (requiresAdminAction() && pendingValues != null && pendingValues != activeValues) |
| | | { |
| | | String name = getName() + ";" + OPTION_PENDING_VALUES; |
| | | |
| | |
| | | } |
| | | else if (! pendingValues.isEmpty()) |
| | | { |
| | | attributeList.add(new javax.management.Attribute(name, |
| | | pendingValues.get(0))); |
| | | attributeList.add(new javax.management.Attribute(name, pendingValues.get(0))); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | reader.readEndSequence(); |
| | | |
| | | if ((orderingRule == null) && |
| | | (attrType.getOrderingMatchingRule() == null)) |
| | | if (orderingRule == null && attrType.getOrderingMatchingRule() == null) |
| | | { |
| | | LocalizableMessage message = |
| | | INFO_SORTREQ_CONTROL_NO_ORDERING_RULE_FOR_ATTR.get(attrName); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | message); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | |
| | | sortKeys.add(new SortKey(attrType, ascending, orderingRule)); |
| | |
| | | getHandler(newHandlerClass,newConfiguration, false, false); |
| | | } |
| | | } |
| | | } else if (enabledOld && (! enabledNew)) { |
| | | } else if (enabledOld && !enabledNew) { |
| | | //Access control has been disabled, switch to the default handler and |
| | | //finalize the old handler. |
| | | newHandlerClass = DefaultAccessControlHandler.class.getName(); |
| | |
| | | if (handler != null) |
| | | { |
| | | String curClassName = handler.getClass().getName(); |
| | | boolean classIsNew = (! newClassName.equals (curClassName)); |
| | | boolean classIsNew = !newClassName.equals(curClassName); |
| | | if (classIsNew) |
| | | { |
| | | changeResult.setAdminActionRequired (true); |
| | |
| | | } |
| | | |
| | | // New entry cache is enabled and there were no previous one. |
| | | // Instantiate the new class and initalize it. |
| | | // Instantiate the new class and initialize it. |
| | | try |
| | | { |
| | | loadAndInstallNotificationHandler (newClassName, configuration); |
| | |
| | | int currentCacheLevel = cacheNameToLevelMap.get(normDN); |
| | | |
| | | // Check if there any existing cache at the same level. |
| | | if ((currentCacheLevel != configuration.getCacheLevel()) && |
| | | (cacheOrderMap.containsKey(configuration.getCacheLevel()))) { |
| | | if (currentCacheLevel != configuration.getCacheLevel() && |
| | | cacheOrderMap.containsKey(configuration.getCacheLevel())) { |
| | | unacceptableReasons.add( |
| | | ERR_CONFIG_ENTRYCACHE_CONFIG_LEVEL_NOT_ACCEPTABLE.get( |
| | | configuration.dn(), configuration.getCacheLevel())); |
| | |
| | | if ( entryCache != null) |
| | | { |
| | | String curClassName = entryCache.getClass().getName(); |
| | | boolean classIsNew = (! newClassName.equals (curClassName)); |
| | | boolean classIsNew = !newClassName.equals(curClassName); |
| | | if (classIsNew) |
| | | { |
| | | changeResult.setAdminActionRequired (true); |
| | |
| | | } |
| | | |
| | | // New entry cache is enabled and there were no previous one. |
| | | // Instantiate the new class and initalize it. |
| | | // Instantiate the new class and initialize it. |
| | | try |
| | | { |
| | | loadAndInstallEntryCache (newClassName, configuration); |
| | |
| | | // If there is some entry cache instance already initialized work with |
| | | // it instead of creating a new one unless explicit init is requested. |
| | | EntryCache<T> cache; |
| | | if (initialize || (entryCache == null)) { |
| | | if (initialize || entryCache == null) { |
| | | cache = cacheClass.newInstance(); |
| | | } else { |
| | | cache = entryCache; |
| | |
| | | } |
| | | } |
| | | LocalizableMessage message = ERR_CONFIG_ENTRYCACHE_CANNOT_INITIALIZE_CACHE.get( |
| | | className, (e.getCause() != null ? e.getCause().getMessage() : |
| | | stackTraceToSingleLineString(e))); |
| | | className, e.getCause() != null ? e.getCause().getMessage() : |
| | | stackTraceToSingleLineString(e)); |
| | | throw new InitializationException(message, e); |
| | | } |
| | | } |
| | |
| | | // and any other controls specified. |
| | | try |
| | | { |
| | | if (AccessControlConfigManager.getInstance() |
| | | .getAccessControlHandler().isAllowed(this) == false) |
| | | if (!AccessControlConfigManager.getInstance().getAccessControlHandler().isAllowed(this)) |
| | | { |
| | | setResultCode(ResultCode.INSUFFICIENT_ACCESS_RIGHTS); |
| | | appendErrorMessage(ERR_EXTENDED_AUTHZ_INSUFFICIENT_ACCESS_RIGHTS.get(requestOID)); |
| | |
| | | |
| | | // Process and register any password policy subentries. |
| | | List<SubEntry> pwpSubEntries = DirectoryServer.getSubentryManager().getSubentries(); |
| | | if ((pwpSubEntries != null) && (!pwpSubEntries.isEmpty())) |
| | | if (pwpSubEntries != null && !pwpSubEntries.isEmpty()) |
| | | { |
| | | for (SubEntry subentry : pwpSubEntries) |
| | | { |
| | |
| | | else |
| | | { |
| | | String syntax = passwordAttribute.getSyntax().getName(); |
| | | if ((syntax == null) || (syntax.length() == 0)) |
| | | if (syntax == null || syntax.length() == 0) |
| | | { |
| | | syntax = syntaxOID; |
| | | } |
| | |
| | | PasswordStorageScheme<?> scheme = DirectoryServer |
| | | .getPasswordStorageScheme(schemeDN); |
| | | |
| | | if (authPasswordSyntax && (!scheme.supportsAuthPasswordSyntax())) |
| | | if (authPasswordSyntax && !scheme.supportsAuthPasswordSyntax()) |
| | | { |
| | | throw new ConfigException(ERR_PWPOLICY_SCHEME_DOESNT_SUPPORT_AUTH.get( |
| | | schemeDN, passwordAttribute.getNameOrOID())); |
| | |
| | | |
| | | // If the expire without warning option is disabled, then there must be a |
| | | // warning interval. |
| | | if ((!configuration.isExpirePasswordsWithoutWarning()) |
| | | && (configuration.getPasswordExpirationWarningInterval() <= 0)) |
| | | if (!configuration.isExpirePasswordsWithoutWarning() |
| | | && configuration.getPasswordExpirationWarningInterval() <= 0) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_PWPOLICY_MUST_HAVE_WARNING_IF_NOT_EXPIRE_WITHOUT_WARNING.get(configEntryDN); |
| | |
| | | configuration.getPasswordExpirationWarningInterval()); |
| | | if (configuration.getMinPasswordAge() > 0) |
| | | { |
| | | if ((warnInterval + configuration.getMinPasswordAge()) >=configuration |
| | | .getMaxPasswordAge()) |
| | | if (warnInterval + configuration.getMinPasswordAge() >= configuration.getMaxPasswordAge()) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_PWPOLICY_MIN_AGE_PLUS_WARNING_GREATER_THAN_MAX_AGE.get(configEntryDN); |
| | |
| | | buffer.append(EOL); |
| | | |
| | | buffer.append("Default Password Storage Schemes: "); |
| | | if ((defaultStorageSchemes == null) || defaultStorageSchemes.isEmpty()) |
| | | if (defaultStorageSchemes == null || defaultStorageSchemes.isEmpty()) |
| | | { |
| | | buffer.append("{none specified}"); |
| | | buffer.append(EOL); |
| | |
| | | } |
| | | |
| | | buffer.append("Deprecated Password Storage Schemes: "); |
| | | if ((deprecatedStorageSchemes == null) |
| | | || deprecatedStorageSchemes.isEmpty()) |
| | | if (deprecatedStorageSchemes == null || deprecatedStorageSchemes.isEmpty()) |
| | | { |
| | | buffer.append("{none specified}"); |
| | | buffer.append(EOL); |
| | |
| | | buffer.append(EOL); |
| | | |
| | | buffer.append("Password Validators: "); |
| | | if ((passwordValidators == null) || passwordValidators.isEmpty()) |
| | | if (passwordValidators == null || passwordValidators.isEmpty()) |
| | | { |
| | | buffer.append("{none specified}"); |
| | | buffer.append(EOL); |
| | |
| | | buffer.append(EOL); |
| | | |
| | | buffer.append("Account Status Notification Handlers: "); |
| | | if ((notificationHandlers == null) || notificationHandlers.isEmpty()) |
| | | if (notificationHandlers == null || notificationHandlers.isEmpty()) |
| | | { |
| | | buffer.append("{none specified}"); |
| | | buffer.append(EOL); |
| | |
| | | buffer.append(EOL); |
| | | |
| | | buffer.append("Previous Last Login Time Formats: "); |
| | | if ((configuration.getPreviousLastLoginTimeFormat().isEmpty())) |
| | | if (configuration.getPreviousLastLoginTimeFormat().isEmpty()) |
| | | { |
| | | buffer.append("{none specified}"); |
| | | buffer.append(EOL); |
| | |
| | | if (storageScheme != null) |
| | | { |
| | | String curClassName = storageScheme.getClass().getName(); |
| | | boolean classIsNew = (! newClassName.equals (curClassName)); |
| | | boolean classIsNew = !newClassName.equals(curClassName); |
| | | if (classIsNew) |
| | | { |
| | | changeResult.setAdminActionRequired (true); |
| | |
| | | } |
| | | |
| | | // New entry cache is enabled and there were no previous one. |
| | | // Instantiate the new class and initalize it. |
| | | // Instantiate the new class and initialize it. |
| | | try |
| | | { |
| | | loadAndInstallPasswordStorageScheme (newClassName, configuration); |
| | |
| | | for (DN altBindDN: configuration.getAlternateBindDN()) |
| | | { |
| | | DN existingRootDN = DirectoryServer.getActualRootBindDN(altBindDN); |
| | | if ((existingRootDN != null) && |
| | | (! existingRootDN.equals(configuration.dn()))) |
| | | if (existingRootDN != null && !existingRootDN.equals(configuration.dn())) |
| | | { |
| | | unacceptableReasons.add(ERR_CONFIG_ROOTDN_CONFLICTING_MAPPING.get( |
| | | altBindDN, configuration.dn(), existingRootDN)); |
| | |
| | | } |
| | | |
| | | long modificationTime = f.lastModified(); |
| | | if ((oldestModificationTime <= 0L) || |
| | | (modificationTime < oldestModificationTime)) |
| | | if (oldestModificationTime <= 0L || |
| | | modificationTime < oldestModificationTime) |
| | | { |
| | | oldestModificationTime = modificationTime; |
| | | } |
| | | |
| | | if ((youngestModificationTime <= 0) || |
| | | (modificationTime > youngestModificationTime)) |
| | | if (youngestModificationTime <= 0 || |
| | | modificationTime > youngestModificationTime) |
| | | { |
| | | youngestModificationTime = modificationTime; |
| | | } |
| | |
| | | Entry oldEntry = modifyOperation.getCurrentEntry(); |
| | | Entry newEntry = modifyOperation.getModifiedEntry(); |
| | | |
| | | if ((newEntry.isSubentry() || newEntry.isLDAPSubentry()) || |
| | | (oldEntry.isSubentry() || oldEntry.isLDAPSubentry())) |
| | | if (newEntry.isSubentry() || newEntry.isLDAPSubentry() || |
| | | oldEntry.isSubentry() || oldEntry.isLDAPSubentry()) |
| | | { |
| | | ClientConnection conn = modifyOperation.getClientConnection(); |
| | | if (!conn.hasPrivilege(Privilege.SUBENTRY_WRITE, |
| | |
| | | { |
| | | Entry entry = modifyOperation.getCurrentEntry(); |
| | | Entry modEntry = modifyOperation.getModifiedEntry(); |
| | | if ((entry != null) && (modEntry != null)) |
| | | if (entry != null && modEntry != null) |
| | | { |
| | | doPostModify(entry, modEntry); |
| | | } |
| | |
| | | { |
| | | Entry oldEntry = modifyDNOperation.getOriginalEntry(); |
| | | Entry newEntry = modifyDNOperation.getUpdatedEntry(); |
| | | if ((oldEntry != null) && (newEntry != null)) |
| | | if (oldEntry != null && newEntry != null) |
| | | { |
| | | doPostModifyDN(oldEntry, newEntry); |
| | | } |
| | |
| | | AttributeType pwdAttrType = |
| | | DirectoryServer.getAttributeTypeOrDefault(PWD_ATTR_VALIDATOR); |
| | | List<Attribute> pwdAttrList = entry.getAttribute(pwdAttrType); |
| | | if ((pwdAttrList != null) && (!pwdAttrList.isEmpty())) |
| | | if (pwdAttrList != null && !pwdAttrList.isEmpty()) |
| | | { |
| | | for (Attribute attr : pwdAttrList) |
| | | { |
| | |
| | | // If we should check a specific set of attributes, then do that now. |
| | | // Otherwise, check all user attributes. |
| | | Set<AttributeType> matchAttributes = config.getMatchAttribute(); |
| | | if ((matchAttributes == null) || matchAttributes.isEmpty()) |
| | | if (matchAttributes == null || matchAttributes.isEmpty()) |
| | | { |
| | | matchAttributes = userEntry.getUserAttributes().keySet(); |
| | | } |
| | |
| | | for (AttributeType t : matchAttributes) |
| | | { |
| | | List<Attribute> attrList = userEntry.getAttribute(t); |
| | | if ((attrList == null) || attrList.isEmpty()) |
| | | if (attrList == null || attrList.isEmpty()) |
| | | { |
| | | continue; |
| | | } |
| | |
| | | |
| | | // Look at the digest portion of the provided credentials. It must have a |
| | | // length of exactly 32 bytes and be comprised only of hex characters. |
| | | if (digest.length() != (2*MD5_DIGEST_LENGTH)) |
| | | if (digest.length() != 2*MD5_DIGEST_LENGTH) |
| | | { |
| | | bindOperation.setResultCode(ResultCode.INVALID_CREDENTIALS); |
| | | |
| | | LocalizableMessage message = ERR_SASLCRAMMD5_INVALID_DIGEST_LENGTH.get( |
| | | digest.length(), |
| | | (2*MD5_DIGEST_LENGTH)); |
| | | 2*MD5_DIGEST_LENGTH); |
| | | bindOperation.setAuthFailureReason(message); |
| | | return; |
| | | } |
| | |
| | | |
| | | PasswordPolicyState pwPolicyState = (PasswordPolicyState) authState; |
| | | clearPasswords = pwPolicyState.getClearPasswords(); |
| | | if ((clearPasswords == null) || clearPasswords.isEmpty()) |
| | | if (clearPasswords == null || clearPasswords.isEmpty()) |
| | | { |
| | | bindOperation.setResultCode(ResultCode.INVALID_CREDENTIALS); |
| | | |
| | |
| | | } |
| | | } |
| | | } |
| | | if ((! found) && (! config.isAllowUnclassifiedCharacters())) |
| | | if (!found && !config.isAllowUnclassifiedCharacters()) |
| | | { |
| | | invalidReason.append(ERR_CHARSET_VALIDATOR_ILLEGAL_CHARACTER.get(c)); |
| | | return false; |
| | |
| | | { |
| | | // Mandatory character set. |
| | | mandatoryCharacterSets++; |
| | | if ((passwordCount == null) || (passwordCount < minimumCount)) |
| | | if (passwordCount == null || passwordCount < minimumCount) |
| | | { |
| | | invalidReason |
| | | .append(ERR_CHARSET_VALIDATOR_TOO_FEW_CHARS_FROM_SET |
| | |
| | | { |
| | | // Mandatory character set. |
| | | mandatoryCharacterSets++; |
| | | if ((passwordCount == null) || (passwordCount < minimumCount)) |
| | | if (passwordCount == null || passwordCount < minimumCount) |
| | | { |
| | | invalidReason |
| | | .append(ERR_CHARSET_VALIDATOR_TOO_FEW_CHARS_FROM_RANGE |
| | |
| | | throw new ConfigException(message); |
| | | } |
| | | |
| | | if (minCharacterSets > (characterSets.size() + characterRanges.size())) |
| | | if (minCharacterSets > characterSets.size() + characterRanges.size()) |
| | | { |
| | | LocalizableMessage message = ERR_CHARSET_VALIDATOR_MIN_CHAR_SETS_TOO_BIG |
| | | .get(minCharacterSets); |
| | |
| | | SearchFilter filter) |
| | | throws DirectoryException |
| | | { |
| | | if ((baseDN == null) && (filter == null)) |
| | | if (baseDN == null && filter == null) |
| | | { |
| | | return new DynamicGroupMemberList(groupEntryDN, memberURLs); |
| | | } |
| | |
| | | } catch (Exception e) {} |
| | | } |
| | | |
| | | return (resultQueue.peek() != null); |
| | | return resultQueue.peek() != null; |
| | | } |
| | | |
| | | |
| | |
| | | Set<SearchFilter> searchFilters = new HashSet<>(); |
| | | |
| | | // Convert the string filters to search filters. |
| | | if ((filters != null) && (! filters.isEmpty())) |
| | | if (filters != null && ! filters.isEmpty()) |
| | | { |
| | | for (String curFilter: filters) |
| | | { |
| | |
| | | { |
| | | // We couldn't decode this filter. Report an error and continue. |
| | | LocalizableMessage message = decodeErrorMsg.get(String.valueOf(configEntryDN), |
| | | curFilter, (de.getMessage() != null ? de.getMessage() : |
| | | stackTraceToSingleLineString(de))); |
| | | curFilter, de.getMessage() != null ? de.getMessage() : |
| | | stackTraceToSingleLineString(de)); |
| | | errorHandler.reportError(message, false, |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX); |
| | | } |
| | |
| | | currentConfig.getMatchAttribute().toArray(new AttributeType[0]); |
| | | |
| | | Set<DN> cfgBaseDNs = configuration.getMatchBaseDN(); |
| | | if ((cfgBaseDNs == null) || cfgBaseDNs.isEmpty()) |
| | | if (cfgBaseDNs == null || cfgBaseDNs.isEmpty()) |
| | | { |
| | | cfgBaseDNs = DirectoryServer.getPublicNamingContexts().keySet(); |
| | | } |
| | |
| | | for (DN baseDN : cfgBaseDNs) |
| | | { |
| | | Backend b = DirectoryServer.getBackend(baseDN); |
| | | if ((b != null) && (! b.isIndexed(t, IndexType.EQUALITY))) |
| | | if (b != null && ! b.isIndexed(t, IndexType.EQUALITY)) |
| | | { |
| | | throw new ConfigException(ERR_EXACTMAP_ATTR_UNINDEXED.get( |
| | | configuration.dn(), t.getNameOrOID(), b.getBackendID())); |
| | |
| | | // then use size and time limits to constrain costly searches resulting from |
| | | // non-unique or inefficient criteria. |
| | | Collection<DN> baseDNs = config.getMatchBaseDN(); |
| | | if ((baseDNs == null) || baseDNs.isEmpty()) |
| | | if (baseDNs == null || baseDNs.isEmpty()) |
| | | { |
| | | baseDNs = DirectoryServer.getPublicNamingContexts().keySet(); |
| | | } |
| | |
| | | throw new DirectoryException(internalSearch.getResultCode(), message); |
| | | } |
| | | |
| | | LinkedList<SearchResultEntry> searchEntries = |
| | | internalSearch.getSearchEntries(); |
| | | if ((searchEntries != null) && (! searchEntries.isEmpty())) |
| | | LinkedList<SearchResultEntry> searchEntries = internalSearch.getSearchEntries(); |
| | | if (searchEntries != null && ! searchEntries.isEmpty()) |
| | | { |
| | | if (matchingEntry == null) |
| | | { |
| | |
| | | // Make sure that all of the configured attributes are indexed for equality |
| | | // in all appropriate backends. |
| | | Set<DN> cfgBaseDNs = configuration.getMatchBaseDN(); |
| | | if ((cfgBaseDNs == null) || cfgBaseDNs.isEmpty()) |
| | | if (cfgBaseDNs == null || cfgBaseDNs.isEmpty()) |
| | | { |
| | | cfgBaseDNs = DirectoryServer.getPublicNamingContexts().keySet(); |
| | | } |
| | |
| | | for (DN baseDN : cfgBaseDNs) |
| | | { |
| | | Backend b = DirectoryServer.getBackend(baseDN); |
| | | if ((b != null) && (! b.isIndexed(t, IndexType.EQUALITY))) |
| | | if (b != null && ! b.isIndexed(t, IndexType.EQUALITY)) |
| | | { |
| | | unacceptableReasons.add(ERR_EXACTMAP_ATTR_UNINDEXED.get( |
| | | configuration.dn(), t.getNameOrOID(), b.getBackendID())); |
| | |
| | | } |
| | | LDAPClientConnection lc = (LDAPClientConnection) clientConnection; |
| | | Certificate[] clientCertChain = lc.getClientCertificateChain(); |
| | | if ((clientCertChain == null) || (clientCertChain.length == 0)) { |
| | | if (clientCertChain == null || clientCertChain.length == 0) { |
| | | bindOperation.setResultCode(ResultCode.INVALID_CREDENTIALS); |
| | | LocalizableMessage message = ERR_SASLEXTERNAL_NO_CLIENT_CERT.get(); |
| | | bindOperation.setAuthFailureReason(message); |
| | |
| | | break; |
| | | |
| | | case SUBORDINATES: |
| | | if (baseDN.equals(nextDN) || (! baseDN.isAncestorOf(nextDN))) |
| | | if (baseDN.equals(nextDN) || !baseDN.isAncestorOf(nextDN)) |
| | | { |
| | | continue; |
| | | } |
| | | break; |
| | | |
| | | default: |
| | | if (! baseDN.isAncestorOf(nextDN)) |
| | | if (!baseDN.isAncestorOf(nextDN)) |
| | | { |
| | | continue; |
| | | } |
| | |
| | | // Make sure that the fingerprint attribute is configured for equality in |
| | | // all appropriate backends. |
| | | Set<DN> cfgBaseDNs = configuration.getUserBaseDN(); |
| | | if ((cfgBaseDNs == null) || cfgBaseDNs.isEmpty()) |
| | | if (cfgBaseDNs == null || cfgBaseDNs.isEmpty()) |
| | | { |
| | | cfgBaseDNs = DirectoryServer.getPublicNamingContexts().keySet(); |
| | | } |
| | |
| | | for (DN baseDN : cfgBaseDNs) |
| | | { |
| | | Backend b = DirectoryServer.getBackend(baseDN); |
| | | if ((b != null) && (! b.isIndexed(t, IndexType.EQUALITY))) |
| | | if (b != null && ! b.isIndexed(t, IndexType.EQUALITY)) |
| | | { |
| | | logger.warn(WARN_SATUACM_ATTR_UNINDEXED, configuration.dn(), |
| | | t.getNameOrOID(), b.getBackendID()); |
| | |
| | | String theFingerprintAlgorithm = this.fingerprintAlgorithm; |
| | | |
| | | // Make sure that a peer certificate was provided. |
| | | if ((certificateChain == null) || (certificateChain.length == 0)) |
| | | if (certificateChain == null || certificateChain.length == 0) |
| | | { |
| | | LocalizableMessage message = ERR_FCM_NO_PEER_CERTIFICATE.get(); |
| | | throw new DirectoryException(ResultCode.INVALID_CREDENTIALS, message); |
| | |
| | | // If we have an explicit set of base DNs, then use it. Otherwise, use the |
| | | // set of public naming contexts in the server. |
| | | Collection<DN> baseDNs = config.getUserBaseDN(); |
| | | if ((baseDNs == null) || baseDNs.isEmpty()) |
| | | if (baseDNs == null || baseDNs.isEmpty()) |
| | | { |
| | | baseDNs = DirectoryServer.getPublicNamingContexts().keySet(); |
| | | } |
| | |
| | | // Make sure that the fingerprint attribute is configured for equality in |
| | | // all appropriate backends. |
| | | Set<DN> cfgBaseDNs = configuration.getUserBaseDN(); |
| | | if ((cfgBaseDNs == null) || cfgBaseDNs.isEmpty()) |
| | | if (cfgBaseDNs == null || cfgBaseDNs.isEmpty()) |
| | | { |
| | | cfgBaseDNs = DirectoryServer.getPublicNamingContexts().keySet(); |
| | | } |
| | |
| | | for (DN baseDN : cfgBaseDNs) |
| | | { |
| | | Backend b = DirectoryServer.getBackend(baseDN); |
| | | if ((b != null) && (! b.isIndexed(t, IndexType.EQUALITY))) |
| | | if (b != null && ! b.isIndexed(t, IndexType.EQUALITY)) |
| | | { |
| | | LocalizableMessage message = WARN_SATUACM_ATTR_UNINDEXED.get( |
| | | configuration.dn(), t.getNameOrOID(), b.getBackendID()); |
| | |
| | | .getExtendedResponseProtocolOp(); |
| | | final String responseOID = extendedResponse.getOID(); |
| | | |
| | | if ((responseOID != null) |
| | | && responseOID.equals(OID_NOTICE_OF_DISCONNECTION)) |
| | | if (OID_NOTICE_OF_DISCONNECTION.equals(responseOID)) |
| | | { |
| | | ResultCode resultCode = ResultCode.valueOf(extendedResponse |
| | | .getResultCode()); |
| | | ResultCode resultCode = ResultCode.valueOf(extendedResponse.getResultCode()); |
| | | |
| | | /* |
| | | * Since the connection has been disconnected we want to ensure that |
| | |
| | | { |
| | | long cachedPasswordTime = GeneralizedTime.valueOf(value.toString()).getTimeInMillis(); |
| | | long currentTime = provider.getCurrentTimeMS(); |
| | | long expiryTime = cachedPasswordTime |
| | | + (cfg.getCachedPasswordTTL() * 1000); |
| | | foundValidCachedPasswordTime = (expiryTime > currentTime); |
| | | long expiryTime = cachedPasswordTime + (cfg.getCachedPasswordTTL() * 1000); |
| | | foundValidCachedPasswordTime = expiryTime > currentTime; |
| | | } |
| | | catch (LocalizedIllegalArgumentException e) |
| | | { |
| | |
| | | // maximum length is greater than or equal to the minimum length. |
| | | int maxLength = configuration.getMaxPasswordLength(); |
| | | int minLength = configuration.getMinPasswordLength(); |
| | | if ((maxLength > 0) && (minLength > 0) && (minLength > maxLength)) |
| | | if (maxLength > 0 && minLength > 0 && minLength > maxLength) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_PWLENGTHVALIDATOR_MIN_GREATER_THAN_MAX.get(minLength, maxLength); |
| | |
| | | int numChars = newPassword.toString().length(); |
| | | |
| | | int minLength = config.getMinPasswordLength(); |
| | | if ((minLength > 0) && (numChars < minLength)) |
| | | if (minLength > 0 && numChars < minLength) |
| | | { |
| | | invalidReason.append(ERR_PWLENGTHVALIDATOR_TOO_SHORT.get(minLength)); |
| | | return false; |
| | | } |
| | | |
| | | int maxLength = config.getMaxPasswordLength(); |
| | | if ((maxLength > 0) && (numChars > maxLength)) |
| | | if (maxLength > 0 && numChars > maxLength) |
| | | { |
| | | invalidReason.append(ERR_PWLENGTHVALIDATOR_TOO_LONG.get(maxLength)); |
| | | return false; |
| | |
| | | // maximum length is greater than or equal to the minimum length. |
| | | int maxLength = configuration.getMaxPasswordLength(); |
| | | int minLength = configuration.getMinPasswordLength(); |
| | | if ((maxLength > 0) && (minLength > 0) && (minLength > maxLength)) |
| | | if (maxLength > 0 && minLength > 0 && minLength > maxLength) |
| | | { |
| | | LocalizableMessage message = ERR_PWLENGTHVALIDATOR_MIN_GREATER_THAN_MAX.get( |
| | | minLength, maxLength); |
| | |
| | | { |
| | | List<String> propertyValues = |
| | | notification.getNotificationProperty(property); |
| | | if ((propertyValues != null) && (! propertyValues.isEmpty())) |
| | | if (propertyValues != null && ! propertyValues.isEmpty()) |
| | | { |
| | | buffer.append(propertyValues.get(0)); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | if ((shutdownRequested) || (numFailures > MAX_RETRY_COUNT)) |
| | | if (shutdownRequested || numFailures > MAX_RETRY_COUNT) |
| | | { |
| | | if (numFailures > MAX_RETRY_COUNT) |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2014 ForgeRock AS. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | */ |
| | | public boolean isActive() |
| | | { |
| | | return (isAlive() && (operation != null)); |
| | | return isAlive() && operation != null; |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | else |
| | | { |
| | | long lockoutTime = lastLoginTime + (lockoutInterval*1000); |
| | | long lockoutTime = lastLoginTime + lockoutInterval*1000; |
| | | long currentTime = pwpState.getCurrentTime(); |
| | | int secondsUntilLockout = (int) ((lockoutTime - currentTime) / 1000L); |
| | | if (secondsUntilLockout <= 0) |
| | |
| | | } |
| | | } |
| | | |
| | | if ((authZEntry == null) || |
| | | (! authZEntry.getName().equals(userEntry.getName()))) |
| | | if (authZEntry == null || !authZEntry.getName().equals(userEntry.getName())) |
| | | { |
| | | AuthenticationInfo tempAuthInfo = |
| | | new AuthenticationInfo(userEntry, |
| | |
| | | currentConfig.getMatchAttribute().toArray(new AttributeType[0]); |
| | | |
| | | Set<DN> cfgBaseDNs = configuration.getMatchBaseDN(); |
| | | if ((cfgBaseDNs == null) || cfgBaseDNs.isEmpty()) |
| | | if (cfgBaseDNs == null || cfgBaseDNs.isEmpty()) |
| | | { |
| | | cfgBaseDNs = DirectoryServer.getPublicNamingContexts().keySet(); |
| | | } |
| | |
| | | for (DN baseDN : cfgBaseDNs) |
| | | { |
| | | Backend b = DirectoryServer.getBackend(baseDN); |
| | | if ((b != null) && (! b.isIndexed(t, IndexType.EQUALITY))) |
| | | if (b != null && ! b.isIndexed(t, IndexType.EQUALITY)) |
| | | { |
| | | throw new ConfigException(ERR_REGEXMAP_ATTR_UNINDEXED.get( |
| | | configuration.dn(), t.getNameOrOID(), b.getBackendID())); |
| | |
| | | // then use size and time limits to constrain costly searches resulting from |
| | | // non-unique or inefficient criteria. |
| | | Collection<DN> baseDNs = config.getMatchBaseDN(); |
| | | if ((baseDNs == null) || baseDNs.isEmpty()) |
| | | if (baseDNs == null || baseDNs.isEmpty()) |
| | | { |
| | | baseDNs = DirectoryServer.getPublicNamingContexts().keySet(); |
| | | } |
| | |
| | | |
| | | LinkedList<SearchResultEntry> searchEntries = |
| | | internalSearch.getSearchEntries(); |
| | | if ((searchEntries != null) && (! searchEntries.isEmpty())) |
| | | if (searchEntries != null && ! searchEntries.isEmpty()) |
| | | { |
| | | if (matchingEntry == null) |
| | | { |
| | |
| | | // Make sure that all of the configured attributes are indexed for equality |
| | | // in all appropriate backends. |
| | | Set<DN> cfgBaseDNs = configuration.getMatchBaseDN(); |
| | | if ((cfgBaseDNs == null) || cfgBaseDNs.isEmpty()) |
| | | if (cfgBaseDNs == null || cfgBaseDNs.isEmpty()) |
| | | { |
| | | cfgBaseDNs = DirectoryServer.getPublicNamingContexts().keySet(); |
| | | } |
| | |
| | | for (DN baseDN : cfgBaseDNs) |
| | | { |
| | | Backend b = DirectoryServer.getBackend(baseDN); |
| | | if ((b != null) && (! b.isIndexed(t, IndexType.EQUALITY))) |
| | | if (b != null && ! b.isIndexed(t, IndexType.EQUALITY)) |
| | | { |
| | | unacceptableReasons.add(ERR_REGEXMAP_ATTR_UNINDEXED.get( |
| | | configuration.dn(), t.getNameOrOID(), b.getBackendID())); |
| | |
| | | final String mechanism, final IdentityMapper<?> identityMapper) |
| | | throws SaslException |
| | | { |
| | | return (new SASLContext(saslProps, serverFQDN, mechanism, identityMapper)); |
| | | return new SASLContext(saslProps, serverFQDN, mechanism, identityMapper); |
| | | } |
| | | |
| | | |
| | |
| | | this.bindOp = bindOp; |
| | | final ByteString clientCredentials = bindOp.getSASLCredentials(); |
| | | |
| | | if ((clientCredentials == null) || (clientCredentials.length() == 0)) |
| | | if (clientCredentials == null || clientCredentials.length() == 0) |
| | | { |
| | | final LocalizableMessage msg = ERR_SASL_NO_CREDENTIALS.get(mechanism, mechanism); |
| | | handleError(msg); |
| | |
| | | } |
| | | } |
| | | |
| | | if ((authzEntry == null) || (!authzEntry.getName(). |
| | | equals(authEntry.getName()))) |
| | | if (authzEntry == null || !authzEntry.getName().equals(authEntry.getName())) |
| | | { |
| | | // Create temporary authorization information and run it both |
| | | // through the privilege and then the access control subsystems. |
| | |
| | | final PasswordPolicyState pwPolicyState = (PasswordPolicyState) authState; |
| | | |
| | | clearPasswords = pwPolicyState.getClearPasswords(); |
| | | if ((clearPasswords == null) || clearPasswords.isEmpty()) |
| | | if (clearPasswords == null || clearPasswords.isEmpty()) |
| | | { |
| | | setCallbackMsg(ERR_SASL_NO_REVERSIBLE_PASSWORDS.get(mechanism, authEntry.getName())); |
| | | return; |
| | |
| | | // Make sure that the Directory Server is configured with information about |
| | | // one or more mail servers. |
| | | List<Properties> propList = DirectoryServer.getMailServerPropertySets(); |
| | | if ((propList == null) || propList.isEmpty()) |
| | | if (propList == null || propList.isEmpty()) |
| | | { |
| | | throw new ConfigException(ERR_SMTP_ASNH_NO_MAIL_SERVERS_CONFIGURED.get(configuration.dn())); |
| | | } |
| | |
| | | // address attributes were provided. |
| | | Set<AttributeType> mailAttrs = configuration.getEmailAddressAttributeType(); |
| | | Set<String> recipients = configuration.getRecipientAddress(); |
| | | if (((mailAttrs == null) || mailAttrs.isEmpty()) && |
| | | ((recipients == null) || recipients.isEmpty())) |
| | | if ((mailAttrs == null || mailAttrs.isEmpty()) && |
| | | (recipients == null || recipients.isEmpty())) |
| | | { |
| | | throw new ConfigException(ERR_SMTP_ASNH_NO_RECIPIENTS.get(configuration.dn())); |
| | | } |
| | |
| | | LinkedList<String> recipients = new LinkedList<>(); |
| | | Set<AttributeType> addressAttrs = config.getEmailAddressAttributeType(); |
| | | Set<String> recipientAddrs = config.getRecipientAddress(); |
| | | if ((addressAttrs != null) && (! addressAttrs.isEmpty())) |
| | | if (addressAttrs != null && !addressAttrs.isEmpty()) |
| | | { |
| | | Entry userEntry = notification.getUserEntry(); |
| | | for (AttributeType t : addressAttrs) |
| | |
| | | |
| | | if (recipients.isEmpty()) |
| | | { |
| | | if ((recipientAddrs == null) || recipientAddrs.isEmpty()) |
| | | if (recipientAddrs == null || recipientAddrs.isEmpty()) |
| | | { |
| | | // There are no recipients at all, so there's no point in generating |
| | | // the message. Return without doing anything. |
| | |
| | | // Make sure that the Directory Server is configured with information about |
| | | // one or more mail servers. |
| | | List<Properties> propList = DirectoryServer.getMailServerPropertySets(); |
| | | if ((propList == null) || propList.isEmpty()) |
| | | if (propList == null || propList.isEmpty()) |
| | | { |
| | | unacceptableReasons.add(ERR_SMTP_ASNH_NO_MAIL_SERVERS_CONFIGURED.get(configuration.dn())); |
| | | configAcceptable = false; |
| | |
| | | // address attributes were provided. |
| | | Set<AttributeType> mailAttrs = configuration.getEmailAddressAttributeType(); |
| | | Set<String> recipients = configuration.getRecipientAddress(); |
| | | if (((mailAttrs == null) || mailAttrs.isEmpty()) && |
| | | ((recipients == null) || recipients.isEmpty())) |
| | | if ((mailAttrs == null || mailAttrs.isEmpty()) && |
| | | (recipients == null || recipients.isEmpty())) |
| | | { |
| | | unacceptableReasons.add(ERR_SMTP_ASNH_NO_RECIPIENTS.get(configuration.dn())); |
| | | configAcceptable = false; |
| | |
| | | { |
| | | // Make sure that the Directory Server is configured with information about |
| | | // at least one SMTP server. |
| | | if ((DirectoryServer.getMailServerPropertySets() == null) || |
| | | if (DirectoryServer.getMailServerPropertySets() == null || |
| | | DirectoryServer.getMailServerPropertySets().isEmpty()) |
| | | { |
| | | LocalizableMessage message = ERR_SMTPALERTHANDLER_NO_SMTP_SERVERS.get(); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_SMTPALERTHANDLER_NO_SMTP_SERVERS.get()); |
| | | } |
| | | |
| | | configuration.addSMTPChangeListener(this); |
| | |
| | | |
| | | |
| | | // Make sure that a peer certificate was provided. |
| | | if ((certificateChain == null) || (certificateChain.length == 0)) |
| | | if (certificateChain == null || certificateChain.length == 0) |
| | | { |
| | | LocalizableMessage message = ERR_SATUACM_NO_PEER_CERTIFICATE.get(); |
| | | throw new DirectoryException(ResultCode.INVALID_CREDENTIALS, message); |
| | |
| | | private Set<DN> getUserBaseDNs(SubjectAttributeToUserAttributeCertificateMapperCfg config) |
| | | { |
| | | Set<DN> baseDNs = config.getUserBaseDN(); |
| | | if ((baseDNs == null) || baseDNs.isEmpty()) |
| | | if (baseDNs == null || baseDNs.isEmpty()) |
| | | { |
| | | baseDNs = DirectoryServer.getPublicNamingContexts().keySet(); |
| | | } |
| | |
| | | |
| | | String certAttrName = lowerMap.substring(0, colonPos).trim(); |
| | | String userAttrName = lowerMap.substring(colonPos+1).trim(); |
| | | if ((certAttrName.length() == 0) || (userAttrName.length() == 0)) |
| | | if (certAttrName.length() == 0 || userAttrName.length() == 0) |
| | | { |
| | | ccr.setResultCodeIfSuccess(ResultCode.CONSTRAINT_VIOLATION); |
| | | ccr.addMessage(ERR_SATUACM_INVALID_MAP_FORMAT.get(cfgEntryDN, mapStr)); |
| | |
| | | // Make sure that the subject attribute is configured for equality in all |
| | | // appropriate backends. |
| | | Set<DN> cfgBaseDNs = configuration.getUserBaseDN(); |
| | | if ((cfgBaseDNs == null) || cfgBaseDNs.isEmpty()) |
| | | if (cfgBaseDNs == null || cfgBaseDNs.isEmpty()) |
| | | { |
| | | cfgBaseDNs = DirectoryServer.getPublicNamingContexts().keySet(); |
| | | } |
| | |
| | | for (DN baseDN : cfgBaseDNs) |
| | | { |
| | | Backend b = DirectoryServer.getBackend(baseDN); |
| | | if ((b != null) && (! b.isIndexed(t, IndexType.EQUALITY))) |
| | | if (b != null && ! b.isIndexed(t, IndexType.EQUALITY)) |
| | | { |
| | | logger.warn(WARN_SATUACM_ATTR_UNINDEXED, configuration.dn(), |
| | | t.getNameOrOID(), b.getBackendID()); |
| | |
| | | |
| | | |
| | | // Make sure that a peer certificate was provided. |
| | | if ((certificateChain == null) || (certificateChain.length == 0)) |
| | | if (certificateChain == null || certificateChain.length == 0) |
| | | { |
| | | LocalizableMessage message = ERR_SDTUACM_NO_PEER_CERTIFICATE.get(); |
| | | throw new DirectoryException(ResultCode.INVALID_CREDENTIALS, message); |
| | |
| | | // If we have an explicit set of base DNs, then use it. Otherwise, use the |
| | | // set of public naming contexts in the server. |
| | | Collection<DN> baseDNs = config.getUserBaseDN(); |
| | | if ((baseDNs == null) || baseDNs.isEmpty()) |
| | | if (baseDNs == null || baseDNs.isEmpty()) |
| | | { |
| | | baseDNs = DirectoryServer.getPublicNamingContexts().keySet(); |
| | | } |
| | |
| | | throws DirectoryException |
| | | { |
| | | // Make sure that a peer certificate was provided. |
| | | if ((certificateChain == null) || (certificateChain.length == 0)) |
| | | if (certificateChain == null || certificateChain.length == 0) |
| | | { |
| | | LocalizableMessage message = ERR_SEDCM_NO_PEER_CERTIFICATE.get(); |
| | | throw new DirectoryException(ResultCode.INVALID_CREDENTIALS, message); |
| | |
| | | final long etime = operation.getProcessingTime(); |
| | | |
| | | final Integer etimeGT = cfg.getResponseEtimeGreaterThan(); |
| | | if (etimeGT != null && etime <= ((long) etimeGT)) |
| | | if (etimeGT != null && etime <= etimeGT) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | final Integer etimeLT = cfg.getResponseEtimeLessThan(); |
| | | if (etimeLT != null && etime >= ((long) etimeLT)) |
| | | if (etimeLT != null && etime >= etimeLT) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | final Group<?> group = groupManager.getGroupInstance(groupDN); |
| | | try |
| | | { |
| | | if ((group != null) && group.isMember(userEntry)) |
| | | if (group != null && group.isMember(userEntry)) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | final Group<?> group = groupManager.getGroupInstance(groupDN); |
| | | try |
| | | { |
| | | if ((group != null) && group.isMember(userEntry)) |
| | | if (group != null && group.isMember(userEntry)) |
| | | { |
| | | return true; |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.loggers; |
| | | |
| | | import java.util.*; |
| | | import java.util.Arrays; |
| | | import java.util.IllegalFormatException; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * This class is responsible for formatting messages and replacing |
| | |
| | | |
| | | private static void concatenateArgs(Object[] args, StringBuilder buffer) |
| | | { |
| | | for (int i = 0; (args != null) && (i < args.length); i++) { |
| | | buffer.append(" ").append(args[i]); |
| | | if (args != null) { |
| | | for (Object arg : args) { |
| | | buffer.append(" ").append(arg); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.loggers; |
| | | |
| | |
| | | StackTraceElement[] stackTrace = null; |
| | | StackTraceElement[] filteredStackTrace = null; |
| | | StackTraceElement callerFrame = null; |
| | | final boolean hasException = (exception != null); |
| | | final boolean hasException = exception != null; |
| | | for (PublisherSettings settings : publisherSettings) |
| | | { |
| | | TraceSettings activeSettings = settings.classSettings; |
| | |
| | | |
| | | if(policy instanceof SizeBasedRotationPolicy) |
| | | { |
| | | SizeBasedRotationPolicy sizePolicy = ((SizeBasedRotationPolicy)policy); |
| | | SizeBasedRotationPolicy sizePolicy = (SizeBasedRotationPolicy) policy; |
| | | if(sizeLimit == 0 || |
| | | sizeLimit > sizePolicy.currentConfig.getFileSizeLimit()) |
| | | { |
| | |
| | | sizeLimit = 0; |
| | | |
| | | // Remove this as a change listener. |
| | | SizeBasedRotationPolicy sizePolicy = ((SizeBasedRotationPolicy)policy); |
| | | SizeBasedRotationPolicy sizePolicy = (SizeBasedRotationPolicy) policy; |
| | | sizePolicy.currentConfig.removeSizeLimitChangeListener(this); |
| | | } |
| | | } |
| | |
| | | { |
| | | long newSizeLimit = Integer.MAX_VALUE; |
| | | |
| | | // Go through all current size rotation policies and get the |
| | | // lowest size setting. |
| | | // Go through all current size rotation policies and get the lowest size setting. |
| | | for(RotationPolicy policy : rotationPolicies) |
| | | { |
| | | if(policy instanceof SizeBasedRotationPolicy) |
| | | { |
| | | SizeBasedRotationPolicy sizePolicy = ((SizeBasedRotationPolicy)policy); |
| | | if(sizePolicy.currentConfig.dn().equals(config.dn()) ) |
| | | SizeBasedRotationPolicy sizePolicy = (SizeBasedRotationPolicy) policy; |
| | | SizeLimitLogRotationPolicyCfg cfg = |
| | | sizePolicy.currentConfig.dn().equals(config.dn()) ? config : sizePolicy.currentConfig; |
| | | if(newSizeLimit > cfg.getFileSizeLimit()) |
| | | { |
| | | if(newSizeLimit > config.getFileSizeLimit()) |
| | | { |
| | | newSizeLimit = config.getFileSizeLimit(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if(newSizeLimit > sizePolicy.currentConfig.getFileSizeLimit()) |
| | | { |
| | | newSizeLimit = sizePolicy.currentConfig.getFileSizeLimit(); |
| | | } |
| | | newSizeLimit = cfg.getFileSizeLimit(); |
| | | } |
| | | } |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.loggers; |
| | | |
| | |
| | | action = new ZIPAction(filename, zipFile, true); |
| | | break; |
| | | case SIGN: |
| | | //String alias = RotationConfigUtil.getCertificateAlias(configEntry); |
| | | //action = new SignatureAction(filename, alias); |
| | | break; |
| | | case ENCRYPT: |
| | | //String certAlias = |
| | | // RotationConfigUtil.getCertificateAlias(configEntry); |
| | | // FIXME - make the encryption algorithm configurable. |
| | | //action = new EncryptAction(filename, encFile, false, certAlias, |
| | | // "RSA"); |
| | | break; |
| | | default: |
| | | System.err.println("Invalid post rollover action:" + at); |
| | | break; |
| | | } |
| | | if(action != null) |
| | | if(action != null && !action.execute()) |
| | | { |
| | | boolean val = action.execute(); |
| | | if(val == false) |
| | | { |
| | | System.err.println("Post rotation action failed."); |
| | | } |
| | | System.err.println("Post rotation action failed."); |
| | | } |
| | | } |
| | | } catch(Exception e) |
| | |
| | | logger.traceException(e); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | && !config.isAsynchronous()) |
| | | { |
| | | // The asynchronous setting is being turned off. |
| | | final AsynchronousTextWriter asyncWriter = |
| | | ((AsynchronousTextWriter) writer); |
| | | final AsynchronousTextWriter asyncWriter = (AsynchronousTextWriter) writer; |
| | | writer = mfWriter; |
| | | asyncWriter.shutdown(false); |
| | | } |
| | |
| | | if (writer instanceof ParallelTextWriter && !config.isAsynchronous()) |
| | | { |
| | | // The asynchronous setting is being turned off. |
| | | final ParallelTextWriter asyncWriter = ((ParallelTextWriter) writer); |
| | | final ParallelTextWriter asyncWriter = (ParallelTextWriter) writer; |
| | | writer = mfWriter; |
| | | asyncWriter.shutdown(false); |
| | | } |
| | |
| | | config.isAutoFlush(), mfWriter); |
| | | } |
| | | |
| | | if ((cfg.isAsynchronous() && config.isAsynchronous()) |
| | | && (cfg.getQueueSize() != config.getQueueSize())) |
| | | if (cfg.isAsynchronous() && config.isAsynchronous() |
| | | && cfg.getQueueSize() != config.getQueueSize()) |
| | | { |
| | | ccr.setAdminActionRequired(true); |
| | | } |
| | |
| | | buffer.append(operation.getResultCode().intValue()); |
| | | |
| | | final LocalizableMessageBuilder msg = operation.getErrorMessage(); |
| | | if ((msg != null) && (msg.length() > 0)) |
| | | if (msg != null && msg.length() > 0) |
| | | { |
| | | appendLabel(buffer, "message", msg); |
| | | } |
| | |
| | | searchOperation.getRawFilter().toString(buffer); |
| | | |
| | | final Set<String> attrs = searchOperation.getAttributes(); |
| | | if ((attrs == null) || attrs.isEmpty()) |
| | | if (attrs == null || attrs.isEmpty()) |
| | | { |
| | | buffer.append("\" attrs=\"ALL\""); |
| | | } |
| | |
| | | if (writer instanceof AsynchronousTextWriter |
| | | && !config.isAsynchronous()) |
| | | { |
| | | // The asynronous setting is being turned off. |
| | | AsynchronousTextWriter asyncWriter = |
| | | ((AsynchronousTextWriter) writer); |
| | | // The asynchronous setting is being turned off. |
| | | AsynchronousTextWriter asyncWriter = (AsynchronousTextWriter) writer; |
| | | writer = mfWriter; |
| | | asyncWriter.shutdown(false); |
| | | } |
| | |
| | | config.getQueueSize(), config.isAutoFlush(), mfWriter); |
| | | } |
| | | |
| | | if ((cfg.isAsynchronous() && config.isAsynchronous()) |
| | | && (cfg.getQueueSize() != config.getQueueSize())) |
| | | if (cfg.isAsynchronous() && config.isAsynchronous() |
| | | && cfg.getQueueSize() != config.getQueueSize()) |
| | | { |
| | | ccr.setAdminActionRequired(true); |
| | | } |
| | |
| | | if(writer instanceof AsynchronousTextWriter && !config.isAsynchronous()) |
| | | { |
| | | // The asynchronous setting is being turned off. |
| | | AsynchronousTextWriter asyncWriter = |
| | | ((AsynchronousTextWriter)writer); |
| | | AsynchronousTextWriter asyncWriter = (AsynchronousTextWriter) writer; |
| | | writer = mfWriter; |
| | | asyncWriter.shutdown(false); |
| | | } |
| | |
| | | config.getQueueSize(), config.isAutoFlush(), mfWriter); |
| | | } |
| | | |
| | | if((currentConfig.isAsynchronous() && config.isAsynchronous()) && |
| | | (currentConfig.getQueueSize() != config.getQueueSize())) |
| | | if(currentConfig.isAsynchronous() && config.isAsynchronous() && |
| | | currentConfig.getQueueSize() != config.getQueueSize()) |
| | | { |
| | | ccr.setAdminActionRequired(true); |
| | | } |
| | |
| | | public boolean isEnabledFor(String category, Severity severity) |
| | | { |
| | | Thread currentThread = Thread.currentThread(); |
| | | return (this.thread.equals(currentThread) || this.thread.getThreadGroup() |
| | | .equals(currentThread.getThreadGroup())); |
| | | return this.thread.equals(currentThread) |
| | | || this.thread.getThreadGroup().equals(currentThread.getThreadGroup()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | @Override |
| | | public List<Attribute> getMonitorData() |
| | | { |
| | | if ((entryCache != null) && |
| | | (monitorConfiguration != null) && |
| | | (monitorConfiguration.isEnabled())) { |
| | | if (entryCache != null && |
| | | monitorConfiguration != null && |
| | | monitorConfiguration.isEnabled()) { |
| | | // Get monitor data from the cache. |
| | | return entryCache.getMonitorData(); |
| | | } |
| | |
| | | { |
| | | long recentGCCount = gcCount - lastGCCount; |
| | | long recentGCTime = gcTime - lastGCTime; |
| | | recentGCDuration = (recentGCTime / recentGCCount); |
| | | recentGCDuration = recentGCTime / recentGCCount; |
| | | } |
| | | |
| | | lastGCCounts.put(gcName, gcCount); |
| | |
| | | if (Character.isUpperCase(c)) |
| | | { |
| | | char lowerCaseCharacter = Character.toLowerCase(c); |
| | | if ((buffer.length() > 0) && (! lastWasUppercase) && (! lastWasDash)) |
| | | if (buffer.length() > 0 && !lastWasUppercase && !lastWasDash) |
| | | { |
| | | buffer.append('-'); |
| | | } |
| | |
| | | lastWasUppercase = false; |
| | | lastWasDash = false; |
| | | } |
| | | else if ((c == ' ') || (c == '_') || (c == '-')) |
| | | else if (c == ' ' || c == '_' || c == '-') |
| | | { |
| | | if (! lastWasDash) |
| | | { |
| | |
| | | // Get the JVM input arguments. |
| | | RuntimeMXBean rtBean = ManagementFactory.getRuntimeMXBean(); |
| | | List<String> jvmArguments = rtBean.getInputArguments(); |
| | | if ((jvmArguments != null) && (! jvmArguments.isEmpty())) |
| | | if (jvmArguments != null && ! jvmArguments.isEmpty()) |
| | | { |
| | | StringBuilder argList = new StringBuilder(); |
| | | for (String jvmArg : jvmArguments) |
| | |
| | | String.valueOf(DynamicConstants.POINT_VERSION))); |
| | | |
| | | String versionQualifier = DynamicConstants.VERSION_QUALIFIER; |
| | | if ((versionQualifier != null) && (versionQualifier.length() > 0)) |
| | | if (versionQualifier != null && versionQualifier.length() > 0) |
| | | { |
| | | attrs.add(createAttribute(ATTR_VERSION_QUALIFIER, versionQualifier)); |
| | | } |
| | |
| | | } |
| | | |
| | | String fixIDs = DynamicConstants.FIX_IDS; |
| | | if ((fixIDs != null) && (fixIDs.length() > 0)) |
| | | if (fixIDs != null && fixIDs.length() > 0) |
| | | { |
| | | attrs.add(createAttribute(ATTR_FIX_IDS, fixIDs)); |
| | | } |
| | |
| | | * ignore attribute options. |
| | | */ |
| | | final int semicolonPos = toAttr.indexOf(";"); |
| | | final String toAttrType = (semicolonPos < 0) |
| | | && (semicolonPos < (toAttr.length() - 1)) ? toAttr : toAttr |
| | | .substring(semicolonPos + 1); |
| | | final String toAttrType = semicolonPos < 0 && semicolonPos < toAttr.length() - 1 |
| | | ? toAttr |
| | | : toAttr.substring(semicolonPos + 1); |
| | | |
| | | if (DirectoryServer.getAttributeType(toLowerCase(toAttrType)) == null) |
| | | { |
| | |
| | | */ |
| | | private void processCsnControl(PostOperationOperation operation) { |
| | | List<Control> requestControls = operation.getRequestControls(); |
| | | if ((requestControls != null) && (! requestControls.isEmpty())) { |
| | | if (requestControls != null && ! requestControls.isEmpty()) { |
| | | for (Control c : requestControls) { |
| | | if (c.getOID().equals(OID_CSN_CONTROL)) { |
| | | OperationContext ctx = (OperationContext) |
| | |
| | | for (AttributeType t : authPasswordTypes) |
| | | { |
| | | attrList = entry.getAttribute(t); |
| | | if ((attrList == null) || attrList.isEmpty()) |
| | | if (attrList == null || attrList.isEmpty()) |
| | | { |
| | | continue; |
| | | } |
| | |
| | | for (AttributeType t : userPasswordTypes) |
| | | { |
| | | attrList = entry.getAttribute(t); |
| | | if ((attrList == null) || attrList.isEmpty()) |
| | | if (attrList == null || attrList.isEmpty()) |
| | | { |
| | | continue; |
| | | } |
| | |
| | | } |
| | | |
| | | Set<DN> cfgBaseDNs = pluginCfg.getBaseDN(); |
| | | if ((cfgBaseDNs == null) || cfgBaseDNs.isEmpty()) |
| | | if (cfgBaseDNs == null || cfgBaseDNs.isEmpty()) |
| | | { |
| | | cfgBaseDNs = DirectoryServer.getPublicNamingContexts().keySet(); |
| | | } |
| | |
| | | for (DN baseDN : cfgBaseDNs) |
| | | { |
| | | Backend<?> b = DirectoryServer.getBackend(baseDN); |
| | | if ((b != null) && (!b.isIndexed(type, IndexType.EQUALITY))) |
| | | if (b != null && !b.isIndexed(type, IndexType.EQUALITY)) |
| | | { |
| | | isAcceptable = false; |
| | | unacceptableReasons.add(ERR_PLUGIN_REFERENT_ATTR_UNINDEXED.get( |
| | |
| | | DN newEntryDN=modifyDNOperation.getUpdatedEntry().getName(); |
| | | modDNmap.put(oldEntryDN, newEntryDN); |
| | | |
| | | processModifyDN(modDNmap, (interval != 0)); |
| | | processModifyDN(modDNmap, interval != 0); |
| | | |
| | | return PluginResult.PostOperation.continueOperationProcessing(); |
| | | } |
| | |
| | | } |
| | | deleteDNset.add(deleteOperation.getEntryDN()); |
| | | |
| | | processDelete(deleteDNset, (interval != 0)); |
| | | processDelete(deleteDNset, interval != 0); |
| | | return PluginResult.PostOperation.continueOperationProcessing(); |
| | | } |
| | | |
| | |
| | | */ |
| | | private boolean isAttributeSyntaxValid(AttributeType attribute) |
| | | { |
| | | return (attribute.getSyntax().getOID().equals(SYNTAX_DN_OID) || |
| | | attribute.getSyntax().getOID().equals(SYNTAX_NAME_AND_OPTIONAL_UID_OID)); |
| | | return attribute.getSyntax().getOID().equals(SYNTAX_DN_OID) || |
| | | attribute.getSyntax().getOID().equals(SYNTAX_NAME_AND_OPTIONAL_UID_OID); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | /* Process only ADD and REPLACE modification types. |
| | | */ |
| | | if ((modType != ModificationType.ADD) |
| | | && (modType != ModificationType.REPLACE)) |
| | | if (modType != ModificationType.ADD |
| | | && modType != ModificationType.REPLACE) |
| | | { |
| | | break; |
| | | } |
| | |
| | | // |
| | | // fill the current word |
| | | // |
| | | while ((xBufOff != 0) && (len > 0)) |
| | | while (xBufOff != 0 && len > 0) |
| | | { |
| | | update(in[inOff]); |
| | | |
| | |
| | | |
| | | private void finish() |
| | | { |
| | | final long bitLength = (byteCount << 3); |
| | | final long bitLength = byteCount << 3; |
| | | |
| | | // |
| | | // add the pad bytes. |
| | |
| | | */ |
| | | private int rotateLeft(final int x, final int n) |
| | | { |
| | | return (x << n) | (x >>> (32 - n)); |
| | | return (x << n) | (x >>> 32 - n); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | key8[0] = key7[0]; |
| | | key8[1] = ((key7[0] << 7) & 0xFF | (key7[1] >> 1)); |
| | | key8[2] = ((key7[1] << 6) & 0xFF | (key7[2] >> 2)); |
| | | key8[3] = ((key7[2] << 5) & 0xFF | (key7[3] >> 3)); |
| | | key8[4] = ((key7[3] << 4) & 0xFF | (key7[4] >> 4)); |
| | | key8[5] = ((key7[4] << 3) & 0xFF | (key7[5] >> 5)); |
| | | key8[6] = ((key7[5] << 2) & 0xFF | (key7[6] >> 6)); |
| | | key8[7] = (key7[6] << 1); |
| | | key8[1] = ((key7[0] << 7) & 0xFF) | (key7[1] >> 1); |
| | | key8[2] = ((key7[1] << 6) & 0xFF) | (key7[2] >> 2); |
| | | key8[3] = ((key7[2] << 5) & 0xFF) | (key7[3] >> 3); |
| | | key8[4] = ((key7[3] << 4) & 0xFF) | (key7[4] >> 4); |
| | | key8[5] = ((key7[4] << 3) & 0xFF) | (key7[5] >> 5); |
| | | key8[6] = ((key7[5] << 2) & 0xFF) | (key7[6] >> 6); |
| | | key8[7] = key7[6] << 1; |
| | | |
| | | for (int i = 0; i < 8; i++) |
| | | { |
| | | key64[i] = (byte) (setOddParity(key8[i])); |
| | | key64[i] = (byte) setOddParity(key8[i]); |
| | | } |
| | | |
| | | return key64; |
| | |
| | | */ |
| | | private static int setOddParity(final int parity) |
| | | { |
| | | final boolean hasEvenBits = ((parity >>> 7) ^ (parity >>> 6) |
| | | ^ (parity >>> 5) ^ (parity >>> 4) |
| | | ^ (parity >>> 3) ^ (parity >>> 2) |
| | | ^ (parity >>> 1) & 0x01) == 0; |
| | | final boolean hasEvenBits = (parity >>> 7 ^ parity >>> 6 |
| | | ^ parity >>> 5 ^ parity >>> 4 |
| | | ^ parity >>> 3 ^ parity >>> 2 |
| | | ^ ((parity >>> 1) & 0x01)) == 0; |
| | | if (hasEvenBits) |
| | | { |
| | | return parity | 0x01; |
| | |
| | | } |
| | | |
| | | Set<DN> cfgBaseDNs = configuration.getBaseDN(); |
| | | if ((cfgBaseDNs == null) || cfgBaseDNs.isEmpty()) |
| | | if (cfgBaseDNs == null || cfgBaseDNs.isEmpty()) |
| | | { |
| | | cfgBaseDNs = DirectoryServer.getPublicNamingContexts().keySet(); |
| | | } |
| | |
| | | for (DN baseDN : cfgBaseDNs) |
| | | { |
| | | Backend b = DirectoryServer.getBackend(baseDN); |
| | | if ((b != null) && (! b.isIndexed(t, IndexType.EQUALITY))) |
| | | if (b != null && ! b.isIndexed(t, IndexType.EQUALITY)) |
| | | { |
| | | throw new ConfigException(ERR_PLUGIN_UNIQUEATTR_ATTR_UNINDEXED.get( |
| | | configuration.dn(), t.getNameOrOID(), b.getBackendID())); |
| | |
| | | private Set<DN> getBaseDNs(UniqueAttributePluginCfg config, DN entryDN) |
| | | { |
| | | Set<DN> baseDNs = config.getBaseDN(); |
| | | if ((baseDNs == null) || baseDNs.isEmpty()) |
| | | if (baseDNs == null || baseDNs.isEmpty()) |
| | | { |
| | | baseDNs = DirectoryServer.getPublicNamingContexts().keySet(); |
| | | } |
| | |
| | | } |
| | | |
| | | Set<DN> cfgBaseDNs = configuration.getBaseDN(); |
| | | if ((cfgBaseDNs == null) || cfgBaseDNs.isEmpty()) |
| | | if (cfgBaseDNs == null || cfgBaseDNs.isEmpty()) |
| | | { |
| | | cfgBaseDNs = DirectoryServer.getPublicNamingContexts().keySet(); |
| | | } |
| | |
| | | for (DN baseDN : cfgBaseDNs) |
| | | { |
| | | Backend b = DirectoryServer.getBackend(baseDN); |
| | | if ((b != null) && (! b.isIndexed(t, IndexType.EQUALITY))) |
| | | if (b != null && ! b.isIndexed(t, IndexType.EQUALITY)) |
| | | { |
| | | unacceptableReasons.add(ERR_PLUGIN_UNIQUEATTR_ATTR_UNINDEXED.get( |
| | | configuration.dn(), t.getNameOrOID(), b.getBackendID())); |
| | |
| | | methodNames = new String[numFrames]; |
| | | lineNumbers = new int[numFrames]; |
| | | |
| | | for (int i=0, j=(numFrames-1); i < numFrames; i++,j--) |
| | | for (int i=0, j=numFrames-1; i < numFrames; i++,j--) |
| | | { |
| | | classNames[i] = stackElements[j].getClassName(); |
| | | methodNames[i] = stackElements[j].getMethodName(); |
| | |
| | | */ |
| | | public int hashCode() |
| | | { |
| | | if (numFrames == 0) |
| | | if (numFrames != 0) |
| | | { |
| | | return 0; |
| | | return classNames[0].hashCode() + methodNames[0].hashCode() + lineNumbers[0]; |
| | | } |
| | | else |
| | | { |
| | | return (classNames[0].hashCode() + methodNames[0].hashCode() + |
| | | lineNumbers[0]); |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | for (int i=0; i < numFrames; i++) |
| | | { |
| | | if ((lineNumbers[i] != s.lineNumbers[i]) || |
| | | (! classNames[i].equals(s.classNames[i])) || |
| | | (! methodNames[i].equals(s.methodNames[i]))) |
| | | if (lineNumbers[i] != s.lineNumbers[i] || |
| | | !classNames[i].equals(s.classNames[i]) || |
| | | !methodNames[i].equals(s.methodNames[i])) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | */ |
| | | public boolean hasSubFrames() |
| | | { |
| | | return (! subordinateFrames.isEmpty()); |
| | | return !subordinateFrames.isEmpty(); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | stackMap.put(stack, count); |
| | | |
| | | subFrame.recurseSubFrames(stack, (depth-1), count, stacksByMethod); |
| | | subFrame.recurseSubFrames(stack, depth-1, count, stacksByMethod); |
| | | } |
| | | |
| | | |
| | |
| | | @Override |
| | | public int hashCode() |
| | | { |
| | | return (className.hashCode() + methodName.hashCode()); |
| | | return className.hashCode() + methodName.hashCode(); |
| | | } |
| | | |
| | | |
| | |
| | | try |
| | | { |
| | | ProfileStackFrame f = (ProfileStackFrame) o; |
| | | return (className.equals(f.className) && methodName.equals(f.methodName)); |
| | | return className.equals(f.className) && methodName.equals(f.methodName); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | * occurrences, with an equivalent number of occurrences falling back on |
| | | * alphabetical by class and method names. |
| | | * |
| | | * @param o The objectfor which to make the comparison. |
| | | * @param o The object for which to make the comparison. |
| | | * |
| | | * @return A negative integer if this stack frame should come before the |
| | | * provided object in a sorted list, a positive integer if it should |
| | |
| | | |
| | | long startTime = reader.readInteger(); |
| | | long stopTime = reader.readInteger(); |
| | | totalDuration += (stopTime - startTime); |
| | | totalDuration += stopTime - startTime; |
| | | reader.readEndSequence(); |
| | | |
| | | |
| | |
| | | String highlightClassAndMethod) |
| | | { |
| | | int numFrames = stack.getNumFrames(); |
| | | for (int i=(numFrames-1); i >= 0; i--) |
| | | for (int i=numFrames-1; i >= 0; i--) |
| | | { |
| | | html.append("<BR> "); |
| | | |
| | |
| | | String methodName = stack.getMethodName(i); |
| | | int lineNumber = stack.getLineNumber(i); |
| | | |
| | | String safeMethod = |
| | | (methodName.equals("<init>") ? "<init>" : methodName); |
| | | String safeMethod = methodName.equals("<init>") ? "<init>" : methodName; |
| | | |
| | | String classAndMethod = className + "." + methodName; |
| | | if (classAndMethod.equals(highlightClassAndMethod)) |
| | |
| | | |
| | | // We'll skip over any stack that doesn't have any information. |
| | | StackTraceElement[] threadStack = stacks.get(t); |
| | | if ((threadStack == null) || (threadStack.length == 0)) |
| | | if (threadStack == null || threadStack.length == 0) |
| | | { |
| | | continue; |
| | | } |
| | |
| | | { |
| | | try |
| | | { |
| | | if ((connectionHandlerThread != null) && |
| | | (connectionHandlerThread.isAlive())) |
| | | if (connectionHandlerThread != null && connectionHandlerThread.isAlive()) |
| | | { |
| | | connectionHandlerThread.join(100); |
| | | connectionHandlerThread.interrupt(); |
| | |
| | | writer.writeComment(m, 78); |
| | | |
| | | LocalizableMessageBuilder errorMessage = operation.getErrorMessage(); |
| | | if ((errorMessage != null) && (errorMessage.length() > 0)) |
| | | if (errorMessage != null && errorMessage.length() > 0) |
| | | { |
| | | m = INFO_LDIF_CONNHANDLER_ERROR_MESSAGE.get(errorMessage); |
| | | writer.writeComment(m, 78); |
| | |
| | | } |
| | | |
| | | List<String> referralURLs = operation.getReferralURLs(); |
| | | if ((referralURLs != null) && (! referralURLs.isEmpty())) |
| | | if (referralURLs != null && !referralURLs.isEmpty()) |
| | | { |
| | | for (String url : referralURLs) |
| | | { |
| | |
| | | close(reader, writer); |
| | | } |
| | | |
| | | if (errorEncountered || (! fullyProcessed)) |
| | | if (errorEncountered || !fullyProcessed) |
| | | { |
| | | String renamedPath = inputPath + ".errors-encountered." + |
| | | TimeThread.getGMTTime(); |
| | |
| | | * |
| | | * |
| | | * Copyright 2013-2014 Manuel Gaupp |
| | | * Copyright 2014 ForgeRock AS |
| | | * Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.protocols.asn1; |
| | | |
| | | |
| | | |
| | | import java.math.BigInteger; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | |
| | | import static org.opends.messages.ProtocolMessages.*; |
| | | import static org.forgerock.util.Reject.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class implements a parser for strings which are encoded using the |
| | | * Generic String Encoding Rules (GSER) defined in RFC 3641. |
| | |
| | | { |
| | | |
| | | private String gserValue; |
| | | |
| | | private int pos; |
| | | |
| | | private int length; |
| | | |
| | | /** |
| | |
| | | */ |
| | | public boolean hasNext() |
| | | { |
| | | return (pos < length); |
| | | return pos < length; |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | HTTPConnectionHandlerCfg config = (HTTPConnectionHandlerCfg) configuration; |
| | | |
| | | if ((currentConfig == null) || (!this.enabled && config.isEnabled())) |
| | | if (currentConfig == null || (!this.enabled && config.isEnabled())) |
| | | { |
| | | // Attempt to bind to the listen port on all configured addresses to |
| | | // verify whether the connection handler will be able to start. |
| | |
| | | private static AuthenticationInfo getAuthInfoForDN(DN userDN) |
| | | throws DirectoryException |
| | | { |
| | | if ((userDN == null) || userDN.isRootDN()) |
| | | if (userDN == null || userDN.isRootDN()) |
| | | { |
| | | return new AuthenticationInfo(); |
| | | } |
| | |
| | | * from this input stream without blocking. |
| | | * |
| | | * @return The number of bytes that can be read (or skipped over) |
| | | * from this input stream wihtout blocking. |
| | | * from this input stream without blocking. |
| | | * @throws IOException if an I/O error occurs. |
| | | */ |
| | | @Override |
| | |
| | | if (messageReader.remaining() < 1) |
| | | { |
| | | LDAPMessage message = messageQueue.poll(); |
| | | if ((message == null) || (message instanceof NullLDAPMessage)) |
| | | if (message == null || message instanceof NullLDAPMessage) |
| | | { |
| | | if (message != null) |
| | | { |
| | |
| | | /** |
| | | * Closes this input stream. This will add a special marker |
| | | * element to the message queue indicating that the end of the |
| | | * stream has been reached. If the queue is full, thenit will be |
| | | * stream has been reached. If the queue is full, then it will be |
| | | * cleared before adding the marker element. |
| | | */ |
| | | @Override |
| | |
| | | |
| | | /** |
| | | * Marks the current position in the input stream. This will not |
| | | * have any effect, as this input stream inplementation does not |
| | | * have any effect, as this input stream implementation does not |
| | | * support marking. |
| | | * |
| | | * @param readLimit The maximum limit of bytes that can be read |
| | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether this input stream inplementation supports the |
| | | * Indicates whether this input stream implementation supports the |
| | | * use of the {@code mark} and {@code reset} methods. This |
| | | * implementation does not support that functionality. |
| | | * |
| | |
| | | message = new NullLDAPMessage(); |
| | | } |
| | | |
| | | if ((message == null) || (message instanceof NullLDAPMessage)) |
| | | if (message == null || message instanceof NullLDAPMessage) |
| | | { |
| | | if (message instanceof NullLDAPMessage) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | return (0xFF & messageReader.get()); |
| | | return 0xFF & messageReader.get(); |
| | | } |
| | | |
| | | |
| | |
| | | message = new NullLDAPMessage(); |
| | | } |
| | | |
| | | if ((message == null) || (message instanceof NullLDAPMessage)) |
| | | if (message == null || message instanceof NullLDAPMessage) |
| | | { |
| | | if (message instanceof NullLDAPMessage) |
| | | { |
| | |
| | | /** |
| | | * Repositions this stream to the position at the time that the |
| | | * {@code mark} method was called on this stream. This will not |
| | | * have any effect, as this input stream inplementation does not |
| | | * have any effect, as this input stream implementation does not |
| | | * support marking. |
| | | */ |
| | | @Override |
| | |
| | | @Override |
| | | public String toString() |
| | | { |
| | | return "InternalLDAPInputStream"; |
| | | return getClass().getSimpleName(); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | | final String cause = (baseDN == null ? "baseDN" : "filter"); |
| | | final String cause = baseDN == null ? "baseDN" : "filter"; |
| | | throw error(LocalizableMessage.raw("Could not decode " + cause), e); |
| | | } |
| | | SearchRequest sr = newSearchRequest(baseDN, request.getScope(), filter) |
| | |
| | | new SearchResultEntryProtocolOp(searchEntry); |
| | | |
| | | socket.getInputStream().addLDAPMessage( |
| | | new LDAPMessage(searchOperation.getMessageID(), entry, |
| | | entryControls)); |
| | | new LDAPMessage(searchOperation.getMessageID(), entry, entryControls)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Performs any processing necessary for the provided search result |
| | | * reference. |
| | | * Performs any processing necessary for the provided search result reference. |
| | | * |
| | | * @param searchOperation The internal search operation being |
| | | * processed. |
| | | * @param searchReference The search result reference to be |
| | | * processed. |
| | | * @param searchOperation The internal search operation being processed. |
| | | * @param searchReference The search result reference to be processed. |
| | | */ |
| | | @Override |
| | | @org.opends.server.types.PublicAPI( |
| | |
| | | @Override |
| | | public String toString() |
| | | { |
| | | return "InternalLDAPOutputStream"; |
| | | return getClass().getSimpleName(); |
| | | } |
| | | } |
| | | |
| | |
| | | @Override |
| | | public boolean isConnected() |
| | | { |
| | | return (! closed); |
| | | return !closed; |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | DirectoryRMIServerSocketFactory that = |
| | | (DirectoryRMIServerSocketFactory) obj; |
| | | return (getClass().equals(that.getClass()) && checkParameters(that)); |
| | | return getClass().equals(that.getClass()) && checkParameters(that); |
| | | } |
| | | |
| | | /** |
| | |
| | | public int hashCode() |
| | | { |
| | | return getClass().hashCode() |
| | | + (needClientCertificate ? Boolean.TRUE.hashCode() : Boolean.FALSE |
| | | .hashCode()) + (sslSocketFactory.hashCode()); |
| | | + Boolean.valueOf(needClientCertificate).hashCode() |
| | | + sslSocketFactory.hashCode(); |
| | | } |
| | | |
| | | } |
| | |
| | | rmiConnectorRestart = true; |
| | | } |
| | | |
| | | if (((currentConfig.getSSLCertNickname() != null) && |
| | | !currentConfig.getSSLCertNickname().equals( |
| | | config.getSSLCertNickname())) || |
| | | ((config.getSSLCertNickname() != null) && |
| | | !config.getSSLCertNickname().equals( |
| | | currentConfig.getSSLCertNickname()))) { |
| | | if (notEqualsNotNull(config.getSSLCertNickname(), currentConfig.getSSLCertNickname()) |
| | | || notEqualsNotNull(config.getSSLCertNickname(), currentConfig.getSSLCertNickname())) { |
| | | rmiConnectorRestart = true; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | private boolean notEqualsNotNull(String o1, String o2) |
| | | { |
| | | return o1 != null && !o1.equals(o2); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | |
| | | } |
| | | |
| | | int dnLength = dnString.length(); |
| | | if ((dnLength <= colsRemaining) || (colsRemaining <= 0)) |
| | | if (dnLength <= colsRemaining || colsRemaining <= 0) |
| | | { |
| | | buffer.append(dnString); |
| | | buffer.append(EOL); |
| | |
| | | buffer.append(EOL); |
| | | |
| | | int startPos = colsRemaining; |
| | | while ((dnLength - startPos) > (wrapColumn - 1)) |
| | | while (dnLength - startPos > wrapColumn - 1) |
| | | { |
| | | buffer.append(" "); |
| | | buffer.append(dnString, startPos, (startPos+wrapColumn-1)); |
| | | buffer.append(dnString, startPos, startPos+wrapColumn-1); |
| | | buffer.append(EOL); |
| | | |
| | | startPos += (wrapColumn-1); |
| | | startPos += wrapColumn-1; |
| | | } |
| | | |
| | | if (startPos < dnLength) |
| | |
| | | } |
| | | |
| | | int valueLength = valueString.length(); |
| | | if ((valueLength <= colsRemaining) || (colsRemaining <= 0)) |
| | | if (valueLength <= colsRemaining || colsRemaining <= 0) |
| | | { |
| | | buffer.append(valueString); |
| | | buffer.append(EOL); |
| | |
| | | buffer.append(EOL); |
| | | |
| | | int startPos = colsRemaining; |
| | | while ((valueLength - startPos) > (wrapColumn - 1)) |
| | | while (valueLength - startPos > wrapColumn - 1) |
| | | { |
| | | buffer.append(" "); |
| | | buffer.append(valueString, startPos, (startPos+wrapColumn-1)); |
| | | buffer.append(valueString, startPos, startPos+wrapColumn-1); |
| | | buffer.append(EOL); |
| | | |
| | | startPos += (wrapColumn-1); |
| | | startPos += wrapColumn-1; |
| | | } |
| | | |
| | | if (startPos < valueLength) |
| | |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.io.IOException; |
| | | |
| | | import org.forgerock.opendj.io.*; |
| | | import org.forgerock.util.Utils; |
| | | import org.opends.server.types.DN; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines the structures and methods for an LDAP add response |
| | | * protocol op, which is used to provide information about the result of |
| | |
| | | stream.writeOctetString(errorMessage.toString()); |
| | | } |
| | | |
| | | if ((referralURLs != null) && (! referralURLs.isEmpty())) |
| | | if (referralURLs != null && ! referralURLs.isEmpty()) |
| | | { |
| | | stream.writeStartSequence(TYPE_REFERRAL_SEQUENCE); |
| | | for (String s : referralURLs) |
| | |
| | | buffer.append("AddResponse(resultCode="); |
| | | buffer.append(resultCode); |
| | | |
| | | if ((errorMessage != null) && (errorMessage.length() > 0)) |
| | | if (errorMessage != null && errorMessage.length() > 0) |
| | | { |
| | | buffer.append(", errorMessage="); |
| | | buffer.append(errorMessage); |
| | | buffer.append(", errorMessage=").append(errorMessage); |
| | | } |
| | | |
| | | if (matchedDN != null) |
| | | { |
| | | buffer.append(", matchedDN="); |
| | | buffer.append(matchedDN); |
| | | buffer.append(", matchedDN=").append(matchedDN); |
| | | } |
| | | |
| | | if ((referralURLs != null) && (! referralURLs.isEmpty())) |
| | | if (referralURLs != null && !referralURLs.isEmpty()) |
| | | { |
| | | buffer.append(", referralURLs={"); |
| | | |
| | | Iterator<String> iterator = referralURLs.iterator(); |
| | | buffer.append(iterator.next()); |
| | | |
| | | while (iterator.hasNext()) |
| | | { |
| | | buffer.append(", "); |
| | | buffer.append(iterator.next()); |
| | | } |
| | | |
| | | buffer.append(Utils.joinAsString(", ", referralURLs)); |
| | | buffer.append("}"); |
| | | } |
| | | |
| | |
| | | buffer.append(EOL); |
| | | } |
| | | |
| | | if ((referralURLs != null) && (! referralURLs.isEmpty())) |
| | | if (referralURLs != null && ! referralURLs.isEmpty()) |
| | | { |
| | | buffer.append(indentBuf); |
| | | buffer.append(" Referral URLs: "); |
| | |
| | | package org.opends.server.protocols.ldap; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.io.IOException; |
| | | |
| | | import org.forgerock.opendj.io.*; |
| | | import org.opends.server.types.DN; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.util.Utils; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines the structures and methods for an LDAP delete response |
| | | * protocol op, which is used to provide information about the result of |
| | |
| | | stream.writeOctetString(errorMessage.toString()); |
| | | } |
| | | |
| | | if ((referralURLs != null) && (! referralURLs.isEmpty())) |
| | | if (referralURLs != null && !referralURLs.isEmpty()) |
| | | { |
| | | stream.writeStartSequence(TYPE_REFERRAL_SEQUENCE); |
| | | for (String s : referralURLs) |
| | |
| | | buffer.append("BindResponse(resultCode="); |
| | | buffer.append(resultCode); |
| | | |
| | | if ((errorMessage != null) && (errorMessage.length() > 0)) |
| | | if (errorMessage != null && errorMessage.length() > 0) |
| | | { |
| | | buffer.append(", errorMessage="); |
| | | buffer.append(errorMessage); |
| | | } |
| | | |
| | | if (matchedDN != null) |
| | | { |
| | | buffer.append(", matchedDN="); |
| | | buffer.append(matchedDN); |
| | | } |
| | | |
| | | if ((referralURLs != null) && (! referralURLs.isEmpty())) |
| | | if (referralURLs != null && !referralURLs.isEmpty()) |
| | | { |
| | | buffer.append(", referralURLs={"); |
| | | |
| | | Iterator<String> iterator = referralURLs.iterator(); |
| | | buffer.append(iterator.next()); |
| | | |
| | | while (iterator.hasNext()) |
| | | { |
| | | buffer.append(", "); |
| | | buffer.append(iterator.next()); |
| | | } |
| | | |
| | | buffer.append(Utils.joinAsString(", ", referralURLs)); |
| | | buffer.append("}"); |
| | | } |
| | | |
| | |
| | | buffer.append(EOL); |
| | | } |
| | | |
| | | if ((referralURLs != null) && (! referralURLs.isEmpty())) |
| | | if (referralURLs != null && !referralURLs.isEmpty()) |
| | | { |
| | | buffer.append(indentBuf); |
| | | buffer.append(" Referral URLs: "); |
| | |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.io.IOException; |
| | | |
| | | import org.forgerock.opendj.io.*; |
| | | import org.forgerock.util.Utils; |
| | | import org.opends.server.types.DN; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines the structures and methods for an LDAP compare response |
| | | * protocol op, which is used to provide information about the result of |
| | |
| | | stream.writeOctetString(errorMessage.toString()); |
| | | } |
| | | |
| | | if ((referralURLs != null) && (! referralURLs.isEmpty())) |
| | | if (referralURLs != null && !referralURLs.isEmpty()) |
| | | { |
| | | stream.writeStartSequence(TYPE_REFERRAL_SEQUENCE); |
| | | for (String s : referralURLs) |
| | |
| | | buffer.append("CompareResponse(resultCode="); |
| | | buffer.append(resultCode); |
| | | |
| | | if ((errorMessage != null) && (errorMessage.length() > 0)) |
| | | if (errorMessage != null && errorMessage.length() > 0) |
| | | { |
| | | buffer.append(", errorMessage="); |
| | | buffer.append(errorMessage); |
| | | } |
| | | |
| | | if (matchedDN != null) |
| | | { |
| | | buffer.append(", matchedDN="); |
| | | buffer.append(matchedDN); |
| | | } |
| | | |
| | | if ((referralURLs != null) && (! referralURLs.isEmpty())) |
| | | if (referralURLs != null && !referralURLs.isEmpty()) |
| | | { |
| | | buffer.append(", referralURLs={"); |
| | | |
| | | Iterator<String> iterator = referralURLs.iterator(); |
| | | buffer.append(iterator.next()); |
| | | |
| | | while (iterator.hasNext()) |
| | | { |
| | | buffer.append(", "); |
| | | buffer.append(iterator.next()); |
| | | } |
| | | |
| | | buffer.append(Utils.joinAsString(", ", referralURLs)); |
| | | buffer.append("}"); |
| | | } |
| | | |
| | |
| | | buffer.append(EOL); |
| | | } |
| | | |
| | | if ((referralURLs != null) && (! referralURLs.isEmpty())) |
| | | if (referralURLs != null && ! referralURLs.isEmpty()) |
| | | { |
| | | buffer.append(indentBuf); |
| | | buffer.append(" Referral URLs: "); |
| | |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.io.IOException; |
| | | |
| | | import org.forgerock.opendj.io.*; |
| | | import org.forgerock.util.Utils; |
| | | import org.opends.server.types.DN; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines the structures and methods for an LDAP delete response |
| | | * protocol op, which is used to provide information about the result of |
| | |
| | | stream.writeOctetString(errorMessage.toString()); |
| | | } |
| | | |
| | | if ((referralURLs != null) && (! referralURLs.isEmpty())) |
| | | if (referralURLs != null && !referralURLs.isEmpty()) |
| | | { |
| | | stream.writeStartSequence(TYPE_REFERRAL_SEQUENCE); |
| | | for (String s : referralURLs) |
| | |
| | | buffer.append("DeleteResponse(resultCode="); |
| | | buffer.append(resultCode); |
| | | |
| | | if ((errorMessage != null) && (errorMessage.length() > 0)) |
| | | if (errorMessage != null && errorMessage.length() > 0) |
| | | { |
| | | buffer.append(", errorMessage="); |
| | | buffer.append(errorMessage); |
| | | } |
| | | |
| | | if (matchedDN != null) |
| | | { |
| | | buffer.append(", matchedDN="); |
| | | buffer.append(matchedDN); |
| | | } |
| | | |
| | | if ((referralURLs != null) && (! referralURLs.isEmpty())) |
| | | if (referralURLs != null && !referralURLs.isEmpty()) |
| | | { |
| | | buffer.append(", referralURLs={"); |
| | | |
| | | Iterator<String> iterator = referralURLs.iterator(); |
| | | buffer.append(iterator.next()); |
| | | |
| | | while (iterator.hasNext()) |
| | | { |
| | | buffer.append(", "); |
| | | buffer.append(iterator.next()); |
| | | } |
| | | |
| | | buffer.append(Utils.joinAsString(", ", referralURLs)); |
| | | buffer.append("}"); |
| | | } |
| | | |
| | |
| | | buffer.append(EOL); |
| | | } |
| | | |
| | | if ((referralURLs != null) && (! referralURLs.isEmpty())) |
| | | if (referralURLs != null && !referralURLs.isEmpty()) |
| | | { |
| | | buffer.append(indentBuf); |
| | | buffer.append(" Referral URLs: "); |
| | |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.io.IOException; |
| | | |
| | | import org.forgerock.opendj.io.*; |
| | | import org.opends.server.types.DN; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.util.Utils; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines the structures and methods for an LDAP extended response |
| | | * protocol op, which is used to provide information about the result of |
| | |
| | | stream.writeOctetString(errorMessage.toString()); |
| | | } |
| | | |
| | | if ((referralURLs != null) && (! referralURLs.isEmpty())) |
| | | if (referralURLs != null && !referralURLs.isEmpty()) |
| | | { |
| | | stream.writeStartSequence(TYPE_REFERRAL_SEQUENCE); |
| | | for (String s : referralURLs) |
| | |
| | | stream.writeEndSequence(); |
| | | } |
| | | |
| | | if ((oid != null) && (oid.length() > 0)) |
| | | if (oid != null && oid.length() > 0) |
| | | { |
| | | stream.writeOctetString(TYPE_EXTENDED_RESPONSE_OID, oid); |
| | | } |
| | |
| | | buffer.append("ExtendedResponse(resultCode="); |
| | | buffer.append(resultCode); |
| | | |
| | | if ((errorMessage != null) && (errorMessage.length() > 0)) |
| | | if (errorMessage != null && errorMessage.length() > 0) |
| | | { |
| | | buffer.append(", errorMessage="); |
| | | buffer.append(errorMessage); |
| | | } |
| | | |
| | | if (matchedDN != null) |
| | | { |
| | | buffer.append(", matchedDN="); |
| | | buffer.append(matchedDN); |
| | | } |
| | | |
| | | if ((referralURLs != null) && (! referralURLs.isEmpty())) |
| | | if (referralURLs != null && !referralURLs.isEmpty()) |
| | | { |
| | | buffer.append(", referralURLs={"); |
| | | |
| | | Iterator<String> iterator = referralURLs.iterator(); |
| | | buffer.append(iterator.next()); |
| | | |
| | | while (iterator.hasNext()) |
| | | { |
| | | buffer.append(", "); |
| | | buffer.append(iterator.next()); |
| | | } |
| | | |
| | | buffer.append(Utils.joinAsString(", ", referralURLs)); |
| | | buffer.append("}"); |
| | | } |
| | | |
| | | if ((oid != null) && (oid.length() > 0)) |
| | | if (oid != null && oid.length() > 0) |
| | | { |
| | | buffer.append(", oid="); |
| | | buffer.append(oid); |
| | | } |
| | | |
| | | if (value != null) |
| | | { |
| | | buffer.append(", value="); |
| | |
| | | buffer.append(EOL); |
| | | } |
| | | |
| | | if ((referralURLs != null) && (! referralURLs.isEmpty())) |
| | | if (referralURLs != null && !referralURLs.isEmpty()) |
| | | { |
| | | buffer.append(indentBuf); |
| | | buffer.append(" Referral URLs: "); |
| | |
| | | } |
| | | } |
| | | |
| | | if ((oid != null) && (oid.length() > 0)) |
| | | if (oid != null && oid.length() > 0) |
| | | { |
| | | buffer.append(indentBuf); |
| | | buffer.append(" Response OID: "); |
| | |
| | | // fall back to a more inefficient way that will work without a |
| | | // selector. |
| | | while (byteBuffer.hasRemaining() |
| | | && (System.currentTimeMillis() < stopTime)) |
| | | && System.currentTimeMillis() < stopTime) |
| | | { |
| | | bytesWritten = clientChannel.write(byteBuffer); |
| | | if (bytesWritten < 0) |
| | |
| | | } |
| | | |
| | | List<String> opReferrals = operation.getReferralURLs(); |
| | | if ((opReferrals != null) && (!opReferrals.isEmpty())) |
| | | if (opReferrals != null && !opReferrals.isEmpty()) |
| | | { |
| | | StringBuilder referralsStr = new StringBuilder(); |
| | | Iterator<String> iterator = opReferrals.iterator(); |
| | |
| | | |
| | | // See if we should send a notification to the client. If so, then |
| | | // construct and send a notice of disconnection unsolicited |
| | | // response. Note that we cannot send this notification to an LDAPv2 |
| | | // client. |
| | | if (sendNotification && (ldapVersion != 2)) |
| | | // response. Note that we cannot send this notification to an LDAPv2 client. |
| | | if (sendNotification && ldapVersion != 2) |
| | | { |
| | | try |
| | | { |
| | |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | if (asn1Reader.hasRemainingData() || (e instanceof SSLException)) |
| | | if (asn1Reader.hasRemainingData() || e instanceof SSLException) |
| | | { |
| | | // The connection failed, but there was an unread partial message so |
| | | // interpret this as an IO error. |
| | |
| | | * connection has been closed as a result (it is the |
| | | * responsibility of this method to close the connection). |
| | | */ |
| | | private boolean processAbandonRequest(LDAPMessage message, |
| | | List<Control> controls) |
| | | private boolean processAbandonRequest(LDAPMessage message, List<Control> controls) |
| | | { |
| | | if ((ldapVersion == 2) && (controls != null) |
| | | && (!controls.isEmpty())) |
| | | if (ldapVersion == 2 && controls != null && !controls.isEmpty()) |
| | | { |
| | | // LDAPv2 clients aren't allowed to send controls. |
| | | disconnect(DisconnectReason.PROTOCOL_ERROR, false, |
| | |
| | | * connection has been closed as a result (it is the |
| | | * responsibility of this method to close the connection). |
| | | */ |
| | | private boolean processAddRequest(LDAPMessage message, |
| | | List<Control> controls) |
| | | private boolean processAddRequest(LDAPMessage message, List<Control> controls) |
| | | { |
| | | if ((ldapVersion == 2) && (controls != null) |
| | | && (!controls.isEmpty())) |
| | | if (ldapVersion == 2 && controls != null && !controls.isEmpty()) |
| | | { |
| | | // LDAPv2 clients aren't allowed to send controls. |
| | | AddResponseProtocolOp responseOp = |
| | |
| | | return false; |
| | | } |
| | | |
| | | if ((controls != null) && (!controls.isEmpty())) |
| | | if (controls != null && !controls.isEmpty()) |
| | | { |
| | | // LDAPv2 clients aren't allowed to send controls. |
| | | BindResponseProtocolOp responseOp = |
| | |
| | | * connection has been closed as a result (it is the |
| | | * responsibility of this method to close the connection). |
| | | */ |
| | | private boolean processCompareRequest(LDAPMessage message, |
| | | List<Control> controls) |
| | | private boolean processCompareRequest(LDAPMessage message, List<Control> controls) |
| | | { |
| | | if ((ldapVersion == 2) && (controls != null) |
| | | && (!controls.isEmpty())) |
| | | if (ldapVersion == 2 && controls != null && !controls.isEmpty()) |
| | | { |
| | | // LDAPv2 clients aren't allowed to send controls. |
| | | CompareResponseProtocolOp responseOp = |
| | |
| | | * connection has been closed as a result (it is the |
| | | * responsibility of this method to close the connection). |
| | | */ |
| | | private boolean processDeleteRequest(LDAPMessage message, |
| | | List<Control> controls) |
| | | private boolean processDeleteRequest(LDAPMessage message, List<Control> controls) |
| | | { |
| | | if ((ldapVersion == 2) && (controls != null) |
| | | && (!controls.isEmpty())) |
| | | if (ldapVersion == 2 && controls != null && !controls.isEmpty()) |
| | | { |
| | | // LDAPv2 clients aren't allowed to send controls. |
| | | DeleteResponseProtocolOp responseOp = |
| | |
| | | * connection has been closed as a result (it is the |
| | | * responsibility of this method to close the connection). |
| | | */ |
| | | private boolean processModifyRequest(LDAPMessage message, |
| | | List<Control> controls) |
| | | private boolean processModifyRequest(LDAPMessage message, List<Control> controls) |
| | | { |
| | | if ((ldapVersion == 2) && (controls != null) |
| | | && (!controls.isEmpty())) |
| | | if (ldapVersion == 2 && controls != null && !controls.isEmpty()) |
| | | { |
| | | // LDAPv2 clients aren't allowed to send controls. |
| | | ModifyResponseProtocolOp responseOp = |
| | |
| | | * connection has been closed as a result (it is the |
| | | * responsibility of this method to close the connection). |
| | | */ |
| | | private boolean processModifyDNRequest(LDAPMessage message, |
| | | List<Control> controls) |
| | | private boolean processModifyDNRequest(LDAPMessage message, List<Control> controls) |
| | | { |
| | | if ((ldapVersion == 2) && (controls != null) |
| | | && (!controls.isEmpty())) |
| | | if (ldapVersion == 2 && controls != null && !controls.isEmpty()) |
| | | { |
| | | // LDAPv2 clients aren't allowed to send controls. |
| | | ModifyDNResponseProtocolOp responseOp = |
| | |
| | | private boolean processSearchRequest(LDAPMessage message, |
| | | List<Control> controls) |
| | | { |
| | | if ((ldapVersion == 2) && (controls != null) |
| | | && (!controls.isEmpty())) |
| | | if (ldapVersion == 2 && controls != null && !controls.isEmpty()) |
| | | { |
| | | // LDAPv2 clients aren't allowed to send controls. |
| | | SearchResultDoneProtocolOp responseOp = |
| | |
| | | if (operationsInProgress.isEmpty() |
| | | && getPersistentSearches().isEmpty()) |
| | | { |
| | | return (TimeThread.getTime() - lastCompletionTime.get()); |
| | | return TimeThread.getTime() - lastCompletionTime.get(); |
| | | } |
| | | else |
| | | { |
| | |
| | | { |
| | | LDAPConnectionHandlerCfg config = (LDAPConnectionHandlerCfg) configuration; |
| | | |
| | | if ((currentConfig == null) |
| | | if (currentConfig == null |
| | | || (!currentConfig.isEnabled() && config.isEnabled())) |
| | | { |
| | | // Attempt to bind to the listen port on all configured addresses to |
| | |
| | | // Enter a loop, waiting for new connections to arrive and |
| | | // then accepting them as they come in. |
| | | boolean lastIterationFailed = false; |
| | | while (enabled && (!shutdownRequested)) |
| | | while (enabled && !shutdownRequested) |
| | | { |
| | | try |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | if (selectorState == 0 && enabled && (!shutdownRequested) |
| | | if (selectorState == 0 && enabled && !shutdownRequested |
| | | && logger.isTraceEnabled()) |
| | | { |
| | | // Selected keys was non empty but select() returned 0. |
| | |
| | | InetAddress clientAddr = clientConnection.getRemoteAddress(); |
| | | // Check to see if the client is on the denied list. |
| | | // If so, then reject it immediately. |
| | | if ((!deniedClients.isEmpty()) |
| | | if (!deniedClients.isEmpty() |
| | | && AddressMask.matchesAny(deniedClients, clientAddr)) |
| | | { |
| | | clientConnection.disconnect(DisconnectReason.CONNECTION_REJECTED, |
| | |
| | | // Check to see if there is an allowed list and if |
| | | // there is whether the client is on that list. If |
| | | // not, then reject the connection. |
| | | if ((!allowedClients.isEmpty()) |
| | | && (!AddressMask.matchesAny(allowedClients, clientAddr))) |
| | | if (!allowedClients.isEmpty() |
| | | && !AddressMask.matchesAny(allowedClients, clientAddr)) |
| | | { |
| | | clientConnection.disconnect(DisconnectReason.CONNECTION_REJECTED, |
| | | currentConfig.isSendRejectionNotice(), |
| | |
| | | */ |
| | | public final boolean hasValue() |
| | | { |
| | | return (value != null); |
| | | return value != null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | { |
| | | // The next two bytes must be the hex characters that comprise the |
| | | // binary value. |
| | | if ((i + 2) >= valueBytes.length) |
| | | if (i + 2 >= valueBytes.length) |
| | | { |
| | | LocalizableMessage message = ERR_LDAP_FILTER_INVALID_ESCAPED_BYTE.get( |
| | | filterString, equalPos+i+1); |
| | |
| | | |
| | | // The first and last characters must be parentheses. If not, then that's |
| | | // an error. |
| | | if ((filterString.charAt(startPos) != '(') || |
| | | (filterString.charAt(endPos-1) != ')')) |
| | | if (filterString.charAt(startPos) != '(' || |
| | | filterString.charAt(endPos-1) != ')') |
| | | { |
| | | LocalizableMessage message = ERR_LDAP_FILTER_COMPOUND_MISSING_PARENTHESES.get( |
| | | filterString, startPos, endPos); |
| | |
| | | { |
| | | // The next two bytes must be the hex characters that comprise the |
| | | // binary value. |
| | | if ((i + 2) >= valueBytes.length) |
| | | if (i + 2 >= valueBytes.length) |
| | | { |
| | | LocalizableMessage message = ERR_LDAP_FILTER_INVALID_ESCAPED_BYTE.get( |
| | | filterString, equalPos+i+1); |
| | |
| | | { |
| | | // The next two bytes must be the hex characters that comprise the |
| | | // binary value. |
| | | if ((i + 2) >= valueBytes.length) |
| | | if (i + 2 >= valueBytes.length) |
| | | { |
| | | LocalizableMessage message = ERR_LDAP_FILTER_INVALID_ESCAPED_BYTE.get( |
| | | filterString, equalPos+i+1); |
| | |
| | | { |
| | | // The next two bytes must be the hex characters that comprise the |
| | | // binary value. |
| | | if ((i + 2) >= valueBytes.length) |
| | | if (i + 2 >= valueBytes.length) |
| | | { |
| | | LocalizableMessage message = ERR_LDAP_FILTER_INVALID_ESCAPED_BYTE.get( |
| | | filterString, equalPos+i+1); |
| | |
| | | { |
| | | dnAttributes = true; |
| | | |
| | | if((startPos+4) < (equalPos-1)) |
| | | if(startPos+4 < equalPos-1) |
| | | { |
| | | matchingRuleID = filterString.substring(startPos+4, equalPos-1); |
| | | } |
| | |
| | | |
| | | // If there is anything left, then it should be ":dn" and/or ":" followed |
| | | // by the matching rule ID. |
| | | if (colonPos < (equalPos-1)) |
| | | if (colonPos < equalPos-1) |
| | | { |
| | | if (lowerLeftStr.startsWith(":dn:", colonPos - startPos)) |
| | | { |
| | | dnAttributes = true; |
| | | |
| | | if ((colonPos+4) < (equalPos-1)) |
| | | if (colonPos+4 < equalPos-1) |
| | | { |
| | | matchingRuleID = filterString.substring(colonPos+4, equalPos-1); |
| | | } |
| | |
| | | { |
| | | // The next two bytes must be the hex characters that comprise the |
| | | // binary value. |
| | | if ((i + 2) >= valueBytes.length) |
| | | if (i + 2 >= valueBytes.length) |
| | | { |
| | | LocalizableMessage message = ERR_LDAP_FILTER_INVALID_ESCAPED_BYTE.get( |
| | | filterString, equalPos+i+1); |
| | |
| | | |
| | | // Make sure that the filter has at least one of an attribute description |
| | | // and/or a matching rule ID. |
| | | if ((attributeType == null) && (matchingRuleID == null)) |
| | | if (attributeType == null && matchingRuleID == null) |
| | | { |
| | | LocalizableMessage message = ERR_LDAP_FILTER_EXTENSIBLE_MATCH_NO_AD_OR_MR.get( |
| | | filterString, startPos); |
| | |
| | | valueToFilterString(buffer, subInitialElement); |
| | | } |
| | | |
| | | if ((subAnyElements != null) && (! subAnyElements.isEmpty())) |
| | | if (subAnyElements != null && !subAnyElements.isEmpty()) |
| | | { |
| | | for (ByteString s : subAnyElements) |
| | | { |
| | |
| | | catch (IOException ioe) |
| | | { |
| | | StackTraceElement[] stackElements = ioe.getStackTrace(); |
| | | if ((stackElements != null) && (stackElements.length > 0)) |
| | | if (stackElements != null && stackElements.length > 0) |
| | | { |
| | | StackTraceElement ste = stackElements[0]; |
| | | if (ste.getClassName().equals("sun.nio.ch.DevPollArrayWrapper") |
| | |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.io.IOException; |
| | | |
| | | import org.forgerock.opendj.io.*; |
| | | import org.forgerock.util.Utils; |
| | | import org.opends.server.types.DN; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines the structures and methods for an LDAP modify DN response |
| | | * protocol op, which is used to provide information about the result of |
| | |
| | | stream.writeOctetString(errorMessage.toString()); |
| | | } |
| | | |
| | | if ((referralURLs != null) && (! referralURLs.isEmpty())) |
| | | if (referralURLs != null && !referralURLs.isEmpty()) |
| | | { |
| | | stream.writeStartSequence(TYPE_REFERRAL_SEQUENCE); |
| | | for (String s : referralURLs) |
| | |
| | | buffer.append("ModifyDNResponse(resultCode="); |
| | | buffer.append(resultCode); |
| | | |
| | | if ((errorMessage != null) && (errorMessage.length() > 0)) |
| | | if (errorMessage != null && errorMessage.length() > 0) |
| | | { |
| | | buffer.append(", errorMessage="); |
| | | buffer.append(errorMessage); |
| | | } |
| | | |
| | | if (matchedDN != null) |
| | | { |
| | | buffer.append(", matchedDN="); |
| | | buffer.append(matchedDN); |
| | | } |
| | | |
| | | if ((referralURLs != null) && (! referralURLs.isEmpty())) |
| | | if (referralURLs != null && ! referralURLs.isEmpty()) |
| | | { |
| | | buffer.append(", referralURLs={"); |
| | | |
| | | Iterator<String> iterator = referralURLs.iterator(); |
| | | buffer.append(iterator.next()); |
| | | |
| | | while (iterator.hasNext()) |
| | | { |
| | | buffer.append(", "); |
| | | buffer.append(iterator.next()); |
| | | } |
| | | |
| | | buffer.append(Utils.joinAsString(", ", referralURLs)); |
| | | buffer.append("}"); |
| | | } |
| | | |
| | |
| | | buffer.append(EOL); |
| | | } |
| | | |
| | | if ((referralURLs != null) && (! referralURLs.isEmpty())) |
| | | if (referralURLs != null && ! referralURLs.isEmpty()) |
| | | { |
| | | buffer.append(indentBuf); |
| | | buffer.append(" Referral URLs: "); |
| | |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.io.IOException; |
| | | |
| | | import org.forgerock.opendj.io.*; |
| | | import org.forgerock.util.Utils; |
| | | import org.opends.server.types.DN; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines the structures and methods for an LDAP modify response |
| | | * protocol op, which is used to provide information about the result of |
| | |
| | | stream.writeOctetString(errorMessage.toString()); |
| | | } |
| | | |
| | | if ((referralURLs != null) && (! referralURLs.isEmpty())) |
| | | if (referralURLs != null && !referralURLs.isEmpty()) |
| | | { |
| | | stream.writeStartSequence(TYPE_REFERRAL_SEQUENCE); |
| | | for (String s : referralURLs) |
| | |
| | | buffer.append("ModifyResponse(resultCode="); |
| | | buffer.append(resultCode); |
| | | |
| | | if ((errorMessage != null) && (errorMessage.length() > 0)) |
| | | if (errorMessage != null && errorMessage.length() > 0) |
| | | { |
| | | buffer.append(", errorMessage="); |
| | | buffer.append(errorMessage); |
| | | } |
| | | |
| | | if (matchedDN != null) |
| | | { |
| | | buffer.append(", matchedDN="); |
| | | buffer.append(matchedDN); |
| | | } |
| | | |
| | | if ((referralURLs != null) && (! referralURLs.isEmpty())) |
| | | if (referralURLs != null && ! referralURLs.isEmpty()) |
| | | { |
| | | buffer.append(", referralURLs={"); |
| | | |
| | | Iterator<String> iterator = referralURLs.iterator(); |
| | | buffer.append(iterator.next()); |
| | | |
| | | while (iterator.hasNext()) |
| | | { |
| | | buffer.append(", "); |
| | | buffer.append(iterator.next()); |
| | | } |
| | | |
| | | buffer.append(Utils.joinAsString(", ", referralURLs)); |
| | | buffer.append("}"); |
| | | } |
| | | |
| | |
| | | buffer.append(EOL); |
| | | } |
| | | |
| | | if ((referralURLs != null) && (! referralURLs.isEmpty())) |
| | | if (referralURLs != null && ! referralURLs.isEmpty()) |
| | | { |
| | | buffer.append(indentBuf); |
| | | buffer.append(" Referral URLs: "); |
| | |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.Iterator; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.Set; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.opends.server.types.RawFilter; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.util.Utils; |
| | | |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | filter.toString(buffer); |
| | | buffer.append(", attributes={"); |
| | | |
| | | if ((attributes != null) && (! attributes.isEmpty())) |
| | | if (attributes != null && ! attributes.isEmpty()) |
| | | { |
| | | Iterator<String> iterator = attributes.iterator(); |
| | | buffer.append(iterator.next()); |
| | | |
| | | while (iterator.hasNext()) |
| | | { |
| | | buffer.append(", "); |
| | | buffer.append(iterator.next()); |
| | | } |
| | | buffer.append(Utils.joinAsString(", ", attributes)); |
| | | } |
| | | |
| | | buffer.append("})"); |
| | |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.io.IOException; |
| | | |
| | | import org.forgerock.opendj.io.*; |
| | | import org.forgerock.util.Utils; |
| | | import org.opends.server.types.DN; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines the structures and methods for an LDAP search result done |
| | | * protocol op, which is used to provide information about the result of |
| | |
| | | stream.writeOctetString(errorMessage.toString()); |
| | | } |
| | | |
| | | if ((referralURLs != null) && (! referralURLs.isEmpty())) |
| | | if (referralURLs != null && !referralURLs.isEmpty()) |
| | | { |
| | | stream.writeStartSequence(TYPE_REFERRAL_SEQUENCE); |
| | | for (String s : referralURLs) |
| | |
| | | buffer.append("SearchResultDone(resultCode="); |
| | | buffer.append(resultCode); |
| | | |
| | | if ((errorMessage != null) && (errorMessage.length() > 0)) |
| | | if (errorMessage != null && errorMessage.length() > 0) |
| | | { |
| | | buffer.append(", errorMessage="); |
| | | buffer.append(errorMessage); |
| | | } |
| | | |
| | | if (matchedDN != null) |
| | | { |
| | | buffer.append(", matchedDN="); |
| | | buffer.append(matchedDN); |
| | | } |
| | | |
| | | if ((referralURLs != null) && (! referralURLs.isEmpty())) |
| | | if (referralURLs != null && !referralURLs.isEmpty()) |
| | | { |
| | | buffer.append(", referralURLs={"); |
| | | |
| | | Iterator<String> iterator = referralURLs.iterator(); |
| | | buffer.append(iterator.next()); |
| | | |
| | | while (iterator.hasNext()) |
| | | { |
| | | buffer.append(", "); |
| | | buffer.append(iterator.next()); |
| | | } |
| | | |
| | | buffer.append(Utils.joinAsString(", ", referralURLs)); |
| | | buffer.append("}"); |
| | | } |
| | | |
| | |
| | | buffer.append(EOL); |
| | | } |
| | | |
| | | if ((referralURLs != null) && (! referralURLs.isEmpty())) |
| | | if (referralURLs != null && ! referralURLs.isEmpty()) |
| | | { |
| | | buffer.append(indentBuf); |
| | | buffer.append(" Referral URLs: "); |
| | |
| | | } |
| | | |
| | | int dnLength = dnString.length(); |
| | | if ((dnLength <= colsRemaining) || (colsRemaining <= 0)) |
| | | if (dnLength <= colsRemaining || colsRemaining <= 0) |
| | | { |
| | | buffer.append(dnString); |
| | | buffer.append(EOL); |
| | |
| | | buffer.append(EOL); |
| | | |
| | | int startPos = colsRemaining; |
| | | while ((dnLength - startPos) > (wrapColumn - 1)) |
| | | while (dnLength - startPos > wrapColumn - 1) |
| | | { |
| | | buffer.append(" "); |
| | | buffer.append(dnString, startPos, (startPos+wrapColumn-1)); |
| | | buffer.append(dnString, startPos, startPos+wrapColumn-1); |
| | | buffer.append(EOL); |
| | | |
| | | startPos += (wrapColumn-1); |
| | | startPos += wrapColumn-1; |
| | | } |
| | | |
| | | if (startPos < dnLength) |
| | |
| | | } |
| | | |
| | | int valueLength = valueString.length(); |
| | | if ((valueLength <= colsRemaining) || (colsRemaining <= 0)) |
| | | if (valueLength <= colsRemaining || colsRemaining <= 0) |
| | | { |
| | | buffer.append(valueString); |
| | | buffer.append(EOL); |
| | |
| | | buffer.append(EOL); |
| | | |
| | | int startPos = colsRemaining; |
| | | while ((valueLength - startPos) > (wrapColumn - 1)) |
| | | while (valueLength - startPos > wrapColumn - 1) |
| | | { |
| | | buffer.append(" "); |
| | | buffer.append(valueString, startPos, (startPos+wrapColumn-1)); |
| | | buffer.append(valueString, startPos, startPos+wrapColumn-1); |
| | | buffer.append(EOL); |
| | | |
| | | startPos += (wrapColumn-1); |
| | | startPos += wrapColumn-1; |
| | | } |
| | | |
| | | if (startPos < valueLength) |
| | |
| | | // on another master server and this operation has a potential |
| | | // conflict with some more recent operations on this same entry |
| | | // we need to take the more complex path to solve them |
| | | if ((CSN.compare(csn, getLastUpdateTime()) < 0) || |
| | | (m.getModificationType() != ModificationType.REPLACE)) |
| | | if (CSN.compare(csn, getLastUpdateTime()) < 0 || |
| | | m.getModificationType() != ModificationType.REPLACE) |
| | | { |
| | | // the attribute was modified after this change -> conflict |
| | | |
| | |
| | | conflict = true; |
| | | modsIterator.remove(); |
| | | } |
| | | else if ((newValue != null) && |
| | | (!modifiedEntry.hasValue(type, modAttr.getOptions(), newValue))) |
| | | else if (newValue != null && |
| | | !modifiedEntry.hasValue(type, modAttr.getOptions(), newValue)) |
| | | { |
| | | conflict = true; |
| | | modsIterator.remove(); |
| | |
| | | } |
| | | else if (csn.equals(addTime)) |
| | | { |
| | | if ((lastMod == HistAttrModificationKey.ADD) |
| | | || (lastMod == HistAttrModificationKey.REPL)) |
| | | if (lastMod == HistAttrModificationKey.ADD |
| | | || lastMod == HistAttrModificationKey.REPL) |
| | | { |
| | | if (csn.isNewerThan(deleteTime)) |
| | | { |
| | |
| | | else |
| | | { |
| | | if (csn.isNewerThanOrEqualTo(deleteTime) |
| | | && ((addTime == null ) || addTime.isOlderThan(deleteTime))) |
| | | && (addTime == null || addTime.isOlderThan(deleteTime))) |
| | | { |
| | | // no conflict : don't do anything beside setting the addTime |
| | | addTime = csn; |
| | |
| | | { |
| | | // Case where CSN = addTime = deleteTime |
| | | if (csn.equals(deleteTime) && csn.equals(addTime) |
| | | && (lastMod == HistAttrModificationKey.DEL)) |
| | | && lastMod == HistAttrModificationKey.DEL) |
| | | { |
| | | // No conflict, record the new value. |
| | | value = newValue; |
| | |
| | | if (obj instanceof AttrValueHistorical) |
| | | { |
| | | AttrValueHistorical objVal = (AttrValueHistorical) obj; |
| | | return (value.equals(objVal.getAttributeValue())); |
| | | return value.equals(objVal.getAttributeValue()); |
| | | } |
| | | return false; |
| | | } |
| | |
| | | * the same checksum value on every platforms, we always exclude the CR and |
| | | * LF characters from the computation. |
| | | */ |
| | | if ((b != 0x0D) && (b != 0x0A)) // CR=0D and LF=0A |
| | | if (b != 0x0D && b != 0x0A) // CR=0D and LF=0A |
| | | { |
| | | checksum += b; |
| | | } |
| | |
| | | /** {@inheritDoc} */ |
| | | public void update(byte[] b, int off, int len) |
| | | { |
| | | for (int i = off; i < (off + len); i++) |
| | | for (int i = off; i < off + len; i++) |
| | | { |
| | | updateWithOneByte(b[i]); |
| | | } |
| | |
| | | // This HistVal is used to store the date when the entry |
| | | // was added to the directory or when it was last renamed. |
| | | attrType = null; |
| | | if ((token.length >= 3) && (token[2].compareTo("moddn") == 0)) |
| | | if (token.length >= 3 && token[2].compareTo("moddn") == 0) |
| | | { |
| | | ismodDN = true; |
| | | } |
| | |
| | | |
| | | boolean replayDone = false; |
| | | int retryCount = 10; |
| | | while (!dependency && !replayDone && (retryCount-- > 0)) |
| | | while (!dependency && !replayDone && retryCount-- > 0) |
| | | { |
| | | if (shutdown.get()) |
| | | { |
| | |
| | | entryBuffer = ebytes.substring(0, endOfEntryIndex); |
| | | |
| | | // Send the entry |
| | | if ((numEntries>0) && (getNumExportedEntries() > numEntries)) |
| | | if (numEntries>0 && getNumExportedEntries() > numEntries) |
| | | { |
| | | // This outputstream has reached the total number |
| | | // of entries to export. |
| | | throw(new IOException()); |
| | | throw new IOException(); |
| | | } |
| | | |
| | | // Add the entry bytes to the checksum |
| | |
| | | ASN1Reader reader = ASN1.getReader(in); |
| | | while (reader.hasNextElement()) |
| | | { |
| | | mods.add((LDAPModification.decode(reader)).toModification()); |
| | | mods.add(LDAPModification.decode(reader).toModification()); |
| | | } |
| | | return mods; |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.replication.protocol; |
| | | |
| | |
| | | */ |
| | | public static short getCompatibleVersion(short version) |
| | | { |
| | | return (version < CURRENT_VERSION ? version : CURRENT_VERSION); |
| | | return version < CURRENT_VERSION ? version : CURRENT_VERSION; |
| | | } |
| | | } |
| | | |
| | |
| | | safeDataLevel = asn1Reader.readOctetString().byteAt(0); |
| | | */ |
| | | status = ServerStatus.valueOf(reader.get()); |
| | | assuredFlag = (reader.get() == 1); |
| | | assuredFlag = reader.get() == 1; |
| | | assuredMode = AssuredMode.valueOf(reader.get()); |
| | | safeDataLevel = reader.get(); |
| | | |
| | |
| | | // Only allow monitor recalculation at a time. |
| | | synchronized (pendingMonitorLock) |
| | | { |
| | | if ((monitorDataLastBuildDate + monitorDataLifeTime) < TimeThread |
| | | .getTime()) |
| | | if (monitorDataLastBuildDate + monitorDataLifeTime < TimeThread.getTime()) |
| | | { |
| | | try |
| | | { |
| | |
| | | numKnownAckStatus++; |
| | | } |
| | | |
| | | return (numKnownAckStatus == expectedServersAckStatus.size()); |
| | | return numKnownAckStatus == expectedServersAckStatus.size(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | final Random random = new Random(); |
| | | final int randomTime = random.nextInt(6); // Random from 0 to 5 |
| | | // Wait at least 3 seconds + (0 to 5 seconds) |
| | | final long timeout = 3000 + (randomTime * 1000); |
| | | final long timeout = 3000 + randomTime * 1000; |
| | | final boolean lockAcquired = replicationServerDomain.tryLock(timeout); |
| | | if (!lockAcquired) |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.replication.server.changelog.je; |
| | | |
| | |
| | | } |
| | | |
| | | // For ON_MATCHING_KEY, do not call next() if the cursor has just been initialized. |
| | | if (positionStrategy == ON_MATCHING_KEY && previousCursor != null |
| | | if ((positionStrategy == ON_MATCHING_KEY && previousCursor != null) |
| | | || positionStrategy == AFTER_MATCHING_KEY) |
| | | { |
| | | cursor.next(); |
| | |
| | | { |
| | | // replication server may be null in tests |
| | | logger.trace("In %s, %s", |
| | | (replicationServer != null ? replicationServer.getMonitorInstanceName() : "[test]"), |
| | | replicationServer != null ? replicationServer.getMonitorInstanceName() : "[test]", |
| | | message); |
| | | } |
| | | |
| | |
| | | * also need to make sure that we don't overflow the semaphore by |
| | | * releasing too many permits. |
| | | */ |
| | | final int MAX_PERMITS = (Integer.MAX_VALUE >>> 2); |
| | | final int MAX_PERMITS = Integer.MAX_VALUE >>> 2; |
| | | if (sendWindow.availablePermits() < MAX_PERMITS) |
| | | { |
| | | /* |
| | |
| | | int count = 0; |
| | | while (count<=length-2) |
| | | { |
| | | if ((entryBytes[pos+count] == '\n') && (entryBytes[pos+count+1] == '\n')) |
| | | if (entryBytes[pos+count] == '\n' && entryBytes[pos+count+1] == '\n') |
| | | { |
| | | entryCount++; |
| | | count++; |
| | |
| | | " our=" + ourLastExportedCnt + " slowest=" + slowestCnt); |
| | | } |
| | | |
| | | if ((ourLastExportedCnt - slowestCnt) > ieCtx.initWindow) |
| | | if (ourLastExportedCnt - slowestCnt > ieCtx.initWindow) |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | |
| | | break; |
| | | } |
| | | // Timeout ? |
| | | if ((System.currentTimeMillis() - startTime) >= getAssuredTimeout()) |
| | | if (System.currentTimeMillis() - startTime >= getAssuredTimeout()) |
| | | { |
| | | /* |
| | | Timeout occurred, be sure that ack is not being received and if so, |
| | |
| | | // whitespace. |
| | | int pos = 0; |
| | | int length = valueStr.length(); |
| | | while (pos < length && (valueStr.charAt(pos) == ' ')) |
| | | while (pos < length && valueStr.charAt(pos) == ' ') |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | } |
| | | |
| | | // Skip over any trailing spaces. |
| | | while (startPos < length && (valueStr.charAt(startPos) == ' ')) |
| | | while (startPos < length && valueStr.charAt(startPos) == ' ') |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // First, ignore any leading whitespace. |
| | | int length = authPasswordValue.length(); |
| | | int pos = 0; |
| | | while ((pos < length) && (authPasswordValue.charAt(pos) == ' ')) |
| | | while (pos < length && authPasswordValue.charAt(pos) == ' ') |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | |
| | | // Ignore any spaces before the dollar sign separator. Then read the dollar |
| | | // sign and ignore any trailing spaces. |
| | | while ((pos < length) && (authPasswordValue.charAt(pos) == ' ')) |
| | | while (pos < length && authPasswordValue.charAt(pos) == ' ') |
| | | { |
| | | pos++; |
| | | } |
| | | |
| | | if ((pos < length) && (authPasswordValue.charAt(pos) == '$')) |
| | | if (pos < length && authPasswordValue.charAt(pos) == '$') |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | message); |
| | | } |
| | | |
| | | while ((pos < length) && (authPasswordValue.charAt(pos) == ' ')) |
| | | while (pos < length && authPasswordValue.charAt(pos) == ' ') |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | while (pos < length) |
| | | { |
| | | char c = authPasswordValue.charAt(pos); |
| | | if ((c == ' ') || (c == '$')) |
| | | if (c == ' ' || c == '$') |
| | | { |
| | | break readAuthInfo; |
| | | } |
| | |
| | | |
| | | // Ignore any spaces before the dollar sign separator. Then read the dollar |
| | | // sign and ignore any trailing spaces. |
| | | while ((pos < length) && (authPasswordValue.charAt(pos) == ' ')) |
| | | while (pos < length && authPasswordValue.charAt(pos) == ' ') |
| | | { |
| | | pos++; |
| | | } |
| | | |
| | | if ((pos < length) && (authPasswordValue.charAt(pos) == '$')) |
| | | if (pos < length && authPasswordValue.charAt(pos) == '$') |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | |
| | | while ((pos < length) && (authPasswordValue.charAt(pos) == ' ')) |
| | | while (pos < length && authPasswordValue.charAt(pos) == ' ') |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | while (pos < length) |
| | | { |
| | | char c = authPasswordValue.charAt(pos); |
| | | if ((c == ' ') || (c == '$')) |
| | | if (c == ' ' || c == '$') |
| | | { |
| | | break ; |
| | | } |
| | |
| | | // whitespace. |
| | | int pos = 0; |
| | | int length = valueStr.length(); |
| | | while ((pos < length) && (valueStr.charAt(pos) == ' ')) |
| | | while (pos < length && valueStr.charAt(pos) == ' ') |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | char c = valueStr.charAt(pos++); |
| | | if (c != '(') |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_DCR_EXPECTED_OPEN_PARENTHESIS.get(valueStr, (pos-1), c); |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_DCR_EXPECTED_OPEN_PARENTHESIS.get(valueStr, pos-1, c); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | |
| | | |
| | | // Skip over any spaces immediately following the opening parenthesis. |
| | | while ((pos < length) && ((c = valueStr.charAt(pos)) == ' ')) |
| | | while (pos < length && ((c = valueStr.charAt(pos)) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | // This must be a numeric OID. In that case, we will accept only digits |
| | | // and periods, but not consecutive periods. |
| | | boolean lastWasPeriod = false; |
| | | while ((pos < length) && ((c = valueStr.charAt(pos++)) != ' ')) |
| | | while (pos < length && ((c = valueStr.charAt(pos++)) != ' ')) |
| | | { |
| | | if (c == '.') |
| | | { |
| | | if (lastWasPeriod) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_DCR_DOUBLE_PERIOD_IN_NUMERIC_OID. |
| | | get(valueStr, (pos-1)); |
| | | get(valueStr, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | | else |
| | | { |
| | | lastWasPeriod = true; |
| | | } |
| | | lastWasPeriod = true; |
| | | } |
| | | else if (! isDigit(c)) |
| | | { |
| | | // This must have been an illegal character. |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_DCR_ILLEGAL_CHAR_IN_NUMERIC_OID.get(valueStr, c, (pos-1)); |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_DCR_ILLEGAL_CHAR_IN_NUMERIC_OID.get(valueStr, c, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | else |
| | |
| | | { |
| | | // This must be a "fake" OID. In this case, we will only accept |
| | | // alphabetic characters, numeric digits, and the hyphen. |
| | | while ((pos < length) && ((c = valueStr.charAt(pos++)) != ' ')) |
| | | while (pos < length && ((c = valueStr.charAt(pos++)) != ' ')) |
| | | { |
| | | if (isAlpha(c) || isDigit(c) || (c == '-') || |
| | | ((c == '_') && DirectoryServer.allowAttributeNameExceptions())) |
| | | if (isAlpha(c) || isDigit(c) || c == '-' || |
| | | (c == '_' && DirectoryServer.allowAttributeNameExceptions())) |
| | | { |
| | | // This is fine. It is an acceptable character. |
| | | } |
| | | else |
| | | { |
| | | // This must have been an illegal character. |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_DCR_ILLEGAL_CHAR_IN_STRING_OID.get(valueStr, c, (pos-1)); |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_DCR_ILLEGAL_CHAR_IN_STRING_OID.get(valueStr, c, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | } |
| | |
| | | |
| | | // If we're at the end of the value, then it isn't a valid DIT content rule |
| | | // description. Otherwise, parse out the OID. |
| | | String oid; |
| | | if (pos >= length) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_DCR_TRUNCATED_VALUE.get(valueStr); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | else |
| | | { |
| | | oid = lowerStr.substring(oidStartPos, (pos-1)); |
| | | } |
| | | |
| | | String oid = lowerStr.substring(oidStartPos, pos-1); |
| | | |
| | | // Get the objectclass with the specified OID. If it does not exist or is |
| | | // not structural, then fail. |
| | |
| | | |
| | | |
| | | // Skip over the space(s) after the OID. |
| | | while ((pos < length) && ((c = valueStr.charAt(pos)) == ' ')) |
| | | while (pos < length && ((c = valueStr.charAt(pos)) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | if (pos < length) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_DCR_UNEXPECTED_CLOSE_PARENTHESIS. |
| | | get(valueStr, (pos-1)); |
| | | get(valueStr, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | |
| | | { |
| | | StringBuilder userBuffer = new StringBuilder(); |
| | | StringBuilder lowerBuffer = new StringBuilder(); |
| | | pos = readQuotedString(valueStr, lowerStr, userBuffer, lowerBuffer, |
| | | (pos-1)); |
| | | pos = readQuotedString(valueStr, lowerStr, userBuffer, lowerBuffer, pos-1); |
| | | names.put(lowerBuffer.toString(), userBuffer.toString()); |
| | | } |
| | | else if (c == '(') |
| | |
| | | { |
| | | // Skip over any spaces after the parenthesis. |
| | | pos++; |
| | | while ((pos < length) && ((c = valueStr.charAt(pos)) == ' ')) |
| | | while (pos < length && ((c = valueStr.charAt(pos)) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | else |
| | | { |
| | | // This is an illegal character. |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_DCR_ILLEGAL_CHAR.get(valueStr, c, (pos-1)); |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_DCR_ILLEGAL_CHAR.get(valueStr, c, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | } |
| | |
| | | while (true) |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos)); |
| | | pos = readWOID(lowerStr, woidBuffer, pos); |
| | | |
| | | ObjectClass oc = schema.getObjectClass(woidBuffer.toString()); |
| | | if (oc == null) |
| | |
| | | else if (c != '$') |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_DCR_ILLEGAL_CHAR.get(valueStr, c, (pos-1)); |
| | | ERR_ATTR_SYNTAX_DCR_ILLEGAL_CHAR.get(valueStr, c, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | } |
| | |
| | | else |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos-1)); |
| | | pos = readWOID(lowerStr, woidBuffer, pos-1); |
| | | |
| | | ObjectClass oc = schema.getObjectClass(woidBuffer.toString()); |
| | | if (oc == null) |
| | |
| | | while (true) |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos)); |
| | | pos = readWOID(lowerStr, woidBuffer, pos); |
| | | attrs.add(getAttribute(schema, allowUnknownElements, valueStr, woidBuffer, |
| | | ERR_ATTR_SYNTAX_DCR_UNKNOWN_REQUIRED_ATTR)); |
| | | |
| | |
| | | else if (c != '$') |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_DCR_ILLEGAL_CHAR.get(valueStr, c, (pos-1)); |
| | | ERR_ATTR_SYNTAX_DCR_ILLEGAL_CHAR.get(valueStr, c, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | } |
| | |
| | | else |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos-1)); |
| | | pos = readWOID(lowerStr, woidBuffer, pos-1); |
| | | attrs.add(getAttribute(schema, allowUnknownElements, valueStr, woidBuffer, |
| | | ERR_ATTR_SYNTAX_DCR_UNKNOWN_REQUIRED_ATTR)); |
| | | } |
| | |
| | | while (true) |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos)); |
| | | pos = readWOID(lowerStr, woidBuffer, pos); |
| | | attrs.add(getAttribute(schema, allowUnknownElements, valueStr, woidBuffer, |
| | | ERR_ATTR_SYNTAX_DCR_UNKNOWN_OPTIONAL_ATTR)); |
| | | |
| | |
| | | else if (c != '$') |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_DCR_ILLEGAL_CHAR.get(valueStr, c, (pos-1)); |
| | | ERR_ATTR_SYNTAX_DCR_ILLEGAL_CHAR.get(valueStr, c, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | } |
| | |
| | | else |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos-1)); |
| | | pos = readWOID(lowerStr, woidBuffer, pos-1); |
| | | attrs.add(getAttribute(schema, allowUnknownElements, valueStr, woidBuffer, |
| | | ERR_ATTR_SYNTAX_DCR_UNKNOWN_OPTIONAL_ATTR)); |
| | | } |
| | |
| | | while (true) |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos)); |
| | | pos = readWOID(lowerStr, woidBuffer, pos); |
| | | attrs.add(getAttribute(schema, allowUnknownElements, valueStr, woidBuffer, |
| | | ERR_ATTR_SYNTAX_DCR_UNKNOWN_PROHIBITED_ATTR)); |
| | | |
| | |
| | | else if (c != '$') |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_DCR_ILLEGAL_CHAR.get(valueStr, c, (pos-1)); |
| | | ERR_ATTR_SYNTAX_DCR_ILLEGAL_CHAR.get(valueStr, c, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | } |
| | |
| | | else |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos-1)); |
| | | pos = readWOID(lowerStr, woidBuffer, pos-1); |
| | | attrs.add(getAttribute(schema, allowUnknownElements, valueStr, woidBuffer, |
| | | ERR_ATTR_SYNTAX_DCR_UNKNOWN_PROHIBITED_ATTR)); |
| | | } |
| | |
| | | // Skip over any spaces at the beginning of the value. |
| | | char c = '\u0000'; |
| | | int length = valueStr.length(); |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | |
| | | |
| | | // Read until we find the next space. |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos++)) != ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos++)) != ' ')) |
| | | { |
| | | tokenName.append(c); |
| | | } |
| | | |
| | | |
| | | // Skip over any trailing spaces after the value. |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // Skip over any spaces at the beginning of the value. |
| | | char c = '\u0000'; |
| | | int length = valueStr.length(); |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | |
| | | // Read until we find the closing quote. |
| | | startPos++; |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) != '\'')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) != '\'')) |
| | | { |
| | | valueBuffer.append(c); |
| | | startPos++; |
| | |
| | | |
| | | // Skip over any trailing spaces after the value. |
| | | startPos++; |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // Skip over any spaces at the beginning of the value. |
| | | char c = '\u0000'; |
| | | int length = lowerStr.length(); |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | |
| | | // Read until we find the closing quote. |
| | | startPos++; |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos)) != '\'')) |
| | | while (startPos < length && ((c = lowerStr.charAt(startPos)) != '\'')) |
| | | { |
| | | lowerBuffer.append(c); |
| | | userBuffer.append(valueStr.charAt(startPos)); |
| | |
| | | |
| | | // Skip over any trailing spaces after the value. |
| | | startPos++; |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // Skip over any spaces at the beginning of the value. |
| | | char c = '\u0000'; |
| | | int length = lowerStr.length(); |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // This must be a numeric OID. In that case, we will accept only digits |
| | | // and periods, but not consecutive periods. |
| | | boolean lastWasPeriod = false; |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos++)) != ' ')) |
| | | while (startPos < length && ((c = lowerStr.charAt(startPos++)) != ' ')) |
| | | { |
| | | if (c == '.') |
| | | { |
| | | if (lastWasPeriod) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_DCR_DOUBLE_PERIOD_IN_NUMERIC_OID. |
| | | get(lowerStr, (startPos-1)); |
| | | get(lowerStr, startPos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | |
| | | // additional characters. |
| | | if (c == ')') |
| | | { |
| | | return (startPos-1); |
| | | return startPos-1; |
| | | } |
| | | |
| | | // This must have been an illegal character. |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_DCR_ILLEGAL_CHAR_IN_NUMERIC_OID.get( |
| | | lowerStr, c, (startPos-1)); |
| | | lowerStr, c, startPos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | else |
| | |
| | | else if (isAlpha(c)) |
| | | { |
| | | // This must be an attribute type/objectclass description. In this case, |
| | | // we will only accept alphabetic characters, numeric digits, and the |
| | | // hyphen. |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos++)) != ' ')) |
| | | // we will only accept alphabetic characters, numeric digits, and the hyphen. |
| | | while (startPos < length && ((c = lowerStr.charAt(startPos++)) != ' ')) |
| | | { |
| | | if (isAlpha(c) || isDigit(c) || (c == '-') || |
| | | ((c == '_') && DirectoryServer.allowAttributeNameExceptions())) |
| | | if (isAlpha(c) || isDigit(c) || c == '-' || |
| | | (c == '_' && DirectoryServer.allowAttributeNameExceptions())) |
| | | { |
| | | woidBuffer.append(c); |
| | | } |
| | |
| | | // additional characters. |
| | | if (c == ')') |
| | | { |
| | | return (startPos-1); |
| | | return startPos-1; |
| | | } |
| | | |
| | | // This must have been an illegal character. |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_DCR_ILLEGAL_CHAR_IN_STRING_OID.get( |
| | | lowerStr, c, (startPos-1)); |
| | | lowerStr, c, startPos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | // Skip over any trailing spaces after the value. |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // Skip over any leading spaces. |
| | | int length = valueStr.length(); |
| | | char c = '\u0000'; |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // Parse until the closing quote. |
| | | StringBuilder valueBuffer = new StringBuilder(); |
| | | startPos++; |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) != '\'')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) != '\'')) |
| | | { |
| | | valueBuffer.append(c); |
| | | startPos++; |
| | |
| | | while (true) |
| | | { |
| | | // Skip over any leading spaces; |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // We have a quoted string |
| | | StringBuilder valueBuffer = new StringBuilder(); |
| | | startPos++; |
| | | while ((startPos < length) && |
| | | while (startPos < length && |
| | | ((c = valueStr.charAt(startPos)) != '\'')) |
| | | { |
| | | valueBuffer.append(c); |
| | |
| | | { |
| | | //Consider unquoted string |
| | | StringBuilder valueBuffer = new StringBuilder(); |
| | | while ((startPos < length) && |
| | | while (startPos < length && |
| | | ((c = valueStr.charAt(startPos)) != ' ')) |
| | | { |
| | | valueBuffer.append(c); |
| | |
| | | { |
| | | // Parse until the next space. |
| | | StringBuilder valueBuffer = new StringBuilder(); |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) != ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) != ' ')) |
| | | { |
| | | valueBuffer.append(c); |
| | | startPos++; |
| | |
| | | } |
| | | |
| | | // Skip over any trailing spaces. |
| | | while ((startPos < length) && (valueStr.charAt(startPos) == ' ')) |
| | | while (startPos < length && valueStr.charAt(startPos) == ' ') |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // whitespace. |
| | | int pos = 0; |
| | | int length = valueStr.length(); |
| | | while ((pos < length) && (valueStr.charAt(pos) == ' ')) |
| | | while (pos < length && valueStr.charAt(pos) == ' ') |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | if (c != '(') |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_DSR_EXPECTED_OPEN_PARENTHESIS.get( |
| | | valueStr, (pos-1), c); |
| | | valueStr, pos-1, c); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | |
| | | |
| | | // Skip over any spaces immediately following the opening parenthesis. |
| | | while ((pos < length) && ((c = valueStr.charAt(pos)) == ' ')) |
| | | while (pos < length && ((c = valueStr.charAt(pos)) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | |
| | | // The next set of characters must be the rule ID, which is an integer. |
| | | int ruleIDStartPos = pos; |
| | | while ((pos < length) && ((c = valueStr.charAt(pos++)) != ' ')) |
| | | while (pos < length && ((c = valueStr.charAt(pos++)) != ' ')) |
| | | { |
| | | if (! isDigit(c)) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_DSR_ILLEGAL_CHAR_IN_RULE_ID.get( |
| | | valueStr, c, (pos-1)); |
| | | valueStr, c, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | |
| | | |
| | | |
| | | // Skip over the space(s) after the rule ID. |
| | | while ((pos < length) && ((c = valueStr.charAt(pos)) == ' ')) |
| | | while (pos < length && ((c = valueStr.charAt(pos)) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | if (pos < length) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_DSR_UNEXPECTED_CLOSE_PARENTHESIS. |
| | | get(valueStr, (pos-1)); |
| | | get(valueStr, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | |
| | | { |
| | | StringBuilder userBuffer = new StringBuilder(); |
| | | StringBuilder lowerBuffer = new StringBuilder(); |
| | | pos = readQuotedString(valueStr, lowerStr, userBuffer, lowerBuffer, |
| | | (pos-1)); |
| | | pos = readQuotedString(valueStr, lowerStr, userBuffer, lowerBuffer, pos-1); |
| | | names.put(lowerBuffer.toString(), userBuffer.toString()); |
| | | } |
| | | else if (c == '(') |
| | |
| | | { |
| | | // Skip over any spaces after the parenthesis. |
| | | pos++; |
| | | while ((pos < length) && ((c = valueStr.charAt(pos)) == ' ')) |
| | | while (pos < length && ((c = valueStr.charAt(pos)) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | { |
| | | // This is an illegal character. |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_DSR_ILLEGAL_CHAR.get(valueStr, c, (pos-1)); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | ERR_ATTR_SYNTAX_DSR_ILLEGAL_CHAR.get(valueStr, c, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | } |
| | | else if (lowerTokenName.equals("desc")) |
| | |
| | | |
| | | nameFormGiven = true; |
| | | nameForm = schema.getNameForm(woidBuffer.toString()); |
| | | if ((nameForm == null) && (! allowUnknownElements)) |
| | | if (nameForm == null && ! allowUnknownElements) |
| | | { |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | ERR_ATTR_SYNTAX_DSR_UNKNOWN_NAME_FORM.get(valueStr, woidBuffer)); |
| | |
| | | while (true) |
| | | { |
| | | // Skip over any leading spaces. |
| | | while ((pos < length) && ((c = valueStr.charAt(pos)) == ' ')) |
| | | while (pos < length && ((c = valueStr.charAt(pos)) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | |
| | | // Read the next integer value. |
| | | ruleIDStartPos = pos; |
| | | while ((pos < length) && ((c = valueStr.charAt(pos++)) != ' ')) |
| | | while (pos < length && ((c = valueStr.charAt(pos++)) != ' ')) |
| | | { |
| | | if (! isDigit(c)) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_DSR_ILLEGAL_CHAR_IN_RULE_ID. |
| | | get(valueStr, c, (pos-1)); |
| | | get(valueStr, c, pos-1); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | |
| | | |
| | | |
| | | // Skip over any trailing spaces. |
| | | while ((pos < length) && ((c = valueStr.charAt(pos)) == ' ')) |
| | | while (pos < length && ((c = valueStr.charAt(pos)) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | if (c == ')') |
| | | { |
| | | pos++; |
| | | while ((pos < length) && ((c = valueStr.charAt(pos)) == ' ')) |
| | | while (pos < length && ((c = valueStr.charAt(pos)) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | |
| | | // Read the next integer value. |
| | | ruleIDStartPos = pos - 1; |
| | | while ((pos < length) && ((c = valueStr.charAt(pos++)) != ' ')) |
| | | while (pos < length && ((c = valueStr.charAt(pos++)) != ' ')) |
| | | { |
| | | if (! isDigit(c)) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_DSR_ILLEGAL_CHAR_IN_RULE_ID.get(valueStr, c, (pos-1)); |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_DSR_ILLEGAL_CHAR_IN_RULE_ID.get(valueStr, c, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | |
| | | |
| | | |
| | | // Skip over any trailing spaces. |
| | | while ((pos < length) && ((c = valueStr.charAt(pos)) == ' ')) |
| | | while (pos < length && ((c = valueStr.charAt(pos)) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | if ((nameForm == null) && (! nameFormGiven)) |
| | | if (nameForm == null && !nameFormGiven) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_DSR_NO_NAME_FORM.get(valueStr); |
| | | throw new DirectoryException( |
| | |
| | | // Skip over any spaces at the beginning of the value. |
| | | char c = '\u0000'; |
| | | int length = valueStr.length(); |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | |
| | | |
| | | // Read until we find the next space. |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos++)) != ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos++)) != ' ')) |
| | | { |
| | | tokenName.append(c); |
| | | } |
| | | |
| | | |
| | | // Skip over any trailing spaces after the value. |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // Skip over any spaces at the beginning of the value. |
| | | char c = '\u0000'; |
| | | int length = valueStr.length(); |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | |
| | | // Read until we find the closing quote. |
| | | startPos++; |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) != '\'')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) != '\'')) |
| | | { |
| | | valueBuffer.append(c); |
| | | startPos++; |
| | |
| | | |
| | | // Skip over any trailing spaces after the value. |
| | | startPos++; |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // Skip over any spaces at the beginning of the value. |
| | | char c = '\u0000'; |
| | | int length = lowerStr.length(); |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | |
| | | // Read until we find the closing quote. |
| | | startPos++; |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos)) != '\'')) |
| | | while (startPos < length && ((c = lowerStr.charAt(startPos)) != '\'')) |
| | | { |
| | | lowerBuffer.append(c); |
| | | userBuffer.append(valueStr.charAt(startPos)); |
| | |
| | | |
| | | // Skip over any trailing spaces after the value. |
| | | startPos++; |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // Skip over any spaces at the beginning of the value. |
| | | char c = '\u0000'; |
| | | int length = lowerStr.length(); |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // This must be a numeric OID. In that case, we will accept only digits |
| | | // and periods, but not consecutive periods. |
| | | boolean lastWasPeriod = false; |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos++)) != ' ')) |
| | | while (startPos < length && ((c = lowerStr.charAt(startPos++)) != ' ')) |
| | | { |
| | | if (c == '.') |
| | | { |
| | | if (lastWasPeriod) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_DSR_DOUBLE_PERIOD_IN_NUMERIC_OID. |
| | | get(lowerStr, (startPos-1)); |
| | | get(lowerStr, startPos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | |
| | | // additional characters. |
| | | if (c == ')') |
| | | { |
| | | return (startPos-1); |
| | | return startPos-1; |
| | | } |
| | | |
| | | // This must have been an illegal character. |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_DSR_ILLEGAL_CHAR_IN_NUMERIC_OID.get(lowerStr, c, (startPos-1)); |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_DSR_ILLEGAL_CHAR_IN_NUMERIC_OID.get(lowerStr, c, startPos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | else |
| | |
| | | // This must be an attribute type/objectclass description. In this case, |
| | | // we will only accept alphabetic characters, numeric digits, and the |
| | | // hyphen. |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos++)) != ' ')) |
| | | while (startPos < length && ((c = lowerStr.charAt(startPos++)) != ' ')) |
| | | { |
| | | if (isAlpha(c) || isDigit(c) || (c == '-') || |
| | | ((c == '_') && DirectoryServer.allowAttributeNameExceptions())) |
| | | if (isAlpha(c) || isDigit(c) || c == '-' || |
| | | (c == '_' && DirectoryServer.allowAttributeNameExceptions())) |
| | | { |
| | | woidBuffer.append(c); |
| | | } |
| | |
| | | // additional characters. |
| | | if (c == ')') |
| | | { |
| | | return (startPos-1); |
| | | return startPos-1; |
| | | } |
| | | |
| | | // This must have been an illegal character. |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_DSR_ILLEGAL_CHAR_IN_STRING_OID.get(lowerStr, c, (startPos-1)); |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_DSR_ILLEGAL_CHAR_IN_STRING_OID.get(lowerStr, c, startPos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | // Skip over any trailing spaces after the value. |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // Skip over any leading spaces. |
| | | int length = valueStr.length(); |
| | | char c = '\u0000'; |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // Parse until the closing quote. |
| | | StringBuilder valueBuffer = new StringBuilder(); |
| | | startPos++; |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) != '\'')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) != '\'')) |
| | | { |
| | | valueBuffer.append(c); |
| | | startPos++; |
| | |
| | | while (true) |
| | | { |
| | | // Skip over any leading spaces; |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // We have a quoted string |
| | | StringBuilder valueBuffer = new StringBuilder(); |
| | | startPos++; |
| | | while ((startPos < length) && |
| | | ((c = valueStr.charAt(startPos)) != '\'')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) != '\'')) |
| | | { |
| | | valueBuffer.append(c); |
| | | startPos++; |
| | |
| | | { |
| | | //Consider unquoted string |
| | | StringBuilder valueBuffer = new StringBuilder(); |
| | | while ((startPos < length) && |
| | | ((c = valueStr.charAt(startPos)) != ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) != ' ')) |
| | | { |
| | | valueBuffer.append(c); |
| | | startPos++; |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_DSR_TRUNCATED_VALUE.get(valueStr); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | // Parse until the next space. |
| | | StringBuilder valueBuffer = new StringBuilder(); |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) != ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) != ' ')) |
| | | { |
| | | valueBuffer.append(c); |
| | | startPos++; |
| | |
| | | } |
| | | |
| | | // Skip over any trailing spaces. |
| | | while ((startPos < length) && (valueStr.charAt(startPos) == ' ')) |
| | | while (startPos < length && valueStr.charAt(startPos) == ' ') |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | case '-': |
| | | // These are fine only if there are exactly two or four more digits that |
| | | // specify a valid offset. |
| | | if ((length == 13) || (length == 15)) |
| | | if (length == 13 || length == 15) |
| | | { |
| | | try |
| | | { |
| | |
| | | case '-': |
| | | // These are fine only if there are exactly two or four more digits that |
| | | // specify a valid offset. |
| | | if ((length == 15) || (length == 17)) |
| | | if (length == 15 || length == 17) |
| | | { |
| | | try |
| | | { |
| | |
| | | case '-': |
| | | // These are fine only if there are exactly two or four more digits that |
| | | // specify a valid offset. |
| | | if ((length == 17) || (length == 19)) |
| | | if (length == 17 || length == 19) |
| | | { |
| | | try |
| | | { |
| | |
| | | |
| | | case 'Z': |
| | | // This is only acceptable if we're at the end of the value. |
| | | if (i != (value.length() - 1)) |
| | | if (i != value.length() - 1) |
| | | { |
| | | LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_ILLEGAL_FRACTION_CHAR. |
| | |
| | | throws DirectoryException |
| | | { |
| | | String offSetStr = value.substring(startPos); |
| | | if ((offSetStr.length() != 3) && (offSetStr.length() != 5)) |
| | | int len = offSetStr.length(); |
| | | if (len != 3 && len != 5) |
| | | { |
| | | LocalizableMessage message = WARN_ATTR_SYNTAX_GENERALIZED_TIME_INVALID_OFFSET.get( |
| | | value, offSetStr); |
| | |
| | | |
| | | // If there are two more characters, then they must be an integer between |
| | | // 00 and 59. |
| | | if (offSetStr.length() == 5) |
| | | if (len == 5) |
| | | { |
| | | switch (offSetStr.charAt(3)) |
| | | { |
| | |
| | | else |
| | | { |
| | | c = criteria.charAt(i+1); |
| | | if ((c == '|') || (c == '&')) |
| | | if (c == '|' || c == '&') |
| | | { |
| | | return criteriaIsValid(criteria.substring(i+2), valueStr, |
| | | invalidReason); |
| | |
| | | { |
| | | invalidReason.append( |
| | | ERR_ATTR_SYNTAX_GUIDE_ILLEGAL_CHAR.get( |
| | | valueStr, criteria, c, (i+1))); |
| | | valueStr, criteria, c, i+1)); |
| | | return false; |
| | | } |
| | | } |
| | |
| | | { |
| | | // The only characters allowed next are a pipe or an ampersand. |
| | | c = criteria.charAt(5); |
| | | if ((c == '|') || (c == '&')) |
| | | if (c == '|' || c == '&') |
| | | { |
| | | return criteriaIsValid(criteria.substring(6), valueStr, |
| | | invalidReason); |
| | |
| | | { |
| | | // The only characters allowed next are a pipe or an ampersand. |
| | | c = criteria.charAt(6); |
| | | if ((c == '|') || (c == '&')) |
| | | if (c == '|' || c == '&') |
| | | { |
| | | return criteriaIsValid(criteria.substring(7), valueStr, |
| | | invalidReason); |
| | |
| | | else |
| | | { |
| | | c = criteria.charAt(endPos); |
| | | if ((c == '|') || (c == '&')) |
| | | if (c == '|' || c == '&') |
| | | { |
| | | return criteriaIsValid(criteria.substring(endPos+1), valueStr, |
| | | invalidReason); |
| | |
| | | // whitespace. |
| | | int pos = 0; |
| | | int length = valueStr.length(); |
| | | while ((pos < length) && (valueStr.charAt(pos) == ' ')) |
| | | while (pos < length && valueStr.charAt(pos) == ' ') |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | if (c != '(') |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_LDAPSYNTAX_EXPECTED_OPEN_PARENTHESIS.get(valueStr, (pos-1), c); |
| | | ERR_ATTR_SYNTAX_LDAPSYNTAX_EXPECTED_OPEN_PARENTHESIS.get(valueStr, pos-1, c); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | | |
| | | |
| | | // Skip over any spaces immediately following the opening parenthesis. |
| | | while ((pos < length) && ((c = valueStr.charAt(pos)) == ' ')) |
| | | while (pos < length && ((c = valueStr.charAt(pos)) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | // This must be a numeric OID. In that case, we will accept only digits |
| | | // and periods, but not consecutive periods. |
| | | boolean lastWasPeriod = false; |
| | | while ((pos < length) && ((c = valueStr.charAt(pos)) != ' ') |
| | | while (pos < length && ((c = valueStr.charAt(pos)) != ' ') |
| | | && (c = valueStr.charAt(pos)) != ')') |
| | | { |
| | | if (c == '.') |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_LDAPSYNTAX_DOUBLE_PERIOD_IN_NUMERIC_OID. |
| | | get(valueStr, (pos-1)); |
| | | get(valueStr, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | |
| | | // This must have been an illegal character. |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_LDAPSYNTAX_ILLEGAL_CHAR_IN_NUMERIC_OID. |
| | | get(valueStr, c, (pos-1)); |
| | | get(valueStr, c, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | |
| | | { |
| | | // This must be a "fake" OID. In this case, we will only accept |
| | | // alphabetic characters, numeric digits, and the hyphen. |
| | | while ((pos < length) && ((c = valueStr.charAt(pos)) != ' ') |
| | | while (pos < length && ((c = valueStr.charAt(pos)) != ' ') |
| | | && (c=valueStr.charAt(pos))!=')') |
| | | { |
| | | if (isAlpha(c) || isDigit(c) || (c == '-') || |
| | | ((c == '_') && DirectoryServer.allowAttributeNameExceptions())) |
| | | if (isAlpha(c) || isDigit(c) || c == '-' || |
| | | (c == '_' && DirectoryServer.allowAttributeNameExceptions())) |
| | | { |
| | | // This is fine. It is an acceptable character. |
| | | pos++; |
| | |
| | | // This must have been an illegal character. |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_LDAPSYNTAX_ILLEGAL_CHAR_IN_STRING_OID. |
| | | get(valueStr, c, (pos-1)); |
| | | get(valueStr, c, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | |
| | | oid = toLowerCase(valueStr.substring(oidStartPos, pos)); |
| | | |
| | | // Skip over the space(s) after the OID. |
| | | while ((pos < length) && ((c = valueStr.charAt(pos)) == ' ')) |
| | | while (pos < length && ((c = valueStr.charAt(pos)) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | if (pos < length) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_LDAPSYNTAX_UNEXPECTED_CLOSE_PARENTHESIS. |
| | | get(valueStr, (pos-1)); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | ERR_ATTR_SYNTAX_LDAPSYNTAX_UNEXPECTED_CLOSE_PARENTHESIS.get(valueStr, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | |
| | | break; |
| | |
| | | // Skip over any spaces at the beginning of the value. |
| | | char c = '\u0000'; |
| | | int length = valueStr.length(); |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | |
| | | |
| | | // Read until we find the next space. |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos++)) != ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos++)) != ' ')) |
| | | { |
| | | tokenName.append(c); |
| | | } |
| | | |
| | | |
| | | // Skip over any trailing spaces after the value. |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // Skip over any spaces at the beginning of the value. |
| | | char c = '\u0000'; |
| | | int length = valueStr.length(); |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | |
| | | // Read until we find the closing quote. |
| | | startPos++; |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) != '\'')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) != '\'')) |
| | | { |
| | | valueBuffer.append(c); |
| | | startPos++; |
| | |
| | | |
| | | // Skip over any trailing spaces after the value. |
| | | startPos++; |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // Skip over any leading spaces. |
| | | int length = valueStr.length(); |
| | | char c = '\u0000'; |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // Parse until the closing quote. |
| | | StringBuilder valueBuffer = new StringBuilder(); |
| | | startPos++; |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) != '\'')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) != '\'')) |
| | | { |
| | | valueBuffer.append(c); |
| | | startPos++; |
| | |
| | | while (true) |
| | | { |
| | | // Skip over any leading spaces; |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // We have a quoted string |
| | | StringBuilder valueBuffer = new StringBuilder(); |
| | | startPos++; |
| | | while ((startPos < length) && |
| | | ((c = valueStr.charAt(startPos)) != '\'')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) != '\'')) |
| | | { |
| | | valueBuffer.append(c); |
| | | startPos++; |
| | |
| | | { |
| | | //Consider unquoted string |
| | | StringBuilder valueBuffer = new StringBuilder(); |
| | | while ((startPos < length) && |
| | | ((c = valueStr.charAt(startPos)) != ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) != ' ')) |
| | | { |
| | | valueBuffer.append(c); |
| | | startPos++; |
| | |
| | | { |
| | | // Parse until the next space. |
| | | StringBuilder valueBuffer = new StringBuilder(); |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) != ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) != ' ')) |
| | | { |
| | | valueBuffer.append(c); |
| | | startPos++; |
| | |
| | | } |
| | | |
| | | // Skip over any trailing spaces. |
| | | while ((startPos < length) && (valueStr.charAt(startPos) == ' ')) |
| | | while (startPos < length && valueStr.charAt(startPos) == ' ') |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // whitespace. |
| | | int pos = 0; |
| | | int length = valueStr.length(); |
| | | while ((pos < length) && (valueStr.charAt(pos) == ' ')) |
| | | while (pos < length && valueStr.charAt(pos) == ' ') |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | char c = valueStr.charAt(pos++); |
| | | if (c != '(') |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_MRUSE_EXPECTED_OPEN_PARENTHESIS.get(valueStr, (pos-1), c); |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_MRUSE_EXPECTED_OPEN_PARENTHESIS.get(valueStr, pos-1, c); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | |
| | | |
| | | // Skip over any spaces immediately following the opening parenthesis. |
| | | while ((pos < length) && ((c = valueStr.charAt(pos)) == ' ')) |
| | | while (pos < length && ((c = valueStr.charAt(pos)) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | // This must be a numeric OID. In that case, we will accept only digits |
| | | // and periods, but not consecutive periods. |
| | | boolean lastWasPeriod = false; |
| | | while ((pos < length) && ((c = valueStr.charAt(pos++)) != ' ')) |
| | | while (pos < length && ((c = valueStr.charAt(pos++)) != ' ')) |
| | | { |
| | | if (c == '.') |
| | | { |
| | | if (lastWasPeriod) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_MRUSE_DOUBLE_PERIOD_IN_NUMERIC_OID. |
| | | get(valueStr, (pos-1)); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | ERR_ATTR_SYNTAX_MRUSE_DOUBLE_PERIOD_IN_NUMERIC_OID.get(valueStr, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | else |
| | | { |
| | | lastWasPeriod = true; |
| | | } |
| | | lastWasPeriod = true; |
| | | } |
| | | else if (! isDigit(c)) |
| | | { |
| | | // This must have been an illegal character. |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_MRUSE_ILLEGAL_CHAR_IN_NUMERIC_OID.get(valueStr, c, (pos-1)); |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_MRUSE_ILLEGAL_CHAR_IN_NUMERIC_OID.get(valueStr, c, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | else |
| | |
| | | { |
| | | // This must be a "fake" OID. In this case, we will only accept |
| | | // alphabetic characters, numeric digits, and the hyphen. |
| | | while ((pos < length) && ((c = valueStr.charAt(pos++)) != ' ')) |
| | | while (pos < length && ((c = valueStr.charAt(pos++)) != ' ')) |
| | | { |
| | | if (isAlpha(c) || isDigit(c) || (c == '-') || |
| | | ((c == '_') && DirectoryServer.allowAttributeNameExceptions())) |
| | | if (isAlpha(c) || isDigit(c) || c == '-' || |
| | | (c == '_' && DirectoryServer.allowAttributeNameExceptions())) |
| | | { |
| | | // This is fine. It is an acceptable character. |
| | | } |
| | |
| | | { |
| | | // This must have been an illegal character. |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_MRUSE_ILLEGAL_CHAR_IN_STRING_OID. |
| | | get(valueStr, c, (pos-1)); |
| | | get(valueStr, c, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | } |
| | |
| | | |
| | | // If we're at the end of the value, then it isn't a valid matching rule use |
| | | // description. Otherwise, parse out the OID. |
| | | String oid; |
| | | if (pos >= length) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_MRUSE_TRUNCATED_VALUE.get(valueStr); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | else |
| | | { |
| | | oid = lowerStr.substring(oidStartPos, (pos-1)); |
| | | } |
| | | |
| | | String oid = lowerStr.substring(oidStartPos, pos-1); |
| | | |
| | | // Get the matching rule with the specified OID. |
| | | MatchingRule matchingRule = schema.getMatchingRule(oid); |
| | |
| | | |
| | | |
| | | // Skip over the space(s) after the OID. |
| | | while ((pos < length) && ((c = valueStr.charAt(pos)) == ' ')) |
| | | while (pos < length && ((c = valueStr.charAt(pos)) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | if (pos < length) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_MRUSE_UNEXPECTED_CLOSE_PARENTHESIS. |
| | | get(valueStr, (pos-1)); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | get(valueStr, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | |
| | | break; |
| | |
| | | { |
| | | StringBuilder userBuffer = new StringBuilder(); |
| | | StringBuilder lowerBuffer = new StringBuilder(); |
| | | pos = readQuotedString(valueStr, lowerStr, userBuffer, lowerBuffer, |
| | | (pos-1)); |
| | | pos = readQuotedString(valueStr, lowerStr, userBuffer, lowerBuffer, pos-1); |
| | | names.put(lowerBuffer.toString(), userBuffer.toString()); |
| | | } |
| | | else if (c == '(') |
| | |
| | | { |
| | | // Skip over any spaces after the parenthesis. |
| | | pos++; |
| | | while ((pos < length) && ((c = valueStr.charAt(pos)) == ' ')) |
| | | while (pos < length && ((c = valueStr.charAt(pos)) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | else |
| | | { |
| | | // This is an illegal character. |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_MRUSE_ILLEGAL_CHAR.get(valueStr, c, (pos-1)); |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_MRUSE_ILLEGAL_CHAR.get(valueStr, c, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | } |
| | |
| | | while (true) |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos)); |
| | | pos = readWOID(lowerStr, woidBuffer, pos); |
| | | attrs.add(getAttributeType(schema, allowUnknownElements, oid, woidBuffer)); |
| | | |
| | | // The next character must be either a dollar sign or a closing parenthesis. |
| | |
| | | else if (c != '$') |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_MRUSE_ILLEGAL_CHAR.get(valueStr, c, (pos-1)); |
| | | ERR_ATTR_SYNTAX_MRUSE_ILLEGAL_CHAR.get(valueStr, c, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | } |
| | |
| | | else |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos-1)); |
| | | pos = readWOID(lowerStr, woidBuffer, pos-1); |
| | | attrs.add(getAttributeType(schema, allowUnknownElements, oid, woidBuffer)); |
| | | } |
| | | |
| | |
| | | // Skip over any spaces at the beginning of the value. |
| | | char c = '\u0000'; |
| | | int length = valueStr.length(); |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | |
| | | |
| | | // Read until we find the next space. |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos++)) != ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos++)) != ' ')) |
| | | { |
| | | tokenName.append(c); |
| | | } |
| | | |
| | | |
| | | // Skip over any trailing spaces after the value. |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // Skip over any spaces at the beginning of the value. |
| | | char c = '\u0000'; |
| | | int length = valueStr.length(); |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | |
| | | // Read until we find the closing quote. |
| | | startPos++; |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) != '\'')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) != '\'')) |
| | | { |
| | | valueBuffer.append(c); |
| | | startPos++; |
| | |
| | | |
| | | // Skip over any trailing spaces after the value. |
| | | startPos++; |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // Skip over any spaces at the beginning of the value. |
| | | char c = '\u0000'; |
| | | int length = lowerStr.length(); |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | |
| | | // Read until we find the closing quote. |
| | | startPos++; |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos)) != '\'')) |
| | | while (startPos < length && ((c = lowerStr.charAt(startPos)) != '\'')) |
| | | { |
| | | lowerBuffer.append(c); |
| | | userBuffer.append(valueStr.charAt(startPos)); |
| | |
| | | |
| | | // Skip over any trailing spaces after the value. |
| | | startPos++; |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // Skip over any spaces at the beginning of the value. |
| | | char c = '\u0000'; |
| | | int length = lowerStr.length(); |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // This must be a numeric OID. In that case, we will accept only digits |
| | | // and periods, but not consecutive periods. |
| | | boolean lastWasPeriod = false; |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos++)) != ' ')) |
| | | while (startPos < length && ((c = lowerStr.charAt(startPos++)) != ' ')) |
| | | { |
| | | if (c == '.') |
| | | { |
| | | if (lastWasPeriod) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_MRUSE_DOUBLE_PERIOD_IN_NUMERIC_OID. |
| | | get(lowerStr, (startPos-1)); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | ERR_ATTR_SYNTAX_MRUSE_DOUBLE_PERIOD_IN_NUMERIC_OID.get(lowerStr, startPos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | else |
| | | { |
| | | woidBuffer.append(c); |
| | | lastWasPeriod = true; |
| | | } |
| | | woidBuffer.append(c); |
| | | lastWasPeriod = true; |
| | | } |
| | | else if (! isDigit(c)) |
| | | { |
| | |
| | | // additional characters. |
| | | if (c == ')') |
| | | { |
| | | return (startPos-1); |
| | | return startPos-1; |
| | | } |
| | | |
| | | // This must have been an illegal character. |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_MRUSE_ILLEGAL_CHAR_IN_NUMERIC_OID. |
| | | get(lowerStr, c, (startPos-1)); |
| | | get(lowerStr, c, startPos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | else |
| | |
| | | { |
| | | // This must be an attribute type description. In this case, we will only |
| | | // accept alphabetic characters, numeric digits, and the hyphen. |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos++)) != ' ')) |
| | | while (startPos < length && ((c = lowerStr.charAt(startPos++)) != ' ')) |
| | | { |
| | | if (isAlpha(c) || isDigit(c) || (c == '-') || |
| | | ((c == '_') && DirectoryServer.allowAttributeNameExceptions())) |
| | | if (isAlpha(c) || isDigit(c) || c == '-' || |
| | | (c == '_' && DirectoryServer.allowAttributeNameExceptions())) |
| | | { |
| | | woidBuffer.append(c); |
| | | } |
| | |
| | | // additional characters. |
| | | if (c == ')') |
| | | { |
| | | return (startPos-1); |
| | | return startPos-1; |
| | | } |
| | | |
| | | // This must have been an illegal character. |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_MRUSE_ILLEGAL_CHAR_IN_STRING_OID. |
| | | get(lowerStr, c, (startPos-1)); |
| | | get(lowerStr, c, startPos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | // Skip over any trailing spaces after the value. |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // Skip over any leading spaces. |
| | | int length = valueStr.length(); |
| | | char c = '\u0000'; |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // Parse until the closing quote. |
| | | StringBuilder valueBuffer = new StringBuilder(); |
| | | startPos++; |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) != '\'')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) != '\'')) |
| | | { |
| | | valueBuffer.append(c); |
| | | startPos++; |
| | |
| | | while (true) |
| | | { |
| | | // Skip over any leading spaces; |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // We have a quoted string |
| | | StringBuilder valueBuffer = new StringBuilder(); |
| | | startPos++; |
| | | while ((startPos < length) && |
| | | ((c = valueStr.charAt(startPos)) != '\'')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) != '\'')) |
| | | { |
| | | valueBuffer.append(c); |
| | | startPos++; |
| | |
| | | { |
| | | //Consider unquoted string |
| | | StringBuilder valueBuffer = new StringBuilder(); |
| | | while ((startPos < length) && |
| | | ((c = valueStr.charAt(startPos)) != ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) != ' ')) |
| | | { |
| | | valueBuffer.append(c); |
| | | startPos++; |
| | |
| | | { |
| | | // Parse until the next space. |
| | | StringBuilder valueBuffer = new StringBuilder(); |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) != ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) != ' ')) |
| | | { |
| | | valueBuffer.append(c); |
| | | startPos++; |
| | |
| | | } |
| | | |
| | | // Skip over any trailing spaces. |
| | | while ((startPos < length) && (valueStr.charAt(startPos) == ' ')) |
| | | while (startPos < length && valueStr.charAt(startPos) == ' ') |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | String lowerStr = toLowerCase(valueStr); |
| | | |
| | | |
| | | // We'll do this a character at a time. First, skip over any leading |
| | | // whitespace. |
| | | // We'll do this a character at a time. First, skip over any leading whitespace. |
| | | int pos = 0; |
| | | int length = valueStr.length(); |
| | | while ((pos < length) && (valueStr.charAt(pos) == ' ')) |
| | | while (pos < length && valueStr.charAt(pos) == ' ') |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | // This means that the value was empty or contained only whitespace. That |
| | | // is illegal. |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_NAME_FORM_EMPTY_VALUE.get(); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | |
| | | |
| | |
| | | if (c != '(') |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_NAME_FORM_EXPECTED_OPEN_PARENTHESIS.get( |
| | | valueStr, (pos-1), c); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | valueStr, pos-1, c); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | |
| | | |
| | | // Skip over any spaces immediately following the opening parenthesis. |
| | | while ((pos < length) && ((c = valueStr.charAt(pos)) == ' ')) |
| | | while (pos < length && ((c = valueStr.charAt(pos)) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | // This must be a numeric OID. In that case, we will accept only digits |
| | | // and periods, but not consecutive periods. |
| | | boolean lastWasPeriod = false; |
| | | while ((pos < length) && ((c = valueStr.charAt(pos++)) != ' ')) |
| | | while (pos < length && ((c = valueStr.charAt(pos++)) != ' ')) |
| | | { |
| | | if (c == '.') |
| | | { |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_NAME_FORM_DOUBLE_PERIOD_IN_NUMERIC_OID. |
| | | get(valueStr, (pos-1)); |
| | | get(valueStr, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | |
| | | // This must have been an illegal character. |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_NAME_FORM_ILLEGAL_CHAR_IN_NUMERIC_OID. |
| | | get(valueStr, c, (pos-1)); |
| | | get(valueStr, c, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | |
| | | { |
| | | // This must be a "fake" OID. In this case, we will only accept |
| | | // alphabetic characters, numeric digits, and the hyphen. |
| | | while ((pos < length) && ((c = valueStr.charAt(pos++)) != ' ')) |
| | | while (pos < length && ((c = valueStr.charAt(pos++)) != ' ')) |
| | | { |
| | | if (isAlpha(c) || isDigit(c) || (c == '-') || |
| | | ((c == '_') && DirectoryServer.allowAttributeNameExceptions())) |
| | | if (isAlpha(c) || isDigit(c) || c == '-' || |
| | | (c == '_' && DirectoryServer.allowAttributeNameExceptions())) |
| | | { |
| | | // This is fine. It is an acceptable character. |
| | | } |
| | |
| | | // This must have been an illegal character. |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_NAME_FORM_ILLEGAL_CHAR_IN_STRING_OID. |
| | | get(valueStr, c, (pos-1)); |
| | | get(valueStr, c, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | else |
| | | { |
| | | oid = lowerStr.substring(oidStartPos, (pos-1)); |
| | | } |
| | | oid = lowerStr.substring(oidStartPos, pos-1); |
| | | |
| | | |
| | | // Skip over the space(s) after the OID. |
| | | while ((pos < length) && ((c = valueStr.charAt(pos)) == ' ')) |
| | | while (pos < length && ((c = valueStr.charAt(pos)) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_NAME_FORM_UNEXPECTED_CLOSE_PARENTHESIS. |
| | | get(valueStr, (pos-1)); |
| | | get(valueStr, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | |
| | | { |
| | | StringBuilder userBuffer = new StringBuilder(); |
| | | StringBuilder lowerBuffer = new StringBuilder(); |
| | | pos = readQuotedString(valueStr, lowerStr, userBuffer, lowerBuffer, |
| | | (pos-1)); |
| | | pos = readQuotedString(valueStr, lowerStr, userBuffer, lowerBuffer, pos-1); |
| | | names.put(lowerBuffer.toString(), userBuffer.toString()); |
| | | } |
| | | else if (c == '(') |
| | |
| | | { |
| | | // Skip over any spaces after the parenthesis. |
| | | pos++; |
| | | while ((pos < length) && ((c = valueStr.charAt(pos)) == ' ')) |
| | | while (pos < length && ((c = valueStr.charAt(pos)) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | { |
| | | // This is an illegal character. |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_NAME_FORM_ILLEGAL_CHAR.get(valueStr, c, (pos-1)); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | ERR_ATTR_SYNTAX_NAME_FORM_ILLEGAL_CHAR.get(valueStr, c, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | } |
| | | else if (lowerTokenName.equals("desc")) |
| | |
| | | while (true) |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos)); |
| | | pos = readWOID(lowerStr, woidBuffer, pos); |
| | | attrs.add(getAttributeType(schema, allowUnknownElements, oid, woidBuffer, |
| | | ERR_ATTR_SYNTAX_NAME_FORM_UNKNOWN_REQUIRED_ATTR)); |
| | | |
| | |
| | | else if (c != '$') |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_NAME_FORM_ILLEGAL_CHAR.get( |
| | | valueStr, c, (pos-1)); |
| | | valueStr, c, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | |
| | | else |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos-1)); |
| | | pos = readWOID(lowerStr, woidBuffer, pos-1); |
| | | attrs.add(getAttributeType(schema, allowUnknownElements, oid, woidBuffer, |
| | | ERR_ATTR_SYNTAX_NAME_FORM_UNKNOWN_REQUIRED_ATTR)); |
| | | } |
| | |
| | | while (true) |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos)); |
| | | pos = readWOID(lowerStr, woidBuffer, pos); |
| | | attrs.add(getAttributeType(schema, allowUnknownElements, oid, woidBuffer, |
| | | ERR_ATTR_SYNTAX_NAME_FORM_UNKNOWN_OPTIONAL_ATTR)); |
| | | |
| | |
| | | else if (c != '$') |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_NAME_FORM_ILLEGAL_CHAR.get( |
| | | valueStr, c, (pos-1)); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | valueStr, c, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos-1)); |
| | | pos = readWOID(lowerStr, woidBuffer, pos-1); |
| | | attrs.add(getAttributeType(schema, allowUnknownElements, oid, woidBuffer, |
| | | ERR_ATTR_SYNTAX_NAME_FORM_UNKNOWN_OPTIONAL_ATTR)); |
| | | } |
| | |
| | | // Skip over any spaces at the beginning of the value. |
| | | char c = '\u0000'; |
| | | int length = valueStr.length(); |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | |
| | | |
| | | // Read until we find the next space. |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos++)) != ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos++)) != ' ')) |
| | | { |
| | | tokenName.append(c); |
| | | } |
| | | |
| | | |
| | | // Skip over any trailing spaces after the value. |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // Skip over any spaces at the beginning of the value. |
| | | char c = '\u0000'; |
| | | int length = valueStr.length(); |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | |
| | | // Read until we find the closing quote. |
| | | startPos++; |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) != '\'')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) != '\'')) |
| | | { |
| | | valueBuffer.append(c); |
| | | startPos++; |
| | |
| | | |
| | | // Skip over any trailing spaces after the value. |
| | | startPos++; |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // Skip over any spaces at the beginning of the value. |
| | | char c = '\u0000'; |
| | | int length = lowerStr.length(); |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | |
| | | // Read until we find the closing quote. |
| | | startPos++; |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos)) != '\'')) |
| | | while (startPos < length && ((c = lowerStr.charAt(startPos)) != '\'')) |
| | | { |
| | | lowerBuffer.append(c); |
| | | userBuffer.append(valueStr.charAt(startPos)); |
| | |
| | | |
| | | // Skip over any trailing spaces after the value. |
| | | startPos++; |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // Skip over any spaces at the beginning of the value. |
| | | char c = '\u0000'; |
| | | int length = lowerStr.length(); |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // This must be a numeric OID. In that case, we will accept only digits |
| | | // and periods, but not consecutive periods. |
| | | boolean lastWasPeriod = false; |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos++)) != ' ')) |
| | | while (startPos < length && ((c = lowerStr.charAt(startPos++)) != ' ')) |
| | | { |
| | | if (c == '.') |
| | | { |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_NAME_FORM_DOUBLE_PERIOD_IN_NUMERIC_OID. |
| | | get(lowerStr, (startPos-1)); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | get(lowerStr, startPos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | else |
| | | { |
| | | woidBuffer.append(c); |
| | | lastWasPeriod = true; |
| | | } |
| | | woidBuffer.append(c); |
| | | lastWasPeriod = true; |
| | | } |
| | | else if (! isDigit(c)) |
| | | { |
| | |
| | | // additional characters. |
| | | if (c == ')') |
| | | { |
| | | return (startPos-1); |
| | | return startPos-1; |
| | | } |
| | | |
| | | // This must have been an illegal character. |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_NAME_FORM_ILLEGAL_CHAR_IN_NUMERIC_OID. |
| | | get(lowerStr, c, (startPos-1)); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | get(lowerStr, c, startPos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | else |
| | | { |
| | |
| | | { |
| | | // This must be an attribute type description. In this case, we will only |
| | | // accept alphabetic characters, numeric digits, and the hyphen. |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos++)) != ' ')) |
| | | while (startPos < length && ((c = lowerStr.charAt(startPos++)) != ' ')) |
| | | { |
| | | if (isAlpha(c) || isDigit(c) || (c == '-') || |
| | | ((c == '_') && DirectoryServer.allowAttributeNameExceptions())) |
| | | if (isAlpha(c) || isDigit(c) || c == '-' || |
| | | (c == '_' && DirectoryServer.allowAttributeNameExceptions())) |
| | | { |
| | | woidBuffer.append(c); |
| | | } |
| | |
| | | // additional characters. |
| | | if (c == ')') |
| | | { |
| | | return (startPos-1); |
| | | return startPos-1; |
| | | } |
| | | |
| | | // This must have been an illegal character. |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_NAME_FORM_ILLEGAL_CHAR_IN_STRING_OID. |
| | | get(lowerStr, c, (startPos-1)); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | get(lowerStr, c, startPos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | // Skip over any trailing spaces after the value. |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // Skip over any leading spaces. |
| | | int length = valueStr.length(); |
| | | char c = '\u0000'; |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // Parse until the closing quote. |
| | | StringBuilder valueBuffer = new StringBuilder(); |
| | | startPos++; |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) != '\'')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) != '\'')) |
| | | { |
| | | valueBuffer.append(c); |
| | | startPos++; |
| | |
| | | while (true) |
| | | { |
| | | // Skip over any leading spaces; |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // We have a quoted string |
| | | StringBuilder valueBuffer = new StringBuilder(); |
| | | startPos++; |
| | | while ((startPos < length) && |
| | | ((c = valueStr.charAt(startPos)) != '\'')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) != '\'')) |
| | | { |
| | | valueBuffer.append(c); |
| | | startPos++; |
| | |
| | | { |
| | | //Consider unquoted string |
| | | StringBuilder valueBuffer = new StringBuilder(); |
| | | while ((startPos < length) && |
| | | ((c = valueStr.charAt(startPos)) != ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) != ' ')) |
| | | { |
| | | valueBuffer.append(c); |
| | | startPos++; |
| | |
| | | { |
| | | // Parse until the next space. |
| | | StringBuilder valueBuffer = new StringBuilder(); |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) != ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) != ' ')) |
| | | { |
| | | valueBuffer.append(c); |
| | | startPos++; |
| | |
| | | } |
| | | |
| | | // Skip over any trailing spaces. |
| | | while ((startPos < length) && (valueStr.charAt(startPos) == ' ')) |
| | | while (startPos < length && valueStr.charAt(startPos) == ' ') |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // whitespace. |
| | | int pos = 0; |
| | | int length = valueStr.length(); |
| | | while ((pos < length) && (valueStr.charAt(pos) == ' ')) |
| | | while (pos < length && valueStr.charAt(pos) == ' ') |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | if (c != '(') |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_OBJECTCLASS_EXPECTED_OPEN_PARENTHESIS. |
| | | get(valueStr, (pos-1), c); |
| | | get(valueStr, pos-1, c); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | |
| | | |
| | | // Skip over any spaces immediately following the opening parenthesis. |
| | | while ((pos < length) && ((c = valueStr.charAt(pos)) == ' ')) |
| | | while (pos < length && ((c = valueStr.charAt(pos)) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | // This must be a numeric OID. In that case, we will accept only digits |
| | | // and periods, but not consecutive periods. |
| | | boolean lastWasPeriod = false; |
| | | while ((pos < length) && ((c = valueStr.charAt(pos++)) != ' ')) |
| | | while (pos < length && ((c = valueStr.charAt(pos++)) != ' ')) |
| | | { |
| | | if (c == '.') |
| | | { |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_OBJECTCLASS_DOUBLE_PERIOD_IN_NUMERIC_OID. |
| | | get(valueStr, (pos-1)); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | get(valueStr, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | else |
| | | { |
| | | lastWasPeriod = true; |
| | | } |
| | | lastWasPeriod = true; |
| | | } |
| | | else if (! isDigit(c)) |
| | | { |
| | | // This must have been an illegal character. |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_OBJECTCLASS_ILLEGAL_CHAR_IN_NUMERIC_OID. |
| | | get(valueStr, c, (pos-1)); |
| | | get(valueStr, c, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | else |
| | |
| | | { |
| | | // This must be a "fake" OID. In this case, we will only accept |
| | | // alphabetic characters, numeric digits, and the hyphen. |
| | | while ((pos < length) && ((c = valueStr.charAt(pos++)) != ' ')) |
| | | while (pos < length && ((c = valueStr.charAt(pos++)) != ' ')) |
| | | { |
| | | if (isAlpha(c) || isDigit(c) || (c == '-') || |
| | | ((c == '_') && allowExceptions)) |
| | | if (isAlpha(c) || isDigit(c) || c == '-' || |
| | | (c == '_' && allowExceptions)) |
| | | { |
| | | // This is fine. It is an acceptable character. |
| | | } |
| | |
| | | // This must have been an illegal character. |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_OBJECTCLASS_ILLEGAL_CHAR_IN_STRING_OID. |
| | | get(valueStr, c, (pos-1)); |
| | | get(valueStr, c, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | |
| | | |
| | | // If we're at the end of the value, then it isn't a valid objectclass |
| | | // description. Otherwise, parse out the OID. |
| | | String oid; |
| | | if (pos >= length) |
| | | { |
| | | LocalizableMessage message = |
| | |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | else |
| | | { |
| | | oid = lowerStr.substring(oidStartPos, (pos-1)); |
| | | } |
| | | |
| | | String oid = lowerStr.substring(oidStartPos, pos-1); |
| | | |
| | | // Skip over the space(s) after the OID. |
| | | while ((pos < length) && ((c = valueStr.charAt(pos)) == ' ')) |
| | | while (pos < length && ((c = valueStr.charAt(pos)) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_OBJECTCLASS_UNEXPECTED_CLOSE_PARENTHESIS. |
| | | get(valueStr, (pos-1)); |
| | | get(valueStr, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | |
| | | { |
| | | StringBuilder userBuffer = new StringBuilder(); |
| | | StringBuilder lowerBuffer = new StringBuilder(); |
| | | pos = readQuotedString(valueStr, lowerStr, userBuffer, lowerBuffer, |
| | | (pos-1)); |
| | | pos = readQuotedString(valueStr, lowerStr, userBuffer, lowerBuffer, pos-1); |
| | | primaryName = userBuffer.toString(); |
| | | names.add(primaryName); |
| | | } |
| | |
| | | { |
| | | // Skip over any spaces after the parenthesis. |
| | | pos++; |
| | | while ((pos < length) && ((c = valueStr.charAt(pos)) == ' ')) |
| | | while (pos < length && ((c = valueStr.charAt(pos)) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | else |
| | | { |
| | | // This is an illegal character. |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_OBJECTCLASS_ILLEGAL_CHAR.get(valueStr, c, (pos-1)); |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_OBJECTCLASS_ILLEGAL_CHAR.get(valueStr, c, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | |
| | | } |
| | | else if (c != '$') |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_OBJECTCLASS_ILLEGAL_CHAR.get(valueStr, c, (pos-1)); |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_OBJECTCLASS_ILLEGAL_CHAR.get(valueStr, c, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | |
| | | else |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos-1)); |
| | | pos = readWOID(lowerStr, woidBuffer, pos-1); |
| | | ObjectClass superiorClass = |
| | | schema.getObjectClass(woidBuffer.toString()); |
| | | if (superiorClass == null) |
| | |
| | | while (true) |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos)); |
| | | pos = readWOID(lowerStr, woidBuffer, pos); |
| | | attrs.add(getAttributeType(schema, allowUnknownElements, oid, woidBuffer, |
| | | WARN_ATTR_SYNTAX_OBJECTCLASS_UNKNOWN_REQUIRED_ATTR)); |
| | | |
| | |
| | | } |
| | | else if (c != '$') |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_OBJECTCLASS_ILLEGAL_CHAR.get(valueStr, c, (pos-1)); |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_OBJECTCLASS_ILLEGAL_CHAR.get(valueStr, c, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | |
| | | else |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos-1)); |
| | | pos = readWOID(lowerStr, woidBuffer, pos-1); |
| | | attrs.add(getAttributeType(schema, allowUnknownElements, oid, woidBuffer, |
| | | WARN_ATTR_SYNTAX_OBJECTCLASS_UNKNOWN_REQUIRED_ATTR)); |
| | | } |
| | |
| | | while (true) |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos)); |
| | | pos = readWOID(lowerStr, woidBuffer, pos); |
| | | attrs.add(getAttributeType(schema, allowUnknownElements, oid, woidBuffer, |
| | | WARN_ATTR_SYNTAX_OBJECTCLASS_UNKNOWN_OPTIONAL_ATTR)); |
| | | |
| | |
| | | } |
| | | else if (c != '$') |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_OBJECTCLASS_ILLEGAL_CHAR.get(valueStr, c, (pos-1)); |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_OBJECTCLASS_ILLEGAL_CHAR.get(valueStr, c, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | |
| | | else |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos-1)); |
| | | pos = readWOID(lowerStr, woidBuffer, pos-1); |
| | | attrs.add(getAttributeType(schema, allowUnknownElements, oid, woidBuffer, |
| | | WARN_ATTR_SYNTAX_OBJECTCLASS_UNKNOWN_OPTIONAL_ATTR)); |
| | | } |
| | |
| | | case AUXILIARY: |
| | | // Auxiliary classes may only inherit from abstract classes or other |
| | | // auxiliary classes. |
| | | if ((superiorType != ObjectClassType.ABSTRACT) && |
| | | (superiorType != ObjectClassType.AUXILIARY)) |
| | | if (superiorType != ObjectClassType.ABSTRACT && |
| | | superiorType != ObjectClassType.AUXILIARY) |
| | | { |
| | | LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_OBJECTCLASS_INVALID_SUPERIOR_TYPE. |
| | |
| | | case STRUCTURAL: |
| | | // Structural classes may only inherit from abstract classes or |
| | | // other structural classes. |
| | | if ((superiorType != ObjectClassType.ABSTRACT) && |
| | | (superiorType != ObjectClassType.STRUCTURAL)) |
| | | if (superiorType != ObjectClassType.ABSTRACT && |
| | | superiorType != ObjectClassType.STRUCTURAL) |
| | | { |
| | | LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_OBJECTCLASS_INVALID_SUPERIOR_TYPE. |
| | |
| | | // Skip over any spaces at the beginning of the value. |
| | | char c = '\u0000'; |
| | | int length = valueStr.length(); |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | |
| | | |
| | | // Read until we find the next space. |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos++)) != ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos++)) != ' ')) |
| | | { |
| | | tokenName.append(c); |
| | | } |
| | | |
| | | |
| | | // Skip over any trailing spaces after the value. |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // Skip over any spaces at the beginning of the value. |
| | | char c = '\u0000'; |
| | | int length = valueStr.length(); |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | |
| | | // Read until we find the closing quote. |
| | | startPos++; |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) != '\'')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) != '\'')) |
| | | { |
| | | valueBuffer.append(c); |
| | | startPos++; |
| | |
| | | |
| | | // Skip over any trailing spaces after the value. |
| | | startPos++; |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // Skip over any spaces at the beginning of the value. |
| | | char c = '\u0000'; |
| | | int length = lowerStr.length(); |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | |
| | | // Read until we find the closing quote. |
| | | startPos++; |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos)) != '\'')) |
| | | while (startPos < length && ((c = lowerStr.charAt(startPos)) != '\'')) |
| | | { |
| | | lowerBuffer.append(c); |
| | | userBuffer.append(valueStr.charAt(startPos)); |
| | |
| | | |
| | | // Skip over any trailing spaces after the value. |
| | | startPos++; |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | int length = lowerStr.length(); |
| | | boolean allowExceptions = DirectoryServer.isRunning()? |
| | | DirectoryServer.allowAttributeNameExceptions():true; |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // This must be a numeric OID. In that case, we will accept only digits |
| | | // and periods, but not consecutive periods. |
| | | boolean lastWasPeriod = false; |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos++)) != ' ')) |
| | | while (startPos < length && ((c = lowerStr.charAt(startPos++)) != ' ')) |
| | | { |
| | | if (c == '.') |
| | | { |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_OBJECTCLASS_DOUBLE_PERIOD_IN_NUMERIC_OID. |
| | | get(lowerStr, (startPos-1)); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | get(lowerStr, startPos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | else |
| | | { |
| | | woidBuffer.append(c); |
| | | lastWasPeriod = true; |
| | | } |
| | | woidBuffer.append(c); |
| | | lastWasPeriod = true; |
| | | } |
| | | else if ((!isDigit(c) && (!allowExceptions || (!isAlpha(c) && (c != '-') && (c != '_'))))) |
| | | else if (!isDigit(c) && (!allowExceptions || (!isAlpha(c) && c != '-' && c != '_'))) |
| | | { |
| | | // Technically, this must be an illegal character. However, it is |
| | | // possible that someone just got sloppy and did not include a space |
| | |
| | | // additional characters. |
| | | if (c == ')') |
| | | { |
| | | return (startPos-1); |
| | | return startPos-1; |
| | | } |
| | | |
| | | // This must have been an illegal character. |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_OBJECTCLASS_ILLEGAL_CHAR_IN_NUMERIC_OID. |
| | | get(lowerStr, c, (startPos-1)); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | get(lowerStr, c, startPos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | else |
| | | { |
| | |
| | | { |
| | | // This must be an objectclass description. In this case, we will only |
| | | // accept alphabetic characters, numeric digits, and the hyphen. |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos++)) != ' ')) |
| | | while (startPos < length && ((c = lowerStr.charAt(startPos++)) != ' ')) |
| | | { |
| | | if (isAlpha(c) || isDigit(c) || (c == '-') || |
| | | ((c == '_') && allowExceptions)) |
| | | if (isAlpha(c) || isDigit(c) || c == '-' || |
| | | (c == '_' && allowExceptions)) |
| | | { |
| | | woidBuffer.append(c); |
| | | } |
| | |
| | | // additional characters. |
| | | if (c == ')') |
| | | { |
| | | return (startPos-1); |
| | | return startPos-1; |
| | | } |
| | | |
| | | // This must have been an illegal character. |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_OBJECTCLASS_ILLEGAL_CHAR_IN_STRING_OID. |
| | | get(lowerStr, c, (startPos-1)); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | get(lowerStr, c, startPos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | // Skip over any trailing spaces after the value. |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | // Skip over any leading spaces. |
| | | int length = valueStr.length(); |
| | | char c = valueStr.charAt(startPos++); |
| | | while ((startPos < length) && (c == ' ')) |
| | | while (startPos < length && c == ' ') |
| | | { |
| | | c = valueStr.charAt(startPos++); |
| | | } |
| | |
| | | { |
| | | // Parse until the closing quote. |
| | | StringBuilder valueBuffer = new StringBuilder(); |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos++)) != '\'')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos++)) != '\'')) |
| | | { |
| | | valueBuffer.append(c); |
| | | } |
| | |
| | | while (true) |
| | | { |
| | | // Skip over any leading spaces; |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | { |
| | | // Parse until the next space. |
| | | StringBuilder valueBuffer = new StringBuilder(); |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos++)) != ' ')) |
| | | while (startPos < length && ((c = valueStr.charAt(startPos++)) != ' ')) |
| | | { |
| | | valueBuffer.append(c); |
| | | } |
| | |
| | | } |
| | | |
| | | // Skip over any trailing spaces. |
| | | while ((startPos < length) && (valueStr.charAt(startPos) == ' ')) |
| | | while (startPos < length && valueStr.charAt(startPos) == ' ') |
| | | { |
| | | startPos++; |
| | | } |
| | |
| | | throws DirectoryException |
| | | { |
| | | // Make sure that there actually is a value to decode. |
| | | if ((userPasswordValue == null) || (userPasswordValue.length() == 0)) |
| | | if (userPasswordValue == null || userPasswordValue.length() == 0) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_USERPW_NO_VALUE.get(); |
| | | throw new DirectoryException( |
| | |
| | | Entry taskEntry = getTaskEntry(); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_TASK_ADDSCHEMAFILE_FILENAME); |
| | | List<Attribute> attrList = taskEntry.getAttribute(attrType); |
| | | if ((attrList == null) || attrList.isEmpty()) |
| | | if (attrList == null || attrList.isEmpty()) |
| | | { |
| | | LocalizableMessage message = ERR_TASK_ADDSCHEMAFILE_NO_FILENAME.get( |
| | | ATTR_TASK_ADDSCHEMAFILE_FILENAME, taskEntry.getName()); |
| | |
| | | |
| | | // If the signHash option was provided, then make sure that the hash option |
| | | // was given. |
| | | if (signHash && (! hash)) |
| | | if (signHash && !hash) |
| | | { |
| | | logger.error(ERR_BACKUPDB_SIGN_REQUIRES_HASH, ATTR_TASK_BACKUP_SIGN_HASH, ATTR_TASK_BACKUP_HASH); |
| | | return false; |
| | |
| | | else |
| | | { |
| | | // See if there are multiple backends to archive. |
| | | multiple = (backendsToArchive.size() > 1); |
| | | multiple = backendsToArchive.size() > 1; |
| | | } |
| | | |
| | | |
| | |
| | | if (operation != null) |
| | | { |
| | | DN authzDN = operation.getAuthorizationDN(); |
| | | if ((authzDN == null) || (! operation.getClientConnection().hasPrivilege( |
| | | Privilege.SERVER_LOCKDOWN, operation))) |
| | | if (authzDN == null || !operation.getClientConnection().hasPrivilege( |
| | | Privilege.SERVER_LOCKDOWN, operation)) |
| | | { |
| | | LocalizableMessage message = ERR_TASK_ENTERLOCKDOWN_NOT_ROOT.get(); |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message); |
| | | } |
| | | |
| | | InetAddress clientAddress = |
| | | operation.getClientConnection().getRemoteAddress(); |
| | | if ((clientAddress != null) && (! clientAddress.isLoopbackAddress())) |
| | | InetAddress clientAddress = operation.getClientConnection().getRemoteAddress(); |
| | | if (clientAddress != null && !clientAddress.isLoopbackAddress()) |
| | | { |
| | | LocalizableMessage message = ERR_TASK_ENTERLOCKDOWN_NOT_LOOPBACK.get(); |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message); |
| | |
| | | if (operation != null) |
| | | { |
| | | DN authzDN = operation.getAuthorizationDN(); |
| | | if ((authzDN == null) || (! operation.getClientConnection().hasPrivilege( |
| | | Privilege.SERVER_LOCKDOWN, operation))) |
| | | if (authzDN == null || !operation.getClientConnection().hasPrivilege( |
| | | Privilege.SERVER_LOCKDOWN, operation)) |
| | | { |
| | | LocalizableMessage message = ERR_TASK_LEAVELOCKDOWN_NOT_ROOT.get(); |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message); |
| | | } |
| | | |
| | | InetAddress clientAddress = |
| | | operation.getClientConnection().getRemoteAddress(); |
| | | if ((clientAddress != null) && (! clientAddress.isLoopbackAddress())) |
| | | InetAddress clientAddress = operation.getClientConnection().getRemoteAddress(); |
| | | if (clientAddress != null && !clientAddress.isLoopbackAddress()) |
| | | { |
| | | LocalizableMessage message = ERR_TASK_LEAVELOCKDOWN_NOT_LOOPBACK.get(); |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message); |
| | |
| | | return TaskState.COMPLETED_SUCCESSFULLY; |
| | | } |
| | | } |
| | | |
| | |
| | | finally |
| | | { |
| | | // Release the exclusive lock on the backend. |
| | | if ( (!verifyOnly) && !unlockBackend(backend)) |
| | | if (!verifyOnly && !unlockBackend(backend)) |
| | | { |
| | | errorsEncountered = true; |
| | | } |
| | |
| | | if (!attr.isEmpty()) |
| | | { |
| | | String valueString = toLowerCase(attr.iterator().next().toString()); |
| | | restart = (valueString.equals("true") || valueString.equals("yes") |
| | | || valueString.equals("on") || valueString.equals("1")); |
| | | restart = valueString.equals("true") || valueString.equals("yes") |
| | | || valueString.equals("on") || valueString.equals("1"); |
| | | } |
| | | } |
| | | |
| | |
| | | public static boolean getBoolean(List<Attribute> attrList, |
| | | boolean defaultValue) |
| | | { |
| | | if ((attrList == null) || attrList.isEmpty()) |
| | | if (attrList == null || attrList.isEmpty()) |
| | | { |
| | | return defaultValue; |
| | | } |
| | |
| | | |
| | | // If the signHash option was provided, then make sure that the hash option |
| | | // was given. |
| | | if (signHash.isPresent() && (! hash.isPresent())) |
| | | if (signHash.isPresent() && !hash.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_BACKUPDB_SIGN_REQUIRES_HASH.get( |
| | | signHash.getLongIdentifier(), |
| | |
| | | |
| | | |
| | | // See if there are multiple backends to archive. |
| | | multiple = (backendsToArchive.size() > 1); |
| | | multiple = backendsToArchive.size() > 1; |
| | | } |
| | | |
| | | |
| | |
| | | exportConfig.setIncludeFilters(includeFilters); |
| | | exportConfig.setSignHash(signHash.isPresent()); |
| | | exportConfig.setIncludeOperationalAttributes( |
| | | (! excludeOperationalAttrs.isPresent())); |
| | | !excludeOperationalAttrs.isPresent()); |
| | | |
| | | // FIXME -- Should this be conditional? |
| | | exportConfig.setInvokeExportPlugins(true); |
| | |
| | | else if (key != null) |
| | | { |
| | | int index = line.indexOf('='); |
| | | if ((index != -1) && ((index + 1) < line.length())) |
| | | if (index != -1 && index + 1 < line.length()) |
| | | { |
| | | lineValue = line.substring(index+1); |
| | | } |
| | | } |
| | | if ((lineValue != null) && (lineValue.length() > 0)) |
| | | if (lineValue != null && lineValue.length() > 0) |
| | | { |
| | | if (sbValue == null) |
| | | { |
| | |
| | | } |
| | | sbValue.append(lineValue); |
| | | } |
| | | if (!hasSlash && (key != null) && (sbValue != null)) |
| | | if (!hasSlash && key != null && sbValue != null) |
| | | { |
| | | properties.put(key, sbValue.toString()); |
| | | } |
| | |
| | | // See if there are any controls in the response. If so, then add them to |
| | | // the response controls list. |
| | | List<Control> respControls = responseMessage.getControls(); |
| | | if ((respControls != null) && (! respControls.isEmpty())) |
| | | if (respControls != null && !respControls.isEmpty()) |
| | | { |
| | | responseControls.addAll(respControls); |
| | | } |
| | |
| | | // Look at the protocol op from the response. If it's a bind response, then |
| | | // continue. If it's an extended response, then it could be a notice of |
| | | // disconnection so check for that. Otherwise, generate an error. |
| | | switch (responseMessage.getProtocolOpType()) |
| | | { |
| | | case OP_TYPE_BIND_RESPONSE: |
| | | // We'll deal with this later. |
| | | break; |
| | | |
| | | case OP_TYPE_EXTENDED_RESPONSE: |
| | | ExtendedResponseProtocolOp extendedResponse = |
| | | responseMessage.getExtendedResponseProtocolOp(); |
| | | String responseOID = extendedResponse.getOID(); |
| | | if ((responseOID != null) && |
| | | responseOID.equals(OID_NOTICE_OF_DISCONNECTION)) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_SERVER_DISCONNECT. |
| | | get(extendedResponse.getResultCode(), |
| | | extendedResponse.getErrorMessage()); |
| | | throw new LDAPException(extendedResponse.getResultCode(), message); |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get(extendedResponse); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | default: |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get(responseMessage.getProtocolOp()); |
| | | throw new ClientException( ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | generateError(responseMessage); |
| | | |
| | | |
| | | BindResponseProtocolOp bindResponse = |
| | |
| | | bindDN = ByteString.empty(); |
| | | } |
| | | |
| | | if ((mechanism == null) || (mechanism.length() == 0)) |
| | | if (mechanism == null || mechanism.length() == 0) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_NO_SASL_MECHANISM.get(); |
| | | throw new ClientException( |
| | |
| | | |
| | | // Evaluate the properties provided. The only one we'll allow is the trace |
| | | // property, but it is not required. |
| | | if ((saslProperties == null) || saslProperties.isEmpty()) |
| | | if (saslProperties == null || saslProperties.isEmpty()) |
| | | { |
| | | // This is fine because there are no required properties for this |
| | | // mechanism. |
| | | // This is fine because there are no required properties for this mechanism. |
| | | } |
| | | else |
| | | { |
| | | Iterator<String> propertyNames = saslProperties.keySet().iterator(); |
| | | while (propertyNames.hasNext()) |
| | | for (String name : saslProperties.keySet()) |
| | | { |
| | | String name = propertyNames.next(); |
| | | if (name.equalsIgnoreCase(SASL_PROPERTY_TRACE)) |
| | | { |
| | | // This is acceptable, and we'll take any single value. |
| | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_TRACE_SINGLE_VALUED.get(); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | } |
| | | } |
| | |
| | | // See if there are any controls in the response. If so, then add them to |
| | | // the response controls list. |
| | | List<Control> respControls = responseMessage.getControls(); |
| | | if ((respControls != null) && (! respControls.isEmpty())) |
| | | if (respControls != null && ! respControls.isEmpty()) |
| | | { |
| | | responseControls.addAll(respControls); |
| | | } |
| | |
| | | // Look at the protocol op from the response. If it's a bind response, then |
| | | // continue. If it's an extended response, then it could be a notice of |
| | | // disconnection so check for that. Otherwise, generate an error. |
| | | switch (responseMessage.getProtocolOpType()) |
| | | { |
| | | case OP_TYPE_BIND_RESPONSE: |
| | | // We'll deal with this later. |
| | | break; |
| | | |
| | | case OP_TYPE_EXTENDED_RESPONSE: |
| | | ExtendedResponseProtocolOp extendedResponse = |
| | | responseMessage.getExtendedResponseProtocolOp(); |
| | | String responseOID = extendedResponse.getOID(); |
| | | if ((responseOID != null) && |
| | | responseOID.equals(OID_NOTICE_OF_DISCONNECTION)) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_SERVER_DISCONNECT. |
| | | get(extendedResponse.getResultCode(), |
| | | extendedResponse.getErrorMessage()); |
| | | throw new LDAPException(extendedResponse.getResultCode(), message); |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get(extendedResponse); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | default: |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get(responseMessage.getProtocolOp()); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | generateError(responseMessage); |
| | | |
| | | |
| | | BindResponseProtocolOp bindResponse = |
| | |
| | | |
| | | // Evaluate the properties provided. The authID is required, no other |
| | | // properties are allowed. |
| | | if ((saslProperties == null) || saslProperties.isEmpty()) |
| | | if (saslProperties == null || saslProperties.isEmpty()) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_NO_SASL_PROPERTIES.get(SASL_MECHANISM_CRAM_MD5); |
| | |
| | | ReturnCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | |
| | | Iterator<String> propertyNames = saslProperties.keySet().iterator(); |
| | | while (propertyNames.hasNext()) |
| | | for (String name : saslProperties.keySet()) |
| | | { |
| | | String name = propertyNames.next(); |
| | | String lowerName = toLowerCase(name); |
| | | |
| | | if (lowerName.equals(SASL_PROPERTY_AUTHID)) |
| | | { |
| | | List<String> values = saslProperties.get(name); |
| | | Iterator<String> iterator = values.iterator(); |
| | | if (iterator.hasNext()) |
| | | { |
| | | authID = iterator.next(); |
| | | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_AUTHID_SINGLE_VALUED.get(); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | | authID = getAuthID(saslProperties, authID, name); |
| | | } |
| | | else |
| | | { |
| | |
| | | |
| | | |
| | | // Make sure that the authID was provided. |
| | | if ((authID == null) || (authID.length() == 0)) |
| | | if (authID == null || authID.length() == 0) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_SASL_AUTHID_REQUIRED.get(SASL_MECHANISM_CRAM_MD5); |
| | |
| | | ExtendedResponseProtocolOp extendedResponse = |
| | | responseMessage1.getExtendedResponseProtocolOp(); |
| | | String responseOID = extendedResponse.getOID(); |
| | | if ((responseOID != null) && |
| | | if (responseOID != null && |
| | | responseOID.equals(OID_NOTICE_OF_DISCONNECTION)) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_SERVER_DISCONNECT. |
| | |
| | | // See if there are any controls in the response. If so, then add them to |
| | | // the response controls list. |
| | | List<Control> respControls = responseMessage2.getControls(); |
| | | if ((respControls != null) && (! respControls.isEmpty())) |
| | | if (respControls != null && ! respControls.isEmpty()) |
| | | { |
| | | responseControls.addAll(respControls); |
| | | } |
| | |
| | | ExtendedResponseProtocolOp extendedResponse = |
| | | responseMessage2.getExtendedResponseProtocolOp(); |
| | | String responseOID = extendedResponse.getOID(); |
| | | if ((responseOID != null) && |
| | | if (responseOID != null && |
| | | responseOID.equals(OID_NOTICE_OF_DISCONNECTION)) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_SERVER_DISCONNECT. |
| | |
| | | |
| | | |
| | | /** |
| | | * @param saslProperties |
| | | * @param authID |
| | | * @param name |
| | | * @return |
| | | * @throws ClientException |
| | | */ |
| | | private String getAuthID(Map<String, List<String>> saslProperties, String authID, String name) throws ClientException |
| | | { |
| | | List<String> values = saslProperties.get(name); |
| | | Iterator<String> iterator = values.iterator(); |
| | | if (iterator.hasNext()) |
| | | { |
| | | authID = iterator.next(); |
| | | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_AUTHID_SINGLE_VALUED.get(); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | } |
| | | return authID; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Generates the appropriate HMAC-MD5 digest for a CRAM-MD5 authentication |
| | | * with the given information. |
| | | * |
| | |
| | | |
| | | // Evaluate the properties provided. The authID is required. The realm, |
| | | // QoP, digest URI, and authzID are optional. |
| | | if ((saslProperties == null) || saslProperties.isEmpty()) |
| | | if (saslProperties == null || saslProperties.isEmpty()) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_NO_SASL_PROPERTIES.get(SASL_MECHANISM_DIGEST_MD5); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | |
| | | Iterator<String> propertyNames = saslProperties.keySet().iterator(); |
| | | while (propertyNames.hasNext()) |
| | | for (String name : saslProperties.keySet()) |
| | | { |
| | | String name = propertyNames.next(); |
| | | String lowerName = toLowerCase(name); |
| | | |
| | | if (lowerName.equals(SASL_PROPERTY_AUTHID)) |
| | | { |
| | | List<String> values = saslProperties.get(name); |
| | | Iterator<String> iterator = values.iterator(); |
| | | if (iterator.hasNext()) |
| | | { |
| | | authID = iterator.next(); |
| | | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_AUTHID_SINGLE_VALUED.get(); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | | authID = getAuthID(saslProperties, authID, name); |
| | | } |
| | | else if (lowerName.equals(SASL_PROPERTY_REALM)) |
| | | { |
| | |
| | | |
| | | |
| | | // Make sure that the authID was provided. |
| | | if ((authID == null) || (authID.length() == 0)) |
| | | if (authID == null || authID.length() == 0) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_SASL_AUTHID_REQUIRED.get(SASL_MECHANISM_DIGEST_MD5); |
| | |
| | | ExtendedResponseProtocolOp extendedResponse = |
| | | responseMessage1.getExtendedResponseProtocolOp(); |
| | | String responseOID = extendedResponse.getOID(); |
| | | if ((responseOID != null) && |
| | | if (responseOID != null && |
| | | responseOID.equals(OID_NOTICE_OF_DISCONNECTION)) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_SERVER_DISCONNECT. |
| | |
| | | // Generate the response digest, and initialize the necessary remaining |
| | | // variables to use in the generation of that digest. |
| | | String nonceCount = "00000001"; |
| | | String charset = (useUTF8 ? "UTF-8" : "ISO-8859-1"); |
| | | String charset = useUTF8 ? "UTF-8" : "ISO-8859-1"; |
| | | String responseDigest; |
| | | try |
| | | { |
| | |
| | | // See if there are any controls in the response. If so, then add them to |
| | | // the response controls list. |
| | | List<Control> respControls = responseMessage2.getControls(); |
| | | if ((respControls != null) && (! respControls.isEmpty())) |
| | | if (respControls != null && ! respControls.isEmpty()) |
| | | { |
| | | responseControls.addAll(respControls); |
| | | } |
| | |
| | | ExtendedResponseProtocolOp extendedResponse = |
| | | responseMessage2.getExtendedResponseProtocolOp(); |
| | | String responseOID = extendedResponse.getOID(); |
| | | if ((responseOID != null) && |
| | | if (responseOID != null && |
| | | responseOID.equals(OID_NOTICE_OF_DISCONNECTION)) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_SERVER_DISCONNECT. |
| | |
| | | // We found the closing quote before the end of the token. This |
| | | // is not fine. |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_DIGESTMD5_INVALID_CLOSING_QUOTE_POS.get((pos-2)); |
| | | ERR_LDAPAUTH_DIGESTMD5_INVALID_CLOSING_QUOTE_POS.get(pos-2); |
| | | throw new LDAPException(ReturnCode.INVALID_CREDENTIALS.get(), |
| | | message); |
| | | } |
| | |
| | | throws ClientException, LDAPException |
| | | { |
| | | // Make sure that no SASL properties were provided. |
| | | if ((saslProperties != null) && (! saslProperties.isEmpty())) |
| | | if (saslProperties != null && ! saslProperties.isEmpty()) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_NO_ALLOWED_SASL_PROPERTIES.get(SASL_MECHANISM_EXTERNAL); |
| | |
| | | // See if there are any controls in the response. If so, then add them to |
| | | // the response controls list. |
| | | List<Control> respControls = responseMessage.getControls(); |
| | | if ((respControls != null) && (! respControls.isEmpty())) |
| | | if (respControls != null && ! respControls.isEmpty()) |
| | | { |
| | | responseControls.addAll(respControls); |
| | | } |
| | |
| | | ExtendedResponseProtocolOp extendedResponse = |
| | | responseMessage.getExtendedResponseProtocolOp(); |
| | | String responseOID = extendedResponse.getOID(); |
| | | if ((responseOID != null) && |
| | | if (responseOID != null && |
| | | responseOID.equals(OID_NOTICE_OF_DISCONNECTION)) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_SERVER_DISCONNECT. |
| | |
| | | |
| | | // Evaluate the properties provided. The authID is required. The authzID, |
| | | // KDC, QoP, and realm are optional. |
| | | if ((saslProperties == null) || saslProperties.isEmpty()) |
| | | if (saslProperties == null || saslProperties.isEmpty()) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_NO_SASL_PROPERTIES.get(SASL_MECHANISM_GSSAPI); |
| | |
| | | ReturnCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | |
| | | Iterator<String> propertyNames = saslProperties.keySet().iterator(); |
| | | while (propertyNames.hasNext()) |
| | | for (String name : saslProperties.keySet()) |
| | | { |
| | | String name = propertyNames.next(); |
| | | String lowerName = toLowerCase(name); |
| | | |
| | | if (lowerName.equals(SASL_PROPERTY_AUTHID)) |
| | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_AUTHID_SINGLE_VALUED.get(); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | // Make sure that the authID was provided. |
| | | if ((gssapiAuthID == null) || (gssapiAuthID.length() == 0)) |
| | | if (gssapiAuthID == null || gssapiAuthID.length() == 0) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_SASL_AUTHID_REQUIRED.get(SASL_MECHANISM_GSSAPI); |
| | |
| | | |
| | | // Evaluate the properties provided. The authID is required, and authzID is |
| | | // optional. |
| | | if ((saslProperties == null) || saslProperties.isEmpty()) |
| | | if (saslProperties == null || saslProperties.isEmpty()) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_NO_SASL_PROPERTIES.get(SASL_MECHANISM_PLAIN); |
| | |
| | | ReturnCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | |
| | | Iterator<String> propertyNames = saslProperties.keySet().iterator(); |
| | | while (propertyNames.hasNext()) |
| | | for (String name : saslProperties.keySet()) |
| | | { |
| | | String name = propertyNames.next(); |
| | | String lowerName = toLowerCase(name); |
| | | |
| | | if (lowerName.equals(SASL_PROPERTY_AUTHID)) |
| | | { |
| | | List<String> values = saslProperties.get(name); |
| | | Iterator<String> iterator = values.iterator(); |
| | | if (iterator.hasNext()) |
| | | { |
| | | authID = iterator.next(); |
| | | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_AUTHID_SINGLE_VALUED.get(); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | | authID = getAuthID(saslProperties, authID, name); |
| | | } |
| | | else if (lowerName.equals(SASL_PROPERTY_AUTHZID)) |
| | | { |
| | |
| | | |
| | | |
| | | // Make sure that at least the authID was provided. |
| | | if ((authID == null) || (authID.length() == 0)) |
| | | if (authID == null || authID.length() == 0) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_SASL_AUTHID_REQUIRED.get(SASL_MECHANISM_PLAIN); |
| | |
| | | // See if there are any controls in the response. If so, then add them to |
| | | // the response controls list. |
| | | List<Control> respControls = responseMessage.getControls(); |
| | | if ((respControls != null) && (! respControls.isEmpty())) |
| | | if (respControls != null && !respControls.isEmpty()) |
| | | { |
| | | responseControls.addAll(respControls); |
| | | } |
| | |
| | | // Look at the protocol op from the response. If it's a bind response, then |
| | | // continue. If it's an extended response, then it could be a notice of |
| | | // disconnection so check for that. Otherwise, generate an error. |
| | | switch (responseMessage.getProtocolOpType()) |
| | | { |
| | | case OP_TYPE_BIND_RESPONSE: |
| | | // We'll deal with this later. |
| | | break; |
| | | |
| | | case OP_TYPE_EXTENDED_RESPONSE: |
| | | ExtendedResponseProtocolOp extendedResponse = |
| | | responseMessage.getExtendedResponseProtocolOp(); |
| | | String responseOID = extendedResponse.getOID(); |
| | | if ((responseOID != null) && |
| | | responseOID.equals(OID_NOTICE_OF_DISCONNECTION)) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_SERVER_DISCONNECT. |
| | | get(extendedResponse.getResultCode(), |
| | | extendedResponse.getErrorMessage()); |
| | | throw new LDAPException(extendedResponse.getResultCode(), message); |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get(extendedResponse); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | default: |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get(responseMessage.getProtocolOp()); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | generateError(responseMessage); |
| | | |
| | | |
| | | BindResponseProtocolOp bindResponse = |
| | |
| | | // Look at the protocol op from the response. If it's a bind response, |
| | | // then continue. If it's an extended response, then it could be a notice |
| | | // of disconnection so check for that. Otherwise, generate an error. |
| | | switch (responseMessage.getProtocolOpType()) |
| | | { |
| | | case OP_TYPE_BIND_RESPONSE: |
| | | // We'll deal with this later. |
| | | break; |
| | | |
| | | case OP_TYPE_EXTENDED_RESPONSE: |
| | | ExtendedResponseProtocolOp extendedResponse = |
| | | responseMessage.getExtendedResponseProtocolOp(); |
| | | String responseOID = extendedResponse.getOID(); |
| | | if ((responseOID != null) && |
| | | responseOID.equals(OID_NOTICE_OF_DISCONNECTION)) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_SERVER_DISCONNECT. |
| | | get(extendedResponse.getResultCode(), |
| | | extendedResponse.getErrorMessage()); |
| | | throw new LDAPException(extendedResponse.getResultCode(), message); |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get(extendedResponse); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | default: |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get(responseMessage.getProtocolOp()); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | generateError(responseMessage); |
| | | |
| | | |
| | | while (true) |
| | |
| | | // response, then continue. If it's an extended response, then it |
| | | // could be a notice of disconnection so check for that. Otherwise, |
| | | // generate an error. |
| | | switch (responseMessage.getProtocolOpType()) |
| | | { |
| | | case OP_TYPE_BIND_RESPONSE: |
| | | // We'll deal with this later. |
| | | break; |
| | | |
| | | case OP_TYPE_EXTENDED_RESPONSE: |
| | | ExtendedResponseProtocolOp extendedResponse = |
| | | responseMessage.getExtendedResponseProtocolOp(); |
| | | String responseOID = extendedResponse.getOID(); |
| | | if ((responseOID != null) && |
| | | responseOID.equals(OID_NOTICE_OF_DISCONNECTION)) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_SERVER_DISCONNECT. |
| | | get(extendedResponse.getResultCode(), |
| | | extendedResponse.getErrorMessage()); |
| | | throw new LDAPException(extendedResponse.getResultCode(), |
| | | message); |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get(extendedResponse); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | default: |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get(responseMessage.getProtocolOp()); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | generateError(responseMessage); |
| | | } |
| | | else |
| | | { |
| | |
| | | return null; |
| | | } |
| | | |
| | | private void generateError(LDAPMessage responseMessage) throws LDAPException, ClientException |
| | | { |
| | | switch (responseMessage.getProtocolOpType()) |
| | | { |
| | | case OP_TYPE_BIND_RESPONSE: |
| | | // We'll deal with this later. |
| | | break; |
| | | |
| | | case OP_TYPE_EXTENDED_RESPONSE: |
| | | ExtendedResponseProtocolOp extendedResponse = |
| | | responseMessage.getExtendedResponseProtocolOp(); |
| | | String responseOID = extendedResponse.getOID(); |
| | | if (OID_NOTICE_OF_DISCONNECTION.equals(responseOID)) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_SERVER_DISCONNECT. |
| | | get(extendedResponse.getResultCode(), extendedResponse.getErrorMessage()); |
| | | throw new LDAPException(extendedResponse.getResultCode(), message); |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get(extendedResponse); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | default: |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get(responseMessage.getProtocolOp()); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Handles the authentication callbacks to provide information needed by the |
| | |
| | | ExtendedResponseProtocolOp extendedResponse = |
| | | responseMessage.getExtendedResponseProtocolOp(); |
| | | String responseOID = extendedResponse.getOID(); |
| | | if ((responseOID != null) && |
| | | responseOID.equals(OID_NOTICE_OF_DISCONNECTION)) |
| | | if (OID_NOTICE_OF_DISCONNECTION.equals(responseOID)) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_SERVER_DISCONNECT.get( |
| | | extendedResponse.getResultCode(), extendedResponse.getErrorMessage()); |
| | |
| | | |
| | | // Get the authorization ID (if there is one) and return it to the caller. |
| | | ByteString authzID = extendedResponse.getValue(); |
| | | if ((authzID == null) || (authzID.length() == 0)) |
| | | if (authzID == null || authzID.length() == 0) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | String valueString = authzID.toString(); |
| | | if ((valueString == null) || (valueString.length() == 0) || |
| | | if (valueString == null || valueString.length() == 0 || |
| | | valueString.equalsIgnoreCase("dn:")) |
| | | { |
| | | return null; |
| | |
| | | return authzID; |
| | | } |
| | | } |
| | | |
| | |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | if ((!authzID.isPresent() || (!currentPW.isPresent() && !currentPWFile.isPresent()))) |
| | | if (!authzID.isPresent() || (!currentPW.isPresent() && !currentPWFile.isPresent())) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPPWMOD_ANON_REQUIRES_AUTHZID_AND_CURRENTPW.get(); |
| | |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | |
| | | LocalizableMessage errorMessage = extendedResponse.getErrorMessage(); |
| | | if ((errorMessage != null) && (errorMessage.length() > 0)) |
| | | if (errorMessage != null && errorMessage.length() > 0) |
| | | { |
| | | message = ERR_LDAPPWMOD_FAILURE_ERROR_MESSAGE.get(errorMessage); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | |
| | | out.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | |
| | | LocalizableMessage additionalInfo = extendedResponse.getErrorMessage(); |
| | | if ((additionalInfo != null) && (additionalInfo.length() > 0)) |
| | | if (additionalInfo != null && additionalInfo.length() > 0) |
| | | { |
| | | message = INFO_LDAPPWMOD_ADDITIONAL_INFO.get(additionalInfo); |
| | | out.println(wrapText(message, MAX_LINE_WIDTH)); |
| | |
| | | } |
| | | |
| | | int dnLength = dnString.length(); |
| | | if ((dnLength <= colsRemaining) || (colsRemaining <= 0)) |
| | | if (dnLength <= colsRemaining || colsRemaining <= 0) |
| | | { |
| | | buffer.append(dnString); |
| | | buffer.append(EOL); |
| | |
| | | buffer.append(EOL); |
| | | |
| | | int startPos = colsRemaining; |
| | | while ((dnLength - startPos) > (wrapColumn - 1)) |
| | | while (dnLength - startPos > wrapColumn - 1) |
| | | { |
| | | buffer.append(" "); |
| | | buffer.append(dnString, startPos, (startPos+wrapColumn-1)); |
| | | buffer.append(dnString, startPos, startPos+wrapColumn-1); |
| | | buffer.append(EOL); |
| | | |
| | | startPos += (wrapColumn-1); |
| | | startPos += wrapColumn-1; |
| | | } |
| | | |
| | | if (startPos < dnLength) |
| | |
| | | } |
| | | |
| | | int valueLength = valueString.length(); |
| | | if ((valueLength <= colsRemaining) || (colsRemaining <= 0)) |
| | | if (valueLength <= colsRemaining || colsRemaining <= 0) |
| | | { |
| | | buffer.append(valueString); |
| | | buffer.append(EOL); |
| | |
| | | buffer.append(EOL); |
| | | |
| | | int startPos = colsRemaining; |
| | | while ((valueLength - startPos) > (wrapColumn - 1)) |
| | | while (valueLength - startPos > wrapColumn - 1) |
| | | { |
| | | buffer.append(" "); |
| | | buffer.append(valueString, startPos, (startPos+wrapColumn-1)); |
| | | buffer.append(valueString, startPos, startPos+wrapColumn-1); |
| | | buffer.append(EOL); |
| | | |
| | | startPos += (wrapColumn-1); |
| | | startPos += wrapColumn-1; |
| | | } |
| | | |
| | | if (startPos < valueLength) |
| | |
| | | err.println(wrapText(ex1.getMessage(), MAX_LINE_WIDTH)); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | boolean val = searchOptions.setSearchScope(searchScope.getValue(), err); |
| | | if(val == false) |
| | | { |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | val = searchOptions.setDereferencePolicy(dereferencePolicy.getValue(), err); |
| | | if(val == false) |
| | | if (!searchOptions.setSearchScope(searchScope.getValue(), err) |
| | | || !searchOptions.setDereferencePolicy(dereferencePolicy.getValue(), err)) |
| | | { |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | |
| | | { |
| | | if(saslOption.startsWith("mech=")) |
| | | { |
| | | boolean mechValue = connectionOptions.setSASLMechanism(saslOption); |
| | | if(mechValue == false) |
| | | if (!connectionOptions.setSASLMechanism(saslOption)) |
| | | { |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } else |
| | | { |
| | | boolean propValue = connectionOptions.addSASLProperty(saslOption); |
| | | if(propValue == false) |
| | | if (!connectionOptions.addSASLProperty(saslOption)) |
| | | { |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | |
| | | int resultCode, LocalizableMessage errorMessage, |
| | | DN matchedDN) |
| | | { |
| | | if ((explanation != null) && (explanation.length() > 0)) |
| | | if (explanation != null && explanation.length() > 0) |
| | | { |
| | | err.println(explanation); |
| | | } |
| | |
| | | LDAPResultCode.toString(resultCode))); |
| | | } |
| | | |
| | | if ((errorMessage != null) && (errorMessage.length() > 0)) |
| | | if (errorMessage != null && errorMessage.length() > 0) |
| | | { |
| | | err.println(ERR_TOOL_ERROR_MESSAGE.get(errorMessage)); |
| | | } |
| | |
| | | |
| | | // If the entry is to be modified, then process the changes. |
| | | LinkedList<Modification> mods = modifications.remove(entryDN); |
| | | if ((mods != null) && (! mods.isEmpty())) |
| | | if (mods != null && !mods.isEmpty()) |
| | | { |
| | | try |
| | | { |
| | |
| | | boolean successful; |
| | | try |
| | | { |
| | | successful = modifyLDIF(sourceReader, changeReader, targetWriter, |
| | | errorList); |
| | | successful = modifyLDIF(sourceReader, changeReader, targetWriter, errorList); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | { |
| | | err.println(s); |
| | | } |
| | | return (successful ? 0 : 1); |
| | | return successful ? 0 : 1; |
| | | } |
| | | } |
| | | |
| | |
| | | else |
| | | { |
| | | ArrayList<String> trailingArguments = argParser.getTrailingArguments(); |
| | | if ((trailingArguments == null) || trailingArguments.isEmpty()) |
| | | if (trailingArguments == null || trailingArguments.isEmpty()) |
| | | { |
| | | LocalizableMessage message = ERR_LDIFSEARCH_NO_FILTER.get(); |
| | | err.println(message); |
| | |
| | | while (true) |
| | | { |
| | | // If the time limit has been reached, then stop now. |
| | | if ((timeLimitMillis > 0) && (System.currentTimeMillis() > stopTime)) |
| | | if (timeLimitMillis > 0 && System.currentTimeMillis() > stopTime) |
| | | { |
| | | resultCode = LDAPResultCode.TIME_LIMIT_EXCEEDED; |
| | | |
| | |
| | | writer.flush(); |
| | | |
| | | matchCount++; |
| | | if ((sizeLimitValue > 0) && (matchCount >= sizeLimitValue)) |
| | | if (sizeLimitValue > 0 && matchCount >= sizeLimitValue) |
| | | { |
| | | resultCode = LDAPResultCode.SIZE_LIMIT_EXCEEDED; |
| | | |
| | |
| | | catch (LDAPConnectionException lce) |
| | | { |
| | | LocalizableMessage message; |
| | | if ((lce.getCause() != null) && (lce.getCause().getCause() != null) && |
| | | if (lce.getCause() != null && lce.getCause().getCause() != null && |
| | | lce.getCause().getCause() instanceof SSLException) { |
| | | message = ERR_PWPSTATE_CANNOT_CONNECT_SSL.get(host.getValue(), |
| | | port.getValue()); |
| | |
| | | else if (subCommandName.equals(SC_SET_ACCOUNT_DISABLED_STATE)) |
| | | { |
| | | Argument a = subCommand.getArgumentForName(ARG_OP_VALUE); |
| | | if ((a != null) && a.isPresent()) |
| | | if (a != null && a.isPresent()) |
| | | { |
| | | String valueStr = a.getValue(); |
| | | if (isTrueValue(valueStr)) |
| | |
| | | else if (subCommandName.equals(SC_SET_ACCOUNT_EXPIRATION_TIME)) |
| | | { |
| | | Argument a = subCommand.getArgumentForName(ARG_OP_VALUE); |
| | | if ((a != null) && a.isPresent()) |
| | | if (a != null && a.isPresent()) |
| | | { |
| | | encode(writer, OP_SET_ACCOUNT_EXPIRATION_TIME, a.getValue()); |
| | | } |
| | |
| | | else if (subCommandName.equals(SC_SET_PASSWORD_CHANGED_TIME)) |
| | | { |
| | | Argument a = subCommand.getArgumentForName(ARG_OP_VALUE); |
| | | if ((a != null) && a.isPresent()) |
| | | if (a != null && a.isPresent()) |
| | | { |
| | | encode(writer, OP_SET_PASSWORD_CHANGED_TIME, a.getValue()); |
| | | } |
| | |
| | | else if(subCommandName.equals(SC_SET_PASSWORD_EXP_WARNED_TIME)) |
| | | { |
| | | Argument a = subCommand.getArgumentForName(ARG_OP_VALUE); |
| | | if ((a != null) && a.isPresent()) |
| | | if (a != null && a.isPresent()) |
| | | { |
| | | encode(writer, OP_SET_PASSWORD_EXPIRATION_WARNED_TIME, |
| | | a.getValue()); |
| | |
| | | else if(subCommandName.equals(SC_ADD_AUTHENTICATION_FAILURE_TIME)) |
| | | { |
| | | Argument a = subCommand.getArgumentForName(ARG_OP_VALUE); |
| | | if ((a != null) && a.isPresent()) |
| | | if (a != null && a.isPresent()) |
| | | { |
| | | encode(writer, OP_ADD_AUTHENTICATION_FAILURE_TIME, |
| | | a.getValue()); |
| | |
| | | else if(subCommandName.equals(SC_SET_AUTHENTICATION_FAILURE_TIMES)) |
| | | { |
| | | Argument a = subCommand.getArgumentForName(ARG_OP_VALUE); |
| | | if ((a != null) && a.isPresent()) |
| | | if (a != null && a.isPresent()) |
| | | { |
| | | ArrayList<String> valueList = new ArrayList<>(a.getValues()); |
| | | String[] values = new String[valueList.size()]; |
| | |
| | | else if(subCommandName.equals(SC_SET_LAST_LOGIN_TIME)) |
| | | { |
| | | Argument a = subCommand.getArgumentForName(ARG_OP_VALUE); |
| | | if ((a != null) && a.isPresent()) |
| | | if (a != null && a.isPresent()) |
| | | { |
| | | encode(writer, OP_SET_LAST_LOGIN_TIME, a.getValue()); |
| | | } |
| | |
| | | else if(subCommandName.equals(SC_SET_PASSWORD_RESET_STATE)) |
| | | { |
| | | Argument a = subCommand.getArgumentForName(ARG_OP_VALUE); |
| | | if ((a != null) && a.isPresent()) |
| | | if (a != null && a.isPresent()) |
| | | { |
| | | String valueStr = a.getValue(); |
| | | if (isTrueValue(valueStr)) |
| | |
| | | else if(subCommandName.equals(SC_ADD_GRACE_LOGIN_USE_TIME)) |
| | | { |
| | | Argument a = subCommand.getArgumentForName(ARG_OP_VALUE); |
| | | if ((a != null) && a.isPresent()) |
| | | if (a != null && a.isPresent()) |
| | | { |
| | | encode(writer, OP_ADD_GRACE_LOGIN_USE_TIME, a.getValue()); |
| | | } |
| | |
| | | else if(subCommandName.equals(SC_SET_GRACE_LOGIN_USE_TIMES)) |
| | | { |
| | | Argument a = subCommand.getArgumentForName(ARG_OP_VALUE); |
| | | if ((a != null) && a.isPresent()) |
| | | if (a != null && a.isPresent()) |
| | | { |
| | | ArrayList<String> valueList = new ArrayList<>(a.getValues()); |
| | | String[] values = new String[valueList.size()]; |
| | |
| | | else if(subCommandName.equals(SC_SET_PASSWORD_CHANGED_BY_REQUIRED_TIME)) |
| | | { |
| | | Argument a = subCommand.getArgumentForName(ARG_OP_VALUE); |
| | | if ((a != null) && a.isPresent()) |
| | | if (a != null && a.isPresent()) |
| | | { |
| | | encode(writer, OP_SET_PASSWORD_CHANGED_BY_REQUIRED_TIME, |
| | | a.getValue()); |
| | |
| | | private static void printLabelAndValues(LocalizableMessage msg, ArrayList<String> values) |
| | | { |
| | | String label = String.valueOf(msg); |
| | | if ((values == null) || values.isEmpty()) |
| | | if (values == null || values.isEmpty()) |
| | | { |
| | | out.print(label); |
| | | out.println(":"); |
| | |
| | | public void checkServerTrusted(X509Certificate[] chain, String authType) |
| | | throws CertificateException |
| | | { |
| | | if ((chain == null) || (chain.length == 0)) |
| | | if (chain == null || chain.length == 0) |
| | | { |
| | | System.out.println(WARN_PROMPTTM_NO_SERVER_CERT_CHAIN.get()); |
| | | } |
| | |
| | | catch (LDAPConnectionException lce) |
| | | { |
| | | LocalizableMessage message = null; |
| | | if ((lce.getCause() != null) && (lce.getCause().getCause() != null) && |
| | | if (lce.getCause() != null && lce.getCause().getCause() != null && |
| | | lce.getCause().getCause() instanceof SSLException) { |
| | | message = ERR_STOPDS_CANNOT_CONNECT_SSL.get(host.getValue(), |
| | | port.getValue()); |
| | |
| | | ExtendedResponseProtocolOp extendedResponse = |
| | | responseMessage.getExtendedResponseProtocolOp(); |
| | | String responseOID = extendedResponse.getOID(); |
| | | if ((responseOID != null) && |
| | | (responseOID.equals(LDAPConstants.OID_NOTICE_OF_DISCONNECTION))) |
| | | if (LDAPConstants.OID_NOTICE_OF_DISCONNECTION.equals(responseOID)) |
| | | { |
| | | LocalizableMessage message = extendedResponse.getErrorMessage(); |
| | | if (message != null) |
| | |
| | | |
| | | boolean quietMode = false; |
| | | Argument quietArg = argParser.getArgumentForLongID(ArgumentConstants.OPTION_LONG_QUIET); |
| | | if ((quietArg != null) && quietArg.isPresent()) |
| | | if (quietArg != null && quietArg.isPresent()) |
| | | { |
| | | quietMode = true; |
| | | } |
| | |
| | | List<LocalizableMessage> warnings) |
| | | throws InitializationException |
| | | { |
| | | if ((arguments.length < 1) || (arguments.length > 2)) |
| | | if (arguments.length < 1 || arguments.length > 2) |
| | | { |
| | | LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get( |
| | | getName(), lineNumber, 1, 2, arguments.length); |
| | |
| | | int lineNumber, List<LocalizableMessage> warnings) |
| | | throws InitializationException |
| | | { |
| | | if ((arguments.length < 1) || (arguments.length > 2)) |
| | | if (arguments.length < 1 || arguments.length > 2) |
| | | { |
| | | LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get( |
| | | getName(), lineNumber, 1, 2, arguments.length); |
| | |
| | | for (TemplateLine l : extraLines) |
| | | { |
| | | TagResult r = l.generateLine(entry); |
| | | if ((!r.keepProcessingEntry() |
| | | if (!r.keepProcessingEntry() |
| | | || !r.keepProcessingParent() |
| | | || !r.keepProcessingTemplateFile())) |
| | | || !r.keepProcessingTemplateFile()) |
| | | { |
| | | return r; |
| | | } |
| | |
| | | TemplateValue templateValue) |
| | | { |
| | | DN dn = templateEntry.getDN(); |
| | | if ((dn == null) || dn.isRootDN()) |
| | | if (dn == null || dn.isRootDN()) |
| | | { |
| | | return TagResult.SUCCESS_RESULT; |
| | | } |
| | |
| | | |
| | | |
| | | // There must be at least one argument, and possibly two. |
| | | if ((arguments.length < 1) || (arguments.length > 2)) |
| | | if (arguments.length < 1 || arguments.length > 2) |
| | | { |
| | | LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get( |
| | | getName(), lineNumber, 1, 2, arguments.length); |
| | |
| | | |
| | | // The first argument should be the path to the file. |
| | | dataFile = templateFile.getFile(arguments[0]); |
| | | if ((dataFile == null) || (! dataFile.exists())) |
| | | if (dataFile == null || !dataFile.exists()) |
| | | { |
| | | LocalizableMessage message = ERR_MAKELDIF_TAG_CANNOT_FIND_FILE.get( |
| | | arguments[0], getName(), lineNumber); |
| | |
| | | List<LocalizableMessage> warnings) |
| | | throws InitializationException |
| | | { |
| | | if ((arguments.length < 1) || (arguments.length > 2)) |
| | | if (arguments.length < 1 || arguments.length > 2) |
| | | { |
| | | LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get( |
| | | getName(), lineNumber, 1, 2, arguments.length); |
| | |
| | | int lineNumber, List<LocalizableMessage> warnings) |
| | | throws InitializationException |
| | | { |
| | | if ((arguments.length < 1) || (arguments.length > 2)) |
| | | if (arguments.length < 1 || arguments.length > 2) |
| | | { |
| | | LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get( |
| | | getName(), lineNumber, 1, 2, arguments.length); |
| | |
| | | TemplateValue templateValue) |
| | | { |
| | | List<TemplateValue> values = templateEntry.getValues(attributeType); |
| | | if ((values == null) || values.isEmpty()) |
| | | if (values == null || values.isEmpty()) |
| | | { |
| | | return TagResult.SUCCESS_RESULT; |
| | | } |
| | |
| | | { |
| | | return TagResult.OMIT_FROM_ENTRY; |
| | | } |
| | | else |
| | | { |
| | | for (TemplateValue v : values) |
| | | { |
| | | if (assertionValue.equals(v.getValue().toString())) |
| | | { |
| | | return TagResult.OMIT_FROM_ENTRY; |
| | | } |
| | | } |
| | | |
| | | return TagResult.SUCCESS_RESULT; |
| | | for (TemplateValue v : values) |
| | | { |
| | | if (assertionValue.equals(v.getValue().toString())) |
| | | { |
| | | return TagResult.OMIT_FROM_ENTRY; |
| | | } |
| | | } |
| | | return TagResult.SUCCESS_RESULT; |
| | | } |
| | | } |
| | | |
| | |
| | | List<LocalizableMessage> warnings) |
| | | throws InitializationException |
| | | { |
| | | if ((arguments.length < 1) || (arguments.length > 2)) |
| | | if (arguments.length < 1 || arguments.length > 2) |
| | | { |
| | | LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get( |
| | | getName(), lineNumber, 1, 2, arguments.length); |
| | |
| | | int lineNumber, List<LocalizableMessage> warnings) |
| | | throws InitializationException |
| | | { |
| | | if ((arguments.length < 1) || (arguments.length > 2)) |
| | | if (arguments.length < 1 || arguments.length > 2) |
| | | { |
| | | LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get( |
| | | getName(), lineNumber, 1, 2, arguments.length); |
| | |
| | | TemplateValue templateValue) |
| | | { |
| | | List<TemplateValue> values = templateEntry.getValues(attributeType); |
| | | if ((values == null) || values.isEmpty()) |
| | | if (values == null || values.isEmpty()) |
| | | { |
| | | return TagResult.OMIT_FROM_ENTRY; |
| | | } |
| | |
| | | { |
| | | return TagResult.SUCCESS_RESULT; |
| | | } |
| | | else |
| | | { |
| | | for (TemplateValue v : values) |
| | | { |
| | | if (assertionValue.equals(v.getValue().toString())) |
| | | { |
| | | return TagResult.SUCCESS_RESULT; |
| | | } |
| | | } |
| | | |
| | | return TagResult.OMIT_FROM_ENTRY; |
| | | for (TemplateValue v : values) |
| | | { |
| | | if (assertionValue.equals(v.getValue().toString())) |
| | | { |
| | | return TagResult.SUCCESS_RESULT; |
| | | } |
| | | } |
| | | return TagResult.OMIT_FROM_ENTRY; |
| | | } |
| | | } |
| | | |
| | |
| | | return -1; |
| | | } |
| | | |
| | | return (0xFF & entryBytes.get()); |
| | | return 0xFF & entryBytes.get(); |
| | | } |
| | | |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.tools.makeldif; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.opends.server.types.DN; |
| | |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines a tag that is used to include the DN of the parent entry |
| | | * in the attribute value. |
| | |
| | | TemplateValue templateValue) |
| | | { |
| | | DN parentDN = templateEntry.getParentDN(); |
| | | if ((parentDN == null) || parentDN.isRootDN()) |
| | | if (parentDN == null || parentDN.isRootDN()) |
| | | { |
| | | return TagResult.SUCCESS_RESULT; |
| | | } |
| | |
| | | return TagResult.SUCCESS_RESULT; |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | // There must be at least one argument, to specify the type of random value |
| | | // to generate. |
| | | if ((arguments == null) || (arguments.length == 0)) |
| | | if (arguments == null || arguments.length == 0) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_MAKELDIF_TAG_NO_RANDOM_TYPE_ARGUMENT.get(lineNumber); |
| | |
| | | throw new InitializationException(message, nfe); |
| | | } |
| | | } |
| | | else if ((numArgs == 3) || (numArgs == 4)) |
| | | else if (numArgs == 3 || numArgs == 4) |
| | | { |
| | | randomType = RANDOM_TYPE_NUMERIC; |
| | | |
| | |
| | | } |
| | | else if (randomTypeString.equals("chars")) |
| | | { |
| | | if ((numArgs < 3) || (numArgs > 4)) |
| | | if (numArgs < 3 || numArgs > 4) |
| | | { |
| | | LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get( |
| | | getName(), lineNumber, 3, 4, numArgs); |
| | |
| | | |
| | | case RANDOM_TYPE_MONTH: |
| | | String month = MONTHS[random.nextInt(MONTHS.length)]; |
| | | if ((maxLength == 0) || (month.length() <= maxLength)) |
| | | if (maxLength == 0 || month.length() <= maxLength) |
| | | { |
| | | buffer.append(month); |
| | | } |
| | |
| | | // Get the information necessary to write the LDIF. |
| | | BufferedWriter writer = exportConfig.getWriter(); |
| | | int wrapColumn = exportConfig.getWrapColumn(); |
| | | boolean wrapLines = (wrapColumn > 1); |
| | | boolean wrapLines = wrapColumn > 1; |
| | | |
| | | |
| | | // First, write the DN. It will always be included. |
| | |
| | | { |
| | | for (Attribute a : userAttributes.get(attrType)) |
| | | { |
| | | if (a.isVirtual() && |
| | | (! exportConfig.includeVirtualAttributes())) |
| | | if (a.isVirtual() && !exportConfig.includeVirtualAttributes()) |
| | | { |
| | | continue; |
| | | } |
| | |
| | | { |
| | | for (Attribute a : operationalAttributes.get(attrType)) |
| | | { |
| | | if (a.isVirtual() && |
| | | (! exportConfig.includeVirtualAttributes())) |
| | | if (a.isVirtual() && !exportConfig.includeVirtualAttributes()) |
| | | { |
| | | continue; |
| | | } |
| | |
| | | { |
| | | templatePath = null; |
| | | File f = getFile(filename); |
| | | if ((f == null) || (! f.exists())) |
| | | if (f == null || !f.exists()) |
| | | { |
| | | LocalizableMessage message = ERR_MAKELDIF_COULD_NOT_FIND_TEMPLATE_FILE.get(filename); |
| | | throw new IOException(message.toString()); |
| | |
| | | templateFileConstants, warnings); |
| | | |
| | | String lowerLine = toLowerCase(line); |
| | | if ((line.length() == 0) || line.startsWith("#")) |
| | | if (line.length() == 0 || line.startsWith("#")) |
| | | { |
| | | // This is a comment or a blank line, so we'll ignore it. |
| | | continue; |
| | |
| | | StringBuilder lineBuffer = new StringBuilder(line); |
| | | int openPos = line.lastIndexOf('[', closePos); |
| | | // Find the opening bracket. If it's escaped, then it's not a constant |
| | | if ((openPos > 0 && line.charAt(openPos - 1) != '\\') || |
| | | (openPos == 0)) |
| | | if ((openPos > 0 && line.charAt(openPos - 1) != '\\') |
| | | || openPos == 0) |
| | | { |
| | | String constantName = |
| | | toLowerCase(line.substring(openPos+1, closePos)); |
| | |
| | | } |
| | | } |
| | | // Then, find the position of the first non-blank character in the line. |
| | | while ((pos < length) && (lowerLine.charAt(pos) == ' ')) |
| | | while (pos < length && lowerLine.charAt(pos) == ' ') |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | for (Branch b : branches.values()) |
| | | { |
| | | TagResult result = b.writeEntries(entryWriter); |
| | | if (! (result.keepProcessingTemplateFile())) |
| | | if (!result.keepProcessingTemplateFile()) |
| | | { |
| | | return result; |
| | | } |
| | |
| | | TemplateValue templateValue) |
| | | { |
| | | DN dn = templateEntry.getDN(); |
| | | if ((dn == null) || dn.isRootDN()) |
| | | if (dn == null || dn.isRootDN()) |
| | | { |
| | | return TagResult.SUCCESS_RESULT; |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.tools.makeldif; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.opends.server.types.DN; |
| | |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines a tag that is used to include the DN of the parent entry |
| | | * in the attribute value, with underscores in place of commas. |
| | |
| | | TemplateValue templateValue) |
| | | { |
| | | DN parentDN = templateEntry.getParentDN(); |
| | | if ((parentDN == null) || parentDN.isRootDN()) |
| | | if (parentDN == null || parentDN.isRootDN()) |
| | | { |
| | | return TagResult.SUCCESS_RESULT; |
| | | } |
| | |
| | | ocValues.add("top"); |
| | | ocValues.add(ConfigConstants.OC_TASK); |
| | | if (scheduleRecurring) { |
| | | ocValues.add((ConfigConstants.OC_RECURRING_TASK)); |
| | | ocValues.add(ConfigConstants.OC_RECURRING_TASK); |
| | | } |
| | | ocValues.add(information.getTaskObjectclass()); |
| | | attributes.add(new LDAPAttribute(ATTR_OBJECTCLASS, ocValues)); |
| | |
| | | * @return boolean where true means this task supports being canceled. |
| | | */ |
| | | public boolean isCancelable() { |
| | | boolean cancelable = false; |
| | | TaskState state = getTaskState(); |
| | | if (state != null) { |
| | | Task task = getTask(); |
| | | cancelable = (TaskState.isPending(state) || |
| | | TaskState.isRecurring(state) || |
| | | (TaskState.isRunning(state) && |
| | | task != null && |
| | | task.isInterruptable())); |
| | | return TaskState.isPending(state) |
| | | || TaskState.isRecurring(state) |
| | | || (TaskState.isRunning(state) |
| | | && task != null |
| | | && task.isInterruptable()); |
| | | } |
| | | return cancelable; |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * Gets a mapping of attributes that are specific to the implementing |
| | | * task as opposed to the superior, or base, task. |
| | | * |
| | | * @return mapping of atribute field labels to lists of string values for |
| | | * each field. |
| | | * @return mapping of attribute field labels to lists of string values for each field. |
| | | */ |
| | | public Map<LocalizableMessage, List<String>> getTaskSpecificAttributeValuePairs() { |
| | | return taskSpecificAttrValues; |
| | |
| | | { |
| | | return false; |
| | | } |
| | | while ((descendant != null) && !ancestor.equals(descendant)) |
| | | while (descendant != null && !ancestor.equals(descendant)) |
| | | { |
| | | descendant = descendant.getParentFile(); |
| | | } |
| | | } |
| | | return (ancestor != null) && (descendant != null); |
| | | return ancestor != null && descendant != null; |
| | | } |
| | | |
| | | /** |
| | |
| | | * either of the files are null |
| | | */ |
| | | static boolean isDescendant(File descendant, File path) { |
| | | boolean isDescendant = false; |
| | | if (descendant != null && path != null) { |
| | | File parent = descendant.getParentFile(); |
| | | while ((parent != null) && !isDescendant) { |
| | | isDescendant = path.equals(parent); |
| | | if (!isDescendant) { |
| | | parent = parent.getParentFile(); |
| | | while (parent != null) { |
| | | if (path.equals(parent)) { |
| | | return true; |
| | | } |
| | | parent = parent.getParentFile(); |
| | | } |
| | | } |
| | | return isDescendant; |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | |
| | | props.put(PASSWORD_EXPIRATION_TIME, newArrayList(new Date(expTime).toString())); |
| | | } |
| | | |
| | | if ((oldPasswords != null) && (! oldPasswords.isEmpty())) |
| | | if (oldPasswords != null && !oldPasswords.isEmpty()) |
| | | { |
| | | props.put(OLD_PASSWORD, toStrings(oldPasswords)); |
| | | } |
| | | |
| | | if ((newPasswords != null) && (! newPasswords.isEmpty())) |
| | | if (newPasswords != null && !newPasswords.isEmpty()) |
| | | { |
| | | props.put(NEW_PASSWORD, toStrings(newPasswords)); |
| | | } |
| | |
| | | @Override |
| | | public boolean hasAllOptions(Collection<String> options) |
| | | { |
| | | return (options == null || options.isEmpty()); |
| | | return options == null || options.isEmpty(); |
| | | } |
| | | |
| | | |
| | |
| | | @Override |
| | | public boolean optionsEqual(Set<String> options) |
| | | { |
| | | return (options == null || options.isEmpty()); |
| | | return options == null || options.isEmpty(); |
| | | } |
| | | } |
| | | |
| | |
| | | return elements.contains(o); |
| | | } |
| | | |
| | | return (firstElement != null && firstElement.equals(o)); |
| | | return firstElement != null && firstElement.equals(o); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | private static boolean isEmpty(final Attribute attribute) { |
| | | return (attribute == null) || attribute.isEmpty(); |
| | | return attribute == null || attribute.isEmpty(); |
| | | } |
| | | |
| | | private final Attribute attribute; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2014 ForgeRock AS |
| | | * Portions Copyright 2013-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | |
| | | this.authenticationEntry = authenticationEntry; |
| | | this.isRoot = isRoot; |
| | | |
| | | isAuthenticated = (authenticationEntry != null); |
| | | isAuthenticated = authenticationEntry != null; |
| | | mustChangePassword = false; |
| | | simpleBindDN = authenticationEntry != null ? |
| | | authenticationEntry.getName() : null; |
| | |
| | | } |
| | | |
| | | CacheEntry e = (CacheEntry) o; |
| | | return ((e.entryID == entryID) && (e.entry.equals(entry))); |
| | | return e.entryID == entryID && e.entry.equals(entry); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | ifNull(name); |
| | | |
| | | if ((values == null) || values.isEmpty()) |
| | | if (values == null || values.isEmpty()) |
| | | { |
| | | extraProperties.remove(name); |
| | | } |
| | |
| | | this.definition = definition; |
| | | } |
| | | |
| | | if ((names == null) || names.isEmpty()) |
| | | if (names == null || names.isEmpty()) |
| | | { |
| | | this.names = new LinkedHashMap<>(0); |
| | | } |
| | |
| | | this.names = new LinkedHashMap<>(names); |
| | | } |
| | | |
| | | if ((auxiliaryClasses == null) || auxiliaryClasses.isEmpty()) |
| | | if (auxiliaryClasses == null || auxiliaryClasses.isEmpty()) |
| | | { |
| | | this.auxiliaryClasses = new LinkedHashSet<>(0); |
| | | } |
| | |
| | | this.auxiliaryClasses = new LinkedHashSet<>(auxiliaryClasses); |
| | | } |
| | | |
| | | if ((requiredAttributes == null) || requiredAttributes.isEmpty()) |
| | | if (requiredAttributes == null || requiredAttributes.isEmpty()) |
| | | { |
| | | this.requiredAttributes = new LinkedHashSet<>(0); |
| | | } |
| | |
| | | this.requiredAttributes = new LinkedHashSet<>(requiredAttributes); |
| | | } |
| | | |
| | | if ((optionalAttributes == null) || optionalAttributes.isEmpty()) |
| | | if (optionalAttributes == null || optionalAttributes.isEmpty()) |
| | | { |
| | | this.optionalAttributes = new LinkedHashSet<>(0); |
| | | } |
| | |
| | | this.optionalAttributes = new LinkedHashSet<>(optionalAttributes); |
| | | } |
| | | |
| | | if ((prohibitedAttributes == null) || |
| | | prohibitedAttributes.isEmpty()) |
| | | if (prohibitedAttributes == null || prohibitedAttributes.isEmpty()) |
| | | { |
| | | this.prohibitedAttributes = new LinkedHashSet<>(0); |
| | | } |
| | |
| | | this.prohibitedAttributes = new LinkedHashSet<>(prohibitedAttributes); |
| | | } |
| | | |
| | | if ((extraProperties == null) || extraProperties.isEmpty()) |
| | | if (extraProperties == null || extraProperties.isEmpty()) |
| | | { |
| | | this.extraProperties = new LinkedHashMap<>(0); |
| | | } |
| | |
| | | */ |
| | | public boolean isRequiredOrOptional(AttributeType attributeType) |
| | | { |
| | | return (requiredAttributes.contains(attributeType) || |
| | | optionalAttributes.contains(attributeType)); |
| | | return requiredAttributes.contains(attributeType) || |
| | | optionalAttributes.contains(attributeType); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | if ((o == null) || (! (o instanceof DITContentRule))) |
| | | if (!(o instanceof DITContentRule)) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | DITContentRule dcr = (DITContentRule) o; |
| | | if (! structuralClass.equals(dcr.structuralClass)) |
| | | if (!structuralClass.equals(dcr.structuralClass)) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | this.definition = definition; |
| | | } |
| | | |
| | | if ((names == null) || names.isEmpty()) |
| | | if (names == null || names.isEmpty()) |
| | | { |
| | | this.names = new LinkedHashMap<>(0); |
| | | } |
| | |
| | | this.names = new LinkedHashMap<>(names); |
| | | } |
| | | |
| | | if ((superiorRules == null) || superiorRules.isEmpty()) |
| | | if (superiorRules == null || superiorRules.isEmpty()) |
| | | { |
| | | this.superiorRules = new LinkedHashSet<>(0); |
| | | } |
| | |
| | | this.superiorRules = new LinkedHashSet<>(superiorRules); |
| | | } |
| | | |
| | | if ((extraProperties == null) || extraProperties.isEmpty()) |
| | | if (extraProperties == null || extraProperties.isEmpty()) |
| | | { |
| | | this.extraProperties = new LinkedHashMap<>(0); |
| | | } |
| | |
| | | */ |
| | | public DN(List<RDN> rdnComponents) |
| | | { |
| | | if ((rdnComponents == null) || rdnComponents.isEmpty()) |
| | | if (rdnComponents == null || rdnComponents.isEmpty()) |
| | | { |
| | | this.rdnComponents = new RDN[0]; |
| | | } |
| | |
| | | */ |
| | | public boolean isRootDN() |
| | | { |
| | | return (numComponents == 0); |
| | | return numComponents == 0; |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | public DN getParentDNInSuffix() |
| | | { |
| | | if ((numComponents <= 1) || |
| | | DirectoryServer.isNamingContext(this)) |
| | | if (numComponents <= 1 || DirectoryServer.isNamingContext(this)) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | RDN[] parentComponents = new RDN[numComponents-1]; |
| | | System.arraycopy(rdnComponents, 1, parentComponents, 0, |
| | | numComponents-1); |
| | | System.arraycopy(rdnComponents, 1, parentComponents, 0, numComponents-1); |
| | | return new DN(parentComponents); |
| | | } |
| | | |
| | |
| | | case SUBORDINATES: |
| | | // This DN must be a descendant of the provided base DN, but |
| | | // not equal to it. |
| | | return ((! equals(baseDN)) && isDescendantOf(baseDN)); |
| | | return !equals(baseDN) && isDescendantOf(baseDN); |
| | | |
| | | default: |
| | | // This is a scope that we don't recognize. |
| | |
| | | for (int i = 0; i < length; i++) |
| | | { |
| | | b = dnString.byteAt(i); |
| | | if (((b & 0x7F) != b) || (b == '\\')) |
| | | if ((b & 0x7F) != b || b == '\\') |
| | | { |
| | | return valueOf(dnString.toString()); |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | // Skip over any spaces between the attribute name and its |
| | | // value. |
| | | // Skip over any spaces between the attribute name and its value. |
| | | b = ' '; |
| | | while (dnReader.remaining() > 0 && (b = dnReader.get()) == ' ') |
| | | {} |
| | |
| | | rdnComponents.add(rdn); |
| | | return new DN(rdnComponents); |
| | | } |
| | | else if ((b == ',') || (b == ';')) |
| | | else if (b == ',' || b == ';') |
| | | { |
| | | // We're at the end of the RDN component, so add it to the |
| | | // list, skip over the comma/semicolon, and start on the next |
| | |
| | | } |
| | | |
| | | |
| | | // Skip over any spaces between the attribute name and its |
| | | // value. |
| | | // Skip over any spaces between the attribute name and its value. |
| | | b = ' '; |
| | | while (dnReader.remaining() > 0 && |
| | | (b = dnReader.get()) == ' ') |
| | |
| | | rdn.addValue(attrType, attributeNameString, parsedValue); |
| | | |
| | | |
| | | // Skip over any spaces that might be after the attribute |
| | | // value. |
| | | // Skip over any spaces that might be after the attribute |
| | | // value. |
| | | // Skip over any spaces that might be after the attribute value. |
| | | // Skip over any spaces that might be after the attribute value. |
| | | b = ' '; |
| | | while (dnReader.remaining() > 0 && |
| | | (b = dnReader.get()) == ' ') |
| | |
| | | rdnComponents.add(rdn); |
| | | return new DN(rdnComponents); |
| | | } |
| | | else if ((b == ',') || (b == ';')) |
| | | else if (b == ',' || b == ';') |
| | | { |
| | | // We're at the end of the RDN component, so add it to the |
| | | // list, skip over the comma/semicolon, and start on the |
| | |
| | | } |
| | | |
| | | |
| | | // Skip over any spaces between the attribute name and its |
| | | // value. |
| | | // Skip over any spaces between the attribute name and its value. |
| | | c = dnString.charAt(pos); |
| | | while (c == ' ') |
| | | { |
| | |
| | | throw new DirectoryException(ResultCode.INVALID_DN_SYNTAX, |
| | | ERR_ATTR_SYNTAX_DN_END_WITH_ATTR_NAME.get(dnString, attributeName)); |
| | | } |
| | | else |
| | | { |
| | | c = dnString.charAt(pos); |
| | | } |
| | | c = dnString.charAt(pos); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | |
| | | // Skip over any spaces after the equal sign. |
| | | while ((pos < length) && ((c = dnString.charAt(pos)) == ' ')) |
| | | while (pos < length && ((c = dnString.charAt(pos)) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | |
| | | |
| | | // Skip over any spaces that might be after the attribute value. |
| | | while ((pos < length) && ((c = dnString.charAt(pos)) == ' ')) |
| | | while (pos < length && ((c = dnString.charAt(pos)) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | rdnComponents.add(rdn); |
| | | return new DN(rdnComponents); |
| | | } |
| | | else if ((c == ',') || (c == ';')) |
| | | else if (c == ',' || c == ';') |
| | | { |
| | | // We're at the end of the RDN component, so add it to the |
| | | // list, skip over the comma/semicolon, and start on the next |
| | |
| | | // Skip over the plus sign and any spaces that may follow it |
| | | // before the next attribute name. |
| | | pos++; |
| | | while ((pos < length) && (dnString.charAt(pos) == ' ')) |
| | | while (pos < length && dnString.charAt(pos) == ' ') |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | // Skip over any spaces between the attribute name and its |
| | | // value. |
| | | // Skip over any spaces between the attribute name and its value. |
| | | c = dnString.charAt(pos); |
| | | while (c == ' ') |
| | | { |
| | |
| | | throw new DirectoryException(ResultCode.INVALID_DN_SYNTAX, |
| | | ERR_ATTR_SYNTAX_DN_END_WITH_ATTR_NAME.get(dnString, attributeName)); |
| | | } |
| | | else |
| | | { |
| | | c = dnString.charAt(pos); |
| | | } |
| | | c = dnString.charAt(pos); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | |
| | | // Skip over any spaces after the equal sign. |
| | | while ((pos < length) && ((c = dnString.charAt(pos)) == ' ')) |
| | | while (pos < length && ((c = dnString.charAt(pos)) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | rdn.addValue(attrType, name, parsedValue.toByteString()); |
| | | |
| | | |
| | | // Skip over any spaces that might be after the attribute |
| | | // value. |
| | | while ((pos < length) && ((c = dnString.charAt(pos)) == ' ')) |
| | | // Skip over any spaces that might be after the attribute value. |
| | | while (pos < length && ((c = dnString.charAt(pos)) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | rdnComponents.add(rdn); |
| | | return new DN(rdnComponents); |
| | | } |
| | | else if ((c == ',') || (c == ';')) |
| | | else if (c == ',' || c == ';') |
| | | { |
| | | // We're at the end of the RDN component, so add it to the |
| | | // list, skip over the comma/semicolon, and start on the |
| | |
| | | } |
| | | } |
| | | |
| | | while (validOID && (namePos < nameLength)) |
| | | while (validOID && namePos < nameLength) |
| | | { |
| | | byte ch = nameBytes.byteAt(namePos++); |
| | | if (isDigit((char)ch)) |
| | | { |
| | | while (validOID && (namePos < nameLength) && |
| | | while (validOID && namePos < nameLength && |
| | | isDigit((char)nameBytes.byteAt(namePos))) |
| | | { |
| | | namePos++; |
| | | } |
| | | |
| | | if ((namePos < nameLength) && |
| | | (nameBytes.byteAt(namePos) != '.')) |
| | | if (namePos < nameLength && nameBytes.byteAt(namePos) != '.') |
| | | { |
| | | validOID = false; |
| | | } |
| | | } |
| | | else if (ch == '.') |
| | | { |
| | | if ((namePos == 1) || |
| | | (nameBytes.byteAt(namePos-2) == '.')) |
| | | if (namePos == 1 || nameBytes.byteAt(namePos-2) == '.') |
| | | { |
| | | validOID = false; |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | if (validOID && (nameBytes.byteAt(nameLength-1) == '.')) |
| | | if (validOID && nameBytes.byteAt(nameLength-1) == '.') |
| | | { |
| | | validOID = false; |
| | | } |
| | | |
| | | |
| | | if (! validOID) |
| | | if (!validOID) |
| | | { |
| | | throw new DirectoryException(ResultCode.INVALID_DN_SYNTAX, |
| | | ERR_ATTR_SYNTAX_DN_ATTR_ILLEGAL_PERIOD.get(dnBytes, nameBytes)); |
| | | } |
| | | } |
| | | else if (isDigit((char)nameBytes.byteAt(0)) && (!allowExceptions)) |
| | | else if (isDigit((char)nameBytes.byteAt(0)) && !allowExceptions) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_DN_ATTR_ILLEGAL_INITIAL_DIGIT. |
| | | get(dnBytes, ((char)nameBytes.byteAt(0)), |
| | | get(dnBytes, (char)nameBytes.byteAt(0), |
| | | ATTR_ALLOW_ATTRIBUTE_NAME_EXCEPTIONS); |
| | | throw new DirectoryException(ResultCode.INVALID_DN_SYNTAX, message); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | while (validOID && (namePos < nameLength)) |
| | | while (validOID && namePos < nameLength) |
| | | { |
| | | char ch = attributeName.charAt(namePos++); |
| | | if (isDigit(ch)) |
| | | { |
| | | while (validOID && (namePos < nameLength) && |
| | | while (validOID && namePos < nameLength && |
| | | isDigit(attributeName.charAt(namePos))) |
| | | { |
| | | namePos++; |
| | | } |
| | | |
| | | if ((namePos < nameLength) && |
| | | (attributeName.charAt(namePos) != '.')) |
| | | if (namePos < nameLength && attributeName.charAt(namePos) != '.') |
| | | { |
| | | validOID = false; |
| | | } |
| | | } |
| | | else if (ch == '.') |
| | | { |
| | | if ((namePos == 1) || |
| | | (attributeName.charAt(namePos-2) == '.')) |
| | | if (namePos == 1 || attributeName.charAt(namePos-2) == '.') |
| | | { |
| | | validOID = false; |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | if (validOID && (attributeName.charAt(nameLength-1) == '.')) |
| | | if (validOID && attributeName.charAt(nameLength-1) == '.') |
| | | { |
| | | validOID = false; |
| | | } |
| | |
| | | ERR_ATTR_SYNTAX_DN_ATTR_ILLEGAL_PERIOD.get(dnString, attributeName)); |
| | | } |
| | | } |
| | | else if (isDigit(attributeName.charAt(0)) && |
| | | (! allowExceptions)) |
| | | else if (isDigit(attributeName.charAt(0)) && !allowExceptions) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_DN_ATTR_ILLEGAL_INITIAL_DIGIT. |
| | | get(dnString, attributeName.charAt(0), |
| | |
| | | ERR_ATTR_SYNTAX_DN_HEX_VALUE_TOO_SHORT.get(dnBytes)); |
| | | } |
| | | } |
| | | else if ((b == ' ') || (b == ',') || (b == ';') || (b == '+')) |
| | | else if (b == ' ' || b == ',' || b == ';' || b == '+') |
| | | { |
| | | // This denotes the end of the value. |
| | | dnBytes.skip(-1); |
| | |
| | | { |
| | | if (dnBytes.remaining() <= 0) |
| | | { |
| | | // This is the end of the DN and therefore the end of the |
| | | // value. |
| | | // This is the end of the DN and therefore the end of the value. |
| | | break; |
| | | } |
| | | |
| | | b = dnBytes.get(); |
| | | if ((b == ',') || (b == ';') || (b == '+')) |
| | | if (b == ',' || b == ';' || b == '+') |
| | | { |
| | | dnBytes.skip(-1); |
| | | break; |
| | |
| | | { |
| | | // The first two characters must be hex characters. |
| | | StringBuilder hexString = new StringBuilder(); |
| | | if ((pos+2) > length) |
| | | if (pos+2 > length) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_DN_HEX_VALUE_TOO_SHORT.get(dnString); |
| | |
| | | message); |
| | | } |
| | | } |
| | | else if ((c == ' ') || (c == ',') || (c == ';')) |
| | | else if (c == ' ' || c == ',' || c == ';') |
| | | { |
| | | // This denotes the end of the value. |
| | | pos--; |
| | |
| | | } |
| | | else |
| | | { |
| | | // This is just a regular character that should be in the |
| | | // value. |
| | | // This is just a regular character that should be in the value. |
| | | valueString.append(c); |
| | | } |
| | | } |
| | |
| | | // containing one or more multi-byte UTF-8 characters so |
| | | // we can't just treat this byte in isolation. Collect |
| | | // all the bytes together and make sure to take care of |
| | | // these hex bytes before appending anything else to the |
| | | // value. |
| | | // these hex bytes before appending anything else to the value. |
| | | if (pos >= length) |
| | | { |
| | | LocalizableMessage message = |
| | |
| | | { |
| | | escaped = true; |
| | | } |
| | | else if ((c == ',') || (c == ';')) |
| | | else if (c == ',' || c == ';') |
| | | { |
| | | appendHexChars(dnString, valueString, hexChars); |
| | | pos--; |
| | |
| | | } |
| | | |
| | | |
| | | // Strip off any unescaped spaces that may be at the end of the |
| | | // value. |
| | | // Strip off any unescaped spaces that may be at the end of the value. |
| | | if (pos > 2 && dnString.charAt(pos-1) == ' ' && |
| | | dnString.charAt(pos-2) != '\\') |
| | | { |
| | |
| | | else |
| | | { |
| | | ditContentRule = DirectoryServer.getDITContentRule(structuralClass); |
| | | if ((ditContentRule != null) && ditContentRule.isObsolete()) |
| | | if (ditContentRule != null && ditContentRule.isObsolete()) |
| | | { |
| | | ditContentRule = null; |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | if (validateStructureRules && (nameForm != null)) |
| | | if (validateStructureRules && nameForm != null) |
| | | { |
| | | ditStructureRule = DirectoryServer.getDITStructureRule(nameForm); |
| | | if ((ditStructureRule != null) && ditStructureRule.isObsolete()) |
| | | if (ditStructureRule != null && ditStructureRule.isObsolete()) |
| | | { |
| | | ditStructureRule = null; |
| | | } |
| | |
| | | return false; |
| | | } |
| | | |
| | | if ((o.getObjectClassType() == ObjectClassType.AUXILIARY) && |
| | | (ditContentRule != null) && |
| | | (! ditContentRule.getAuxiliaryClasses().contains(o))) |
| | | if (o.getObjectClassType() == ObjectClassType.AUXILIARY |
| | | && ditContentRule != null && !ditContentRule.getAuxiliaryClasses().contains(o)) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_ENTRY_SCHEMA_DISALLOWED_AUXILIARY_CLASS.get( |
| | |
| | | invalidReason.append(ERR_ENTRY_SCHEMA_ATTR_NO_VALUES.get(dn, t.getNameOrOID())); |
| | | return false; |
| | | } |
| | | else if (t.isSingleValue() && (a.size() != 1)) |
| | | else if (t.isSingleValue() && a.size() != 1) |
| | | { |
| | | invalidReason.append(ERR_ENTRY_SCHEMA_ATTR_SINGLE_VALUED.get(dn, t.getNameOrOID())); |
| | | return false; |
| | |
| | | */ |
| | | public boolean isOwnerReadable() |
| | | { |
| | | return ((encodedPermission & OWNER_READABLE) == OWNER_READABLE); |
| | | return is(encodedPermission, OWNER_READABLE); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | public boolean isOwnerWritable() |
| | | { |
| | | return ((encodedPermission & OWNER_WRITABLE) == OWNER_WRITABLE); |
| | | return is(encodedPermission, OWNER_WRITABLE); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | public boolean isOwnerExecutable() |
| | | { |
| | | return ((encodedPermission & OWNER_EXECUTABLE) == |
| | | OWNER_EXECUTABLE); |
| | | return is(encodedPermission, OWNER_EXECUTABLE); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | public boolean isGroupReadable() |
| | | { |
| | | return ((encodedPermission & GROUP_READABLE) == GROUP_READABLE); |
| | | return is(encodedPermission, GROUP_READABLE); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | public boolean isGroupWritable() |
| | | { |
| | | return ((encodedPermission & GROUP_WRITABLE) == GROUP_WRITABLE); |
| | | return is(encodedPermission, GROUP_WRITABLE); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | public boolean isGroupExecutable() |
| | | { |
| | | return ((encodedPermission & GROUP_EXECUTABLE) == |
| | | GROUP_EXECUTABLE); |
| | | return is(encodedPermission, GROUP_EXECUTABLE); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | public boolean isOtherReadable() |
| | | { |
| | | return ((encodedPermission & OTHER_READABLE) == OTHER_READABLE); |
| | | return is(encodedPermission, OTHER_READABLE); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | public boolean isOtherWritable() |
| | | { |
| | | return ((encodedPermission & OTHER_WRITABLE) == OTHER_WRITABLE); |
| | | return is(encodedPermission, OTHER_WRITABLE); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | public boolean isOtherExecutable() |
| | | { |
| | | return ((encodedPermission & OTHER_EXECUTABLE) == |
| | | OTHER_EXECUTABLE); |
| | | return is(encodedPermission, OTHER_EXECUTABLE); |
| | | } |
| | | |
| | | |
| | | private boolean is(int encodedPermissions, int permission) |
| | | { |
| | | return (encodedPermissions & permission) == permission; |
| | | } |
| | | |
| | | /** |
| | | * Attempts to set the given permissions on the specified file. If |
| | |
| | | public static FilePermission decodeUNIXMode(String modeString) |
| | | throws DirectoryException |
| | | { |
| | | if ((modeString == null) || (modeString.length() != 3)) |
| | | if (modeString == null || modeString.length() != 3) |
| | | { |
| | | LocalizableMessage message = ERR_FILEPERM_INVALID_UNIX_MODE_STRING.get(modeString); |
| | | throw new DirectoryException(ResultCode.OTHER, message); |
| | |
| | | buffer.append(name); |
| | | buffer.append('('); |
| | | |
| | | if ((arguments != null) && (arguments.length > 0)) |
| | | if (arguments != null && arguments.length > 0) |
| | | { |
| | | buffer.append(arguments[0].getDataType()); |
| | | buffer.append(' '); |
| | |
| | | this.definition = definition; |
| | | } |
| | | |
| | | if ((extraProperties == null) || extraProperties.isEmpty()) |
| | | if (extraProperties == null || extraProperties.isEmpty()) |
| | | { |
| | | this.extraProperties = new LinkedHashMap<>(0); |
| | | } |
| | |
| | | { |
| | | ifNull(name); |
| | | |
| | | if ((values == null) || values.isEmpty()) |
| | | if (values == null || values.isEmpty()) |
| | | { |
| | | extraProperties.remove(name); |
| | | } |
| | |
| | | this.scheme = toLowerCase(scheme); |
| | | } |
| | | |
| | | if ((port <= 0) || (port > 65535)) |
| | | { |
| | | this.port = DEFAULT_PORT; |
| | | } |
| | | else |
| | | { |
| | | this.port = port; |
| | | } |
| | | this.port = toPort(port); |
| | | |
| | | if (rawBaseDN == null) |
| | | { |
| | |
| | | this.scheme = toLowerCase(scheme); |
| | | } |
| | | |
| | | if ((port <= 0) || (port > 65535)) |
| | | { |
| | | this.port = DEFAULT_PORT; |
| | | } |
| | | else |
| | | { |
| | | this.port = port; |
| | | } |
| | | this.port = toPort(port); |
| | | |
| | | if (baseDN == null) |
| | | { |
| | |
| | | */ |
| | | public void setPort(int port) |
| | | { |
| | | if ((port <= 0) || (port > 65535)) |
| | | { |
| | | this.port = DEFAULT_PORT; |
| | | } |
| | | else |
| | | { |
| | | this.port = port; |
| | | } |
| | | this.port = toPort(port); |
| | | } |
| | | |
| | | |
| | | private int toPort(int port) |
| | | { |
| | | if (0 < port && port <= 65535) |
| | | { |
| | | return port; |
| | | } |
| | | return DEFAULT_PORT; |
| | | } |
| | | |
| | | /** |
| | | * Retrieve the raw, unprocessed base DN for this LDAP URL. |
| | |
| | | { |
| | | if (baseDN == null) |
| | | { |
| | | if ((rawBaseDN == null) || (rawBaseDN.length() == 0)) |
| | | if (rawBaseDN == null || rawBaseDN.length() == 0) |
| | | { |
| | | return DEFAULT_BASE_DN; |
| | | } |
| | |
| | | this.definition = definition; |
| | | } |
| | | |
| | | if ((names == null) || names.isEmpty()) |
| | | if (names == null || names.isEmpty()) |
| | | { |
| | | this.names = new LinkedHashMap<>(0); |
| | | } |
| | |
| | | this.names = new LinkedHashMap<>(names); |
| | | } |
| | | |
| | | if ((attributes == null) || attributes.isEmpty()) |
| | | if (attributes == null || attributes.isEmpty()) |
| | | { |
| | | this.attributes = new LinkedHashSet<>(0); |
| | | } |
| | |
| | | this.attributes = new LinkedHashSet<>(attributes); |
| | | } |
| | | |
| | | if ((extraProperties == null) || extraProperties.isEmpty()) |
| | | if (extraProperties == null || extraProperties.isEmpty()) |
| | | { |
| | | this.extraProperties = new LinkedHashMap<>(0); |
| | | } |
| | |
| | | this.definition = definition; |
| | | } |
| | | |
| | | if ((names == null) || names.isEmpty()) |
| | | if (names == null || names.isEmpty()) |
| | | { |
| | | this.names = new LinkedHashMap<>(0); |
| | | } |
| | |
| | | this.names = new LinkedHashMap<>(names); |
| | | } |
| | | |
| | | if ((requiredAttributes == null) || requiredAttributes.isEmpty()) |
| | | if (requiredAttributes == null || requiredAttributes.isEmpty()) |
| | | { |
| | | this.requiredAttributes = new LinkedHashSet<>(0); |
| | | } |
| | |
| | | this.requiredAttributes = new LinkedHashSet<>(requiredAttributes); |
| | | } |
| | | |
| | | if ((optionalAttributes == null) || optionalAttributes.isEmpty()) |
| | | if (optionalAttributes == null || optionalAttributes.isEmpty()) |
| | | { |
| | | this.optionalAttributes = new LinkedHashSet<>(0); |
| | | } |
| | |
| | | this.optionalAttributes = new LinkedHashSet<>(optionalAttributes); |
| | | } |
| | | |
| | | if ((extraProperties == null) || extraProperties.isEmpty()) |
| | | if (extraProperties == null || extraProperties.isEmpty()) |
| | | { |
| | | this.extraProperties = new LinkedHashMap<>(0); |
| | | } |
| | |
| | | */ |
| | | public boolean isRequiredOrOptional(AttributeType attributeType) |
| | | { |
| | | return (requiredAttributes.contains(attributeType) || |
| | | optionalAttributes.contains(attributeType)); |
| | | return requiredAttributes.contains(attributeType) || |
| | | optionalAttributes.contains(attributeType); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | random = new Random(); |
| | | |
| | | if ((name == null) || (name.length() == 0)) |
| | | if (name == null || name.length() == 0) |
| | | { |
| | | LocalizableMessage message = ERR_CHARSET_CONSTRUCTOR_NO_NAME.get(); |
| | | throw new ConfigException(message); |
| | |
| | | this.characters = characters; |
| | | this.random = random; |
| | | |
| | | if ((name == null) || (name.length() == 0)) |
| | | if (name == null || name.length() == 0) |
| | | { |
| | | LocalizableMessage message = ERR_CHARSET_CONSTRUCTOR_NO_NAME.get(); |
| | | throw new ConfigException(message); |
| | |
| | | */ |
| | | public char getRandomCharacter() |
| | | { |
| | | if ((characters == null) || (characters.length == 0)) |
| | | if (characters == null || characters.length == 0) |
| | | { |
| | | return 0; |
| | | } |
| | |
| | | */ |
| | | public void getRandomCharacters(StringBuilder buffer, int count) |
| | | { |
| | | if ((characters == null) || (characters.length == 0)) |
| | | if (characters == null || characters.length == 0) |
| | | { |
| | | return; |
| | | } |
| | |
| | | |
| | | // FIXME -- Do we need to do any other checks here, like whether |
| | | // the attribute type is actually defined in the schema? |
| | | return (isExtensibleObject || |
| | | requiredAndOptionalChain.contains(attributeType)); |
| | | return isExtensibleObject || requiredAndOptionalChain.contains(attributeType); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | needsEscaping: { |
| | | char c = value.charAt(0); |
| | | if ((c == ' ') || (c == '#')) { |
| | | if (c == ' ' || c == '#') { |
| | | needsEscaping = true; |
| | | break needsEscaping; |
| | | } |
| | |
| | | // If the lead character is a space or a # it must be escaped. |
| | | int start = 0; |
| | | char c = value.charAt(0); |
| | | if ((c == ' ') || (c == '#')) { |
| | | if (c == ' ' || c == '#') { |
| | | buffer.append('\\'); |
| | | buffer.append(c); |
| | | start = 1; |
| | |
| | | |
| | | |
| | | // Skip over any spaces between the equal sign and the value. |
| | | while ((pos < length) && ((c = rdnString.charAt(pos)) == ' ')) |
| | | while (pos < length && ((c = rdnString.charAt(pos)) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | |
| | | |
| | | // Skip over any spaces that might be after the attribute value. |
| | | while ((pos < length) && ((c = rdnString.charAt(pos)) == ' ')) |
| | | while (pos < length && ((c = rdnString.charAt(pos)) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | |
| | | // If the next character is a comma or semicolon, then that is not |
| | | // allowed. It would be legal for a DN but not an RDN. |
| | | if ((c == ',') || (c == ';')) |
| | | if (c == ',' || c == ';') |
| | | { |
| | | LocalizableMessage message = ERR_RDN_UNEXPECTED_COMMA.get(rdnString, pos); |
| | | throw new DirectoryException(ResultCode.INVALID_DN_SYNTAX, message); |
| | |
| | | // Skip over the plus sign and any spaces that may follow it |
| | | // before the next attribute name. |
| | | pos++; |
| | | while ((pos < length) && ((c = rdnString.charAt(pos)) == ' ')) |
| | | while (pos < length && ((c = rdnString.charAt(pos)) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | |
| | | |
| | | // Skip over any spaces after the equal sign. |
| | | while ((pos < length) && ((c = rdnString.charAt(pos)) == ' ')) |
| | | while (pos < length && ((c = rdnString.charAt(pos)) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | |
| | | |
| | | // Skip over any spaces that might be after the attribute value. |
| | | while ((pos < length) && ((c = rdnString.charAt(pos)) == ' ')) |
| | | while (pos < length && ((c = rdnString.charAt(pos)) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | |
| | | // If the next character is a comma or semicolon, then that is |
| | | // not allowed. It would be legal for a DN but not an RDN. |
| | | if ((c == ',') || (c == ';')) |
| | | if (c == ',' || c == ';') |
| | | { |
| | | LocalizableMessage message = ERR_RDN_UNEXPECTED_COMMA.get(rdnString, pos); |
| | | throw new DirectoryException(ResultCode.INVALID_DN_SYNTAX, message); |
| | |
| | | |
| | | stream.writeStartSet(); |
| | | List<ByteString> values = getValues(); |
| | | if ((values != null)) |
| | | if (values != null) |
| | | { |
| | | for(ByteString value : values) |
| | | { |
| | |
| | | } |
| | | |
| | | ArrayList<ByteString> subAnyElements = getSubAnyElements(); |
| | | if ((subAnyElements != null) && (! subAnyElements.isEmpty())) |
| | | if (subAnyElements != null && !subAnyElements.isEmpty()) |
| | | { |
| | | for (ByteString s : subAnyElements) |
| | | { |
| | |
| | | |
| | | for (AttributeType at : attributeTypes.values()) |
| | | { |
| | | if ((at.getSuperiorType() != null) && |
| | | at.getSuperiorType().equals(t)) |
| | | if (at.getSuperiorType() != null && at.getSuperiorType().equals(t)) |
| | | { |
| | | AttributeType newAT = recreateFromDefinition(at); |
| | | deregisterAttributeType(at); |
| | |
| | | { |
| | | break; |
| | | } |
| | | else if (line.startsWith("#") || (line.length() == 0)) |
| | | else if (line.startsWith("#") || line.length() == 0) |
| | | { |
| | | continue; |
| | | } |
| | |
| | | boolean dnAttributes) |
| | | throws DirectoryException |
| | | { |
| | | if ((attributeType == null) && (matchingRuleID == null)) |
| | | if (attributeType == null && matchingRuleID == null) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_SEARCH_FILTER_CREATE_EXTENSIBLE_MATCH_NO_AT_OR_MR.get(); |
| | |
| | | boolean dnAttributes) |
| | | throws DirectoryException |
| | | { |
| | | if ((attributeType == null) && (matchingRuleID == null)) |
| | | if (attributeType == null && matchingRuleID == null) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_SEARCH_FILTER_CREATE_EXTENSIBLE_MATCH_NO_AT_OR_MR.get(); |
| | |
| | | { |
| | | // The next two bytes must be the hex characters that |
| | | // comprise the binary value. |
| | | if ((i + 2) >= valueBytes.length) |
| | | if (i + 2 >= valueBytes.length) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_SEARCH_FILTER_INVALID_ESCAPED_BYTE. |
| | |
| | | |
| | | // The first and last characters must be parentheses. If not, |
| | | // then that's an error. |
| | | if ((filterString.charAt(startPos) != '(') || |
| | | (filterString.charAt(endPos-1) != ')')) |
| | | if (filterString.charAt(startPos) != '(' || |
| | | filterString.charAt(endPos-1) != ')') |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_SEARCH_FILTER_COMPOUND_MISSING_PARENTHESES. |
| | |
| | | { |
| | | // The next two bytes must be the hex characters that |
| | | // comprise the binary value. |
| | | if ((i + 2) >= valueBytes.length) |
| | | if (i + 2 >= valueBytes.length) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_SEARCH_FILTER_INVALID_ESCAPED_BYTE. |
| | |
| | | { |
| | | // The next two bytes must be the hex characters that |
| | | // comprise the binary value. |
| | | if ((i + 2) >= valueBytes.length) |
| | | if (i + 2 >= valueBytes.length) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_SEARCH_FILTER_INVALID_ESCAPED_BYTE. |
| | |
| | | { |
| | | // The next two bytes must be the hex characters that |
| | | // comprise the binary value. |
| | | if ((i + 2) >= valueBytes.length) |
| | | if (i + 2 >= valueBytes.length) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_SEARCH_FILTER_INVALID_ESCAPED_BYTE. |
| | |
| | | |
| | | // If there is anything left, then it should be ":dn" and/or ":" |
| | | // followed by the matching rule ID. |
| | | if (colonPos < (equalPos-1)) |
| | | if (colonPos < equalPos-1) |
| | | { |
| | | if (lowerLeftStr.startsWith(":dn:", colonPos)) |
| | | { |
| | | dnAttributes = true; |
| | | |
| | | if ((colonPos+4) < (equalPos-1)) |
| | | if (colonPos+4 < equalPos-1) |
| | | { |
| | | matchingRuleID = |
| | | filterString.substring(colonPos+4, equalPos-1); |
| | |
| | | { |
| | | // The next two bytes must be the hex characters that |
| | | // comprise the binary value. |
| | | if ((i + 2) >= valueBytes.length) |
| | | if (i + 2 >= valueBytes.length) |
| | | { |
| | | LocalizableMessage message = ERR_SEARCH_FILTER_INVALID_ESCAPED_BYTE. |
| | | get(filterString, equalPos+i+1); |
| | |
| | | // See if the entry has an attribute with the requested type. |
| | | List<Attribute> attrs = entry.getAttribute(attributeType, |
| | | attributeOptions); |
| | | if ((attrs == null) || (attrs.isEmpty())) |
| | | if (attrs == null || attrs.isEmpty()) |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | |
| | | throw new DirectoryException(ResultCode.PROTOCOL_ERROR, message); |
| | | } |
| | | |
| | | // Make sure that at least one substring element has been |
| | | // defined. |
| | | if ((subInitialElement == null) && |
| | | (subFinalElement == null) && |
| | | ((subAnyElements == null) || subAnyElements.isEmpty())) |
| | | // Make sure that at least one substring element has been defined. |
| | | if (subInitialElement == null && |
| | | subFinalElement == null && |
| | | (subAnyElements == null || subAnyElements.isEmpty())) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_SEARCH_FILTER_SUBSTRING_NO_SUBSTRING_COMPONENTS. |
| | |
| | | } |
| | | |
| | | // See if the entry has an attribute with the requested type. |
| | | List<Attribute> attrs = |
| | | entry.getAttribute(attributeType, attributeOptions); |
| | | if ((attrs == null) || (attrs.isEmpty())) |
| | | List<Attribute> attrs = entry.getAttribute(attributeType, attributeOptions); |
| | | if (attrs == null || attrs.isEmpty()) |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | |
| | | } |
| | | |
| | | // See if the entry has an attribute with the requested type. |
| | | List<Attribute> attrs = |
| | | entry.getAttribute(attributeType, attributeOptions); |
| | | if ((attrs == null) || (attrs.isEmpty())) |
| | | List<Attribute> attrs = entry.getAttribute(attributeType, attributeOptions); |
| | | if (attrs == null || attrs.isEmpty()) |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | |
| | | // See if the entry has an attribute with the requested type. |
| | | List<Attribute> attrs = |
| | | entry.getAttribute(attributeType, attributeOptions); |
| | | if ((attrs == null) || (attrs.isEmpty())) |
| | | if (attrs == null || attrs.isEmpty()) |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | |
| | | // See if the entry has an attribute with the requested type. |
| | | List<Attribute> attrs = |
| | | entry.getAttribute(attributeType, attributeOptions); |
| | | if ((attrs == null) || (attrs.isEmpty())) |
| | | if (attrs == null || attrs.isEmpty()) |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | |
| | | { |
| | | try |
| | | { |
| | | if ((attributeType == null) || |
| | | attributeType.equals(rdn.getAttributeType(i))) |
| | | if (attributeType == null || attributeType.equals(rdn.getAttributeType(i))) |
| | | { |
| | | ByteString v = rdn.getAttributeValue(i); |
| | | ByteString nv = matchingRule.normalizeAttributeValue(v); |
| | |
| | | case LESS_OR_EQUAL: |
| | | return typeAndOptionsAndAssertionEqual(f); |
| | | case PRESENT: |
| | | return (attributeType.equals(f.attributeType) && |
| | | optionsEqual(attributeOptions, f.attributeOptions)); |
| | | return attributeType.equals(f.attributeType) && |
| | | optionsEqual(attributeOptions, f.attributeOptions); |
| | | case APPROXIMATE_MATCH: |
| | | return typeAndOptionsAndAssertionEqual(f); |
| | | case EXTENSIBLE_MATCH: |
| | |
| | | private static boolean optionsEqual(Set<String> options1, |
| | | Set<String> options2) |
| | | { |
| | | if ((options1 == null) || options1.isEmpty()) |
| | | if (options1 == null || options1.isEmpty()) |
| | | { |
| | | return ((options2 == null) || options2.isEmpty()); |
| | | return options2 == null || options2.isEmpty(); |
| | | } |
| | | else if ((options2 == null) || options2.isEmpty()) |
| | | else if (options2 == null || options2.isEmpty()) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | valueToFilterString(buffer, subInitialElement); |
| | | } |
| | | |
| | | if ((subAnyElements != null) && (! subAnyElements.isEmpty())) |
| | | if (subAnyElements != null && !subAnyElements.isEmpty()) |
| | | { |
| | | for (ByteString s : subAnyElements) |
| | | { |
| | |
| | | */ |
| | | public String getReferralURLString() |
| | | { |
| | | if ((referralURLs == null) || (referralURLs.isEmpty())) |
| | | if (referralURLs == null || referralURLs.isEmpty()) |
| | | { |
| | | return ""; |
| | | } |
| | |
| | | { |
| | | List<Attribute> attrList = entry.getAttribute( |
| | | ATTR_INHERIT_COLLECTIVE_FROM_DN); |
| | | if ((attrList != null) && !attrList.isEmpty()) |
| | | if (attrList != null && !attrList.isEmpty()) |
| | | { |
| | | for (Attribute attr : attrList) |
| | | { |
| | |
| | | if (this.isInheritedFromRDNCollective) |
| | | { |
| | | List<Attribute> attrList = entry.getAttribute(ATTR_INHERIT_COLLECTIVE_FROM_RDN); |
| | | if ((attrList != null) && !attrList.isEmpty()) |
| | | if (attrList != null && !attrList.isEmpty()) |
| | | { |
| | | for (Attribute attr : attrList) |
| | | { |
| | |
| | | } |
| | | } |
| | | attrList = entry.getAttribute(ATTR_INHERIT_COLLECTIVE_FROM_RDN_TYPE); |
| | | if ((attrList != null) && !attrList.isEmpty()) |
| | | if (attrList != null && !attrList.isEmpty()) |
| | | { |
| | | for (Attribute attr : attrList) |
| | | { |
| | |
| | | } |
| | | } |
| | | attrList = entry.getAttribute(ATTR_INHERIT_COLLECTIVE_FROM_BASE); |
| | | if ((attrList != null) && !attrList.isEmpty()) |
| | | if (attrList != null && !attrList.isEmpty()) |
| | | { |
| | | for (Attribute attr : attrList) |
| | | { |
| | |
| | | |
| | | List<Attribute> attrList = entry.getAttribute( |
| | | ATTR_INHERIT_COLLECTIVE_ATTR); |
| | | if ((attrList != null) && !attrList.isEmpty()) |
| | | if (attrList != null && !attrList.isEmpty()) |
| | | { |
| | | for (Attribute attr : attrList) |
| | | { |
| | |
| | | { |
| | | List<Attribute> attrList = entry.getAttribute( |
| | | ATTR_COLLECTIVE_CONFLICT_BEHAVIOR); |
| | | if ((attrList != null) && !attrList.isEmpty()) |
| | | if (attrList != null && !attrList.isEmpty()) |
| | | { |
| | | for (Attribute attr : attrList) |
| | | { |
| | |
| | | { |
| | | for (final Refinement refinement : refinementSet) |
| | | { |
| | | if (refinement.matches(entry) == false) |
| | | if (!refinement.matches(entry)) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | { |
| | | for (final Refinement refinement : refinementSet) |
| | | { |
| | | if (refinement.matches(entry) == true) |
| | | if (refinement.matches(entry)) |
| | | { |
| | | return true; |
| | | } |
| | |
| | | final Iterable<DN> chopBefore = getChopBefore(); |
| | | final Iterable<DN> chopAfter = getChopAfter(); |
| | | |
| | | if ((chopBefore.iterator().hasNext()) |
| | | || (chopAfter.iterator().hasNext())) |
| | | if (chopBefore.iterator().hasNext() |
| | | || chopAfter.iterator().hasNext()) |
| | | { |
| | | if (!isFirstElement) |
| | | { |
| | |
| | | |
| | | while (--length >= 0) |
| | | { |
| | | output.append(itoa64.charAt((value & 0x3f))); |
| | | output.append(itoa64.charAt(value & 0x3f)); |
| | | value >>= 6; |
| | | } |
| | | |
| | |
| | | { |
| | | ctx1.update(digest); |
| | | } |
| | | if ((i % 3) != 0) |
| | | if (i % 3 != 0) |
| | | { |
| | | ctx1.update(salt.getBytes()); |
| | | } |
| | | if ((i % 7) != 0) |
| | | if (i % 7 != 0) |
| | | { |
| | | ctx1.update(plaintextBytes); |
| | | } |
| | |
| | | l = ((digest[4] & 0xff) << 16) | ((digest[10] & 0xff) << 8) |
| | | | (digest[5] & 0xff); |
| | | output.append(intTo64(l, 4)); |
| | | l = (digest[11] & 0xff); |
| | | l = digest[11] & 0xff; |
| | | output.append(intTo64(l, 2)); |
| | | |
| | | /* Don't leave anything around in vm they could use. */ |
| | |
| | | */ |
| | | public static void main(String argv[]) |
| | | { |
| | | if ((argv.length < 1) || (argv.length > 2)) |
| | | if (argv.length < 1 || argv.length > 2) |
| | | { |
| | | System.err.println("Usage: BSDMD5Crypt password salt"); |
| | | System.exit(1); |
| | |
| | | |
| | | // The encoded value must have length that is a multiple of four bytes. |
| | | int length = encodedData.length(); |
| | | if ((length % 4) != 0) |
| | | if (length % 4 != 0) |
| | | { |
| | | LocalizableMessage message = ERR_BASE64_DECODE_INVALID_LENGTH.get(encodedData); |
| | | throw new ParseException(message.toString(), 0); |
| | |
| | | } |
| | | } else { |
| | | final File keyStoreDirectory = keyStoreFile.getParentFile(); |
| | | if ((keyStoreDirectory == null) || (! keyStoreDirectory.exists()) || |
| | | (! keyStoreDirectory.isDirectory())) { |
| | | if (keyStoreDirectory == null || !keyStoreDirectory.exists() || !keyStoreDirectory.isDirectory()) { |
| | | LocalizableMessage msg = ERR_CERTMGR_INVALID_PARENT.get(keyStorePath); |
| | | throw new IllegalArgumentException(msg.toString()); |
| | | } |
| | |
| | | throws KeyStoreException, IllegalArgumentException { |
| | | ensureValid(alias, CERT_ALIAS_MSG); |
| | | ensureFileValid(certificateFile, CERT_REQUEST_FILE_MSG); |
| | | if ((! certificateFile.exists()) || |
| | | (! certificateFile.isFile())) { |
| | | if (!certificateFile.exists() || !certificateFile.isFile()) { |
| | | LocalizableMessage msg = ERR_CERTMGR_INVALID_CERT_FILE.get( |
| | | certificateFile.getAbsolutePath()); |
| | | throw new IllegalArgumentException(msg.toString()); |
| | |
| | | { |
| | | _c._iobuf[1] = _c._iobuf[0]; |
| | | } |
| | | return (_c._iobuf); |
| | | return _c._iobuf; |
| | | } |
| | | } |
| | |
| | | // This is a comment. Ignore it. |
| | | continue; |
| | | } |
| | | else if ((line.charAt(0) == ' ') || (line.charAt(0) == '\t')) |
| | | else if (line.charAt(0) == ' ' || line.charAt(0) == '\t') |
| | | { |
| | | // This is a continuation of the previous line. If there is no |
| | | // previous line, then that's a problem. Note that while RFC 2849 |
| | |
| | | { |
| | | final int length = line.length(); |
| | | int pos = startPos; |
| | | while ((pos < length) && (line.charAt(pos) == ' ')) |
| | | while (pos < length && line.charAt(pos) == ' ') |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | throw new LDIFException(message, lastEntryLineNumber,true); |
| | | } |
| | | if (checkSchema && |
| | | (DirectoryServer.getSyntaxEnforcementPolicy() != |
| | | AcceptRejectWarn.ACCEPT)) |
| | | DirectoryServer.getSyntaxEnforcementPolicy() != AcceptRejectWarn.ACCEPT) |
| | | { |
| | | LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder(); |
| | | if (! attrType.getSyntax().valueIsAcceptable(value, invalidReason)) |
| | | { |
| | | LocalizableMessage message = WARN_LDIF_VALUE_VIOLATES_SYNTAX.get( |
| | | entryDN, lastEntryLineNumber, value, attrName, invalidReason); |
| | | if (DirectoryServer.getSyntaxEnforcementPolicy() == |
| | | AcceptRejectWarn.WARN) |
| | | if (DirectoryServer.getSyntaxEnforcementPolicy() == AcceptRejectWarn.WARN) |
| | | { |
| | | logger.error(message); |
| | | } |
| | |
| | | logToRejectWriter(lines, message); |
| | | throw new LDIFException(message, lastEntryLineNumber, true); |
| | | } |
| | | if (attrType.isSingleValue() && (a.size() > 1) && checkSchema) |
| | | if (attrType.isSingleValue() && a.size() > 1 && checkSchema) |
| | | { |
| | | LocalizableMessage message = ERR_LDIF_MULTIPLE_VALUES_FOR_SINGLE_VALUED_ATTR |
| | | .get(entryDN, lastEntryLineNumber, attrName); |
| | |
| | | { |
| | | try |
| | | { |
| | | if ((message != null) && (message.length() > 0)) |
| | | if (message != null && message.length() > 0) |
| | | { |
| | | rejectWriter.write("# "); |
| | | rejectWriter.write(message.toString()); |
| | |
| | | entriesRejected.incrementAndGet(); |
| | | if (rejectWriter != null) { |
| | | try { |
| | | if ((message != null) && (message.length() > 0)) { |
| | | if (message != null && message.length() > 0) { |
| | | rejectWriter.write("# "); |
| | | rejectWriter.write(message.toString()); |
| | | rejectWriter.newLine(); |
| | |
| | | */ |
| | | public static char byteToASCII(byte b) |
| | | { |
| | | if ((b >= 32) && (b <= 126)) |
| | | if (32 <= b && b <= 126) |
| | | { |
| | | return (char) b; |
| | | } |
| | |
| | | */ |
| | | public static String bytesToHexNoSpace(byte[] b) |
| | | { |
| | | if ((b == null) || (b.length == 0)) |
| | | if (b == null || b.length == 0) |
| | | { |
| | | return ""; |
| | | } |
| | |
| | | */ |
| | | public static String bytesToHex(byte[] b) |
| | | { |
| | | if ((b == null) || (b.length == 0)) |
| | | if (b == null || b.length == 0) |
| | | { |
| | | return ""; |
| | | } |
| | |
| | | */ |
| | | public static String bytesToHex(ByteSequence b) |
| | | { |
| | | if ((b == null) || (b.length() == 0)) |
| | | if (b == null || b.length() == 0) |
| | | { |
| | | return ""; |
| | | } |
| | |
| | | */ |
| | | public static String bytesToColonDelimitedHex(byte[] b) |
| | | { |
| | | if ((b == null) || (b.length == 0)) |
| | | if (b == null || b.length == 0) |
| | | { |
| | | return ""; |
| | | } |
| | |
| | | |
| | | int length = b.length; |
| | | int pos = 0; |
| | | while ((length - pos) >= 16) |
| | | while (length - pos >= 16) |
| | | { |
| | | StringBuilder asciiBuf = new StringBuilder(17); |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | int remaining = (length - pos); |
| | | int remaining = length - pos; |
| | | if (remaining > 0) |
| | | { |
| | | StringBuilder asciiBuf = new StringBuilder(remaining+1); |
| | |
| | | int limit = b.limit(); |
| | | int length = limit - position; |
| | | int pos = 0; |
| | | while ((length - pos) >= 16) |
| | | while (length - pos >= 16) |
| | | { |
| | | StringBuilder asciiBuf = new StringBuilder(17); |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | int remaining = (length - pos); |
| | | int remaining = length - pos; |
| | | if (remaining > 0) |
| | | { |
| | | StringBuilder asciiBuf = new StringBuilder(remaining+1); |
| | |
| | | } |
| | | } |
| | | |
| | | return (a.length - a2.length); |
| | | return a.length - a2.length; |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | if (list1 == null) |
| | | { |
| | | return (list2 == null); |
| | | return list2 == null; |
| | | } |
| | | else if (list2 == null) |
| | | { |
| | |
| | | */ |
| | | public static boolean objectsAreEqual(Object o1, Object o2) |
| | | { |
| | | if (o1 == null) |
| | | { |
| | | return (o2 == null); |
| | | } |
| | | else |
| | | { |
| | | return o1.equals(o2); |
| | | } |
| | | return Objects.equals(o1, o2); |
| | | } |
| | | |
| | | |
| | |
| | | message.append(")"); |
| | | return message.toMessage(); |
| | | } |
| | | else if ((t instanceof InvocationTargetException) && |
| | | (t.getCause() != null)) |
| | | else if (t instanceof InvocationTargetException && t.getCause() != null) |
| | | { |
| | | return getExceptionMessage(t.getCause()); |
| | | } |
| | |
| | | throws ParseException |
| | | { |
| | | int length; |
| | | if ((hexString == null) || ((length = hexString.length()) == 0)) |
| | | if (hexString == null || ((length = hexString.length()) == 0)) |
| | | { |
| | | return new byte[0]; |
| | | } |
| | |
| | | |
| | | |
| | | int pos = 0; |
| | | int arrayLength = (length / 2); |
| | | int arrayLength = length / 2; |
| | | byte[] returnArray = new byte[arrayLength]; |
| | | for (int i=0; i < arrayLength; i++) |
| | | { |
| | |
| | | public static boolean needsBase64Encoding(ByteSequence valueBytes) |
| | | { |
| | | int length; |
| | | if ((valueBytes == null) || ((length = valueBytes.length()) == 0)) |
| | | if (valueBytes == null || ((length = valueBytes.length()) == 0)) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | |
| | | |
| | | // If the value ends with a space, then it needs to be base64-encoded. |
| | | if ((length > 1) && (valueBytes.byteAt(length-1) == 0x20)) |
| | | if (length > 1 && valueBytes.byteAt(length-1) == 0x20) |
| | | { |
| | | return true; |
| | | } |
| | |
| | | for (int i = 0; i < valueBytes.length(); i++) |
| | | { |
| | | b = valueBytes.byteAt(i); |
| | | if ((b > 127) || (b < 0)) |
| | | if (b < 0 || 127 < b) |
| | | { |
| | | return true; |
| | | } |
| | |
| | | public static boolean needsBase64Encoding(String valueString) |
| | | { |
| | | int length; |
| | | if ((valueString == null) || ((length = valueString.length()) == 0)) |
| | | if (valueString == null || ((length = valueString.length()) == 0)) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | |
| | | |
| | | // If the value ends with a space, then it needs to be base64-encoded. |
| | | if ((length > 1) && (valueString.charAt(length-1) == ' ')) |
| | | if (length > 1 && valueString.charAt(length-1) == ' ') |
| | | { |
| | | return true; |
| | | } |
| | |
| | | for (int i=0; i < length; i++) |
| | | { |
| | | char c = valueString.charAt(i); |
| | | if ((c <= 0) || (c == 0x0A) || (c == 0x0D) || (c > 127)) |
| | | if (c <= 0 || c == 0x0A || c == 0x0D || c > 127) |
| | | { |
| | | return true; |
| | | } |
| | |
| | | */ |
| | | public static boolean mayUseExec() |
| | | { |
| | | return (! DirectoryServer.getEnvironmentConfig().disableExec()); |
| | | return !DirectoryServer.getEnvironmentConfig().disableExec(); |
| | | } |
| | | |
| | | |
| | |
| | | ProcessBuilder processBuilder = new ProcessBuilder(commandAndArgs); |
| | | processBuilder.redirectErrorStream(true); |
| | | |
| | | if ((workingDirectory != null) && workingDirectory.isDirectory()) |
| | | if (workingDirectory != null && workingDirectory.isDirectory()) |
| | | { |
| | | processBuilder.directory(workingDirectory); |
| | | } |
| | | |
| | | if ((environment != null) && (! environment.isEmpty())) |
| | | if (environment != null && !environment.isEmpty()) |
| | | { |
| | | processBuilder.environment().putAll(environment); |
| | | } |
| | |
| | | int endPos, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | if ((element == null) || (startPos >= endPos)) |
| | | if (element == null || startPos >= endPos) |
| | | { |
| | | invalidReason.append(ERR_SCHEMANAME_EMPTY_VALUE.get()); |
| | | return false; |
| | |
| | | // This should indicate an OID, but it may also be a name if name |
| | | // exceptions are enabled. Since we don't know for sure, we'll just |
| | | // hold off until we know for sure. |
| | | boolean isKnown = (! DirectoryServer.allowAttributeNameExceptions()); |
| | | boolean isKnown = !DirectoryServer.allowAttributeNameExceptions(); |
| | | boolean isNumeric = true; |
| | | boolean lastWasDot = false; |
| | | |
| | |
| | | { |
| | | lastWasDot = false; |
| | | |
| | | if (isAlpha(c) || (c == '-') || (c == '_')) |
| | | if (isAlpha(c) || c == '-' || c == '_') |
| | | { |
| | | if (isKnown) |
| | | { |
| | |
| | | { |
| | | case ' ': |
| | | // If we don't care about trimming, then we can always append the |
| | | // space. Otherwise, only do so if there are other characters in the |
| | | // value. |
| | | if (trim && (bufferLength == 0)) |
| | | // space. Otherwise, only do so if there are other characters in the value. |
| | | if (trim && bufferLength == 0) |
| | | { |
| | | break; |
| | | } |
| | |
| | | { |
| | | case ' ': |
| | | // If we don't care about trimming, then we can always append the |
| | | // space. Otherwise, only do so if there are other characters in the |
| | | // value. |
| | | if (trim && (bufferLength == 0)) |
| | | // space. Otherwise, only do so if there are other characters in the value. |
| | | if (trim && bufferLength == 0) |
| | | { |
| | | break; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | return (successful & file.delete()); |
| | | return successful & file.delete(); |
| | | } |
| | | return false; |
| | | } |
| | |
| | | public static boolean isRelativePath(String path) |
| | | { |
| | | File f = new File(path); |
| | | return (! f.isAbsolute()); |
| | | return !f.isAbsolute(); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | // If the provided DN was null or empty, then return null because we don't |
| | | // support it. |
| | | if ((dn == null) || dn.isRootDN()) |
| | | if (dn == null || dn.isRootDN()) |
| | | { |
| | | return null; |
| | | } |
| | |
| | | |
| | | // First, see if this type is allowed by the untypedObject class. If not, |
| | | // then we'll need to include the extensibleObject class. |
| | | if ((! structuralClass.isRequiredOrOptional(attrType)) && |
| | | (! extensibleObjectAdded)) |
| | | if (!structuralClass.isRequiredOrOptional(attrType) && !extensibleObjectAdded) |
| | | { |
| | | ObjectClass extensibleObjectOC = |
| | | DirectoryServer.getObjectClass(OC_EXTENSIBLE_OBJECT_LC); |
| | |
| | | // fall back |
| | | // to a more inefficient way that will work without a selector. |
| | | while (buffer.hasRemaining() |
| | | && (System.currentTimeMillis() < stopTime)) |
| | | && System.currentTimeMillis() < stopTime) |
| | | { |
| | | if (socketChannel.write(buffer) < 0) |
| | | { |
| | |
| | | |
| | | import static org.opends.messages.CoreMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.types.Privilege.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | |
| | | |
| | | // Update the authentication information for the user. |
| | | AuthenticationInfo authInfo = getAuthenticationInfo(); |
| | | if ((getResultCode() == ResultCode.SUCCESS) && (authInfo != null)) |
| | | if (getResultCode() == ResultCode.SUCCESS && authInfo != null) |
| | | { |
| | | clientConnection.setAuthenticationInfo(authInfo); |
| | | clientConnection.setSizeLimit(sizeLimit); |
| | |
| | | // See if this is an anonymous bind. If so, then determine whether |
| | | // to allow it. |
| | | ByteString simplePassword = getSimplePassword(); |
| | | if ((simplePassword == null) || (simplePassword.length() == 0)) |
| | | if (simplePassword == null || simplePassword.length() == 0) |
| | | { |
| | | return processAnonymousSimpleBind(); |
| | | } |
| | |
| | | |
| | | AttributeType pwType = policy.getPasswordAttribute(); |
| | | List<Attribute> pwAttr = userEntry.getAttribute(pwType); |
| | | if ((pwAttr == null) || (pwAttr.isEmpty())) |
| | | if (pwAttr == null || pwAttr.isEmpty()) |
| | | { |
| | | throw new DirectoryException(ResultCode.INVALID_CREDENTIALS, |
| | | ERR_BIND_OPERATION_NO_PASSWORD.get()); |
| | |
| | | checkVerifiedPasswordPolicyState(userEntry, null); |
| | | |
| | | if (DirectoryServer.lockdownMode() |
| | | && (!ClientConnection.hasPrivilege(userEntry, |
| | | Privilege.BYPASS_LOCKDOWN))) |
| | | && !ClientConnection.hasPrivilege(userEntry, BYPASS_LOCKDOWN)) |
| | | { |
| | | throw new DirectoryException(ResultCode.INVALID_CREDENTIALS, |
| | | ERR_BIND_REJECTED_LOCKDOWN_MODE.get()); |
| | |
| | | setResultCode(ResultCode.SUCCESS); |
| | | |
| | | if (DirectoryServer.lockdownMode() |
| | | && (!ClientConnection.hasPrivilege(userEntry, |
| | | Privilege.BYPASS_LOCKDOWN))) |
| | | && !ClientConnection.hasPrivilege(userEntry, BYPASS_LOCKDOWN)) |
| | | { |
| | | throw new DirectoryException(ResultCode.INVALID_CREDENTIALS, |
| | | ERR_BIND_REJECTED_LOCKDOWN_MODE.get()); |
| | |
| | | if (resultCode != ResultCode.SASL_BIND_IN_PROGRESS |
| | | && (resultCode != ResultCode.SUCCESS |
| | | || saslAuthUserEntry == null |
| | | || !ClientConnection.hasPrivilege(saslAuthUserEntry, Privilege.BYPASS_LOCKDOWN))) |
| | | || !ClientConnection.hasPrivilege(saslAuthUserEntry, BYPASS_LOCKDOWN))) |
| | | { |
| | | throw new DirectoryException(ResultCode.INVALID_CREDENTIALS, |
| | | ERR_BIND_REJECTED_LOCKDOWN_MODE.get()); |
| | |
| | | PasswordPolicyState pwPolicyState = (PasswordPolicyState) authPolicyState; |
| | | PasswordPolicy policy = pwPolicyState.getAuthenticationPolicy(); |
| | | |
| | | boolean isSASLBind = (saslHandler != null); |
| | | boolean isSASLBind = saslHandler != null; |
| | | |
| | | // If the password policy is configured to track authentication failures or |
| | | // keep the last login time and the associated backend is disabled, then we |
| | |
| | | // Check to see if the authentication must be done in a secure |
| | | // manner. If so, then the client connection must be secure. |
| | | if (policy.isRequireSecureAuthentication() |
| | | && (!clientConnection.isSecure())) |
| | | && !clientConnection.isSecure()) |
| | | { |
| | | if (isSASLBind) |
| | | { |
| | |
| | | PasswordPolicyState pwPolicyState = (PasswordPolicyState) authPolicyState; |
| | | PasswordPolicy policy = pwPolicyState.getAuthenticationPolicy(); |
| | | |
| | | boolean isSASLBind = (saslHandler != null); |
| | | boolean isSASLBind = saslHandler != null; |
| | | |
| | | // Check to see if the user is administratively disabled or locked. |
| | | if (pwPolicyState.isDisabled()) |
| | |
| | | |
| | | // If it's a simple bind, or if it's a password-based SASL bind, then |
| | | // perform a number of password-based checks. |
| | | if ((! isSASLBind) || saslHandler.isPasswordBased(saslMechanism)) |
| | | if (!isSASLBind || saslHandler.isPasswordBased(saslMechanism)) |
| | | { |
| | | // Check to see if the account is locked due to the maximum reset age. |
| | | if (pwPolicyState.lockedDueToMaximumResetAge()) |
| | |
| | | } |
| | | |
| | | int maxGraceLogins = policy.getGraceLoginCount(); |
| | | if ((maxGraceLogins > 0) && pwPolicyState.mayUseGraceLogin()) |
| | | if (maxGraceLogins > 0 && pwPolicyState.mayUseGraceLogin()) |
| | | { |
| | | List<Long> graceLoginTimes = pwPolicyState.getGraceLoginTimes(); |
| | | if ((graceLoginTimes == null) || |
| | | (graceLoginTimes.size() < maxGraceLogins)) |
| | | if (graceLoginTimes == null || |
| | | graceLoginTimes.size() < maxGraceLogins) |
| | | { |
| | | isGraceLogin = true; |
| | | mustChangePassword = true; |
| | |
| | | { |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(attributeTypeName); |
| | | List<Attribute> attrList = userEntry.getAttribute(attrType); |
| | | if ((attrList != null) && (attrList.size() == 1)) |
| | | if (attrList != null && attrList.size() == 1) |
| | | { |
| | | Attribute a = attrList.get(0); |
| | | if (a.size() == 1) |
| | |
| | | AttributeType attrType = getAttributeType(); |
| | | |
| | | List<Attribute> attrList = entry.getAttribute(attrType, options); |
| | | if ((attrList == null) || attrList.isEmpty()) |
| | | if (attrList == null || attrList.isEmpty()) |
| | | { |
| | | setResultCode(ResultCode.NO_SUCH_ATTRIBUTE); |
| | | if (options == null) |
| | |
| | | fileManager.deleteRecursively(dir, killChildFileFilter, |
| | | FileManager.DeletionPolicy.DELETE_IMMEDIATELY); |
| | | assertTrue(dir.exists()); |
| | | assertEquals((childCount -1), countSelfAndAllChildren(dir)); |
| | | assertEquals(childCount - 1, countSelfAndAllChildren(dir)); |
| | | assertFalse(f2b1.exists()); |
| | | } |
| | | |
| | |
| | | { |
| | | int count = DummyAlertHandler.getAlertCount(); |
| | | |
| | | DirectoryServer.sendAlertNotification(this, ALERT_TYPE, |
| | | ALERT_MESSAGE); |
| | | assertEquals(DummyAlertHandler.getAlertCount(), (count+1)); |
| | | DirectoryServer.sendAlertNotification(this, ALERT_TYPE, ALERT_MESSAGE); |
| | | assertEquals(DummyAlertHandler.getAlertCount(), count+1); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | int count = DummyAlertHandler.getAlertCount(); |
| | | |
| | | DirectoryServer.sendAlertNotification(this, ALERT_TYPE, |
| | | ALERT_MESSAGE); |
| | | assertEquals(DummyAlertHandler.getAlertCount(), (count+1)); |
| | | DirectoryServer.sendAlertNotification(this, ALERT_TYPE, ALERT_MESSAGE); |
| | | assertEquals(DummyAlertHandler.getAlertCount(), count+1); |
| | | } |
| | | finally |
| | | { |
| | |
| | | { |
| | | int count = DummyAlertHandler.getAlertCount(); |
| | | |
| | | DirectoryServer.sendAlertNotification(this, ALERT_TYPE, |
| | | ALERT_MESSAGE); |
| | | DirectoryServer.sendAlertNotification(this, ALERT_TYPE, ALERT_MESSAGE); |
| | | assertEquals(DummyAlertHandler.getAlertCount(), count); |
| | | } |
| | | finally |
| | |
| | | { |
| | | int count = DummyAlertHandler.getAlertCount(); |
| | | |
| | | DirectoryServer.sendAlertNotification(this, ALERT_TYPE, |
| | | ALERT_MESSAGE); |
| | | DirectoryServer.sendAlertNotification(this, ALERT_TYPE, ALERT_MESSAGE); |
| | | assertEquals(DummyAlertHandler.getAlertCount(), count); |
| | | } |
| | | finally |
| | |
| | | { |
| | | int count = DummyAlertHandler.getAlertCount(); |
| | | |
| | | DirectoryServer.sendAlertNotification(this, ALERT_TYPE, |
| | | ALERT_MESSAGE); |
| | | assertEquals(DummyAlertHandler.getAlertCount(), (count+1)); |
| | | DirectoryServer.sendAlertNotification(this, ALERT_TYPE, ALERT_MESSAGE); |
| | | assertEquals(DummyAlertHandler.getAlertCount(), count+1); |
| | | } |
| | | finally |
| | | { |
| | |
| | | { |
| | | int count = DummyAlertHandler.getAlertCount(); |
| | | |
| | | DirectoryServer.sendAlertNotification(this, ALERT_TYPE, |
| | | ALERT_MESSAGE); |
| | | DirectoryServer.sendAlertNotification(this, ALERT_TYPE, ALERT_MESSAGE); |
| | | assertEquals(DummyAlertHandler.getAlertCount(), count); |
| | | } |
| | | finally |
| | |
| | | System.err.println(); |
| | | } |
| | | |
| | | if ((! newAbstractMethods.isEmpty()) || |
| | | (! expectedAbstractMethods.isEmpty())) |
| | | if (!newAbstractMethods.isEmpty() || !expectedAbstractMethods.isEmpty()) |
| | | { |
| | | fail("It appears that set of abstract methods defined in the plugin " + |
| | | "API have been altered. This will only be allowed under " + |
| | |
| | | continue; |
| | | } |
| | | |
| | | if (Modifier.isPublic(m.getModifiers()) && |
| | | (! Modifier.isAbstract(m.getModifiers()))) |
| | | if (Modifier.isPublic(m.getModifiers()) |
| | | && !Modifier.isAbstract(m.getModifiers())) |
| | | { |
| | | LinkedList<String> foundList = new LinkedList<>(); |
| | | foundList.add(m.getName()); |
| | |
| | | // Add this test only if the mask tells us we haven't seen it before. |
| | | // Also guard against ArrayIndexOutOfBoundsExceptions in case the |
| | | // mask isn't long enough. |
| | | if ((i < mask.length()) && |
| | | ((mask.charAt(i) == '-') || (mask.charAt(i) == '\"'))) { |
| | | if (i < mask.length() |
| | | && (mask.charAt(i) == '-' || mask.charAt(i) == '\"')) { |
| | | acisMissingOneChar.add("aci: " + aci.substring(0, i) + aci.substring(i + 1, aci.length())); |
| | | } |
| | | } |
| | |
| | | * @return An ACI string. |
| | | */ |
| | | private static String buildGlobalAciValue(String... aciFields) { |
| | | return(_buildAciValue(ATTR_AUTHZ_GLOBAL_ACI + ": ", aciFields)); |
| | | return _buildAciValue(ATTR_AUTHZ_GLOBAL_ACI + ": ", aciFields); |
| | | } |
| | | |
| | | /** |
| | |
| | | * to more easily generate combinations of acis. |
| | | */ |
| | | private static String buildAciValue(String... aciFields) { |
| | | return(_buildAciValue("aci:", aciFields)); |
| | | return _buildAciValue("aci:", aciFields); |
| | | } |
| | | |
| | | /** |
| | |
| | | private void ldapModify(String[] args, boolean expectSuccess) throws Exception { |
| | | clearOutputStream(); |
| | | int retVal = LDAPModify.mainModify(args, false, getOutputStream(), getOutputStream()); |
| | | assertEquals((retVal == 0), expectSuccess, "Return value = " + retVal); |
| | | assertEquals(retVal == 0, expectSuccess, "Return value = " + retVal); |
| | | } |
| | | |
| | | private String ldapSearch(String[] args) throws Exception { |
| | |
| | | while (TaskState.isPending(task.getTaskState())) |
| | | { |
| | | Thread.sleep(10); |
| | | if (System.currentTimeMillis() > (startTime + 300000L)) |
| | | if (System.currentTimeMillis() > startTime + 300000L) |
| | | { |
| | | throw new AssertionError("Waited too long for the task to start"); |
| | | } |
| | |
| | | while (TaskState.isPending(task.getTaskState())) |
| | | { |
| | | Thread.sleep(10); |
| | | if (System.currentTimeMillis() > (startTime + 300000L)) |
| | | if (System.currentTimeMillis() > startTime + 300000L) |
| | | { |
| | | throw new AssertionError("Waited too long for the task to start"); |
| | | } |
| | |
| | | // We may have to wait for the task to register as done, but it should |
| | | // definitely be done before it would have stopped normally. |
| | | task = TasksTestCase.getCompletedTask(DN.valueOf(taskDN)); |
| | | assertTrue((System.currentTimeMillis() - startTime) < 300000L); |
| | | assertTrue(System.currentTimeMillis() - startTime < 300000L); |
| | | assertTrue(TaskState.isDone(task.getTaskState())); |
| | | |
| | | |
| | |
| | | // As we provide dummy type and value string, attType and attVal |
| | | // could |
| | | // be null. |
| | | if ((attType != null) && (attVal != null)) |
| | | if (attType != null && attVal != null) |
| | | { |
| | | mvf = MatchedValuesFilter.createEqualityFilter(attType, attVal); |
| | | assertNotNull(mvf); |
| | |
| | | { |
| | | rawAttTypeTestCurrent = null ; |
| | | } |
| | | boolean exceptionExpected = (attTypeCurrent == null); |
| | | boolean exceptionExpected = attTypeCurrent == null; |
| | | |
| | | try |
| | | { |
| | |
| | | } |
| | | |
| | | // Check type, value |
| | | // As we provide dummy type and value string, attType and attVal could |
| | | // be null. |
| | | if ((type != null) && (value != null)) |
| | | // As we provide dummy type and value string, attType and attVal could be null. |
| | | if (type != null && value != null) |
| | | { |
| | | MatchedValuesFilter mvf; |
| | | mvf = MatchedValuesFilter.createGreaterOrEqualFilter(type, |
| | |
| | | } |
| | | |
| | | // Check type, value |
| | | if ((attType != null) && (attVal != null)) |
| | | if (attType != null && attVal != null) |
| | | { |
| | | MatchedValuesFilter mvf; |
| | | mvf = MatchedValuesFilter.createGreaterOrEqualFilter(attType, attVal); |
| | |
| | | } |
| | | |
| | | // Check type, value |
| | | // As we provide dummy type and value string, attType and attVal could |
| | | // be null. |
| | | if ((attType != null) && (attVal != null)) |
| | | // As we provide dummy type and value string, attType and attVal could be null. |
| | | if (attType != null && attVal != null) |
| | | { |
| | | mvf = MatchedValuesFilter.createLessOrEqualFilter(attType, attVal); |
| | | assertNotNull(mvf); |
| | |
| | | } |
| | | |
| | | // Check type, value |
| | | // As we provide dummy type and value string, attType and attVal could |
| | | // be null. |
| | | if ((attType != null) && (attVal != null)) |
| | | // As we provide dummy type and value string, attType and attVal could be null. |
| | | if (attType != null && attVal != null) |
| | | { |
| | | mvf = MatchedValuesFilter.createApproximateFilter(attType, attVal); |
| | | assertNotNull(mvf); |
| | |
| | | attValueTestCurrent = attValueTest; |
| | | } |
| | | |
| | | boolean exceptionExpected = (attTypeTestCurrent == null) |
| | | || (attValueTestCurrent == null) || (matchingRuleidTestCurrent == null); |
| | | boolean exceptionExpected = attTypeTestCurrent == null |
| | | || attValueTestCurrent == null |
| | | || matchingRuleidTestCurrent == null; |
| | | |
| | | MatchedValuesFilter mvf = null; |
| | | try |
| | |
| | | "--set", "min-password-age:24 hours"); |
| | | |
| | | p = DirectoryServer.getDefaultPasswordPolicy(); |
| | | assertEquals(p.getMinPasswordAge(), (24*60*60)); |
| | | assertEquals(p.getMinPasswordAge(), 24*60*60); |
| | | |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | |
| | | "--set", "min-password-age:24 hours"); |
| | | |
| | | p = (PasswordPolicy) DirectoryServer.getAuthenticationPolicy(dn); |
| | | assertEquals(p.getMinPasswordAge(), (24*60*60)); |
| | | assertEquals(p.getMinPasswordAge(), 24*60*60); |
| | | |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | |
| | | "--set", "max-password-age:90 days"); |
| | | |
| | | p = DirectoryServer.getDefaultPasswordPolicy(); |
| | | assertEquals(p.getMaxPasswordAge(), (90*60*60*24)); |
| | | assertEquals(p.getMaxPasswordAge(), 90*60*60*24); |
| | | |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | |
| | | "--set", "max-password-age:90 days"); |
| | | |
| | | p = (PasswordPolicy) DirectoryServer.getAuthenticationPolicy(dn); |
| | | assertEquals(p.getMaxPasswordAge(), (90*60*60*24)); |
| | | assertEquals(p.getMaxPasswordAge(), 90*60*60*24); |
| | | |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | |
| | | "--set", "max-password-reset-age:24 hours"); |
| | | |
| | | p = DirectoryServer.getDefaultPasswordPolicy(); |
| | | assertEquals(p.getMaxPasswordResetAge(), (24*60*60)); |
| | | assertEquals(p.getMaxPasswordResetAge(), 24*60*60); |
| | | |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | |
| | | "--set", "max-password-reset-age:24 hours"); |
| | | |
| | | p = (PasswordPolicy) DirectoryServer.getAuthenticationPolicy(dn); |
| | | assertEquals(p.getMaxPasswordResetAge(), (24*60*60)); |
| | | assertEquals(p.getMaxPasswordResetAge(), 24*60*60); |
| | | |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | |
| | | throws Exception |
| | | { |
| | | PasswordPolicy p = DirectoryServer.getDefaultPasswordPolicy(); |
| | | assertEquals(p.getPasswordExpirationWarningInterval(), (5*60*60*24)); |
| | | assertEquals(p.getPasswordExpirationWarningInterval(), 5*60*60*24); |
| | | |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | |
| | | "--set", "password-expiration-warning-interval:24 hours"); |
| | | |
| | | p = DirectoryServer.getDefaultPasswordPolicy(); |
| | | assertEquals(p.getPasswordExpirationWarningInterval(), (24*60*60)); |
| | | assertEquals(p.getPasswordExpirationWarningInterval(), 24*60*60); |
| | | |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | |
| | | DN dn = DN.valueOf("cn=SHA1 AuthPassword Policy,cn=Password Policies," + |
| | | "cn=config"); |
| | | PasswordPolicy p = (PasswordPolicy) DirectoryServer.getAuthenticationPolicy(dn); |
| | | assertEquals(p.getPasswordExpirationWarningInterval(), (5*60*60*24)); |
| | | assertEquals(p.getPasswordExpirationWarningInterval(), 5*60*60*24); |
| | | |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | |
| | | "--set", "password-expiration-warning-interval:24 hours"); |
| | | |
| | | p = (PasswordPolicy) DirectoryServer.getAuthenticationPolicy(dn); |
| | | assertEquals(p.getPasswordExpirationWarningInterval(), (24*60*60)); |
| | | assertEquals(p.getPasswordExpirationWarningInterval(), 24*60*60); |
| | | |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | |
| | | "--set", "lockout-duration:15 minutes"); |
| | | |
| | | p = DirectoryServer.getDefaultPasswordPolicy(); |
| | | assertEquals(p.getLockoutDuration(), (15*60)); |
| | | assertEquals(p.getLockoutDuration(), 15*60); |
| | | |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | |
| | | "--set", "lockout-duration:15 minutes"); |
| | | |
| | | p = (PasswordPolicy) DirectoryServer.getAuthenticationPolicy(dn); |
| | | assertEquals(p.getLockoutDuration(), (15*60)); |
| | | assertEquals(p.getLockoutDuration(), 15*60); |
| | | |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | |
| | | "--set", "lockout-failure-expiration-interval:10 minutes"); |
| | | |
| | | p = DirectoryServer.getDefaultPasswordPolicy(); |
| | | assertEquals(p.getLockoutFailureExpirationInterval(), (10*60)); |
| | | assertEquals(p.getLockoutFailureExpirationInterval(), 10*60); |
| | | |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | |
| | | "--set", "lockout-failure-expiration-interval:10 minutes"); |
| | | |
| | | p = (PasswordPolicy) DirectoryServer.getAuthenticationPolicy(dn); |
| | | assertEquals(p.getLockoutFailureExpirationInterval(), (10*60)); |
| | | assertEquals(p.getLockoutFailureExpirationInterval(), 10*60); |
| | | |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | |
| | | "--set", "idle-lockout-interval:90 days"); |
| | | |
| | | p = DirectoryServer.getDefaultPasswordPolicy(); |
| | | assertEquals(p.getIdleLockoutInterval(), (90*60*60*24)); |
| | | assertEquals(p.getIdleLockoutInterval(), 90*60*60*24); |
| | | |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | |
| | | "--set", "idle-lockout-interval:90 days"); |
| | | |
| | | p = (PasswordPolicy) DirectoryServer.getAuthenticationPolicy(dn); |
| | | assertEquals(p.getIdleLockoutInterval(), (90*60*60*24)); |
| | | assertEquals(p.getIdleLockoutInterval(), 90*60*60*24); |
| | | |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | |
| | | Date date = new Date(System.currentTimeMillis() + 86400000L); |
| | | notificationProperties.put(PASSWORD_EXPIRATION_TIME, newArrayList(date.toString())); |
| | | } |
| | | else if ((notificationType == PASSWORD_CHANGED) || |
| | | (notificationType == PASSWORD_RESET)) |
| | | else if (notificationType == PASSWORD_CHANGED || |
| | | notificationType == PASSWORD_RESET) |
| | | { |
| | | notificationProperties.put(OLD_PASSWORD, newArrayList("oldpassword")); |
| | | notificationProperties.put(NEW_PASSWORD, newArrayList("newpassword")); |
| | |
| | | ModifyOperationBasis op = newModifyOperation(buffer); |
| | | |
| | | LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder(); |
| | | assertEquals((buffer.length() >= 10), |
| | | validator.passwordIsAcceptable(password, |
| | | new HashSet<ByteString>(0), |
| | | op, userEntry, |
| | | invalidReason)); |
| | | boolean actual = validator.passwordIsAcceptable( |
| | | password, new HashSet<ByteString>(0), op, userEntry, invalidReason); |
| | | assertEquals(buffer.length() >= 10, actual); |
| | | } |
| | | |
| | | validator.finalizePasswordValidator(); |
| | |
| | | ModifyOperationBasis op = newModifyOperation(buffer); |
| | | |
| | | LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder(); |
| | | assertEquals((buffer.length() <= 10), |
| | | validator.passwordIsAcceptable(password, |
| | | new HashSet<ByteString>(0), |
| | | op, userEntry, |
| | | invalidReason)); |
| | | boolean actual = validator.passwordIsAcceptable( |
| | | password, new HashSet<ByteString>(0), op, userEntry, invalidReason); |
| | | assertEquals(buffer.length() <= 10, actual); |
| | | } |
| | | |
| | | validator.finalizePasswordValidator(); |
| | |
| | | ModifyOperationBasis op = newModifyOperation(buffer); |
| | | |
| | | LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder(); |
| | | assertEquals(((buffer.length() >= 6) && (buffer.length() <= 10)), |
| | | validator.passwordIsAcceptable(password, |
| | | new HashSet<ByteString>(0), |
| | | op, userEntry, |
| | | invalidReason)); |
| | | boolean actual = validator.passwordIsAcceptable( |
| | | password, new HashSet<ByteString>(0), op, userEntry, invalidReason); |
| | | assertEquals(buffer.length() >= 6 && buffer.length() <= 10, actual); |
| | | } |
| | | |
| | | validator.finalizePasswordValidator(); |
| | |
| | | DN.valueOf("cn=uid=test.user,o=test"), mods); |
| | | |
| | | LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder(); |
| | | assertEquals((buffer.length() >= 6), |
| | | validator.passwordIsAcceptable(password, |
| | | currentPassword, |
| | | op, userEntry, |
| | | invalidReason)); |
| | | boolean actual = validator.passwordIsAcceptable( |
| | | password, currentPassword, op, userEntry, invalidReason); |
| | | assertEquals(buffer.length() >= 6, actual); |
| | | } |
| | | |
| | | validator.finalizePasswordValidator(); |
| | |
| | | long startTime = System.currentTimeMillis(); |
| | | assertTrue(DirectoryServer.getWorkQueue().waitUntilIdle(10000)); |
| | | long stopTime = System.currentTimeMillis(); |
| | | assertTrue((stopTime - startTime) <= 1000); |
| | | assertTrue(stopTime - startTime <= 1000); |
| | | } |
| | | |
| | | |
| | |
| | | long startTime = System.currentTimeMillis(); |
| | | assertTrue(DirectoryServer.getWorkQueue().waitUntilIdle(0)); |
| | | long stopTime = System.currentTimeMillis(); |
| | | assertTrue((stopTime - startTime) <= 1000); |
| | | assertTrue(stopTime - startTime <= 1000); |
| | | } |
| | | |
| | | |
| | |
| | | long startTime = System.currentTimeMillis(); |
| | | assertTrue(DirectoryServer.getWorkQueue().waitUntilIdle(10000)); |
| | | long stopTime = System.currentTimeMillis(); |
| | | assertTrue((stopTime - startTime) >= 4000); |
| | | assertTrue(stopTime - startTime >= 4000); |
| | | } |
| | | |
| | | /** |
| | |
| | | long startTime = System.currentTimeMillis(); |
| | | assertFalse(DirectoryServer.getWorkQueue().waitUntilIdle(1000)); |
| | | long stopTime = System.currentTimeMillis(); |
| | | assertTrue((stopTime - startTime) <= 2000); |
| | | assertTrue(stopTime - startTime <= 2000); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | long opID1 = InternalClientConnection.nextOperationID(); |
| | | long opID2 = InternalClientConnection.nextOperationID(); |
| | | assertEquals(opID2, (opID1 + 1)); |
| | | assertEquals(opID2, opID1 + 1); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | int msgID1 = InternalClientConnection.nextMessageID(); |
| | | int msgID2 = InternalClientConnection.nextMessageID(); |
| | | assertEquals(msgID2, (msgID1 + 1)); |
| | | assertEquals(msgID2, msgID1 + 1); |
| | | } |
| | | |
| | | |
| | |
| | | boolean expectedResult) throws Exception { |
| | | OpendsJmxConnector connector = connect(user, password, |
| | | TestCaseUtils.getServerJmxPort()); |
| | | assertEquals((connector != null), expectedResult); |
| | | assertEquals(connector != null, expectedResult); |
| | | if (connector != null) { |
| | | connector.close(); |
| | | } |
| | |
| | | // Provide the credentials required by the server to successfully |
| | | // perform user authentication |
| | | String[] credentials; |
| | | if ((user == null) && (password == null)) { |
| | | if (user == null && password == null) { |
| | | credentials = null; |
| | | } |
| | | else |
| | |
| | | // Provide the credentials required by the server to successfully |
| | | // perform user authentication |
| | | String[] credentials; |
| | | if ((user == null) && (password == null)) { |
| | | if (user == null && password == null) { |
| | | credentials = null; |
| | | } |
| | | else |
| | |
| | | long endTime = System.currentTimeMillis() + 5000; |
| | | int postConnectAfter = postConnectBefore; |
| | | |
| | | while ((System.currentTimeMillis() < endTime) |
| | | && (postConnectAfter == postConnectBefore)) |
| | | while (System.currentTimeMillis() < endTime |
| | | && postConnectAfter == postConnectBefore) |
| | | { |
| | | Thread.sleep(10); |
| | | postConnectAfter = InvocationCounterPlugin.getPostConnectCount(); |
| | |
| | | // Don't wait more than 5 seconds |
| | | endTime = System.currentTimeMillis() + 5000; |
| | | postDisconnectAfter = postDisconnectBefore; |
| | | while ((System.currentTimeMillis() < endTime) |
| | | && (postDisconnectAfter == postDisconnectBefore)) |
| | | while (System.currentTimeMillis() < endTime |
| | | && postDisconnectAfter == postDisconnectBefore) |
| | | { |
| | | Thread.sleep(10); |
| | | postDisconnectAfter = InvocationCounterPlugin.getPostDisconnectCount(); |
| | |
| | | { |
| | | // First, test with the standard Boolean type. |
| | | byte[] elementArray = new byte[] { 0x01, 0x01, b[0] }; |
| | | assertEquals(getReader(elementArray, 0).readBoolean(), (b[0] != 0x00)); |
| | | assertEquals(getReader(elementArray, 0).readBoolean(), b[0] != 0x00); |
| | | |
| | | |
| | | // Next, test with a nonstandard Boolean type. |
| | | elementArray[0] = 0x50; |
| | | assertEquals(getReader(elementArray, 0).readBoolean(), (b[0] != 0x00)); |
| | | assertEquals(getReader(elementArray, 0).readBoolean(), b[0] != 0x00); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | // First, test with the standard Boolean type. |
| | | byte[] elementArray = new byte[] { 0x01, (byte) 0x81, 0x01, b[0] }; |
| | | assertEquals(getReader(elementArray, 0).readBoolean(), (b[0] != 0x00)); |
| | | assertEquals(getReader(elementArray, 0).readBoolean(), b[0] != 0x00); |
| | | |
| | | |
| | | // Next, test with a nonstandard Boolean type. |
| | | elementArray[0] = 0x50; |
| | | assertEquals(getReader(elementArray, 0).readBoolean(), (b[0] != 0x00)); |
| | | assertEquals(getReader(elementArray, 0).readBoolean(), b[0] != 0x00); |
| | | } |
| | | |
| | | |
| | |
| | | int count = 0; |
| | | while (count<=entryBytes.length-2) |
| | | { |
| | | if ((entryBytes[count] == '\n') && (entryBytes[count+1] == '\n')) |
| | | if (entryBytes[count] == '\n' && entryBytes[count+1] == '\n') |
| | | { |
| | | entryCount++; |
| | | count++; |
| | |
| | | } |
| | | op = connection.processSearch(newSearchRequest("cn=replication,cn=monitor", WHOLE_SUBTREE, monitorFilter)); |
| | | } |
| | | while (op.getSearchEntries().isEmpty() && (count<100)); |
| | | while (op.getSearchEntries().isEmpty() && count<100); |
| | | assertFalse(op.getSearchEntries().isEmpty(), "Could not read monitoring information"); |
| | | |
| | | SearchResultEntry entry = op.getSearchEntries().getFirst(); |
| | |
| | | if (newEntry != null) |
| | | { |
| | | List<Attribute> tmpAttrList = newEntry.getAttribute(attrTypeStr); |
| | | if ((tmpAttrList != null) && (!tmpAttrList.isEmpty())) |
| | | if (tmpAttrList != null && !tmpAttrList.isEmpty()) |
| | | { |
| | | Attribute tmpAttr = tmpAttrList.get(0); |
| | | found = tmpAttr.contains(ByteString.valueOf(valueString)); |
| | |
| | | { |
| | | Thread.sleep(100); |
| | | } |
| | | } while ((--count > 0) && (found != hasAttribute)); |
| | | } while (--count > 0 && found != hasAttribute); |
| | | return found; |
| | | } |
| | | |
| | |
| | | } |
| | | Thread.sleep(50); |
| | | boolean found = DirectoryServer.entryExists(dn); |
| | | while ((count> 0) && (found != exist)) |
| | | while (count> 0 && found != exist) |
| | | { |
| | | Thread.sleep(200); |
| | | |
| | |
| | | protected long getMonitorDelta() throws Exception |
| | | { |
| | | long currentCount = getMonitorAttrValue(monitorDN, monitorAttr); |
| | | long delta = (currentCount - lastCount); |
| | | long delta = currentCount - lastCount; |
| | | lastCount = currentCount; |
| | | return delta; |
| | | } |
| | |
| | | while (taskState != expectedTaskState |
| | | && taskState != TaskState.STOPPED_BY_ERROR |
| | | && taskState != TaskState.COMPLETED_SUCCESSFULLY |
| | | && (System.currentTimeMillis() - startTime < maxWaitTimeInMillis)); |
| | | && System.currentTimeMillis() - startTime < maxWaitTimeInMillis); |
| | | |
| | | // Check that the task contains some log messages. |
| | | Set<String> logMessages = resultEntry.parseAttribute( |
| | |
| | | } |
| | | logger.trace("waitForSpecificMsg received : " + replMsg); |
| | | msgs.add(replMsg); |
| | | timedOut = (System.currentTimeMillis() - startTime) > timeOut; |
| | | timedOut = System.currentTimeMillis() - startTime > timeOut; |
| | | } |
| | | // Timeout |
| | | fail("Failed to receive an expected " + msgType + " message after 5 seconds." |
| | |
| | | synchronized (this) |
| | | { |
| | | int i = 20; |
| | | while ((finished != true) && (i-- >0)) |
| | | while (!finished && (i-- >0)) |
| | | { |
| | | try |
| | | { |
| | |
| | | sslEncryption = serverStartMsg.getSSLEncryption(); |
| | | |
| | | // Send replication server start |
| | | String serverURL = ("localhost:" + port); |
| | | String serverURL = "localhost:" + port; |
| | | ReplServerStartMsg replServerStartMsg = new ReplServerStartMsg(serverId, |
| | | serverURL, baseDN, windowSize, serverState, generationId, sslEncryption, |
| | | groupId, degradedStatusThreshold); |
| | |
| | | else |
| | | { |
| | | // RS has a different group id, addEntry should have returned quickly |
| | | assertTrue((endTime - startTime) < 3000); |
| | | assertTrue(endTime - startTime < 3000); |
| | | |
| | | // No error should be seen in monitoring and update should have not been |
| | | // sent in assured mode |
| | |
| | | else |
| | | { |
| | | // RS has a different group id, addEntry should have returned quickly |
| | | assertTrue((endTime - startTime) < 3000); |
| | | assertTrue(endTime - startTime < 3000); |
| | | |
| | | // No error should be seen in monitoring and update should have not been |
| | | // sent in assured mode |
| | |
| | | */ |
| | | private void assertBlockedLongerThanTimeout(long startTime, long endTime, int TIMEOUT) |
| | | { |
| | | assertTrue((endTime - startTime) >= TIMEOUT); |
| | | assertTrue(endTime - startTime >= TIMEOUT); |
| | | } |
| | | |
| | | /** |
| | |
| | | private void waitOpResult(Operation operation, ResultCode expectedResult) throws Exception |
| | | { |
| | | int ii=0; |
| | | while((operation.getResultCode()==ResultCode.UNDEFINED) || |
| | | (operation.getResultCode()!=expectedResult)) |
| | | while (operation.getResultCode() == ResultCode.UNDEFINED || |
| | | operation.getResultCode() != expectedResult) |
| | | { |
| | | Thread.sleep(50); |
| | | ii++; |
| | |
| | | else |
| | | { |
| | | // Other strings are attributes |
| | | String endString = (addSynchroAttribute ? ("," + SYNCHRO_OPTIONAL_ATTR + "\n") : "\n"); |
| | | String endString = addSynchroAttribute ? ("," + SYNCHRO_OPTIONAL_ATTR + "\n") : "\n"; |
| | | topEntryLdif += fracCfgValue + ( (i<size-1) ? "," : endString); |
| | | } |
| | | i++; |
| | |
| | | else |
| | | { |
| | | // Other strings are attributes |
| | | String endString = (addSynchroAttribute ? ("," + SYNCHRO_OPTIONAL_ATTR + "\n") : "\n"); |
| | | String endString = addSynchroAttribute ? ("," + SYNCHRO_OPTIONAL_ATTR + "\n") : "\n"; |
| | | configEntryLdif += fracCfgValue + ( (i<size-1) ? "," : endString); |
| | | } |
| | | i++; |
| | |
| | | // Wait for connections to be finished |
| | | // DS must see expected numbers of fake DSs and RSs |
| | | final FakeReplicationDomain fakeRd1 = fakeRDs[1]; |
| | | waitForStableTopo(fakeRd1, (otherFakeDS ? 1 : 0), 4); |
| | | waitForStableTopo(fakeRd1, otherFakeDS ? 1 : 0, 4); |
| | | |
| | | /*********************************************************************** |
| | | * Send update from DS 1 (3 fake RSs available) and check what happened |
| | |
| | | |
| | | // Wait for disconnection to be finished |
| | | // DS must see expected numbers of fake DSs and RSs |
| | | waitForStableTopo(fakeRd1, (otherFakeDS ? 1 : 0), 3); |
| | | waitForStableTopo(fakeRd1, otherFakeDS ? 1 : 0, 3); |
| | | |
| | | // Keep track of monitoring values for incremental test step |
| | | acknowledgedUpdates = fakeRd1.getAssuredSdAcknowledgedUpdates(); |
| | |
| | | |
| | | // Wait for disconnection to be finished |
| | | // DS must see expected numbers of fake DSs and RSs |
| | | waitForStableTopo(fakeRd1, (otherFakeDS ? 1 : 0), 2); |
| | | waitForStableTopo(fakeRd1, otherFakeDS ? 1 : 0, 2); |
| | | |
| | | // Keep track of monitoring values for incremental test step |
| | | acknowledgedUpdates = fakeRd1.getAssuredSdAcknowledgedUpdates(); |
| | |
| | | |
| | | // Wait for disconnection to be finished |
| | | // DS must see expected numbers of fake DSs and RSs |
| | | waitForStableTopo(fakeRd1, (otherFakeDS ? 1 : 0), 1); |
| | | waitForStableTopo(fakeRd1, otherFakeDS ? 1 : 0, 1); |
| | | |
| | | // Keep track of monitoring values for incremental test step |
| | | acknowledgedUpdates = fakeRd1.getAssuredSdAcknowledgedUpdates(); |
| | |
| | | /* |
| | | * Now check timeout or not according to test configuration parameters |
| | | */ |
| | | if ( (sdLevel == 1) || (fakeRsGid != DEFAULT_GID) || |
| | | (fakeRsGenId != DEFAULT_GENID) || (!sendInAssured) ) |
| | | if (sdLevel == 1 || fakeRsGid != DEFAULT_GID |
| | | || fakeRsGenId != DEFAULT_GENID || !sendInAssured ) |
| | | { |
| | | // Should have timed out (no ack) |
| | | assertTrue(timeout); |
| | |
| | | |
| | | // Check monitoring values in DS 1 |
| | | final SafeReadAssertions srAssertsRD1 = fakeRd1.newSafeReadAssertions().sentUpdates(1); |
| | | if (( (otherFakeDsGid == DEFAULT_GID) && (otherFakeDsGenId == DEFAULT_GENID) && (otherFakeDsScen != REPLY_OK_DS_SCENARIO) ) |
| | | || ( (otherFakeRsGid == DEFAULT_GID) && (otherFakeRsGenId == DEFAULT_GENID) && (otherFakeRsScen != REPLY_OK_RS_SCENARIO) )) |
| | | if ((otherFakeDsGid == DEFAULT_GID && otherFakeDsGenId == DEFAULT_GENID && otherFakeDsScen != REPLY_OK_DS_SCENARIO) |
| | | || (otherFakeRsGid == DEFAULT_GID && otherFakeRsGenId == DEFAULT_GENID && otherFakeRsScen != REPLY_OK_RS_SCENARIO)) |
| | | { |
| | | srAssertsRD1.notAcknowledgedUpdates(1); |
| | | } |
| | |
| | | boolean fakeDsIsEligible = areGroupAndGenerationIdOk(fakeDsGid, fakeDsGenId); |
| | | |
| | | // Check call time |
| | | if (fakeDsIsEligible && (fakeDsScen == TIMEOUT_DS_SCENARIO)) |
| | | if (fakeDsIsEligible && fakeDsScen == TIMEOUT_DS_SCENARIO) |
| | | { |
| | | assertBetweenInclusive(sendUpdateTime, SMALL_TIMEOUT, SMALL_TIMEOUT + 1000); |
| | | } |
| | |
| | | */ |
| | | for (int i =0; i< CLIENT_THREADS; i++) |
| | | { |
| | | clientBroker[i] = openReplicationSession(TEST_ROOT_DN, |
| | | (100+i), 100, replicationServerPort, 1000); |
| | | clientBroker[i] = openReplicationSession(TEST_ROOT_DN, 100+i, 100, replicationServerPort, 1000); |
| | | client[i] = new BrokerReader(clientBroker[i], TOTAL_MSG); |
| | | } |
| | | |
| | |
| | | private boolean isNumericOID(String oid) |
| | | { |
| | | // It must not be null, and it must not be empty. |
| | | if ((oid == null) || (oid.length() == 0)) |
| | | if (oid == null || oid.length() == 0) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | // It must start and end with numeric digits. |
| | | if ((! Character.isDigit(oid.charAt(0))) || |
| | | (! Character.isDigit(oid.charAt(oid.length()-1)))) |
| | | if (!Character.isDigit(oid.charAt(0)) || |
| | | !Character.isDigit(oid.charAt(oid.length()-1))) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | protected TaskState runTask() |
| | | { |
| | | long stopTime = System.currentTimeMillis() + sleepTime; |
| | | while ((interruptedState == null) && |
| | | (System.currentTimeMillis() < stopTime)) |
| | | while (interruptedState == null && System.currentTimeMillis() < stopTime) |
| | | { |
| | | try |
| | | { |
| | |
| | | } catch (Exception e) {} |
| | | } |
| | | |
| | | if (interruptedState == null) |
| | | { |
| | | return TaskState.COMPLETED_SUCCESSFULLY; |
| | | } |
| | | else |
| | | if (interruptedState != null) |
| | | { |
| | | return interruptedState; |
| | | } |
| | | return TaskState.COMPLETED_SUCCESSFULLY; |
| | | } |
| | | |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.server.tasks; |
| | |
| | | // Use a big timeout since this test is sensitive to host environment (e.g. |
| | | // low memory, etc). See issue OPENDJ-256. |
| | | testTask(taskEntry, expectedState, 600); |
| | | if ((expectedState == TaskState.COMPLETED_SUCCESSFULLY) || |
| | | (expectedState == TaskState.COMPLETED_WITH_ERRORS)) |
| | | if (expectedState == TaskState.COMPLETED_SUCCESSFULLY || |
| | | expectedState == TaskState.COMPLETED_WITH_ERRORS) |
| | | { |
| | | if (taskEntry.hasObjectClass(exportClass)) |
| | | { |
| | | assertEquals(TestTaskListener.exportBeginCount.get(), |
| | | (exportBeginCount+1)); |
| | | assertEquals(TestTaskListener.exportEndCount.get(), (exportEndCount+1)); |
| | | assertEquals(TestTaskListener.exportBeginCount.get(), exportBeginCount+1); |
| | | assertEquals(TestTaskListener.exportEndCount.get(), exportEndCount+1); |
| | | assertEquals(TestTaskListener.exportBeginCount.get(), |
| | | TestTaskListener.exportEndCount.get()); |
| | | } |
| | | else |
| | | { |
| | | assertEquals(TestTaskListener.importBeginCount.get(), |
| | | (importBeginCount+1)); |
| | | assertEquals(TestTaskListener.importEndCount.get(), (importEndCount+1)); |
| | | assertEquals(TestTaskListener.importBeginCount.get(), importBeginCount+1); |
| | | assertEquals(TestTaskListener.importEndCount.get(), importEndCount+1); |
| | | assertEquals(TestTaskListener.importBeginCount.get(), |
| | | TestTaskListener.importEndCount.get()); |
| | | } |
| | |
| | | @Test(dataProvider = "invalidArgs") |
| | | public void testInvalidArguments(String[] args, String invalidReason) |
| | | { |
| | | assertFalse((EncodePassword.encodePassword(args, false, null, null) == 0), |
| | | assertFalse(EncodePassword.encodePassword(args, false, null, null) == 0, |
| | | "Should have been invalid because: " + invalidReason); |
| | | } |
| | | |
| | |
| | | { |
| | | // If the command is expected to fail, or if there aren't any differences, |
| | | // then bail out now. |
| | | if ((normalDiffFile == null) || normalDiffFile.equals(noDiffsFile)) |
| | | if (normalDiffFile == null || normalDiffFile.equals(noDiffsFile)) |
| | | { |
| | | return; |
| | | } |
| | |
| | | { |
| | | // If the command is expected to fail, or if there aren't any differences, |
| | | // then bail out now. |
| | | if ((normalDiffFile == null) || singleValueDiffFile.equals(noDiffsFile)) |
| | | if (normalDiffFile == null || singleValueDiffFile.equals(noDiffsFile)) |
| | | { |
| | | return; |
| | | } |
| | |
| | | @Test(dataProvider = "invalidArgs") |
| | | public void testInvalidArguments(String[] args, String invalidReason) |
| | | { |
| | | assertFalse((ListBackends.listBackends(args, false, null, null) == 0), |
| | | assertFalse(ListBackends.listBackends(args, false, null, null) == 0, |
| | | "Should have been invalid because: " + invalidReason); |
| | | } |
| | | |
| | |
| | | if (task == null) |
| | | { |
| | | long stopWaitingTime = System.currentTimeMillis() + 10000L; |
| | | while ((task == null) && (System.currentTimeMillis() < stopWaitingTime)) |
| | | while (task == null && System.currentTimeMillis() < stopWaitingTime) |
| | | { |
| | | Thread.sleep(10); |
| | | task = taskBackend.getScheduledTask(taskEntryDN); |
| | |
| | | if (! TaskState.isDone(task.getTaskState())) |
| | | { |
| | | long stopWaitingTime = System.currentTimeMillis() + 20000L; |
| | | while ((! TaskState.isDone(task.getTaskState())) && |
| | | (System.currentTimeMillis() < stopWaitingTime)) |
| | | while (!TaskState.isDone(task.getTaskState()) |
| | | && System.currentTimeMillis() < stopWaitingTime) |
| | | { |
| | | Thread.sleep(10); |
| | | } |
| | |
| | | for (String property : extraProperties.keySet()) |
| | | { |
| | | List<String> values = extraProperties.get(property); |
| | | if ((values == null) || values.isEmpty()) |
| | | if (values == null || values.isEmpty()) |
| | | { |
| | | continue; |
| | | } |
| | |
| | | public void testGetParent(String s, String p, String r) |
| | | throws Exception { |
| | | DN dn = DN.valueOf(s); |
| | | DN parent = (p != null ? DN.valueOf(p) : null); |
| | | DN parent = p != null ? DN.valueOf(p) : null; |
| | | |
| | | assertEquals(dn.parent(), parent, "For DN " + s); |
| | | } |
| | |
| | | public void testGetRDN(String s, String p, String r) |
| | | throws Exception { |
| | | DN dn = DN.valueOf(s); |
| | | RDN rdn = (r != null ? RDN.decode(r) : null); |
| | | RDN rdn = r != null ? RDN.decode(r) : null; |
| | | |
| | | assertEquals(dn.rdn(), rdn, "For DN " + s); |
| | | } |
| | |
| | | for (String property : extraProperties.keySet()) |
| | | { |
| | | List<String> values = extraProperties.get(property); |
| | | if ((values == null) || values.isEmpty()) |
| | | if (values == null || values.isEmpty()) |
| | | { |
| | | continue; |
| | | } |
| | |
| | | |
| | | |
| | | |
| | | private void append(StringBuilder definition, String word, |
| | | Set<AttributeType> attrTypes) |
| | | private void append(StringBuilder definition, String word, Set<AttributeType> attrTypes) |
| | | { |
| | | if ((attrTypes != null) && (!attrTypes.isEmpty())) |
| | | if (attrTypes != null && !attrTypes.isEmpty()) |
| | | { |
| | | definition.append(" "); |
| | | definition.append(word); |
| | |
| | | private byte[] getBytes(String hexData) { |
| | | int sz = hexData.length(); |
| | | |
| | | if ((sz % 2) != 0) { |
| | | if (sz % 2 != 0) { |
| | | throw new IllegalArgumentException( |
| | | "Hex string does not contain an even number of hex digits"); |
| | | } |