OPENDJ-1802 Make ByteString methods more intentional
ByteString.java:
Renamed:
- valueOf(byte[]) to valueOfBytes(byte[])
- valueOf(byte[], int, int) to valueOfBytes(byte[], int, int)
- valueOf(char[]) to valueOfUtf8(char[])
- valueOf(CharSequence) to valueOfUtf8(CharSequence)
- valueOf(Object) to valueOfObject(Object)
- valueOf(int) to valueOfInt(int)
- valueOf(long) to valueOfLong(long)
| | |
| | | private void addObjectClassesToEntry(List<String> objectClasses, Entry entry) { |
| | | for (String objectClass : objectClasses) { |
| | | Attribute attr = new LinkedAttribute("objectClass"); |
| | | attr.add(ByteString.valueOf(objectClass)); |
| | | attr.add(ByteString.valueOfUtf8(objectClass)); |
| | | entry.addAttribute(attr); |
| | | } |
| | | } |
| | |
| | | { |
| | | if (obj instanceof String) |
| | | { |
| | | bs = ByteString.valueOf((String)obj); |
| | | bs = ByteString.valueOfUtf8((String)obj); |
| | | } |
| | | else if (obj instanceof byte []) |
| | | { |
| | |
| | | else if (obj instanceof Element) |
| | | { |
| | | Element element = (Element) obj; |
| | | bs = ByteString.valueOf(element.getTextContent()); |
| | | bs = ByteString.valueOfUtf8(element.getTextContent()); |
| | | } |
| | | } |
| | | return bs; |
| | |
| | | LDAPResult addResponse = objFactory.createLDAPResult(); |
| | | addResponse.setRequestID(addRequest.getRequestID()); |
| | | |
| | | ByteString dnStr = ByteString.valueOf(addRequest.getDn()); |
| | | ByteString dnStr = ByteString.valueOfUtf8(addRequest.getDn()); |
| | | ArrayList<RawAttribute> attributes = new ArrayList<>(); |
| | | |
| | | List<DsmlAttr> addList = addRequest.getAttr(); |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2014 ForgeRock AS. |
| | | * Portions Copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | package org.opends.dsml.protocol; |
| | | |
| | |
| | | String attrName = attrValAssertion.getName(); |
| | | Object assertion = attrValAssertion.getValue(); |
| | | ByteString attrValue = ByteStringUtility.convertValue(assertion); |
| | | ByteString dnStr = ByteString.valueOf(compareRequest.getDn()); |
| | | ByteString dnStr = ByteString.valueOfUtf8(compareRequest.getDn()); |
| | | |
| | | // Create and send the LDAP compare request to the server. |
| | | ProtocolOp op = new CompareRequestProtocolOp(dnStr, attrName, attrValue); |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2014 ForgeRock AS. |
| | | * Portions Copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | package org.opends.dsml.protocol; |
| | | |
| | |
| | | delResponse.setRequestID(deleteRequest.getRequestID()); |
| | | |
| | | // Create and send the LDAP delete request to the server. |
| | | ByteString dnStr = ByteString.valueOf(deleteRequest.getDn()); |
| | | ByteString dnStr = ByteString.valueOfUtf8(deleteRequest.getDn()); |
| | | ProtocolOp op = new DeleteRequestProtocolOp(dnStr); |
| | | LDAPMessage msg = new LDAPMessage(DSMLServlet.nextMessageID(), op, |
| | | controls); |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2014 ForgeRock AS. |
| | | * Portions Copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | package org.opends.dsml.protocol; |
| | | |
| | |
| | | { |
| | | LDAPResult modDNResponse = objFactory.createLDAPResult(); |
| | | modDNResponse.setRequestID(modifyDNRequest.getRequestID()); |
| | | ByteString dnStr = ByteString.valueOf(modifyDNRequest.getDn()); |
| | | ByteString dnStr = ByteString.valueOfUtf8(modifyDNRequest.getDn()); |
| | | ProtocolOp op = null; |
| | | |
| | | if (modifyDNRequest.getNewSuperior() != null) |
| | | { |
| | | op = new ModifyDNRequestProtocolOp(dnStr, ByteString |
| | | .valueOf(modifyDNRequest.getNewrdn()), modifyDNRequest |
| | | .isDeleteoldrdn(), ByteString.valueOf(modifyDNRequest |
| | | .valueOfUtf8(modifyDNRequest.getNewrdn()), modifyDNRequest |
| | | .isDeleteoldrdn(), ByteString.valueOfUtf8(modifyDNRequest |
| | | .getNewSuperior())); |
| | | } |
| | | else |
| | | { |
| | | op = new ModifyDNRequestProtocolOp(dnStr, ByteString |
| | | .valueOf(modifyDNRequest.getNewrdn()), modifyDNRequest |
| | | .valueOfUtf8(modifyDNRequest.getNewrdn()), modifyDNRequest |
| | | .isDeleteoldrdn()); |
| | | } |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | ByteString dnStr = ByteString.valueOf(modifyRequest.getDn()); |
| | | ByteString dnStr = ByteString.valueOfUtf8(modifyRequest.getDn()); |
| | | |
| | | // Create and send the LDAP request to the server. |
| | | ProtocolOp op = new ModifyRequestProtocolOp(dnStr, modifications); |
| | |
| | | } |
| | | |
| | | SearchRequestProtocolOp protocolOp = new SearchRequestProtocolOp(ByteString |
| | | .valueOf(searchRequest.getDn()), scope, derefPolicy, |
| | | .valueOfUtf8(searchRequest.getDn()), scope, derefPolicy, |
| | | (int) searchRequest.getSizeLimit(), (int) searchRequest.getTimeLimit(), |
| | | searchRequest.isTypesOnly(), filter, attributes); |
| | | try |
| | |
| | | attributes.add(SchemaConstants.NO_ATTRIBUTES); |
| | | ArrayList<org.opends.server.types.Control> controls = new ArrayList<>(1); |
| | | org.opends.server.types.Control proxyAuthzControl = |
| | | new ProxiedAuthV2Control(true, ByteString.valueOf(authorizationID)); |
| | | new ProxiedAuthV2Control(true, ByteString.valueOfUtf8(authorizationID)); |
| | | controls.add(proxyAuthzControl); |
| | | |
| | | try |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2013-2014 ForgeRock AS. |
| | | * Copyright 2013-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.adapter.server3x; |
| | | |
| | |
| | | @Override |
| | | public Result modifyDN(final ModifyDNRequest request) throws LdapException { |
| | | final ModifyDNOperation modifyDNOperation = |
| | | icc.processModifyDN(valueOf(request.getName()), |
| | | valueOf(request.getNewRDN()), |
| | | icc.processModifyDN(valueOfObject(request.getName()), |
| | | valueOfObject(request.getNewRDN()), |
| | | request.isDeleteOldRDN(), |
| | | request.getNewSuperior() != null ? valueOf(request.getNewSuperior()) : null, |
| | | request.getNewSuperior() != null ? valueOfObject(request.getNewSuperior()) : null, |
| | | to(request.getControls())); |
| | | return getResponseResult(modifyDNOperation); |
| | | } |
| | |
| | | @Override |
| | | public Result modify(final ModifyRequest request) throws LdapException { |
| | | final ModifyOperation modifyOperation = |
| | | icc.processModify(valueOf(request.getName()), toRawModifications(request |
| | | icc.processModify(valueOfObject(request.getName()), toRawModifications(request |
| | | .getModifications()), to(request.getControls())); |
| | | return getResponseResult(modifyOperation); |
| | | } |
| | |
| | | @Override |
| | | public Result delete(final DeleteRequest request) throws LdapException { |
| | | final DeleteOperation deleteOperation = |
| | | icc.processDelete(valueOf(request.getName()), to(request.getControls())); |
| | | icc.processDelete(valueOfObject(request.getName()), to(request.getControls())); |
| | | return getResponseResult(deleteOperation); |
| | | } |
| | | |
| | | @Override |
| | | public CompareResult compare(final CompareRequest request) throws LdapException { |
| | | final CompareOperation compareOperation = |
| | | icc.processCompare(valueOf(request.getName()), |
| | | icc.processCompare(valueOfObject(request.getName()), |
| | | request.getAttributeDescription().toString(), |
| | | request.getAssertionValue(), to(request.getControls())); |
| | | |
| | |
| | | BindOperation bindOperation = null; |
| | | if (request instanceof SimpleBindRequest) { |
| | | bindOperation = |
| | | icc.processSimpleBind(valueOf(request.getName()), |
| | | icc.processSimpleBind(valueOfUtf8(request.getName()), |
| | | ByteString.wrap(((SimpleBindRequest) request).getPassword()), |
| | | to(request.getControls())); |
| | | } else if (request instanceof SASLBindRequest) { |
| | |
| | | final GenericBindRequest genericBindRequest = bindClient.nextBindRequest(); |
| | | bindOperation = |
| | | icc.processSASLBind( |
| | | valueOf(request.getName()), |
| | | valueOfUtf8(request.getName()), |
| | | ((SASLBindRequest) request).getSASLMechanism(), |
| | | getCredentials(genericBindRequest.getAuthenticationValue()), |
| | | to(request.getControls())); |
| | |
| | | @Override |
| | | public Result add(final AddRequest request) throws LdapException { |
| | | final AddOperation addOperation = |
| | | icc.processAdd(valueOf(request.getName()), to(request |
| | | icc.processAdd(valueOfObject(request.getName()), to(request |
| | | .getAllAttributes()), to(request.getControls())); |
| | | return getResponseResult(addOperation); |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | bs = ByteString.valueOf(value.toString()); |
| | | bs = ByteString.valueOfUtf8(value.toString()); |
| | | } |
| | | builder.add(bs); |
| | | } |
| | |
| | | { |
| | | if (value instanceof String) |
| | | { |
| | | return ByteString.valueOf((String) value); |
| | | return ByteString.valueOfUtf8((String) value); |
| | | } |
| | | else if (value instanceof byte[]) |
| | | { |
| | | return ByteString.wrap((byte[]) value); |
| | | } |
| | | return ByteString.valueOf(String.valueOf(value)); |
| | | return ByteString.valueOfUtf8(String.valueOf(value)); |
| | | } |
| | | |
| | | /** |
| | |
| | | // Try this alternative: |
| | | AttributeType attrType = |
| | | getInfo().getServerDescriptor().getSchema().getAttributeType(attr.toString().toLowerCase()); |
| | | return new LDAPFilter(SearchFilter.createEqualityFilter(attrType, ByteString.valueOf(filterText))).toString(); |
| | | ByteString filterBytes = ByteString.valueOfUtf8(filterText); |
| | | return new LDAPFilter(SearchFilter.createEqualityFilter(attrType, filterBytes)).toString(); |
| | | } |
| | | } |
| | | else |
| | |
| | | } |
| | | else |
| | | { |
| | | bs = ByteString.valueOf(value.toString()); |
| | | bs = ByteString.valueOfUtf8(value.toString()); |
| | | } |
| | | builder.add(bs); |
| | | } |
| | |
| | | AttributeType attr = rdn.getAttributeType(i); |
| | | attributeTypes.add(attr); |
| | | attributeNames.add(rdn.getAttributeName(i)); |
| | | attributeValues.add(ByteString.valueOf(firstNonEmpty)); |
| | | attributeValues.add(ByteString.valueOfUtf8(firstNonEmpty)); |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | attributeTypes.add(attr); |
| | | attributeNames.add(attrName); |
| | | attributeValues.add(ByteString.valueOf((String) o)); |
| | | attributeValues.add(ByteString.valueOfUtf8((String) o)); |
| | | } |
| | | break; |
| | | } |
| | |
| | | AttributeType attr = rdn.getAttributeType(i); |
| | | attributeTypes.add(attr); |
| | | attributeNames.add(rdn.getAttributeName(i)); |
| | | attributeValues.add(ByteString.valueOf(firstNonEmpty)); |
| | | attributeValues.add(ByteString.valueOfUtf8(firstNonEmpty)); |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | attributeTypes.add(attr); |
| | | attributeNames.add(attrName); |
| | | attributeValues.add(ByteString.valueOf((String) o)); |
| | | attributeValues.add(ByteString.valueOfUtf8((String) o)); |
| | | } |
| | | break; |
| | | } |
| | |
| | | public static String getRDNString(String attrName, String attrValue) |
| | | { |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(attrName); |
| | | RDN rdn = new RDN(attrType, attrName, ByteString.valueOf(attrValue)); |
| | | RDN rdn = new RDN(attrType, attrName, ByteString.valueOfUtf8(attrValue)); |
| | | return rdn.toString(); |
| | | } |
| | | |
| | |
| | | ifNull(value); |
| | | |
| | | try { |
| | | return Aci.decode(ByteString.valueOf(value), DN.NULL_DN); |
| | | return Aci.decode(ByteString.valueOfUtf8(value), DN.NULL_DN); |
| | | } catch (AciException e) { |
| | | // TODO: it would be nice to throw the cause. |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | |
| | | // Now add the single RDN representing the named instance. |
| | | String type = profile.getRelationChildRDNType(r); |
| | | AttributeType atype = DirectoryServer.getAttributeTypeOrDefault(type.toLowerCase()); |
| | | ByteString avalue = ByteString.valueOf(name); |
| | | ByteString avalue = ByteString.valueOfUtf8(name); |
| | | dn = dn.child(RDN.create(atype, avalue)); |
| | | } |
| | | |
| | |
| | | // Now add the single RDN representing the instance. |
| | | String type = profile.getRelationChildRDNType(r); |
| | | AttributeType atype = DirectoryServer.getAttributeTypeOrDefault(type.toLowerCase()); |
| | | ByteString avalue = ByteString.valueOf(d.getName()); |
| | | ByteString avalue = ByteString.valueOfUtf8(d.getName()); |
| | | dn = dn.child(RDN.create(atype, avalue)); |
| | | } |
| | | |
| | |
| | | //Write right is more complicated. Create a dummy value and set that as |
| | | //the attribute's value. Call the special writeRightsString method, rather |
| | | //than rightsString. |
| | | ByteString val= ByteString.valueOf("dum###Val"); |
| | | ByteString val= ByteString.valueOfUtf8("dum###Val"); |
| | | container.setCurrentAttributeValue(val); |
| | | evalInfo.append(attributeLevelWriteRights(container, handler, skipCheck)); |
| | | addAttrLevelRightsInfo(container, mask, a, retEntry, "write"); |
| | | evalInfo.append(','); |
| | | //Perform both selfwrite_add and selfwrite_delete and append results. |
| | | ByteString val1 = ByteString.valueOf(container.getClientDN().toString()); |
| | | ByteString val1 = ByteString.valueOfUtf8(container.getClientDN().toString()); |
| | | if(!specificAttr) |
| | | { |
| | | container.setCurrentAttributeType(dnAttributeType); |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2014 ForgeRock AS |
| | | * Portions Copyright 2013-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.authorization.dseecompat; |
| | | |
| | |
| | | for(Aci aci : hashEntry.getValue()) { |
| | | try { |
| | | Aci newAci = |
| | | Aci.decode(ByteString.valueOf(aci.toString()), relocateDN); |
| | | Aci.decode(ByteString.valueOfUtf8(aci.toString()), relocateDN); |
| | | acis.add(newAci); |
| | | } catch (AciException ex) { |
| | | //This should never happen since only a copy of the |
| | |
| | | } |
| | | } |
| | | |
| | | attributeValues.add(ByteString.valueOf(valueString)); |
| | | attributeValues.add(ByteString.valueOfUtf8(valueString)); |
| | | return pos; |
| | | } |
| | | |
| | |
| | | else if (c == '*') |
| | | { |
| | | escaped = false; |
| | | attributeValues.add(ByteString.valueOf(valueString)); |
| | | attributeValues.add(ByteString.valueOfUtf8(valueString)); |
| | | } |
| | | else |
| | | { |
| | |
| | | throw new DirectoryException(ResultCode.INVALID_DN_SYNTAX, |
| | | message); |
| | | } |
| | | attributeValues.add(ByteString.valueOf(valueString)); |
| | | attributeValues.add(ByteString.valueOfUtf8(valueString)); |
| | | valueString = new StringBuilder(); |
| | | hexChars = new StringBuilder(); |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | attributeValues.add(ByteString.valueOf(valueString)); |
| | | attributeValues.add(ByteString.valueOfUtf8(valueString)); |
| | | return pos; |
| | | } |
| | | } |
| | |
| | | InternalSearchOperation op = getRootConnection().processSearch(request); |
| | | LinkedList<SearchResultEntry> result = op.getSearchEntries(); |
| | | if (!result.isEmpty()) { |
| | | ByteString val= ByteString.valueOf(attrVal); |
| | | ByteString val= ByteString.valueOfUtf8(attrVal); |
| | | SearchResultEntry resultEntry = result.getFirst(); |
| | | if(resultEntry.hasValue(attrType, null, val)) { |
| | | Entry e=evalCtx.getResourceEntry(); |
| | |
| | | userAttrs.put(t, asList(t, v)); |
| | | |
| | | t = DirectoryServer.getAttributeTypeOrDefault(ATTR_BACKUP_BACKEND_DN); |
| | | userAttrs.put(t, asList(t, ByteString.valueOf(backupDirectory.getConfigEntryDN().toString()))); |
| | | userAttrs.put(t, asList(t, ByteString.valueOfUtf8(backupDirectory.getConfigEntryDN().toString()))); |
| | | |
| | | Entry e = new Entry(entryDN, ocMap, userAttrs, opAttrs); |
| | | e.processVirtualAttributes(); |
| | |
| | | if (backupDate != null) { |
| | | t = DirectoryServer.getAttributeTypeOrDefault(ATTR_BACKUP_DATE); |
| | | userAttrs.put(t, |
| | | asList(t, ByteString.valueOf(GeneralizedTimeSyntax.format(backupDate)))); |
| | | asList(t, ByteString.valueOfUtf8(GeneralizedTimeSyntax.format(backupDate)))); |
| | | } |
| | | |
| | | putBoolean(userAttrs, ATTR_BACKUP_COMPRESSED, backupInfo.isCompressed()); |
| | |
| | | if (properties != null && !properties.isEmpty()) { |
| | | for (Map.Entry<String, String> e : properties.entrySet()) { |
| | | t = DirectoryServer.getAttributeTypeOrDefault(toLowerCase(e.getKey())); |
| | | userAttrs.put(t, asList(t, ByteString.valueOf(e.getValue()))); |
| | | userAttrs.put(t, asList(t, ByteString.valueOfUtf8(e.getValue()))); |
| | | } |
| | | } |
| | | |
| | |
| | | public static DN makeChildDN(DN parentDN, AttributeType rdnAttrType, |
| | | String rdnStringValue) |
| | | { |
| | | ByteString attrValue = ByteString.valueOf(rdnStringValue); |
| | | ByteString attrValue = ByteString.valueOfUtf8(rdnStringValue); |
| | | return parentDN.child(RDN.create(rdnAttrType, attrValue)); |
| | | } |
| | | } |
| | |
| | | cfg.getBaseDN().toArray(newBaseDNs); |
| | | this.baseDNs = newBaseDNs; |
| | | |
| | | creatorsName = ByteString.valueOf(newBaseDNs[0].toString()); |
| | | modifiersName = ByteString.valueOf(newBaseDNs[0].toString()); |
| | | creatorsName = ByteString.valueOfUtf8(newBaseDNs[0].toString()); |
| | | modifiersName = ByteString.valueOfUtf8(newBaseDNs[0].toString()); |
| | | |
| | | long createTime = DirectoryServer.getSchema().getOldestModificationTime(); |
| | | createTimestamp = |
| | |
| | | authzDN = DN.rootDN(); |
| | | } |
| | | |
| | | modifiersName = ByteString.valueOf(authzDN.toString()); |
| | | modifiersName = ByteString.valueOfUtf8(authzDN.toString()); |
| | | modifyTimestamp = GeneralizedTimeSyntax.createGeneralizedTimeValue( |
| | | System.currentTimeMillis()); |
| | | } |
| | |
| | | { |
| | | if (schemaFile.equals(getSchemaFile(ldapSyntax))) |
| | | { |
| | | values.add(ByteString.valueOf(ldapSyntax.toString())); |
| | | values.add(ByteString.valueOfUtf8(ldapSyntax.toString())); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | if (schemaFile.equals(getSchemaFile(nf))) |
| | | { |
| | | values.add(ByteString.valueOf(nf.toString())); |
| | | values.add(ByteString.valueOfUtf8(nf.toString())); |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | if (schemaFile.equals(getSchemaFile(dcr))) |
| | | { |
| | | values.add(ByteString.valueOf(dcr.toString())); |
| | | values.add(ByteString.valueOfUtf8(dcr.toString())); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | if (schemaFile.equals(getSchemaFile(mru))) |
| | | { |
| | | values.add(ByteString.valueOf(mru.toString())); |
| | | values.add(ByteString.valueOfUtf8(mru.toString())); |
| | | } |
| | | } |
| | | |
| | |
| | | addedTypes, depth+1); |
| | | } |
| | | |
| | | values.add(ByteString.valueOf(attributeType.toString())); |
| | | values.add(ByteString.valueOfUtf8(attributeType.toString())); |
| | | addedTypes.add(attributeType); |
| | | } |
| | | |
| | |
| | | addedClasses, depth+1); |
| | | } |
| | | } |
| | | values.add(ByteString.valueOf(objectClass.toString())); |
| | | values.add(ByteString.valueOfUtf8(objectClass.toString())); |
| | | addedClasses.add(objectClass); |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | values.add(ByteString.valueOf(ditStructureRule.toString())); |
| | | values.add(ByteString.valueOfUtf8(ditStructureRule.toString())); |
| | | addedDSRs.add(ditStructureRule); |
| | | } |
| | | |
| | |
| | | public static DN makeChildDN(DN parentDN, AttributeType rdnAttrType, |
| | | String rdnStringValue) |
| | | { |
| | | ByteString attrValue = ByteString.valueOf(rdnStringValue); |
| | | ByteString attrValue = ByteString.valueOfUtf8(rdnStringValue); |
| | | return parentDN.child(RDN.create(rdnAttrType, attrValue)); |
| | | } |
| | | |
| | |
| | | |
| | | private Pair<String, DN> decodeURIAndDN(byte[] data) throws DirectoryException { |
| | | try { |
| | | final ByteSequenceReader reader = ByteString.valueOf(data).asReader(); |
| | | final ByteSequenceReader reader = ByteString.valueOfBytes(data).asReader(); |
| | | final String labeledURI = reader.readStringUtf8(getNextStringLength(reader)); |
| | | // skip the string separator |
| | | reader.skip(1); |
| | |
| | | indexRemoveEntry(indexBuffer, entry, leafID); |
| | | |
| | | // Remove the id2c and id2s records for this entry. |
| | | final ByteString leafIDKeyBytes = ByteString.valueOf(leafID.longValue()); |
| | | final ByteString leafIDKeyBytes = ByteString.valueOfLong(leafID.longValue()); |
| | | id2children.delete(indexBuffer, leafIDKeyBytes); |
| | | id2subtree.delete(indexBuffer, leafIDKeyBytes); |
| | | |
| | |
| | | throw new JebException(ERR_MISSING_DN2ID_RECORD.get(parentDN)); |
| | | } |
| | | |
| | | ByteString parentIDBytes = ByteString.valueOf(parentID.longValue()); |
| | | ByteString parentIDBytes = ByteString.valueOfLong(parentID.longValue()); |
| | | // Remove from id2children. |
| | | if (isParent) |
| | | { |
| | |
| | | dn = getParentWithinBase(dn)) |
| | | { |
| | | EntryID parentID = dn2id.get(txn, dn, LockMode.DEFAULT); |
| | | ByteString parentIDKeyBytes = ByteString.valueOf(parentID.longValue()); |
| | | ByteString parentIDKeyBytes = ByteString.valueOfLong(parentID.longValue()); |
| | | if(isParent) |
| | | { |
| | | id2children.insertID(buffer, parentIDKeyBytes, newID); |
| | |
| | | for (DN dn = oldSuperiorDN; dn != null; dn = getParentWithinBase(dn)) |
| | | { |
| | | EntryID parentID = dn2id.get(txn, dn, LockMode.DEFAULT); |
| | | ByteString parentIDKeyBytes = ByteString.valueOf(parentID.longValue()); |
| | | ByteString parentIDKeyBytes = ByteString.valueOfLong(parentID.longValue()); |
| | | if(isParent) |
| | | { |
| | | id2children.removeID(buffer, parentIDKeyBytes, oldID); |
| | |
| | | { |
| | | // All the subordinates will be renumbered so we have to rebuild |
| | | // id2c and id2s with the new ID. |
| | | ByteString oldIDKeyBytes = ByteString.valueOf(oldID.longValue()); |
| | | ByteString oldIDKeyBytes = ByteString.valueOfLong(oldID.longValue()); |
| | | id2children.delete(buffer, oldIDKeyBytes); |
| | | id2subtree.delete(buffer, oldIDKeyBytes); |
| | | |
| | |
| | | for (DN dn = oldSuperiorDN; dn != null; dn = getParentWithinBase(dn)) |
| | | { |
| | | EntryID parentID = dn2id.get(txn, dn, LockMode.DEFAULT); |
| | | ByteString parentIDKeyBytes = ByteString.valueOf(parentID.longValue()); |
| | | ByteString parentIDKeyBytes = ByteString.valueOfLong(parentID.longValue()); |
| | | id2subtree.removeID(buffer, parentIDKeyBytes, oldID); |
| | | } |
| | | } |
| | |
| | | { |
| | | // All the subordinates will be renumbered so we have to rebuild |
| | | // id2c and id2s with the new ID. |
| | | ByteString oldIDKeyBytes = ByteString.valueOf(oldID.longValue()); |
| | | ByteString oldIDKeyBytes = ByteString.valueOfLong(oldID.longValue()); |
| | | id2children.delete(buffer, oldIDKeyBytes); |
| | | id2subtree.delete(buffer, oldIDKeyBytes); |
| | | |
| | |
| | | return -1; |
| | | } |
| | | |
| | | final ByteString val1 = ByteString.valueOf(b1Bytes); |
| | | final ByteString val2 = ByteString.valueOf(b2Bytes); |
| | | final ByteString val1 = ByteString.valueOfBytes(b1Bytes); |
| | | final ByteString val2 = ByteString.valueOfBytes(b2Bytes); |
| | | final int result = ascending[j] ? val1.compareTo(val2) : val2.compareTo(val1); |
| | | if(result != 0) |
| | | { |
| | |
| | | ex = getNewExchange(treeName, true); |
| | | // Work around a problem with forced shutdown right after tree creation. |
| | | // Tree operations are not part of the journal, so force a couple operations to be able to recover. |
| | | ByteString dummyKey = ByteString.valueOf(DUMMY_RECORD); |
| | | ByteString dummyKey = ByteString.valueOfUtf8(DUMMY_RECORD); |
| | | put(treeName, dummyKey, ByteString.empty()); |
| | | delete(treeName, dummyKey); |
| | | } |
| | |
| | | @Override |
| | | public ByteString generateKey(String key) |
| | | { |
| | | return ByteString.valueOf(key.getBytes()); |
| | | return ByteString.valueOfUtf8(key); |
| | | } |
| | | } |
| | | |
| | |
| | | try |
| | | { |
| | | SortedSet<ByteString> keys = new TreeSet<>(); |
| | | indexer.createKeys(Schema.getDefaultSchema(), ByteString.valueOf(key.getBytes()), keys); |
| | | indexer.createKeys(Schema.getDefaultSchema(), ByteString.valueOfUtf8(key), keys); |
| | | return keys.first(); |
| | | } |
| | | catch (DecodeException e) |
| | |
| | | } |
| | | |
| | | /** The key bytes used for the presence index as a {@link ByteString}. */ |
| | | static final ByteString PRESENCE_KEY = ByteString.valueOf("+"); |
| | | static final ByteString PRESENCE_KEY = ByteString.valueOfUtf8("+"); |
| | | |
| | | /** A special indexer for generating presence indexes. */ |
| | | private static final Indexer PRESENCE_INDEXER = new Indexer() |
| | |
| | | @Override |
| | | public ByteString getTreeKey(String data) |
| | | { |
| | | return ByteString.valueOf(data); |
| | | return ByteString.valueOfUtf8(data); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | return ByteString.valueOf(key.getBytes()); |
| | | return ByteString.valueOfBytes(key.getBytes()); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | if (value == null) |
| | | { |
| | | value = ByteString.valueOf(id); |
| | | value = ByteString.valueOfLong(id); |
| | | } |
| | | return value; |
| | | } |
| | |
| | | public static final EntryIDSetCodec CODEC_V1 = new EntryIDSetCodecV1(); |
| | | public static final EntryIDSetCodec CODEC_V2 = new EntryIDSetCodecV2(); |
| | | |
| | | private static final ByteSequence NO_KEY = ByteString.valueOf("<none>"); |
| | | private static final ByteSequence NO_KEY = ByteString.valueOfUtf8("<none>"); |
| | | private static final long[] EMPTY_LONG_ARRAY = new long[0]; |
| | | private static final long[] NO_ENTRY_IDS_RANGE = new long[] { 0, 0 }; |
| | | |
| | |
| | | ByteString toValue(final long count) |
| | | { |
| | | Reject.ifFalse(count != 0, "count must be != 0"); |
| | | return ByteString.valueOf(count); |
| | | return ByteString.valueOfLong(count); |
| | | } |
| | | |
| | | long fromValue(ByteString value) |
| | |
| | | for(IndexFlag flag : flags) { |
| | | value |= flag.mask; |
| | | } |
| | | return ByteString.valueOf(new byte[] { value }); |
| | | return ByteString.valueOfBytes(new byte[] { value }); |
| | | } |
| | | |
| | | /** |
| | |
| | | ATTR_TASK_LOG_MESSAGES.toLowerCase(), ATTR_TASK_LOG_MESSAGES); |
| | | |
| | | final List<Attribute> attrList = taskEntry.getAttribute(type); |
| | | ByteString value = ByteString.valueOf(messageString); |
| | | ByteString value = ByteString.valueOfUtf8(messageString); |
| | | if (attrList == null) |
| | | { |
| | | taskEntry.putAttribute(type, newArrayList(Attributes.create(type, value))); |
| | |
| | | static LinkedHashSet<ByteString> getValueSet(String value) |
| | | { |
| | | LinkedHashSet<ByteString> valueSet = new LinkedHashSet<>(1); |
| | | valueSet.add(ByteString.valueOf(value)); |
| | | valueSet.add(ByteString.valueOfUtf8(value)); |
| | | return valueSet; |
| | | } |
| | | |
| | |
| | | LinkedHashSet<ByteString> valueSet = new LinkedHashSet<>(values.size()); |
| | | for (String value : values) |
| | | { |
| | | valueSet.add(ByteString.valueOf(value)); |
| | | valueSet.add(ByteString.valueOfUtf8(value)); |
| | | } |
| | | return valueSet; |
| | | } |
| | |
| | | throw new ConfigException(ERR_CONFIG_ATTR_DN_NULL.get(getName())); |
| | | } |
| | | |
| | | ByteString attrValue = ByteString.valueOf(value.toString()); |
| | | ByteString attrValue = ByteString.valueOfUtf8(value.toString()); |
| | | if (valueSet.contains(attrValue)) |
| | | { |
| | | throw new ConfigException(ERR_CONFIG_ATTR_ADD_VALUES_ALREADY_EXISTS.get(getName(), value)); |
| | |
| | | { |
| | | return new LinkedHashSet<>(0); |
| | | } |
| | | return newLinkedHashSet(ByteString.valueOf(value.toString())); |
| | | return newLinkedHashSet(ByteString.valueOfUtf8(value.toString())); |
| | | } |
| | | |
| | | |
| | |
| | | LinkedHashSet<ByteString> valueSet = new LinkedHashSet<>(values.size()); |
| | | for (DN value : values) |
| | | { |
| | | valueSet.add(ByteString.valueOf(value.toString())); |
| | | valueSet.add(ByteString.valueOfUtf8(value.toString())); |
| | | } |
| | | return valueSet; |
| | | } |
| | |
| | | continue; |
| | | } |
| | | |
| | | valueSet.add(ByteString.valueOf(dn.toString())); |
| | | valueSet.add(ByteString.valueOfUtf8(dn.toString())); |
| | | } |
| | | |
| | | // If this method was configured to continue on error, then it is possible |
| | |
| | | } |
| | | |
| | | String valueString = String.valueOf(value); |
| | | ByteString attrValue = ByteString.valueOf(valueString); |
| | | ByteString attrValue = ByteString.valueOfUtf8(valueString); |
| | | if (valueSet.contains(attrValue)) |
| | | { |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_ADD_VALUES_ALREADY_EXISTS.get( |
| | |
| | | LinkedHashSet<ByteString> valueSet = new LinkedHashSet<>(values.size()); |
| | | for (long value : values) |
| | | { |
| | | valueSet.add(ByteString.valueOf(String.valueOf(value))); |
| | | valueSet.add(ByteString.valueOfUtf8(String.valueOf(value))); |
| | | } |
| | | return valueSet; |
| | | } |
| | |
| | | continue; |
| | | } |
| | | |
| | | valueSet.add(ByteString.valueOf(valueString)); |
| | | valueSet.add(ByteString.valueOfUtf8(valueString)); |
| | | } |
| | | |
| | | // If this method was configured to continue on error, then it is possible |
| | |
| | | continue; |
| | | } |
| | | |
| | | valueSet.add(ByteString.valueOf(valueString)); |
| | | valueSet.add(ByteString.valueOfUtf8(valueString)); |
| | | } |
| | | |
| | | |
| | |
| | | throw new ConfigException(ERR_CONFIG_ATTR_VALUE_NOT_ALLOWED.get(value, getName())); |
| | | } |
| | | |
| | | ByteString attrValue = ByteString.valueOf(value); |
| | | ByteString attrValue = ByteString.valueOfUtf8(value); |
| | | if (valueSet.contains(attrValue)) |
| | | { |
| | | throw new ConfigException(ERR_CONFIG_ATTR_ADD_VALUES_ALREADY_EXISTS.get(getName(), value)); |
| | |
| | | continue; |
| | | } |
| | | |
| | | valueSet.add(ByteString.valueOf(valueString)); |
| | | valueSet.add(ByteString.valueOfUtf8(valueString)); |
| | | } |
| | | |
| | | // If this method was configured to continue on error, then it is possible |
| | |
| | | throw new ConfigException(ERR_CONFIG_ATTR_EMPTY_STRING_VALUE.get(getName())); |
| | | } |
| | | |
| | | ByteString attrValue = ByteString.valueOf(value); |
| | | ByteString attrValue = ByteString.valueOfUtf8(value); |
| | | if (valueSet.contains(attrValue)) |
| | | { |
| | | throw new ConfigException(ERR_CONFIG_ATTR_ADD_VALUES_ALREADY_EXISTS.get(getName(), value)); |
| | |
| | | continue; |
| | | } |
| | | |
| | | valueSet.add(ByteString.valueOf(valueString)); |
| | | valueSet.add(ByteString.valueOfUtf8(valueString)); |
| | | } |
| | | |
| | | // If this method was configured to continue on error, then it is possible |
| | |
| | | |
| | | this.authorizationDN = authorizationDN; |
| | | |
| | | rawAuthorizationDN = ByteString.valueOf(authorizationDN.toString()); |
| | | rawAuthorizationDN = ByteString.valueOfUtf8(authorizationDN.toString()); |
| | | } |
| | | |
| | | |
| | |
| | | this.userAttributes = userAttributes; |
| | | this.operationalAttributes = operationalAttributes; |
| | | |
| | | rawEntryDN = ByteString.valueOf(entryDN.toString()); |
| | | rawEntryDN = ByteString.valueOfUtf8(entryDN.toString()); |
| | | |
| | | ArrayList<String> values = new ArrayList<>(objectClasses.values()); |
| | | rawAttributes = new ArrayList<>(); |
| | |
| | | { |
| | | if (bindDN != null) |
| | | { |
| | | return ByteString.valueOf(bindDN.toString()); |
| | | return ByteString.valueOfUtf8(bindDN.toString()); |
| | | } |
| | | return ByteString.empty(); |
| | | } |
| | |
| | | this.assertionValue = assertionValue; |
| | | |
| | | responseControls = new ArrayList<>(); |
| | | rawEntryDN = ByteString.valueOf(entryDN.toString()); |
| | | rawEntryDN = ByteString.valueOfUtf8(entryDN.toString()); |
| | | rawAttributeType = attributeType.getNameOrOID(); |
| | | cancelRequest = null; |
| | | proxiedAuthorizationDN = null; |
| | |
| | | super(clientConnection, operationID, messageID, requestControls); |
| | | |
| | | this.entryDN = entryDN; |
| | | rawEntryDN = ByteString.valueOf(entryDN.toString()); |
| | | rawEntryDN = ByteString.valueOfUtf8(entryDN.toString()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | this.deleteOldRDN = deleteOldRDN; |
| | | this.newSuperior = newSuperior; |
| | | |
| | | rawEntryDN = ByteString.valueOf(entryDN.toString()); |
| | | rawNewRDN = ByteString.valueOf(newRDN.toString()); |
| | | rawEntryDN = ByteString.valueOfUtf8(entryDN.toString()); |
| | | rawNewRDN = ByteString.valueOfUtf8(newRDN.toString()); |
| | | |
| | | if (newSuperior == null) |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | rawNewSuperior = ByteString.valueOf(newSuperior.toString()); |
| | | rawNewSuperior = ByteString.valueOfUtf8(newSuperior.toString()); |
| | | } |
| | | |
| | | responseControls = new ArrayList<>(); |
| | |
| | | this.entryDN = entryDN; |
| | | this.modifications = modifications; |
| | | |
| | | rawEntryDN = ByteString.valueOf(entryDN.toString()); |
| | | rawEntryDN = ByteString.valueOfUtf8(entryDN.toString()); |
| | | |
| | | rawModifications = new ArrayList<>(modifications.size()); |
| | | for (Modification m : modifications) |
| | |
| | | { |
| | | if (requireChangeBy != null) |
| | | { |
| | | ByteString valueString = ByteString.valueOf(requireChangeBy); |
| | | ByteString valueString = ByteString.valueOfUtf8(requireChangeBy); |
| | | requireChangeByTime = GeneralizedTime.valueOf(valueString.toString()).getTimeInMillis(); |
| | | } |
| | | } |
| | |
| | | valuesToRemove = new LinkedHashSet<>(); |
| | | } |
| | | |
| | | valuesToRemove.add(ByteString.valueOf(GeneralizedTimeSyntax.format(l))); |
| | | valuesToRemove.add(ByteString.valueOfUtf8(GeneralizedTimeSyntax.format(l))); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | return passwordPolicy.isAuthPasswordSyntax() |
| | | ? scheme.getAuthPasswordPlaintextValue(pwComponents[1], pwComponents[2]) |
| | | : scheme.getPlaintextValue(ByteString.valueOf(pwComponents[1])); |
| | | : scheme.getPlaintextValue(ByteString.valueOfUtf8(pwComponents[1])); |
| | | } |
| | | |
| | | @Override |
| | |
| | | { |
| | | return passwordPolicy.isAuthPasswordSyntax() |
| | | ? scheme.authPasswordMatches(password, pwComponents[1], pwComponents[2]) |
| | | : scheme.passwordMatches(password, ByteString.valueOf(pwComponents[1])); |
| | | : scheme.passwordMatches(password, ByteString.valueOfUtf8(pwComponents[1])); |
| | | } |
| | | |
| | | private ByteString encodePassword(ByteString password, PasswordStorageScheme<?> s) throws DirectoryException |
| | |
| | | { |
| | | try |
| | | { |
| | | long timestamp = |
| | | GeneralizedTimeSyntax.decodeGeneralizedTimeValue(ByteString.valueOf(histStr.substring(0, hashPos))); |
| | | ByteString timeValue = ByteString.valueOfUtf8(histStr.substring(0, hashPos)); |
| | | long timestamp = GeneralizedTimeSyntax.decodeGeneralizedTimeValue(timeValue); |
| | | historyMap.put(timestamp, v); |
| | | } |
| | | catch (Exception e) |
| | |
| | | { |
| | | String[] userPWComponents = UserPasswordSyntax.decodeUserPassword(encodedUserPassword); |
| | | PasswordStorageScheme<?> scheme = DirectoryServer.getPasswordStorageScheme(userPWComponents[0]); |
| | | return scheme.passwordMatches(password, ByteString.valueOf(userPWComponents[1])); |
| | | return scheme.passwordMatches(password, ByteString.valueOfUtf8(userPWComponents[1])); |
| | | } |
| | | |
| | | private boolean logResult(String passwordType, boolean passwordMatches) |
| | |
| | | } |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | ModifyOperation internalModify = conn.processModify(ByteString.valueOf(userDNString), modList); |
| | | ModifyOperation internalModify = conn.processModify(ByteString.valueOfUtf8(userDNString), modList); |
| | | |
| | | ResultCode resultCode = internalModify.getResultCode(); |
| | | if (resultCode != ResultCode.SUCCESS) |
| | |
| | | this.filter = filter; |
| | | this.attributes = attributes != null ? attributes : new LinkedHashSet<String>(0); |
| | | |
| | | rawBaseDN = ByteString.valueOf(baseDN.toString()); |
| | | rawBaseDN = ByteString.valueOfUtf8(baseDN.toString()); |
| | | rawFilter = new LDAPFilter(filter); |
| | | |
| | | this.sizeLimit = getSizeLimit(sizeLimit, clientConnection); |
| | |
| | | filteredEntry.getObjectClasses().values().iterator(); |
| | | while (ocIterator.hasNext()) |
| | | { |
| | | ByteString ocName = ByteString.valueOf(ocIterator.next()); |
| | | ByteString ocName = ByteString.valueOfUtf8(ocIterator.next()); |
| | | if (! matchedValuesControl.valueMatches(attrType, ocName)) |
| | | { |
| | | ocIterator.remove(); |
| | |
| | | static byte[] getInstanceKeyCertificateFromLocalTruststore() |
| | | throws CryptoManagerException { |
| | | // Construct the key entry DN. |
| | | final ByteString distinguishedValue = ByteString.valueOf(ADS_CERTIFICATE_ALIAS); |
| | | final ByteString distinguishedValue = ByteString.valueOfUtf8(ADS_CERTIFICATE_ALIAS); |
| | | final DN entryDN = localTruststoreDN.child(RDN.create(attrKeyID, distinguishedValue)); |
| | | // Construct the search filter. |
| | | final String FILTER_OC_INSTANCE_KEY = "(objectclass=" + ocInstanceKey.getNameOrOID() + ")"; |
| | |
| | | final byte[] instanceKeyCertificate = getInstanceKeyCertificateFromLocalTruststore(); |
| | | final String instanceKeyID = getInstanceKeyID(instanceKeyCertificate); |
| | | // Construct the key entry DN. |
| | | final ByteString distinguishedValue = ByteString.valueOf(instanceKeyID); |
| | | final ByteString distinguishedValue = ByteString.valueOfUtf8(instanceKeyID); |
| | | final DN entryDN = instanceKeysDN.child( |
| | | RDN.create(attrKeyID, distinguishedValue)); |
| | | |
| | |
| | | { |
| | | // Construct the key entry DN. |
| | | ByteString distinguishedValue = |
| | | ByteString.valueOf(keyEntry.getKeyID().getStringValue()); |
| | | ByteString.valueOfUtf8(keyEntry.getKeyID().getStringValue()); |
| | | DN entryDN = secretKeysDN.child( |
| | | RDN.create(attrKeyID, distinguishedValue)); |
| | | |
| | |
| | | { |
| | | // Construct the key entry DN. |
| | | ByteString distinguishedValue = |
| | | ByteString.valueOf(keyEntry.getKeyID().getStringValue()); |
| | | ByteString.valueOfUtf8(keyEntry.getKeyID().getStringValue()); |
| | | DN entryDN = secretKeysDN.child( |
| | | RDN.create(attrKeyID, distinguishedValue)); |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2014 ForgeRock AS |
| | | * Portions Copyright 2013-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.crypto; |
| | | |
| | |
| | | |
| | | operation.setResponseOID( |
| | | ServerConstants.OID_GET_SYMMETRIC_KEY_EXTENDED_OP); |
| | | operation.setResponseValue(ByteString.valueOf(responseSymmetricKey)); |
| | | operation.setResponseValue(ByteString.valueOfUtf8(responseSymmetricKey)); |
| | | operation.setResultCode(ResultCode.SUCCESS); |
| | | } |
| | | catch (CryptoManagerException e) |
| | |
| | | byte[] encodedBytes = cryptoManager.encrypt(CIPHER_TRANSFORMATION_AES, |
| | | KEY_SIZE_AES, |
| | | plaintextBytes); |
| | | return ByteString.valueOf(Base64.encode(encodedBytes)); |
| | | return ByteString.valueOfUtf8(Base64.encode(encodedBytes)); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | return ByteString.valueOf(buffer); |
| | | return ByteString.valueOfUtf8(buffer); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | continue; |
| | | } |
| | | |
| | | ByteString vf = ByteString.valueOf(password); |
| | | ByteString vr = ByteString.valueOf(reversed); |
| | | ByteString vf = ByteString.valueOfUtf8(password); |
| | | ByteString vr = ByteString.valueOfUtf8(reversed); |
| | | |
| | | for (Attribute a : attrList) |
| | | { |
| | |
| | | public ByteString encodePassword(ByteSequence plaintext) |
| | | throws DirectoryException |
| | | { |
| | | return ByteString.valueOf(Base64.encode(plaintext)); |
| | | return ByteString.valueOfUtf8(Base64.encode(plaintext)); |
| | | } |
| | | |
| | | |
| | |
| | | buffer.append('}'); |
| | | buffer.append(Base64.encode(plaintext)); |
| | | |
| | | return ByteString.valueOf(buffer); |
| | | return ByteString.valueOfUtf8(buffer); |
| | | } |
| | | |
| | | |
| | |
| | | byte[] encodedBytes = |
| | | cryptoManager.encrypt(CIPHER_TRANSFORMATION_BLOWFISH, |
| | | KEY_SIZE_BLOWFISH, plaintextBytes); |
| | | return ByteString.valueOf(Base64.encode(encodedBytes)); |
| | | return ByteString.valueOfUtf8(Base64.encode(encodedBytes)); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | return ByteString.valueOf(buffer); |
| | | return ByteString.valueOfUtf8(buffer); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | challengeString.append('>'); |
| | | |
| | | final ByteString challenge = ByteString.valueOf(challengeString); |
| | | final ByteString challenge = ByteString.valueOfUtf8(challengeString); |
| | | clientConnection.setSASLAuthStateInfo(challenge); |
| | | bindOperation.setServerSASLCredentials(challenge); |
| | | bindOperation.setResultCode(ResultCode.SASL_BIND_IN_PROGRESS); |
| | |
| | | buffer.append('}'); |
| | | buffer.append(plaintext.toString()); |
| | | |
| | | return ByteString.valueOf(buffer); |
| | | return ByteString.valueOfUtf8(buffer); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | try |
| | | { |
| | | ByteString ts = ByteString.valueOf(name.substring(7, dotPos)); |
| | | ByteString ts = ByteString.valueOfUtf8(name.substring(7, dotPos)); |
| | | long timestamp = GeneralizedTimeSyntax.decodeGeneralizedTimeValue(ts); |
| | | if (timestamp > latestTimestamp) |
| | | { |
| | |
| | | { |
| | | try |
| | | { |
| | | ByteString ts = ByteString.valueOf(name.substring(7, dashPos)); |
| | | ByteString ts = ByteString.valueOfUtf8(name.substring(7, dashPos)); |
| | | long timestamp = GeneralizedTimeSyntax.decodeGeneralizedTimeValue(ts); |
| | | int counter = Integer.parseInt(name.substring(dashPos+1, dotPos)); |
| | | |
| | |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | message, e); |
| | | } |
| | | return ByteString.valueOf(output); |
| | | return ByteString.valueOfUtf8(output); |
| | | } |
| | | |
| | | private ByteString sha256CryptEncodePassword(ByteSequence plaintext) |
| | |
| | | Arrays.fill(plaintextBytes, (byte) 0); |
| | | } |
| | | } |
| | | return ByteString.valueOf(output); |
| | | return ByteString.valueOfUtf8(output); |
| | | } |
| | | |
| | | private ByteString sha512CryptEncodePassword(ByteSequence plaintext) |
| | |
| | | Arrays.fill(plaintextBytes, (byte) 0); |
| | | } |
| | | } |
| | | return ByteString.valueOf(output); |
| | | return ByteString.valueOfUtf8(output); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | |
| | | buffer.append(encodePassword(plaintext)); |
| | | |
| | | return ByteString.valueOf(buffer); |
| | | return ByteString.valueOfUtf8(buffer); |
| | | } |
| | | |
| | | /** |
| | |
| | | try |
| | | { |
| | | MatchingRule eqRule = rule.getAttributeType().getEqualityMatchingRule(); |
| | | ByteString dn = ByteString.valueOf(entry.getName().toString()); |
| | | ByteString dn = ByteString.valueOfUtf8(entry.getName().toString()); |
| | | ByteString normalizedDN = eqRule.normalizeAttributeValue(dn); |
| | | ByteString normalizedValue = eqRule.normalizeAttributeValue(value); |
| | | return normalizedDN.equals(normalizedValue); |
| | |
| | | SearchFilter filter; |
| | | if (attributeTypes.length == 1) |
| | | { |
| | | ByteString value = ByteString.valueOf(id); |
| | | ByteString value = ByteString.valueOfUtf8(id); |
| | | filter = SearchFilter.createEqualityFilter(attributeTypes[0], value); |
| | | } |
| | | else |
| | |
| | | ArrayList<SearchFilter> filterComps = new ArrayList<>(attributeTypes.length); |
| | | for (AttributeType t : attributeTypes) |
| | | { |
| | | ByteString value = ByteString.valueOf(id); |
| | | ByteString value = ByteString.valueOfUtf8(id); |
| | | filterComps.add(SearchFilter.createEqualityFilter(t, value)); |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | // Create the search filter from the fingerprint. |
| | | ByteString value = ByteString.valueOf(fingerprintString); |
| | | ByteString value = ByteString.valueOfUtf8(fingerprintString); |
| | | SearchFilter filter = |
| | | SearchFilter.createEqualityFilter(fingerprintAttributeType, value); |
| | | |
| | |
| | | { |
| | | try |
| | | { |
| | | connection.simpleBind(ByteString.valueOf(username.toString()), |
| | | ByteString.valueOf(password)); |
| | | connection.simpleBind(ByteString.valueOfUtf8(username.toString()), |
| | | ByteString.valueOfUtf8(password)); |
| | | } |
| | | catch (final DirectoryException e) |
| | | { |
| | |
| | | // Create the search request and send it to the server. |
| | | final SearchRequestProtocolOp searchRequest = |
| | | new SearchRequestProtocolOp( |
| | | ByteString.valueOf(baseDN.toString()), scope, |
| | | ByteString.valueOfUtf8(baseDN.toString()), scope, |
| | | DereferenceAliasesPolicy.ALWAYS, 1 /* size limit */, |
| | | (timeoutMS / 1000), true /* types only */, |
| | | RawFilter.create(filter), NO_ATTRIBUTES); |
| | |
| | | .getSearchResultEntryProtocolOp(); |
| | | if (username == null) |
| | | { |
| | | username = ByteString.valueOf(searchEntry.getDN().toString()); |
| | | username = ByteString.valueOfUtf8(searchEntry.getDN().toString()); |
| | | } |
| | | resultCount++; |
| | | break; |
| | |
| | | { |
| | | case UNMAPPED: |
| | | // The bind DN is the name of the user's entry. |
| | | username = ByteString.valueOf(userEntry.getName().toString()); |
| | | username = ByteString.valueOfUtf8(userEntry.getName().toString()); |
| | | break; |
| | | case MAPPED_BIND: |
| | | // The bind DN is contained in an attribute in the user's entry. |
| | |
| | | if (scheme != null) |
| | | { |
| | | return scheme.passwordMatches(password, |
| | | ByteString.valueOf(userPwComponents[1])); |
| | | ByteString.valueOfUtf8(userPwComponents[1])); |
| | | } |
| | | } |
| | | catch (DirectoryException e) |
| | |
| | | } |
| | | } |
| | | |
| | | return ByteString.valueOf(Base64.encode(digestBytes)); |
| | | return ByteString.valueOfUtf8(Base64.encode(digestBytes)); |
| | | } |
| | | |
| | | |
| | |
| | | buffer.append(Base64.encode(digestBytes)); |
| | | |
| | | |
| | | return ByteString.valueOf(buffer); |
| | | return ByteString.valueOfUtf8(buffer); |
| | | } |
| | | |
| | | |
| | |
| | | DN memberDN = memberList.nextMemberDN(); |
| | | if (memberDN != null) |
| | | { |
| | | builder.add(ByteString.valueOf(memberDN.toString())); |
| | | builder.add(ByteString.valueOfUtf8(memberDN.toString())); |
| | | } |
| | | } |
| | | catch (MembershipException me) |
| | |
| | | byte[] digestBytes = encodeWithRandomSalt(plaintext, saltBytes, iterations,random); |
| | | byte[] hashPlusSalt = concatenateHashPlusSalt(saltBytes, digestBytes); |
| | | |
| | | return ByteString.valueOf(iterations + ":" + Base64.encode(hashPlusSalt)); |
| | | return ByteString.valueOfUtf8(iterations + ":" + Base64.encode(hashPlusSalt)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | public ByteString encodePasswordWithScheme(ByteSequence plaintext) |
| | | throws DirectoryException |
| | | { |
| | | return ByteString.valueOf('{' + STORAGE_SCHEME_NAME_PBKDF2 + '}' + encodePassword(plaintext)); |
| | | return ByteString.valueOfUtf8('{' + STORAGE_SCHEME_NAME_PBKDF2 + '}' + encodePassword(plaintext)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | byte[] digestBytes = encodeWithRandomSalt(plaintext, saltBytes, iterations,random); |
| | | |
| | | // Encode and return the value. |
| | | return ByteString.valueOf(AUTH_PASSWORD_SCHEME_NAME_PBKDF2 + '$' |
| | | return ByteString.valueOfUtf8(AUTH_PASSWORD_SCHEME_NAME_PBKDF2 + '$' |
| | | + iterations + ':' + Base64.encode(saltBytes) + '$' + Base64.encode(digestBytes)); |
| | | } |
| | | |
| | |
| | | byte[] digestBytes = encodeWithRandomSalt(plaintext, saltBytes,random); |
| | | byte[] hashPlusSalt = concatenateSaltPlusHash(saltBytes, digestBytes); |
| | | |
| | | return ByteString.valueOf(Base64.encode(hashPlusSalt)); |
| | | return ByteString.valueOfUtf8(Base64.encode(hashPlusSalt)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | public ByteString encodePasswordWithScheme(ByteSequence plaintext) |
| | | throws DirectoryException |
| | | { |
| | | return ByteString.valueOf('{' + STORAGE_SCHEME_NAME_PKCS5S2 + '}' + encodePassword(plaintext)); |
| | | return ByteString.valueOfUtf8('{' + STORAGE_SCHEME_NAME_PKCS5S2 + '}' + encodePassword(plaintext)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | byte[] saltBytes = new byte[NUM_SALT_BYTES]; |
| | | byte[] digestBytes = encodeWithRandomSalt(plaintext, saltBytes,random); |
| | | // Encode and return the value. |
| | | return ByteString.valueOf(AUTH_PASSWORD_SCHEME_NAME_PKCS5S2 + '$' + iterations |
| | | return ByteString.valueOfUtf8(AUTH_PASSWORD_SCHEME_NAME_PKCS5S2 + '$' + iterations |
| | | + ':' + Base64.encode(saltBytes) + '$' + Base64.encode(digestBytes)); |
| | | } |
| | | |
| | |
| | | { |
| | | return pwPolicyState.getAuthenticationPolicy().isAuthPasswordSyntax() |
| | | ? scheme.authPasswordMatches(oldPassword, components[1], components[2]) |
| | | : scheme.passwordMatches(oldPassword, ByteString.valueOf(components[1])); |
| | | : scheme.passwordMatches(oldPassword, ByteString.valueOfUtf8(components[1])); |
| | | } |
| | | |
| | | private boolean isSelfChange(ByteString userIdentity, Entry requestorEntry, DN userDN, ByteString oldPassword) |
| | |
| | | { |
| | | try |
| | | { |
| | | ByteString valueString = ByteString.valueOf(opValues.get(0)); |
| | | ByteString valueString = ByteString.valueOfUtf8(opValues.get(0)); |
| | | long time = GeneralizedTime.valueOf(valueString.toString()).getTimeInMillis(); |
| | | pwpState.setAccountExpirationTime(time); |
| | | } |
| | |
| | | { |
| | | try |
| | | { |
| | | ByteString valueString = ByteString.valueOf(opValues.get(0)); |
| | | ByteString valueString = ByteString.valueOfUtf8(opValues.get(0)); |
| | | long time = GeneralizedTime.valueOf(valueString.toString()).getTimeInMillis(); |
| | | pwpState.setPasswordChangedTime(time); |
| | | } |
| | |
| | | { |
| | | try |
| | | { |
| | | ByteString valueString = ByteString.valueOf(opValues.get(0)); |
| | | ByteString valueString = ByteString.valueOfUtf8(opValues.get(0)); |
| | | long time = GeneralizedTime.valueOf(valueString.toString()).getTimeInMillis(); |
| | | pwpState.setWarnedTime(time); |
| | | } |
| | |
| | | { |
| | | try |
| | | { |
| | | ByteString valueString = ByteString.valueOf(opValues.get(0)); |
| | | ByteString valueString = ByteString.valueOfUtf8(opValues.get(0)); |
| | | long time = GeneralizedTime.valueOf(valueString.toString()).getTimeInMillis(); |
| | | List<Long> authFailureTimes = pwpState.getAuthFailureTimes(); |
| | | ArrayList<Long> newFailureTimes = new ArrayList<>(authFailureTimes.size()+1); |
| | |
| | | { |
| | | try |
| | | { |
| | | ByteString valueString = ByteString.valueOf(opValues.get(0)); |
| | | ByteString valueString = ByteString.valueOfUtf8(opValues.get(0)); |
| | | long time = GeneralizedTime.valueOf(valueString.toString()).getTimeInMillis(); |
| | | pwpState.setLastLoginTime(time); |
| | | } |
| | |
| | | { |
| | | try |
| | | { |
| | | ByteString valueString = ByteString.valueOf(opValues.get(0)); |
| | | ByteString valueString = ByteString.valueOfUtf8(opValues.get(0)); |
| | | long time = GeneralizedTime.valueOf(valueString.toString()).getTimeInMillis(); |
| | | List<Long> authFailureTimes = pwpState.getGraceLoginTimes(); |
| | | ArrayList<Long> newGraceTimes = new ArrayList<>(authFailureTimes.size()+1); |
| | |
| | | { |
| | | try |
| | | { |
| | | ByteString valueString = ByteString.valueOf(opValues.get(0)); |
| | | ByteString valueString = ByteString.valueOfUtf8(opValues.get(0)); |
| | | long time = GeneralizedTime.valueOf(valueString.toString()).getTimeInMillis(); |
| | | pwpState.setRequiredChangeTime(time); |
| | | } |
| | |
| | | return; |
| | | } |
| | | |
| | | if (!authState.passwordMatches(ByteString.valueOf(password))) |
| | | if (!authState.passwordMatches(ByteString.valueOfUtf8(password))) |
| | | { |
| | | bindOperation.setResultCode(ResultCode.INVALID_CREDENTIALS); |
| | | LocalizableMessage message = ERR_SASLPLAIN_INVALID_PASSWORD.get(); |
| | |
| | | byte[] encodedBytes = cryptoManager.encrypt(CIPHER_TRANSFORMATION_RC4, |
| | | KEY_SIZE_RC4, |
| | | plaintextBytes); |
| | | return ByteString.valueOf(Base64.encode(encodedBytes)); |
| | | return ByteString.valueOfUtf8(Base64.encode(encodedBytes)); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | return ByteString.valueOf(buffer); |
| | | return ByteString.valueOfUtf8(buffer); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | return ByteString.valueOf(buffer); |
| | | return ByteString.valueOfUtf8(buffer); |
| | | } |
| | | |
| | | |
| | |
| | | SearchFilter filter; |
| | | if (attributeTypes.length == 1) |
| | | { |
| | | ByteString value = ByteString.valueOf(processedID); |
| | | ByteString value = ByteString.valueOfUtf8(processedID); |
| | | filter = SearchFilter.createEqualityFilter(attributeTypes[0], value); |
| | | } |
| | | else |
| | |
| | | ArrayList<SearchFilter> filterComps = new ArrayList<>(attributeTypes.length); |
| | | for (AttributeType t : attributeTypes) |
| | | { |
| | | ByteString value = ByteString.valueOf(processedID); |
| | | ByteString value = ByteString.valueOfUtf8(processedID); |
| | | filterComps.add(SearchFilter.createEqualityFilter(t, value)); |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | return ByteString.valueOf(Base64.encode(digestBytes)); |
| | | return ByteString.valueOfUtf8(Base64.encode(digestBytes)); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | buffer.append(Base64.encode(digestBytes)); |
| | | |
| | | return ByteString.valueOf(buffer); |
| | | return ByteString.valueOfUtf8(buffer); |
| | | } |
| | | |
| | | |
| | |
| | | System.arraycopy(saltBytes, 0, hashPlusSalt, digestBytes.length, |
| | | NUM_SALT_BYTES); |
| | | |
| | | return ByteString.valueOf(Base64.encode(hashPlusSalt)); |
| | | return ByteString.valueOfUtf8(Base64.encode(hashPlusSalt)); |
| | | } |
| | | |
| | | |
| | |
| | | NUM_SALT_BYTES); |
| | | buffer.append(Base64.encode(hashPlusSalt)); |
| | | |
| | | return ByteString.valueOf(buffer); |
| | | return ByteString.valueOfUtf8(buffer); |
| | | } |
| | | |
| | | |
| | |
| | | authPWValue.append('$'); |
| | | authPWValue.append(Base64.encode(digestBytes)); |
| | | |
| | | return ByteString.valueOf(authPWValue); |
| | | return ByteString.valueOfUtf8(authPWValue); |
| | | } |
| | | |
| | | |
| | |
| | | System.arraycopy(saltBytes, 0, hashPlusSalt, digestBytes.length, |
| | | NUM_SALT_BYTES); |
| | | |
| | | return ByteString.valueOf(Base64.encode(hashPlusSalt)); |
| | | return ByteString.valueOfUtf8(Base64.encode(hashPlusSalt)); |
| | | } |
| | | |
| | | |
| | |
| | | NUM_SALT_BYTES); |
| | | buffer.append(Base64.encode(hashPlusSalt)); |
| | | |
| | | return ByteString.valueOf(buffer); |
| | | return ByteString.valueOfUtf8(buffer); |
| | | } |
| | | |
| | | |
| | |
| | | authPWValue.append('$'); |
| | | authPWValue.append(Base64.encode(digestBytes)); |
| | | |
| | | return ByteString.valueOf(authPWValue); |
| | | return ByteString.valueOfUtf8(authPWValue); |
| | | } |
| | | |
| | | |
| | |
| | | System.arraycopy(saltBytes, 0, hashPlusSalt, digestBytes.length, |
| | | NUM_SALT_BYTES); |
| | | |
| | | return ByteString.valueOf(Base64.encode(hashPlusSalt)); |
| | | return ByteString.valueOfUtf8(Base64.encode(hashPlusSalt)); |
| | | } |
| | | |
| | | |
| | |
| | | NUM_SALT_BYTES); |
| | | buffer.append(Base64.encode(hashPlusSalt)); |
| | | |
| | | return ByteString.valueOf(buffer); |
| | | return ByteString.valueOfUtf8(buffer); |
| | | } |
| | | |
| | | |
| | |
| | | authPWValue.append('$'); |
| | | authPWValue.append(Base64.encode(digestBytes)); |
| | | |
| | | return ByteString.valueOf(authPWValue); |
| | | return ByteString.valueOfUtf8(authPWValue); |
| | | } |
| | | |
| | | |
| | |
| | | System.arraycopy(saltBytes, 0, hashPlusSalt, digestBytes.length, |
| | | NUM_SALT_BYTES); |
| | | |
| | | return ByteString.valueOf(Base64.encode(hashPlusSalt)); |
| | | return ByteString.valueOfUtf8(Base64.encode(hashPlusSalt)); |
| | | } |
| | | |
| | | |
| | |
| | | NUM_SALT_BYTES); |
| | | buffer.append(Base64.encode(hashPlusSalt)); |
| | | |
| | | return ByteString.valueOf(buffer); |
| | | return ByteString.valueOfUtf8(buffer); |
| | | } |
| | | |
| | | |
| | |
| | | authPWValue.append('$'); |
| | | authPWValue.append(Base64.encode(digestBytes)); |
| | | |
| | | return ByteString.valueOf(authPWValue); |
| | | return ByteString.valueOfUtf8(authPWValue); |
| | | } |
| | | |
| | | |
| | |
| | | System.arraycopy(saltBytes, 0, hashPlusSalt, digestBytes.length, |
| | | NUM_SALT_BYTES); |
| | | |
| | | return ByteString.valueOf(Base64.encode(hashPlusSalt)); |
| | | return ByteString.valueOfUtf8(Base64.encode(hashPlusSalt)); |
| | | } |
| | | |
| | | |
| | |
| | | NUM_SALT_BYTES); |
| | | buffer.append(Base64.encode(hashPlusSalt)); |
| | | |
| | | return ByteString.valueOf(buffer); |
| | | return ByteString.valueOfUtf8(buffer); |
| | | } |
| | | |
| | | |
| | |
| | | authPWValue.append('$'); |
| | | authPWValue.append(Base64.encode(digestBytes)); |
| | | |
| | | return ByteString.valueOf(authPWValue); |
| | | return ByteString.valueOfUtf8(authPWValue); |
| | | } |
| | | |
| | | |
| | |
| | | X500Principal peerPrincipal = peerCertificate.getSubjectX500Principal(); |
| | | String peerName = peerPrincipal.getName(X500Principal.RFC2253); |
| | | SearchFilter filter = SearchFilter.createEqualityFilter( |
| | | subjectAttributeType, ByteString.valueOf(peerName)); |
| | | subjectAttributeType, ByteString.valueOfUtf8(peerName)); |
| | | |
| | | |
| | | // If we have an explicit set of base DNs, then use it. Otherwise, use the |
| | |
| | | byte[] encodedBytes = cryptoManager.encrypt(CIPHER_TRANSFORMATION_3DES, |
| | | KEY_SIZE_3DES, |
| | | plaintextBytes); |
| | | return ByteString.valueOf(Base64.encode(encodedBytes)); |
| | | return ByteString.valueOfUtf8(Base64.encode(encodedBytes)); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | return ByteString.valueOf(buffer); |
| | | return ByteString.valueOfUtf8(buffer); |
| | | } |
| | | |
| | | |
| | |
| | | authzID = "dn:" + authzDN; |
| | | } |
| | | |
| | | operation.setResponseValue(ByteString.valueOf(authzID)); |
| | | operation.setResponseValue(ByteString.valueOfUtf8(authzID)); |
| | | operation.addAdditionalLogItem(AdditionalLogItem.quotedKeyValue( |
| | | getClass(), "authzID", authzID)); |
| | | operation.setResultCode(ResultCode.SUCCESS); |
| | |
| | | for(AttributeType attributeType : attributeTypes) |
| | | { |
| | | componentFilters.add(SearchFilter.createEqualityFilter(attributeType, |
| | | ByteString.valueOf(oldEntryDN.toString()))); |
| | | ByteString.valueOfUtf8(oldEntryDN.toString()))); |
| | | } |
| | | |
| | | SearchFilter orFilter = SearchFilter.createORFilter(componentFilters); |
| | |
| | | { |
| | | if(e.hasAttribute(type)) |
| | | { |
| | | ByteString value = ByteString.valueOf(oldEntryDN.toString()); |
| | | ByteString value = ByteString.valueOfUtf8(oldEntryDN.toString()); |
| | | if (e.hasValue(type, null, value)) |
| | | { |
| | | mods.add(new Modification(ModificationType.DELETE, Attributes |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Portions Copyright 2013-2014 ForgeRock AS |
| | | * Portions Copyright 2013-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.protocols.http; |
| | | |
| | |
| | | { |
| | | final int messageID = nextMessageID.getAndIncrement(); |
| | | return enqueueOperation(new AddOperationBasis(clientConnection, messageID, messageID, to(request.getControls()), |
| | | valueOf(request.getName()), to(request.getAllAttributes()))); |
| | | valueOfObject(request.getName()), to(request.getAllAttributes()))); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | String userName = request.getName(); |
| | | byte[] password = ((SimpleBindRequest) request).getPassword(); |
| | | return enqueueOperation(new BindOperationBasis(clientConnection, messageID, messageID, to(request.getControls()), |
| | | "3", ByteString.valueOf(userName), ByteString.wrap(password))); |
| | | "3", ByteString.valueOfUtf8(userName), ByteString.wrap(password))); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | { |
| | | final int messageID = nextMessageID.getAndIncrement(); |
| | | return enqueueOperation(new CompareOperationBasis(clientConnection, messageID, messageID, |
| | | to(request.getControls()), valueOf(request.getName()), |
| | | to(request.getControls()), valueOfObject(request.getName()), |
| | | request.getAttributeDescription().getAttributeType().getOID(), |
| | | request.getAssertionValue())); |
| | | } |
| | |
| | | { |
| | | final int messageID = nextMessageID.getAndIncrement(); |
| | | return enqueueOperation(new DeleteOperationBasis(clientConnection, messageID, messageID, |
| | | to(request.getControls()), valueOf(request.getName()))); |
| | | to(request.getControls()), valueOfObject(request.getName()))); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | public AddOperation processAdd(String rawEntryDN, |
| | | List<RawAttribute> rawAttributes) |
| | | { |
| | | return processAdd(ByteString.valueOf(rawEntryDN), rawAttributes, null); |
| | | return processAdd(ByteString.valueOfUtf8(rawEntryDN), rawAttributes, null); |
| | | } |
| | | |
| | | |
| | |
| | | public BindOperation processSimpleBind(String rawBindDN, |
| | | String password) |
| | | { |
| | | return processSimpleBind(ByteString.valueOf(rawBindDN), |
| | | ByteString.valueOf(password), null); |
| | | return processSimpleBind(ByteString.valueOfUtf8(rawBindDN), |
| | | ByteString.valueOfUtf8(password), null); |
| | | } |
| | | |
| | | |
| | |
| | | String password, |
| | | List<Control> controls) |
| | | { |
| | | return processSimpleBind(ByteString.valueOf(rawBindDN), |
| | | ByteString.valueOf(password), controls); |
| | | return processSimpleBind(ByteString.valueOfUtf8(rawBindDN), |
| | | ByteString.valueOfUtf8(password), controls); |
| | | } |
| | | |
| | | |
| | |
| | | String attributeType, |
| | | String assertionValue) |
| | | { |
| | | return processCompare(ByteString.valueOf(rawEntryDN), attributeType, |
| | | ByteString.valueOf(assertionValue), null); |
| | | return processCompare(ByteString.valueOfUtf8(rawEntryDN), attributeType, |
| | | ByteString.valueOfUtf8(assertionValue), null); |
| | | } |
| | | |
| | | |
| | |
| | | String assertionValue, |
| | | List<Control> controls) |
| | | { |
| | | return processCompare(ByteString.valueOf(rawEntryDN), attributeType, |
| | | ByteString.valueOf(assertionValue), controls); |
| | | return processCompare(ByteString.valueOfUtf8(rawEntryDN), attributeType, |
| | | ByteString.valueOfUtf8(assertionValue), controls); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | public DeleteOperation processDelete(String rawEntryDN) |
| | | { |
| | | return processDelete(ByteString.valueOf(rawEntryDN), null); |
| | | return processDelete(ByteString.valueOfUtf8(rawEntryDN), null); |
| | | } |
| | | |
| | | |
| | |
| | | public DeleteOperation processDelete(String rawEntryDN, |
| | | List<Control> controls) |
| | | { |
| | | return processDelete(ByteString.valueOf(rawEntryDN), controls); |
| | | return processDelete(ByteString.valueOfUtf8(rawEntryDN), controls); |
| | | } |
| | | |
| | | |
| | |
| | | public ModifyOperation processModify(String rawEntryDN, |
| | | List<RawModification> rawModifications) |
| | | { |
| | | return processModify(ByteString.valueOf(rawEntryDN), |
| | | return processModify(ByteString.valueOfUtf8(rawEntryDN), |
| | | rawModifications, null); |
| | | } |
| | | |
| | |
| | | List<RawModification> rawModifications, |
| | | List<Control> controls) |
| | | { |
| | | return processModify(ByteString.valueOf(rawEntryDN), |
| | | return processModify(ByteString.valueOfUtf8(rawEntryDN), |
| | | rawModifications, controls); |
| | | } |
| | | |
| | |
| | | String rawNewRDN, |
| | | boolean deleteOldRDN) |
| | | { |
| | | return processModifyDN(ByteString.valueOf(rawEntryDN), |
| | | ByteString.valueOf(rawNewRDN), |
| | | return processModifyDN(ByteString.valueOfUtf8(rawEntryDN), |
| | | ByteString.valueOfUtf8(rawNewRDN), |
| | | deleteOldRDN, null, null); |
| | | } |
| | | |
| | |
| | | boolean deleteOldRDN, |
| | | List<Control> controls) |
| | | { |
| | | return processModifyDN(ByteString.valueOf(rawEntryDN), |
| | | ByteString.valueOf(rawNewRDN), |
| | | return processModifyDN(ByteString.valueOfUtf8(rawEntryDN), |
| | | ByteString.valueOfUtf8(rawNewRDN), |
| | | deleteOldRDN, null, controls); |
| | | } |
| | | |
| | |
| | | boolean deleteOldRDN, |
| | | String rawNewSuperior) |
| | | { |
| | | return processModifyDN(ByteString.valueOf(rawEntryDN), |
| | | ByteString.valueOf(rawNewRDN), deleteOldRDN, |
| | | ByteString.valueOf(rawNewSuperior), null); |
| | | return processModifyDN(ByteString.valueOfUtf8(rawEntryDN), |
| | | ByteString.valueOfUtf8(rawNewRDN), deleteOldRDN, |
| | | ByteString.valueOfUtf8(rawNewSuperior), null); |
| | | } |
| | | |
| | | |
| | |
| | | String rawNewSuperior, |
| | | List<Control> controls) |
| | | { |
| | | return processModifyDN(ByteString.valueOf(rawEntryDN), |
| | | ByteString.valueOf(rawNewRDN), deleteOldRDN, |
| | | ByteString.valueOf(rawNewSuperior), controls); |
| | | return processModifyDN(ByteString.valueOfUtf8(rawEntryDN), |
| | | ByteString.valueOfUtf8(rawNewRDN), deleteOldRDN, |
| | | ByteString.valueOfUtf8(rawNewSuperior), controls); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | ArrayList<Control> requestControls = new ArrayList<>(); |
| | | ByteString bindPW = password != null ? ByteString.valueOf(password) : null; |
| | | ByteString bindPW = password != null ? ByteString.valueOfUtf8(password) : null; |
| | | |
| | | AuthenticationInfo authInfo = new AuthenticationInfo(); |
| | | JmxClientConnection jmxClientConnection = new JmxClientConnection( |
| | |
| | | jmxClientConnection.nextOperationID(), |
| | | jmxClientConnection.nextMessageID(), requestControls, |
| | | jmxConnectionHandler.getRMIConnector().getProtocolVersion(), |
| | | ByteString.valueOf(authcID), bindPW); |
| | | ByteString.valueOfUtf8(authcID), bindPW); |
| | | |
| | | bindOp.run(); |
| | | if (bindOp.getResultCode() == ResultCode.SUCCESS) |
| | |
| | | { |
| | | this.attributeType = attributeType; |
| | | |
| | | values = newArrayList(ByteString.valueOf(value)); |
| | | values = newArrayList(ByteString.valueOfUtf8(value)); |
| | | } |
| | | |
| | | |
| | |
| | | this.values = new ArrayList<>(values.size()); |
| | | for (String value : values) |
| | | { |
| | | this.values.add(ByteString.valueOf(value)); |
| | | this.values.add(ByteString.valueOfUtf8(value)); |
| | | } |
| | | } |
| | | } |
| | |
| | | final ArrayList<ByteString> values = new ArrayList<>(0); |
| | | for (CSN csn : serverIdToCSN.values()) |
| | | { |
| | | values.add(ByteString.valueOf(csn.toString())); |
| | | values.add(ByteString.valueOfUtf8(csn.toString())); |
| | | } |
| | | return values; |
| | | } |
| | |
| | | if (token.length == 4) |
| | | { |
| | | stringValue = token[3]; |
| | | attributeValue = ByteString.valueOf(stringValue); |
| | | attributeValue = ByteString.valueOfUtf8(stringValue); |
| | | } |
| | | else |
| | | { |
| | |
| | | try |
| | | { |
| | | filter = LDAPFilter.createEqualityFilter(DS_SYNC_CONFLICT, |
| | | ByteString.valueOf(freedDN.toString())).toSearchFilter(); |
| | | ByteString.valueOfUtf8(freedDN.toString())).toSearchFilter(); |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | |
| | | private ResultCode runSaveGenerationId(DN entryDN, long generationId) |
| | | { |
| | | // The generationId is stored in the root entry of the domain. |
| | | final ByteString asn1BaseDn = ByteString.valueOf(entryDN.toString()); |
| | | final ByteString asn1BaseDn = ByteString.valueOfUtf8(entryDN.toString()); |
| | | |
| | | LDAPAttribute attr = new LDAPAttribute(REPLICATION_GENERATION_ID, Long.toString(generationId)); |
| | | List<RawModification> mods = new ArrayList<>(1); |
| | |
| | | |
| | | ModifyOperationBasis op = new ModifyOperationBasis(getRootConnection(), |
| | | nextOperationID(), nextMessageID(), null, |
| | | ByteString.valueOf(serverStateEntryDN.toString()), |
| | | ByteString.valueOfUtf8(serverStateEntryDN.toString()), |
| | | Collections.singletonList(mod)); |
| | | op.setInternalOperation(true); |
| | | op.setSynchronizationOperation(true); |
| | |
| | | AddOperation add = new AddOperationBasis(connection, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), null, |
| | | ByteString.valueOf(newDN.toString()), attr); |
| | | ByteString.valueOfUtf8(newDN.toString()), attr); |
| | | AddContext ctx = new AddContext(getCSN(), getEntryUUID(), parentEntryUUID); |
| | | add.setAttachment(SYNCHROCONTEXT, ctx); |
| | | return add; |
| | |
| | | ModifyDNOperation moddn = new ModifyDNOperationBasis(connection, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), null, |
| | | ByteString.valueOf(newDN.toString()), |
| | | ByteString.valueOf(newRDN), |
| | | ByteString.valueOfUtf8(newDN.toString()), |
| | | ByteString.valueOfUtf8(newRDN), |
| | | deleteOldRdn, |
| | | (newSuperior == null ? null : ByteString.valueOf(newSuperior))); |
| | | (newSuperior == null ? null : ByteString.valueOfUtf8(newSuperior))); |
| | | |
| | | for (Modification mod : decodeMods(encodedMods)) |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.replication.protocol; |
| | | |
| | |
| | | ModifyOperation mod = new ModifyOperationBasis(connection, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), null, |
| | | ByteString.valueOf(newDN.toString()), ldapmods); |
| | | ByteString.valueOfUtf8(newDN.toString()), ldapmods); |
| | | ModifyContext ctx = new ModifyContext(getCSN(), getEntryUUID()); |
| | | mod.setAttachment(SYNCHROCONTEXT, ctx); |
| | | return mod; |
| | |
| | | dataRemaining -= distanceToBlockStart; |
| | | } |
| | | // append the offset to the record |
| | | writer.write(ByteString.valueOf(cumulatedDistanceToBeginning)); |
| | | writer.write(ByteString.valueOfInt(cumulatedDistanceToBeginning)); |
| | | |
| | | // next step |
| | | distanceToBlockStart = dataSizeForOneBlock; |
| | |
| | | */ |
| | | public static ByteString createGeneralizedTimeValue(long time) |
| | | { |
| | | return ByteString.valueOf(format(time)); |
| | | return ByteString.valueOfUtf8(format(time)); |
| | | } |
| | | |
| | | /** |
| | |
| | | List<String> entries = new LinkedList<>(); |
| | | for (String v : values) |
| | | { |
| | | ByteString entry = ByteString.valueOf(v); |
| | | ByteString entry = ByteString.valueOfUtf8(v); |
| | | if (entries.contains(entry)) |
| | | { |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | |
| | | |
| | | // We support the scheme, so make the determination. |
| | | return ConditionResult.valueOf( |
| | | storageScheme.passwordMatches(assertionValue, ByteString.valueOf(userPWComponents[1]))); |
| | | storageScheme.passwordMatches(assertionValue, ByteString.valueOfUtf8(userPWComponents[1]))); |
| | | } |
| | | |
| | | } |
| | |
| | | ArrayList<RawModification> modList = CollectionUtils.<RawModification> newArrayList(m); |
| | | |
| | | String backendDNString = configEntryDN.toString(); |
| | | ByteString rawEntryDN = ByteString.valueOf(backendDNString); |
| | | ByteString rawEntryDN = ByteString.valueOfUtf8(backendDNString); |
| | | ModifyOperation internalModify = getRootConnection().processModify(rawEntryDN, modList); |
| | | |
| | | ResultCode resultCode = internalModify.getResultCode(); |
| | |
| | | ArrayList<RawModification> modList = CollectionUtils.<RawModification> newArrayList(m); |
| | | |
| | | String backendDNString = configEntryDN.toString(); |
| | | ByteString rawEntryDN = ByteString.valueOf(backendDNString); |
| | | ByteString rawEntryDN = ByteString.valueOfUtf8(backendDNString); |
| | | ModifyOperation internalModify = getRootConnection().processModify(rawEntryDN, modList); |
| | | |
| | | ResultCode resultCode = internalModify.getResultCode(); |
| | |
| | | if (encodedPassword.hasValue()) |
| | | { |
| | | compareMode = true; |
| | | encodedPW = ByteString.valueOf(encodedPassword.getValue()); |
| | | encodedPW = ByteString.valueOfUtf8(encodedPassword.getValue()); |
| | | } |
| | | else if (encodedPasswordFile.hasValue()) |
| | | { |
| | | compareMode = true; |
| | | encodedPW = ByteString.valueOf(encodedPasswordFile.getValue()); |
| | | encodedPW = ByteString.valueOfUtf8(encodedPasswordFile.getValue()); |
| | | } |
| | | else |
| | | { |
| | |
| | | } |
| | | boolean passwordMatches = |
| | | storageScheme.passwordMatches(clearPW, ByteString |
| | | .valueOf(encodedPWString)); |
| | | .valueOfUtf8(encodedPWString)); |
| | | out.println(getOutputMessage(passwordMatches)); |
| | | if (useCompareResultCode.isPresent()) |
| | | { |
| | |
| | | { |
| | | if (clearPassword.hasValue()) |
| | | { |
| | | return ByteString.valueOf(clearPassword.getValue()); |
| | | return ByteString.valueOfUtf8(clearPassword.getValue()); |
| | | } |
| | | else if (clearPasswordFile.hasValue()) |
| | | { |
| | | return ByteString.valueOf(clearPasswordFile.getValue()); |
| | | return ByteString.valueOfUtf8(clearPasswordFile.getValue()); |
| | | } |
| | | else if (interactivePassword.isPresent()) |
| | | { |
| | |
| | | String pwd2 = encodePassword.getPassword(INFO_ENCPW_INPUT_PWD_2.get().toString()); |
| | | if (pwd1.equals(pwd2)) |
| | | { |
| | | return ByteString.valueOf(pwd1); |
| | | return ByteString.valueOfUtf8(pwd1); |
| | | } |
| | | else |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | saslCredentials = ByteString.valueOf(trace); |
| | | saslCredentials = ByteString.valueOfUtf8(trace); |
| | | } |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | |
| | | // Create and send the second bind request to the server. |
| | | BindRequestProtocolOp bindRequest2 = |
| | | new BindRequestProtocolOp(bindDN.toByteString(), |
| | | SASL_MECHANISM_CRAM_MD5, ByteString.valueOf(buffer.toString())); |
| | | SASL_MECHANISM_CRAM_MD5, ByteString.valueOfUtf8(buffer.toString())); |
| | | LDAPMessage requestMessage2 = |
| | | new LDAPMessage(nextMessageID.getAndIncrement(), bindRequest2, |
| | | requestControls); |
| | |
| | | BindRequestProtocolOp bindRequest2 = |
| | | new BindRequestProtocolOp(bindDN.toByteString(), |
| | | SASL_MECHANISM_DIGEST_MD5, |
| | | ByteString.valueOf(credBuffer.toString())); |
| | | ByteString.valueOfUtf8(credBuffer.toString())); |
| | | LDAPMessage requestMessage2 = |
| | | new LDAPMessage(nextMessageID.getAndIncrement(), bindRequest2, |
| | | requestControls); |
| | |
| | | credBuffer.append(bindPassword.toString()); |
| | | |
| | | ByteString saslCredentials = |
| | | ByteString.valueOf(credBuffer.toString()); |
| | | ByteString.valueOfUtf8(credBuffer.toString()); |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(bindDN.toByteString(), SASL_MECHANISM_PLAIN, |
| | | saslCredentials); |
| | |
| | | throws IOException, LDAPException |
| | | { |
| | | ArrayList<Control> controls = compareOptions.getControls(); |
| | | ByteString dnOctetStr = ByteString.valueOf(line); |
| | | ByteString dnOctetStr = ByteString.valueOfUtf8(line); |
| | | ByteString attrValOctetStr = ByteString.wrap(attributeVal); |
| | | |
| | | ProtocolOp protocolOp = new CompareRequestProtocolOp(dnOctetStr, |
| | |
| | | } |
| | | else |
| | | { |
| | | bindDNBytes = ByteString.valueOf(bindDN); |
| | | bindDNBytes = ByteString.valueOfUtf8(bindDN); |
| | | } |
| | | |
| | | ByteString bindPW; |
| | |
| | | } |
| | | else |
| | | { |
| | | bindPW = ByteString.valueOf(bindPassword); |
| | | bindPW = ByteString.valueOfUtf8(bindPassword); |
| | | } |
| | | |
| | | String result = null; |
| | |
| | | { |
| | | ArrayList<Control> controls = deleteOptions.getControls(); |
| | | ProtocolOp protocolOp = null; |
| | | ByteString asn1OctetStr = ByteString.valueOf(line); |
| | | ByteString asn1OctetStr = ByteString.valueOfUtf8(line); |
| | | |
| | | protocolOp = new DeleteRequestProtocolOp(asn1OctetStr); |
| | | |
| | |
| | | |
| | | ProtocolOp protocolOp = null; |
| | | ByteString asn1OctetStr = |
| | | ByteString.valueOf(entry.getDN().toString()); |
| | | ByteString.valueOfUtf8(entry.getDN().toString()); |
| | | |
| | | String operationType = ""; |
| | | switch(entry.getChangeOperationType()) |
| | |
| | | if(modDNEntry.getNewSuperiorDN() != null) |
| | | { |
| | | protocolOp = new ModifyDNRequestProtocolOp(asn1OctetStr, |
| | | ByteString.valueOf(modDNEntry.getNewRDN().toString()), |
| | | ByteString.valueOfUtf8(modDNEntry.getNewRDN().toString()), |
| | | modDNEntry.deleteOldRDN(), |
| | | ByteString.valueOf( |
| | | ByteString.valueOfUtf8( |
| | | modDNEntry.getNewSuperiorDN().toString())); |
| | | } else |
| | | { |
| | | protocolOp = new ModifyDNRequestProtocolOp(asn1OctetStr, |
| | | ByteString.valueOf(modDNEntry.getNewRDN().toString()), |
| | | ByteString.valueOfUtf8(modDNEntry.getNewRDN().toString()), |
| | | modDNEntry.deleteOldRDN()); |
| | | } |
| | | |
| | |
| | | { |
| | | Control proxyControl = |
| | | new ProxiedAuthV2Control(true, |
| | | ByteString.valueOf(proxyAuthzID.getValue())); |
| | | ByteString.valueOfUtf8(proxyAuthzID.getValue())); |
| | | modifyOptions.getControls().add(proxyControl); |
| | | } |
| | | |
| | |
| | | |
| | | for (LDAPFilter filter: filters) |
| | | { |
| | | ByteString asn1OctetStr = ByteString.valueOf(baseDN); |
| | | ByteString asn1OctetStr = ByteString.valueOfUtf8(baseDN); |
| | | |
| | | SearchRequestProtocolOp protocolOp = |
| | | new SearchRequestProtocolOp(asn1OctetStr, |
| | |
| | | { |
| | | Control proxyControl = |
| | | new ProxiedAuthV2Control(true, |
| | | ByteString.valueOf(proxyAuthzID.getValue())); |
| | | ByteString.valueOfUtf8(proxyAuthzID.getValue())); |
| | | searchOptions.getControls().add(proxyControl); |
| | | } |
| | | |
| | |
| | | { |
| | | int beforeCount = Integer.parseInt(tokenizer.nextToken()); |
| | | int afterCount = Integer.parseInt(tokenizer.nextToken()); |
| | | ByteString assertionValue = ByteString.valueOf(tokenizer.nextToken()); |
| | | ByteString assertionValue = ByteString.valueOfUtf8(tokenizer.nextToken()); |
| | | searchOptions.getControls().add( |
| | | new VLVRequestControl(beforeCount, afterCount, assertionValue)); |
| | | } |
| | |
| | | if(valString.charAt(0) == ':') |
| | | { |
| | | controlValue = |
| | | ByteString.valueOf(valString.substring(1, valString.length())); |
| | | ByteString.valueOfUtf8(valString.substring(1, valString.length())); |
| | | } else if(valString.charAt(0) == '<') |
| | | { |
| | | // Read data from the file. |
| | |
| | | } |
| | | } else |
| | | { |
| | | controlValue = ByteString.valueOf(valString); |
| | | controlValue = ByteString.valueOfUtf8(valString); |
| | | } |
| | | |
| | | return new LDAPControl(controlOID, controlCriticality, controlValue); |
| | |
| | | // Construct the add request to send to the server. |
| | | String taskID = UUID.randomUUID().toString(); |
| | | ByteString entryDN = |
| | | ByteString.valueOf(ATTR_TASK_ID + "=" + taskID + "," + |
| | | ByteString.valueOfUtf8(ATTR_TASK_ID + "=" + taskID + "," + |
| | | SCHEDULED_TASK_BASE_RDN + "," + DN_TASK_ROOT); |
| | | |
| | | ArrayList<RawAttribute> attributes = new ArrayList<>(); |
| | |
| | | if (proxyAuthzID.isPresent()) |
| | | { |
| | | controls.add(new ProxiedAuthV2Control( |
| | | ByteString.valueOf(proxyAuthzID.getValue()))); |
| | | ByteString.valueOfUtf8(proxyAuthzID.getValue()))); |
| | | } |
| | | |
| | | AddRequestProtocolOp addRequest = new AddRequestProtocolOp(entryDN, attributes); |
| | |
| | | while (values.hasMore()) |
| | | { |
| | | Object v = values.next(); |
| | | rawValues.add(ByteString.valueOf(v.toString())); |
| | | rawValues.add(ByteString.valueOfUtf8(v.toString())); |
| | | } |
| | | RawAttribute rAttr = RawAttribute.create(attr.getID(), rawValues); |
| | | rawAttrs.add(rAttr); |
| | |
| | | return null; |
| | | } |
| | | |
| | | rdn = new RDN(t, ByteString.valueOf(v.getValue().toString())); |
| | | rdn = new RDN(t, ByteString.valueOfUtf8(v.getValue().toString())); |
| | | } |
| | | else |
| | | { |
| | |
| | | } |
| | | |
| | | names[i] = t.getPrimaryName(); |
| | | values[i] = ByteString.valueOf(v.getValue().toString()); |
| | | values[i] = ByteString.valueOfUtf8(v.getValue().toString()); |
| | | } |
| | | |
| | | rdn = new RDN(rdnAttrs, names, values); |
| | |
| | | AttributeBuilder base64Builder = null; |
| | | for (TemplateValue v : valueList) |
| | | { |
| | | ByteString value = ByteString.valueOf(v.getValue().toString()); |
| | | ByteString value = ByteString.valueOfUtf8(v.getValue().toString()); |
| | | builder.add(value); |
| | | if (v.getTemplateLine().isURL()) |
| | | { |
| | |
| | | // First, write the DN. It will always be included. |
| | | StringBuilder dnLine = new StringBuilder("dn"); |
| | | appendLDIFSeparatorAndValue(dnLine, |
| | | ByteString.valueOf(getDN().toString())); |
| | | ByteString.valueOfUtf8(getDN().toString())); |
| | | writeLDIFLine(dnLine, writer, wrapLines, wrapColumn); |
| | | |
| | | |
| | |
| | | ArrayList<Control> controls = new ArrayList<>(); |
| | | ArrayList<RawAttribute> attributes = getTaskAttributes(information); |
| | | |
| | | ByteString entryDN = ByteString.valueOf(getTaskDN(attributes)); |
| | | ByteString entryDN = ByteString.valueOfUtf8(getTaskDN(attributes)); |
| | | AddRequestProtocolOp addRequest = new AddRequestProtocolOp(entryDN, attributes); |
| | | LDAPMessage requestMessage = |
| | | new LDAPMessage(nextMessageID.getAndIncrement(), addRequest, controls); |
| | |
| | | List<Entry> entries = new ArrayList<>(); |
| | | |
| | | writeSearch(new SearchRequestProtocolOp( |
| | | ByteString.valueOf(ConfigConstants.DN_TASK_ROOT), |
| | | ByteString.valueOfUtf8(ConfigConstants.DN_TASK_ROOT), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | |
| | | Entry entry = null; |
| | | |
| | | writeSearch(new SearchRequestProtocolOp( |
| | | ByteString.valueOf(ConfigConstants.DN_TASK_ROOT), |
| | | ByteString.valueOfUtf8(ConfigConstants.DN_TASK_ROOT), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | |
| | | if (state != null) { |
| | | if (!TaskState.isDone(state)) { |
| | | |
| | | ByteString dn = ByteString.valueOf(entry.getDN().toString()); |
| | | ByteString dn = ByteString.valueOfUtf8(entry.getDN().toString()); |
| | | |
| | | ArrayList<RawModification> mods = new ArrayList<>(); |
| | | |
| | |
| | | } |
| | | } else if (TaskState.isRecurring(state)) { |
| | | |
| | | ByteString dn = ByteString.valueOf(entry.getDN().toString()); |
| | | ByteString dn = ByteString.valueOfUtf8(entry.getDN().toString()); |
| | | DeleteRequestProtocolOp deleteRequest = |
| | | new DeleteRequestProtocolOp(dn); |
| | | |
| | |
| | | Assertion assertion; |
| | | try |
| | | { |
| | | assertion = mrule.getAssertion(ByteString.valueOf(oid)); |
| | | assertion = mrule.getAssertion(ByteString.valueOfUtf8(oid)); |
| | | for (final ByteString value : attribute) |
| | | { |
| | | final ByteString nvalue = mrule.normalizeAttributeValue(value); |
| | |
| | | */ |
| | | public boolean add(String valueString) |
| | | { |
| | | return add(ByteString.valueOf(valueString)); |
| | | return add(ByteString.valueOfUtf8(valueString)); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | public boolean remove(String valueString) |
| | | { |
| | | return remove(ByteString.valueOf(valueString)); |
| | | return remove(ByteString.valueOfUtf8(valueString)); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | public void replace(String valueString) |
| | | { |
| | | replace(ByteString.valueOf(valueString)); |
| | | replace(ByteString.valueOfUtf8(valueString)); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | public static Attribute create(AttributeType attributeType, String name, String valueString) |
| | | { |
| | | return create(attributeType, name, ByteString.valueOf(valueString)); |
| | | return create(attributeType, name, ByteString.valueOfUtf8(valueString)); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | // First, append the DN. |
| | | StringBuilder dnLine = new StringBuilder("dn"); |
| | | appendLDIFSeparatorAndValue(dnLine, ByteString.valueOf(dn.toString())); |
| | | appendLDIFSeparatorAndValue(dnLine, ByteString.valueOfUtf8(dn.toString())); |
| | | ldifLines.add(dnLine); |
| | | |
| | | // Next, add the set of objectclasses. |
| | |
| | | |
| | | // First, write the DN. It will always be included. |
| | | StringBuilder dnLine = new StringBuilder("dn"); |
| | | appendLDIFSeparatorAndValue(dnLine, ByteString.valueOf(dn.toString())); |
| | | appendLDIFSeparatorAndValue(dnLine, ByteString.valueOfUtf8(dn.toString())); |
| | | LDIFWriter.writeLDIFLine(dnLine, writer, wrapLines, wrapColumn); |
| | | |
| | | |
| | |
| | | private AttributeType recreateFromDefinition(AttributeType attrType) |
| | | throws DirectoryException |
| | | { |
| | | ByteString value = ByteString.valueOf(attrType.toString()); |
| | | ByteString value = ByteString.valueOfUtf8(attrType.toString()); |
| | | AttributeType copy = |
| | | AttributeTypeSyntax.decodeAttributeType(value, this, false); |
| | | setSchemaFile(copy, getSchemaFile(attrType)); |
| | |
| | | private DITContentRule recreateFromDefinition(DITContentRule dcr) |
| | | throws DirectoryException |
| | | { |
| | | ByteString value = ByteString.valueOf(dcr.toString()); |
| | | ByteString value = ByteString.valueOfUtf8(dcr.toString()); |
| | | DITContentRule copy = |
| | | DITContentRuleSyntax.decodeDITContentRule(value, this, false); |
| | | setSchemaFile(copy, getSchemaFile(dcr)); |
| | |
| | | private DITStructureRule recreateFromDefinition(DITStructureRule dsr) |
| | | throws DirectoryException |
| | | { |
| | | ByteString value = ByteString.valueOf(dsr.toString()); |
| | | ByteString value = ByteString.valueOfUtf8(dsr.toString()); |
| | | DITStructureRule copy = |
| | | DITStructureRuleSyntax.decodeDITStructureRule(value, this, false); |
| | | setSchemaFile(copy, getSchemaFile(dsr)); |
| | |
| | | private MatchingRuleUse recreateFromDefinition(MatchingRuleUse mru) |
| | | throws DirectoryException |
| | | { |
| | | ByteString value = ByteString.valueOf(mru.toString()); |
| | | ByteString value = ByteString.valueOfUtf8(mru.toString()); |
| | | MatchingRuleUse copy = |
| | | MatchingRuleUseSyntax.decodeMatchingRuleUse(value, this, false); |
| | | setSchemaFile(copy, getSchemaFile(mru)); |
| | |
| | | private NameForm recreateFromDefinition(NameForm nf) |
| | | throws DirectoryException |
| | | { |
| | | ByteString value = ByteString.valueOf(nf.toString()); |
| | | ByteString value = ByteString.valueOfUtf8(nf.toString()); |
| | | NameForm copy = NameFormSyntax.decodeNameForm(value, this, false); |
| | | setSchemaFile(copy, getSchemaFile(nf)); |
| | | return copy; |
| | |
| | | private ObjectClass recreateFromDefinition(ObjectClass oc) |
| | | throws DirectoryException |
| | | { |
| | | ByteString value = ByteString.valueOf(oc.toString()); |
| | | ByteString value = ByteString.valueOfUtf8(oc.toString()); |
| | | ObjectClass copy = ObjectClassSyntax.decodeObjectClass(value, this, false); |
| | | setSchemaFile(copy, getSchemaFile(oc)); |
| | | return copy; |
| | |
| | | { |
| | | if (argv.length == 2) |
| | | { |
| | | System.out.println(BSDMD5Crypt.crypt(ByteString.valueOf(argv[0]), |
| | | System.out.println(BSDMD5Crypt.crypt(ByteString.valueOfUtf8(argv[0]), |
| | | argv[1])); |
| | | } else |
| | | { |
| | | System.out.println(BSDMD5Crypt.crypt(ByteString.valueOf(argv[0]))); |
| | | System.out.println(BSDMD5Crypt.crypt(ByteString.valueOfUtf8(argv[0]))); |
| | | } |
| | | } catch (Exception e) |
| | | { |
| | |
| | | // The rest of the line should be the value. Skip over any |
| | | // spaces and take the rest of the line as the value. |
| | | int pos = findFirstNonSpaceCharPosition(line, colonPos + 1); |
| | | value = ByteString.valueOf(line.substring(pos)); |
| | | value = ByteString.valueOfUtf8(line.substring(pos)); |
| | | } |
| | | } |
| | | return value; |
| | |
| | | |
| | | // Write the newRDN element. |
| | | StringBuilder rdnLine = new StringBuilder("newrdn"); |
| | | appendLDIFSeparatorAndValue(rdnLine, ByteString.valueOf(newRDN.toString())); |
| | | appendLDIFSeparatorAndValue(rdnLine, ByteString.valueOfUtf8(newRDN.toString())); |
| | | writeLDIFLine(rdnLine, writer, wrapLines, wrapColumn); |
| | | |
| | | |
| | |
| | | boolean wrapLines, int wrapColumn) throws IOException |
| | | { |
| | | final StringBuilder newLine = new StringBuilder(attrType); |
| | | appendLDIFSeparatorAndValue(newLine, ByteString.valueOf(dn.toString())); |
| | | appendLDIFSeparatorAndValue(newLine, ByteString.valueOfUtf8(dn.toString())); |
| | | writeLDIFLine(newLine, writer, wrapLines, wrapColumn); |
| | | } |
| | | |
| | |
| | | /** |
| | | * The value representing just one space character. |
| | | */ |
| | | public static final ByteString SINGLE_SPACE_VALUE = ByteString.valueOf(" "); |
| | | public static final ByteString SINGLE_SPACE_VALUE = ByteString.valueOfUtf8(" "); |
| | | |
| | | /** |
| | | * The normalized true value. |
| | | */ |
| | | public static final ByteString TRUE_VALUE = ByteString.valueOf("TRUE"); |
| | | public static final ByteString TRUE_VALUE = ByteString.valueOfUtf8("TRUE"); |
| | | |
| | | /** |
| | | * The normalized false value. |
| | | */ |
| | | public static final ByteString FALSE_VALUE = ByteString.valueOf("FALSE"); |
| | | public static final ByteString FALSE_VALUE = ByteString.valueOfUtf8("FALSE"); |
| | | |
| | | /** |
| | | * The root Dn for the external change log. |
| | |
| | | } else { |
| | | String[] components = UserPasswordSyntax.decodeUserPassword(av.toString()); |
| | | PasswordStorageScheme<?> scheme = DirectoryServer.getPasswordStorageScheme(toLowerCase(components[0])); |
| | | return scheme != null && scheme.passwordMatches(val, ByteString.valueOf(components[1])); |
| | | return scheme != null && scheme.passwordMatches(val, ByteString.valueOfUtf8(components[1])); |
| | | } |
| | | } |
| | | |
| | |
| | | entry.addControl(control); |
| | | } |
| | | entry.addAttribute(new LinkedAttribute("test", "value1")); |
| | | entry.addAttribute(new LinkedAttribute("Another", ByteString.valueOf("myValue"))); |
| | | entry.addAttribute(new LinkedAttribute("Another", ByteString.valueOfUtf8("myValue"))); |
| | | |
| | | SearchResultEntry result = to(entry); |
| | | assertThat(result.getName().toString()).isEqualTo(entry.getName().toString()); |
| | |
| | | new LinkedHashMapEntry(org.forgerock.opendj.ldap.DN |
| | | .valueOf("uid=scarter,ou=People,dc=example,dc=com")); |
| | | entry.addAttribute(new LinkedAttribute("test", "value1")); |
| | | entry.addAttribute(new LinkedAttribute("Another", ByteString.valueOf("myValue"))); |
| | | entry.addAttribute(new LinkedAttribute("Another", ByteString.valueOfUtf8("myValue"))); |
| | | |
| | | org.opends.server.types.Entry result = to(entry); |
| | | assertThat(result.getName().toString()).isEqualTo(entry.getName().toString()); |
| | |
| | | assertThat(srvAttribute.getValues().get(0).toString()).isEqualTo("value1"); |
| | | |
| | | org.forgerock.opendj.ldap.Attribute attribute2 = |
| | | new LinkedAttribute("Another", ByteString.valueOf("myValue")); |
| | | new LinkedAttribute("Another", ByteString.valueOfUtf8("myValue")); |
| | | |
| | | org.opends.server.types.RawAttribute srvAttribute2 = to(attribute2); |
| | | assertThat(srvAttribute2.getAttributeType()).isEqualTo("Another"); |
| | |
| | | assertThat(srvAttribute.iterator().next().toString()).isEqualTo("value1"); |
| | | |
| | | org.forgerock.opendj.ldap.Attribute attribute2 = |
| | | new LinkedAttribute("Another", ByteString.valueOf("myValue")); |
| | | new LinkedAttribute("Another", ByteString.valueOfUtf8("myValue")); |
| | | |
| | | org.opends.server.types.Attribute srvAttribute2 = toAttribute(attribute2); |
| | | assertThat(srvAttribute2.getAttributeType().getNameOrOID()).isEqualTo("Another"); |
| | |
| | | @Test |
| | | public final void testToRawModification() { |
| | | org.forgerock.opendj.ldap.Attribute attribute = |
| | | new LinkedAttribute("test", ByteString.valueOf("value1"), ByteString |
| | | .valueOf("value2")); |
| | | new LinkedAttribute("test", ByteString.valueOfUtf8("value1"), ByteString |
| | | .valueOfUtf8("value2")); |
| | | |
| | | Modification mod = new Modification(ModificationType.ADD, attribute); |
| | | |
| | |
| | | @Test |
| | | public final void testToModification() { |
| | | org.forgerock.opendj.ldap.Attribute attribute = |
| | | new LinkedAttribute("test", ByteString.valueOf("value1"), ByteString |
| | | .valueOf("value2")); |
| | | new LinkedAttribute("test", ByteString.valueOfUtf8("value1"), ByteString |
| | | .valueOfUtf8("value2")); |
| | | |
| | | Modification mod = new Modification(ModificationType.ADD, attribute); |
| | | |
| | |
| | | @Test |
| | | public static void testFromLDAPControl() { |
| | | org.opends.server.protocols.ldap.LDAPControl ldapControl = |
| | | new LDAPControl("1.2.3.4", false, ByteString.valueOf("myData")); |
| | | new LDAPControl("1.2.3.4", false, ByteString.valueOfUtf8("myData")); |
| | | Control sdkControl = from(ldapControl); |
| | | |
| | | Control expectedSdkControl = GenericControl.newControl("1.2.3.4", false, "myData"); |
| | |
| | | @Test |
| | | public static void testFromControl() { |
| | | final org.opends.server.types.Control control = |
| | | new LDAPControl("1.2.3.4", false, ByteString.valueOf("myData")); |
| | | new LDAPControl("1.2.3.4", false, ByteString.valueOfUtf8("myData")); |
| | | Control sdkControl = from(control); |
| | | |
| | | Control expectedSdkControl = GenericControl.newControl("1.2.3.4", false, "myData"); |
| | |
| | | final GenericBindRequest genericBindRequest = bindClient.nextBindRequest(); |
| | | |
| | | assertThat(getCredentials(genericBindRequest.getAuthenticationValue())).isEqualTo( |
| | | ByteString.valueOf("\u0000u:user.0\u0000password")); |
| | | ByteString.valueOfUtf8("\u0000u:user.0\u0000password")); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp( |
| | | ByteString.valueOf(dn), |
| | | ByteString.valueOfUtf8(dn), |
| | | 3, |
| | | ByteString.valueOf(pw)); |
| | | ByteString.valueOfUtf8(pw)); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | message.write(w); |
| | | |
| | |
| | | + "MAY ( ds-cfg-base-dn $ ds-cfg-group-dn $ " |
| | | + "ds-cfg-filter $ ds-cfg-conflict-behavior ) " |
| | | + "X-ORIGIN 'OpenDS Directory Server' )"; |
| | | ByteString b = ByteString.valueOf(ocd); |
| | | ByteString b = ByteString.valueOfUtf8(ocd); |
| | | |
| | | TEST_PARENT_OCD = ObjectClassSyntax.decodeObjectClass(b, DirectoryServer |
| | | .getSchema(), false); |
| | |
| | | + "MAY ( ds-cfg-base-dn $ ds-cfg-group-dn $ " |
| | | + "ds-cfg-filter $ ds-cfg-conflict-behavior $" |
| | | + "ds-cfg-rotation-policy) " + "X-ORIGIN 'OpenDS Directory Server' )"; |
| | | ByteString b = ByteString.valueOf(ocd); |
| | | ByteString b = ByteString.valueOfUtf8(ocd); |
| | | |
| | | TEST_CHILD_OCD = ObjectClassSyntax.decodeObjectClass(b, DirectoryServer |
| | | .getSchema(), false); |
| | |
| | | 0); |
| | | |
| | | assertEquals(TestPasswordValidator.getLastNewPassword(), |
| | | ByteString.valueOf("newPassword")); |
| | | ByteString.valueOfUtf8("newPassword")); |
| | | assertFalse(TestPasswordValidator.getLastCurrentPasswords().isEmpty()); |
| | | } |
| | | |
| | |
| | | assertNotEquals(returnCode, 0); |
| | | |
| | | assertEquals(TestPasswordValidator.getLastNewPassword(), |
| | | ByteString.valueOf("newPassword")); |
| | | ByteString.valueOfUtf8("newPassword")); |
| | | assertFalse(TestPasswordValidator.getLastCurrentPasswords().isEmpty()); |
| | | |
| | | TestPasswordValidator.setNextReturnValue(true); |
| | |
| | | assertFalse(currentPasswords.isEmpty()); |
| | | assertEquals(currentPasswords.size(), 1); |
| | | assertEquals(currentPasswords.iterator().next(), |
| | | ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("password")); |
| | | } |
| | | |
| | | |
| | |
| | | assertFalse(currentPasswords.isEmpty()); |
| | | assertEquals(currentPasswords.size(), 1); |
| | | assertEquals(currentPasswords.iterator().next(), |
| | | ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("password")); |
| | | } |
| | | |
| | | |
| | |
| | | assertFalse(currentPasswords.isEmpty()); |
| | | assertEquals(currentPasswords.size(), 1); |
| | | assertEquals(currentPasswords.iterator().next(), |
| | | ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("password")); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp( |
| | | ByteString.valueOf("uid=test.user,o=test"), |
| | | 3, ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("uid=test.user,o=test"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | |
| | | ModifyRequestProtocolOp modifyRequest = |
| | | new ModifyRequestProtocolOp( |
| | | ByteString.valueOf("uid=test.user,o=test"), mods); |
| | | ByteString.valueOfUtf8("uid=test.user,o=test"), mods); |
| | | message = new LDAPMessage(2, modifyRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | assertEquals(modifyResponse.getResultCode(), 0); |
| | | |
| | | assertEquals(TestPasswordValidator.getLastNewPassword(), |
| | | ByteString.valueOf("newPassword")); |
| | | ByteString.valueOfUtf8("newPassword")); |
| | | assertTrue(TestPasswordValidator.getLastCurrentPasswords().isEmpty()); |
| | | } |
| | | |
| | |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp( |
| | | ByteString.valueOf("uid=test.user,o=test"), |
| | | 3, ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("uid=test.user,o=test"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | TestPasswordValidator.setNextReturnValue(false); |
| | | ModifyRequestProtocolOp modifyRequest = |
| | | new ModifyRequestProtocolOp( |
| | | ByteString.valueOf("uid=test.user,o=test"), mods); |
| | | ByteString.valueOfUtf8("uid=test.user,o=test"), mods); |
| | | message = new LDAPMessage(2, modifyRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | assertNotEquals(modifyResponse.getResultCode(), 0); |
| | | |
| | | assertEquals(TestPasswordValidator.getLastNewPassword(), |
| | | ByteString.valueOf("newPassword")); |
| | | ByteString.valueOfUtf8("newPassword")); |
| | | assertTrue(TestPasswordValidator.getLastCurrentPasswords().isEmpty()); |
| | | |
| | | TestPasswordValidator.setNextReturnValue(true); |
| | |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp( |
| | | ByteString.valueOf("uid=test.user,o=test"), |
| | | 3, ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("uid=test.user,o=test"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | |
| | | ModifyRequestProtocolOp modifyRequest = |
| | | new ModifyRequestProtocolOp( |
| | | ByteString.valueOf("uid=test.user,o=test"), mods); |
| | | ByteString.valueOfUtf8("uid=test.user,o=test"), mods); |
| | | message = new LDAPMessage(2, modifyRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | assertFalse(currentPasswords.isEmpty()); |
| | | assertEquals(currentPasswords.size(), 1); |
| | | assertEquals(currentPasswords.iterator().next(), |
| | | ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("password")); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp( |
| | | ByteString.valueOf("uid=test.user,o=test"), |
| | | 3, ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("uid=test.user,o=test"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | |
| | | ModifyRequestProtocolOp modifyRequest = |
| | | new ModifyRequestProtocolOp( |
| | | ByteString.valueOf("uid=test.user,o=test"), mods); |
| | | ByteString.valueOfUtf8("uid=test.user,o=test"), mods); |
| | | message = new LDAPMessage(2, modifyRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | assertFalse(currentPasswords.isEmpty()); |
| | | assertEquals(currentPasswords.size(), 1); |
| | | assertEquals(currentPasswords.iterator().next(), |
| | | ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("password")); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp( |
| | | ByteString.valueOf("uid=test.user,o=test"), |
| | | 3, ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("uid=test.user,o=test"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | |
| | | ModifyRequestProtocolOp modifyRequest = |
| | | new ModifyRequestProtocolOp( |
| | | ByteString.valueOf("uid=test.user,o=test"), mods); |
| | | ByteString.valueOfUtf8("uid=test.user,o=test"), mods); |
| | | message = new LDAPMessage(2, modifyRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | assertFalse(currentPasswords.isEmpty()); |
| | | assertEquals(currentPasswords.size(), 1); |
| | | assertEquals(currentPasswords.iterator().next(), |
| | | ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("password")); |
| | | } |
| | | } |
| | | |
| | |
| | | public void applicableTargets(String aciDN, String aciString, String entryDN) |
| | | throws Exception |
| | | { |
| | | Aci aci = Aci.decode(ByteString.valueOf(aciString), DN.valueOf(aciDN)); |
| | | Aci aci = Aci.decode(ByteString.valueOfUtf8(aciString), DN.valueOf(aciDN)); |
| | | boolean match = AciTargets.isTargetApplicable(aci, |
| | | aci.getTargets(), |
| | | DN.valueOf(entryDN)); |
| | |
| | | String entryDN) |
| | | throws Exception |
| | | { |
| | | Aci aci = Aci.decode(ByteString.valueOf(aciString), DN.valueOf(aciDN)); |
| | | Aci aci = Aci.decode(ByteString.valueOfUtf8(aciString), DN.valueOf(aciDN)); |
| | | boolean match = AciTargets.isTargetApplicable(aci, |
| | | aci.getTargets(), |
| | | DN.valueOf(entryDN)); |
| | |
| | | Attributes.create("title", "debugger"))); |
| | | |
| | | final Attribute cnAttr = entry.getAttribute("cn").get(0); |
| | | assertTrue(cnAttr.contains(ByteString.valueOf("Aaren Rigor"))); |
| | | assertTrue(cnAttr.contains(ByteString.valueOf("Aarenister Rigor"))); |
| | | assertFalse(cnAttr.contains(ByteString.valueOf("Aaren Atp"))); |
| | | assertTrue(cnAttr.contains(ByteString.valueOfUtf8("Aaren Rigor"))); |
| | | assertTrue(cnAttr.contains(ByteString.valueOfUtf8("Aarenister Rigor"))); |
| | | assertFalse(cnAttr.contains(ByteString.valueOfUtf8("Aaren Atp"))); |
| | | |
| | | Set<String> options = Collections.singleton("lang-de"); |
| | | assertTrue(entry.getAttribute("givenname", options).get(0).contains( |
| | | ByteString.valueOf("test"))); |
| | | ByteString.valueOfUtf8("test"))); |
| | | options = Collections.singleton("lang-cn"); |
| | | assertNull(entry.getAttribute("givenname", options)); |
| | | options = Collections.singleton("lang-es"); |
| | | assertTrue(entry.getAttribute("givenname", options).get(0).contains( |
| | | ByteString.valueOf("newtest3"))); |
| | | ByteString.valueOfUtf8("newtest3"))); |
| | | options = Collections.singleton("lang-fr"); |
| | | assertTrue(entry.getAttribute("givenname", options).get(0).contains( |
| | | ByteString.valueOf("test2"))); |
| | | ByteString.valueOfUtf8("test2"))); |
| | | |
| | | assertTrue(entry.getAttribute("employeenumber").contains( |
| | | Attributes.create("employeenumber", "222"))); |
| | |
| | | assertNotNull(entry); |
| | | |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrNull("cn"); |
| | | assertTrue(entry.hasValue(attrType, null, ByteString.valueOf("Annalee Bogard"))); |
| | | assertTrue(entry.hasValue(attrType, null, ByteString.valueOfUtf8("Annalee Bogard"))); |
| | | |
| | | assertEquals(verifyBackend(importtest1DN), 0); |
| | | } |
| | |
| | | { |
| | | final SearchRequest request = Requests.newSearchRequest(DN.valueOf("dc=vlvtest,dc=com"), SearchScope.WHOLE_SUBTREE) |
| | | .addControl(new ServerSideSortRequestControl(sortOrder)) |
| | | .addControl(new VLVRequestControl(0, 3, ByteString.valueOf("a"))); |
| | | .addControl(new VLVRequestControl(0, 3, ByteString.valueOfUtf8("a"))); |
| | | InternalSearchOperation internalSearch = getRootConnection().processSearch(request); |
| | | |
| | | assertEquals(internalSearch.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | { |
| | | final SearchRequest request = Requests.newSearchRequest(DN.valueOf("dc=vlvtest,dc=com"), SearchScope.WHOLE_SUBTREE) |
| | | .addControl(new ServerSideSortRequestControl(sortOrder)) |
| | | .addControl(new VLVRequestControl(0, 3, ByteString.valueOf("aaccf"))); |
| | | .addControl(new VLVRequestControl(0, 3, ByteString.valueOfUtf8("aaccf"))); |
| | | |
| | | InternalSearchOperation internalSearch = getRootConnection().processSearch(request); |
| | | assertEquals(internalSearch.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | { |
| | | final SearchRequest request = Requests.newSearchRequest(DN.valueOf("dc=vlvtest,dc=com"), SearchScope.WHOLE_SUBTREE) |
| | | .addControl(new ServerSideSortRequestControl(sortOrder)) |
| | | .addControl(new VLVRequestControl(0, 3, ByteString.valueOf("albert"))); |
| | | .addControl(new VLVRequestControl(0, 3, ByteString.valueOfUtf8("albert"))); |
| | | |
| | | InternalSearchOperation internalSearch = getRootConnection().processSearch(request); |
| | | assertEquals(internalSearch.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | { |
| | | final SearchRequest request = Requests.newSearchRequest(DN.valueOf("dc=vlvtest,dc=com"), SearchScope.WHOLE_SUBTREE) |
| | | .addControl(new ServerSideSortRequestControl(sortOrder)) |
| | | .addControl(new VLVRequestControl(1, 3, ByteString.valueOf("albert"))); |
| | | .addControl(new VLVRequestControl(1, 3, ByteString.valueOfUtf8("albert"))); |
| | | |
| | | InternalSearchOperation internalSearch = getRootConnection().processSearch(request); |
| | | assertEquals(internalSearch.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | { |
| | | final SearchRequest request = Requests.newSearchRequest(DN.valueOf("dc=vlvtest,dc=com"), SearchScope.WHOLE_SUBTREE) |
| | | .addControl(new ServerSideSortRequestControl(sortOrder)) |
| | | .addControl(new VLVRequestControl(0, 3, ByteString.valueOf("zz"))); |
| | | .addControl(new VLVRequestControl(0, 3, ByteString.valueOfUtf8("zz"))); |
| | | InternalSearchOperation internalSearch = getRootConnection().processSearch(request); |
| | | |
| | | // It will be successful because the control isn't critical. |
| | |
| | | final SearchRequest request = |
| | | newSearchRequest(BACKEND_BASE_DN, SearchScope.WHOLE_SUBTREE, VLV_FILTER).addControl( |
| | | new ServerSideSortRequestControl(mangleSortOrder(sortOrder))).addControl( |
| | | new VLVRequestControl(beforeCount, afterCount, ByteString.valueOf(assertion))); |
| | | new VLVRequestControl(beforeCount, afterCount, ByteString.valueOfUtf8(assertion))); |
| | | final InternalSearchOperation internalSearch = getRootConnection().processSearch(request); |
| | | assertThat(internalSearch.getResultCode()).isEqualTo(ResultCode.SUCCESS); |
| | | assertThat(getDNs(internalSearch.getSearchEntries())).isEqualTo(getDNs(expectedOrder)); |
| | |
| | | package org.opends.server.backends.pluggable; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.forgerock.opendj.ldap.ByteString.valueOf; |
| | | import static org.forgerock.opendj.ldap.ByteString.valueOfUtf8; |
| | | import static org.mockito.Matchers.*; |
| | | import static org.mockito.Mockito.*; |
| | | import static org.opends.server.backends.pluggable.EntryIDSet.*; |
| | |
| | | put(newDefinedSet(1, 2, 3, 4)); |
| | | update(newDefinedSet(1, 2, 3, 4), newDefinedSet()); |
| | | |
| | | assertThat(txn.read(index.getName(), valueOf("key"))).isNull(); |
| | | assertThat(txn.read(index.getName(), valueOfUtf8("key"))).isNull(); |
| | | } |
| | | |
| | | private void update(EntryIDSet deletedIDSet, EntryIDSet addedIDSet) { |
| | | index.update(txn, valueOf("key"), deletedIDSet, addedIDSet); |
| | | index.update(txn, valueOfUtf8("key"), deletedIDSet, addedIDSet); |
| | | } |
| | | |
| | | private void put(EntryIDSet idSet) |
| | | { |
| | | txn.put(index.getName(), valueOf("key"), CODEC_V2.encode(idSet)); |
| | | txn.put(index.getName(), valueOfUtf8("key"), CODEC_V2.encode(idSet)); |
| | | } |
| | | |
| | | private ByteString getFromDb() { |
| | | return txn.read(index.getName(), valueOf("key")); |
| | | return txn.read(index.getName(), valueOfUtf8("key")); |
| | | } |
| | | |
| | | private EntryIDSet get() { |
| | | return CODEC_V2.decode(valueOf("key"), getFromDb()); |
| | | return CODEC_V2.decode(valueOfUtf8("key"), getFromDb()); |
| | | } |
| | | |
| | | private static DefaultIndex newIndex(String name, int indexLimit, EnumSet<IndexFlag> indexFlags) |
| | |
| | | @Test(groups = { "precommit", "pluggablebackend", "unit" }, sequential=true) |
| | | public class EntryIDSetTest extends DirectoryServerTestCase |
| | | { |
| | | private final static ByteString KEY = ByteString.valueOf("test"); |
| | | private final static ByteString KEY = ByteString.valueOfUtf8("test"); |
| | | |
| | | @Test(expectedExceptions = NullPointerException.class) |
| | | public void testDefinedCannotCreateWithNull() |
| | |
| | | assertThat(codec.decode(KEY, string).isDefined()).isFalse(); |
| | | assertThat(codec.decode(KEY, string).size()).isEqualTo(Long.MAX_VALUE); |
| | | |
| | | string = codec.encode(newUndefinedSetWithKey(ByteString.valueOf("none"))); |
| | | string = codec.encode(newUndefinedSetWithKey(ByteString.valueOfUtf8("none"))); |
| | | assertThat(codec.decode(KEY, string).isDefined()).isFalse(); |
| | | assertThat(codec.decode(KEY, string).size()).isEqualTo(Long.MAX_VALUE); |
| | | } |
| | |
| | | public void testExternalSortChunk() throws Exception |
| | | { |
| | | final int NB_REGION = 10; |
| | | final ByteString KEY = ByteString.valueOf("key"); |
| | | final ByteString KEY = ByteString.valueOfUtf8("key"); |
| | | final File tempDir = TestCaseUtils.createTemporaryDirectory("testExternalSortChunk"); |
| | | try(final BufferPool bufferPool = new BufferPool(2, 4 + 1 + KEY.length() + 1 + 4)) { |
| | | // 4: record offset, 1: key length, 1: value length, 4: value |
| | |
| | | List<ByteString> expected = new ArrayList<>(NB_REGION); |
| | | for (int i = 0; i < NB_REGION; i++) |
| | | { |
| | | final ByteString value = ByteString.valueOf(String.format("%02d", i)); |
| | | final ByteString value = ByteString.valueOfUtf8(String.format("%02d", i)); |
| | | chunk.put(KEY, value); |
| | | expected.add(value); |
| | | } |
| | |
| | | final List<Pair<ByteString, ByteString>> content = new ArrayList<>(data.length); |
| | | for (String[] keyValue : data) |
| | | { |
| | | content.add(Pair.of(ByteString.valueOf(keyValue[0]), ByteString.valueOf(keyValue[1]))); |
| | | content.add(Pair.of(ByteString.valueOfUtf8(keyValue[0]), ByteString.valueOfUtf8(keyValue[1]))); |
| | | } |
| | | return content; |
| | | } |
| | |
| | | protected String[] backendVlvIndexes = { "people" }; |
| | | |
| | | private AttributeType modifyAttribute; |
| | | private final ByteString modifyValue = ByteString.valueOf("foo"); |
| | | private final ByteString modifyValue = ByteString.valueOfUtf8("foo"); |
| | | private String backupPath; |
| | | private BackupDirectory backupDirectory; |
| | | |
| | |
| | | @Override |
| | | public void run(WriteableTransaction txn) throws Exception |
| | | { |
| | | txn.put(new TreeName("dc=test,dc=com", "id2entry"), ByteString.valueOf("key"), ByteString.valueOf("value")); |
| | | txn.put(new TreeName("dc=test,dc=com", "id2entry"), ByteString.valueOfUtf8("key"), ByteString.valueOfUtf8("value")); |
| | | } |
| | | }); |
| | | } |
| | |
| | | // excepted behavior |
| | | } |
| | | |
| | | MatchedValuesFilter mvf = MatchedValuesFilter.createEqualityFilter(type, ByteString.valueOf(value)); |
| | | MatchedValuesFilter mvf = MatchedValuesFilter.createEqualityFilter(type, ByteString.valueOfUtf8(value)); |
| | | assertNotNull(mvf); |
| | | assertEquals(mvf.getRawAttributeType(), type); |
| | | assertEquals(mvf.getRawAssertionValue(), ByteString.valueOf(value)); |
| | | assertEquals(mvf.getRawAssertionValue(), ByteString.valueOfUtf8(value)); |
| | | assertEquals(mvf.getMatchType(), MatchedValuesFilter.EQUALITY_MATCH_TYPE); |
| | | checkEncodeDecode(mvf); |
| | | |
| | | try |
| | | { |
| | | MatchedValuesFilter.createEqualityFilter((String) null, ByteString.valueOf(value)); |
| | | MatchedValuesFilter.createEqualityFilter((String) null, ByteString.valueOfUtf8(value)); |
| | | fail("Expected NullPointerException"); |
| | | } |
| | | catch (NullPointerException e) |
| | |
| | | ByteString attVal = null; |
| | | if (attType != null) |
| | | { |
| | | attVal = ByteString.valueOf(value); |
| | | attVal = ByteString.valueOfUtf8(value); |
| | | } |
| | | |
| | | try |
| | |
| | | // input parameter |
| | | String rawAttTypeTest = type; |
| | | AttributeType attTypeTest = DirectoryServer.getAttributeTypeOrNull(type); |
| | | ByteString subInitialTest = ByteString.valueOf(subInitial); |
| | | ByteString subInitialTest = ByteString.valueOfUtf8(subInitial); |
| | | List<ByteString> subAnyTest = new ArrayList<>(subAny.size()); |
| | | for (String s : subAny) |
| | | { |
| | | subAnyTest.add(ByteString.valueOf(s)); |
| | | subAnyTest.add(ByteString.valueOfUtf8(s)); |
| | | } |
| | | ByteString subFinalTest = ByteString.valueOf(subFinal); |
| | | ByteString subFinalTest = ByteString.valueOfUtf8(subFinal); |
| | | |
| | | // test parameter |
| | | AttributeType attTypeCurrent; |
| | |
| | | { |
| | | MatchedValuesFilter mvf; |
| | | mvf = MatchedValuesFilter.createGreaterOrEqualFilter(type, |
| | | ByteString.valueOf(value)); |
| | | ByteString.valueOfUtf8(value)); |
| | | assertNotNull(mvf); |
| | | assertEquals(mvf.getRawAttributeType(), type); |
| | | assertEquals(mvf.getRawAssertionValue(), ByteString.valueOf(value)); |
| | | assertEquals(mvf.getRawAssertionValue(), ByteString.valueOfUtf8(value)); |
| | | assertEquals(mvf.getMatchType(), |
| | | MatchedValuesFilter.GREATER_OR_EQUAL_TYPE); |
| | | } |
| | | |
| | | try |
| | | { |
| | | MatchedValuesFilter.createGreaterOrEqualFilter((String) null, ByteString.valueOf(value)); |
| | | MatchedValuesFilter.createGreaterOrEqualFilter((String) null, ByteString.valueOfUtf8(value)); |
| | | fail("Expected NullPointerException"); |
| | | } |
| | | catch (NullPointerException e) |
| | |
| | | ByteString attVal = null; |
| | | if (attType != null) |
| | | { |
| | | attVal = ByteString.valueOf(value); |
| | | attVal = ByteString.valueOfUtf8(value); |
| | | } |
| | | |
| | | try |
| | |
| | | // Check type, value |
| | | MatchedValuesFilter mvf; |
| | | mvf = MatchedValuesFilter.createLessOrEqualFilter(type, |
| | | ByteString.valueOf(value)); |
| | | ByteString.valueOfUtf8(value)); |
| | | assertNotNull(mvf); |
| | | assertEquals(mvf.getRawAttributeType(), type); |
| | | assertEquals(mvf.getRawAssertionValue(), ByteString.valueOf(value)); |
| | | assertEquals(mvf.getRawAssertionValue(), ByteString.valueOfUtf8(value)); |
| | | assertEquals(mvf.getMatchType(), MatchedValuesFilter.LESS_OR_EQUAL_TYPE); |
| | | |
| | | try |
| | | { |
| | | mvf = MatchedValuesFilter.createLessOrEqualFilter((String) null, |
| | | ByteString.valueOf(value)); |
| | | ByteString.valueOfUtf8(value)); |
| | | } |
| | | catch (NullPointerException e) |
| | | { |
| | |
| | | ByteString attVal = null ; |
| | | if (attType != null) |
| | | { |
| | | attVal = ByteString.valueOf(value); |
| | | attVal = ByteString.valueOfUtf8(value); |
| | | } |
| | | |
| | | try |
| | |
| | | // Check type, value |
| | | MatchedValuesFilter mvf; |
| | | mvf = MatchedValuesFilter.createApproximateFilter(type, |
| | | ByteString.valueOf(value)); |
| | | ByteString.valueOfUtf8(value)); |
| | | assertNotNull(mvf); |
| | | assertEquals(mvf.getRawAttributeType(), type); |
| | | assertEquals(mvf.getRawAssertionValue(), ByteString.valueOf(value)); |
| | | assertEquals(mvf.getRawAssertionValue(), ByteString.valueOfUtf8(value)); |
| | | assertEquals(mvf.getMatchType(), MatchedValuesFilter.APPROXIMATE_MATCH_TYPE); |
| | | |
| | | try |
| | | { |
| | | MatchedValuesFilter.createApproximateFilter((String) null, ByteString.valueOf(value)); |
| | | MatchedValuesFilter.createApproximateFilter((String) null, ByteString.valueOfUtf8(value)); |
| | | fail("Expected NullPointerException"); |
| | | } |
| | | catch (NullPointerException e) |
| | |
| | | ByteString attVal = null ; |
| | | if (attType != null) |
| | | { |
| | | attVal = ByteString.valueOf(value); |
| | | attVal = ByteString.valueOfUtf8(value); |
| | | } |
| | | |
| | | try |
| | |
| | | String rawAttTypeTest = type ; |
| | | AttributeType attTypeTest = DirectoryServer.getAttributeTypeOrNull(type) ; |
| | | String matchingRuleIdTest = matchingRule.getOID() ; |
| | | ByteString attValueTest = (attTypeTest == null) ? null : ByteString.valueOf(value); |
| | | ByteString attValueTest = (attTypeTest == null) ? null : ByteString.valueOfUtf8(value); |
| | | // parameter used for the test. |
| | | String rawAttTypeTestCurrent; |
| | | AttributeType attTypeTestCurrent ; |
| | |
| | | String assertion) |
| | | { |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrNull("usercertificate"); |
| | | MatchedValuesFilter mvf = MatchedValuesFilter.createEqualityFilter(type, ByteString.valueOf(assertion)); |
| | | MatchedValuesFilter mvf = MatchedValuesFilter.createEqualityFilter(type, ByteString.valueOfUtf8(assertion)); |
| | | assertTrue(mvf.valueMatches(attrType, value)); |
| | | } |
| | | } |
| | |
| | | assertEquals(pec.getOID(),OID_NS_PASSWORD_EXPIRED); |
| | | |
| | | control = new LDAPControl(OID_NS_PASSWORD_EXPIRED, isCritical, |
| | | ByteString.valueOf("value")); |
| | | ByteString.valueOfUtf8("value")); |
| | | try |
| | | { |
| | | pec = PasswordExpiredControl.DECODER.decode(control.isCritical(), control.getValue()); |
| | |
| | | } |
| | | |
| | | control = new LDAPControl(OID_NS_PASSWORD_EXPIRING, isCritical, |
| | | ByteString.valueOf("Wrong value")); |
| | | ByteString.valueOfUtf8("Wrong value")); |
| | | try |
| | | { |
| | | pec = PasswordExpiringControl.DECODER.decode(control.isCritical(), control.getValue()); |
| | |
| | | assertEquals(pec.getOID(),OID_PASSWORD_POLICY_CONTROL); |
| | | |
| | | control = new LDAPControl(OID_PASSWORD_POLICY_CONTROL, |
| | | isCritical, ByteString.valueOf("value")); |
| | | isCritical, ByteString.valueOfUtf8("value")); |
| | | try |
| | | { |
| | | pec = PasswordPolicyRequestControl.DECODER.decode(control.isCritical(), control.getValue()); |
| | |
| | | controls.add(new LDAPControl(OID_PASSWORD_POLICY_CONTROL, true)); |
| | | |
| | | BindRequestProtocolOp bindRequest = new BindRequestProtocolOp( |
| | | ByteString.valueOf("uid=test.user,o=test"), 3, |
| | | ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("uid=test.user,o=test"), 3, |
| | | ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest, controls); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | rawAttrs.add(RawAttribute.create("ou", "People")); |
| | | |
| | | AddRequestProtocolOp addRequest = new AddRequestProtocolOp( |
| | | ByteString.valueOf("ou=People,o=test"), rawAttrs); |
| | | ByteString.valueOfUtf8("ou=People,o=test"), rawAttrs); |
| | | |
| | | controls = new ArrayList<>(); |
| | | controls.add(new LDAPControl(OID_PASSWORD_POLICY_CONTROL, true)); |
| | |
| | | try |
| | | { |
| | | BindRequestProtocolOp bindRequest = new BindRequestProtocolOp( |
| | | ByteString.valueOf("cn=Directory Manager"), 3, |
| | | ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("cn=Directory Manager"), 3, |
| | | ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | "{SSHA}0pZPpMIm6xSBIW4hGvR/72fjO4M9p3Ff1g7QFw==")); |
| | | |
| | | AddRequestProtocolOp addRequest = new AddRequestProtocolOp( |
| | | ByteString.valueOf("ou=uid=test.user,o=test"), rawAttrs); |
| | | ByteString.valueOfUtf8("ou=uid=test.user,o=test"), rawAttrs); |
| | | |
| | | List<Control> controls = new ArrayList<>(); |
| | | controls.add(new LDAPControl(OID_PASSWORD_POLICY_CONTROL, true)); |
| | |
| | | try |
| | | { |
| | | BindRequestProtocolOp bindRequest = new BindRequestProtocolOp( |
| | | ByteString.valueOf("cn=Directory Manager"), 3, |
| | | ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("cn=Directory Manager"), 3, |
| | | ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | rawAttrs.add(RawAttribute.create("userPassword", "short")); |
| | | |
| | | AddRequestProtocolOp addRequest = new AddRequestProtocolOp( |
| | | ByteString.valueOf("ou=uid=test.user,o=test"), rawAttrs); |
| | | ByteString.valueOfUtf8("ou=uid=test.user,o=test"), rawAttrs); |
| | | |
| | | List<Control> controls = new ArrayList<>(); |
| | | controls.add(new LDAPControl(OID_PASSWORD_POLICY_CONTROL, true)); |
| | |
| | | try |
| | | { |
| | | BindRequestProtocolOp bindRequest = new BindRequestProtocolOp( |
| | | ByteString.valueOf("uid=test.user,o=test"), 3, |
| | | ByteString.valueOf("wrong")); |
| | | ByteString.valueOfUtf8("uid=test.user,o=test"), 3, |
| | | ByteString.valueOfUtf8("wrong")); |
| | | |
| | | for (int i=1; i <= 3; i++) |
| | | { |
| | |
| | | } |
| | | |
| | | bindRequest = new BindRequestProtocolOp( |
| | | ByteString.valueOf("uid=test.user,o=test"), 3, |
| | | ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("uid=test.user,o=test"), 3, |
| | | ByteString.valueOfUtf8("password")); |
| | | |
| | | List<Control> controls = new ArrayList<>(); |
| | | controls.add(new LDAPControl(OID_PASSWORD_POLICY_CONTROL, true)); |
| | |
| | | try |
| | | { |
| | | BindRequestProtocolOp bindRequest = new BindRequestProtocolOp( |
| | | ByteString.valueOf("uid=test.user,o=test"), 3, |
| | | ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("uid=test.user,o=test"), 3, |
| | | ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | |
| | | |
| | | CompareRequestProtocolOp compareRequest = |
| | | new CompareRequestProtocolOp(ByteString.valueOf("o=test"), "o", |
| | | ByteString.valueOf("test")); |
| | | new CompareRequestProtocolOp(ByteString.valueOfUtf8("o=test"), "o", |
| | | ByteString.valueOfUtf8("test")); |
| | | |
| | | List<Control> controls = new ArrayList<>(); |
| | | controls.add(new LDAPControl(OID_PASSWORD_POLICY_CONTROL, true)); |
| | |
| | | try |
| | | { |
| | | BindRequestProtocolOp bindRequest = new BindRequestProtocolOp( |
| | | ByteString.valueOf("uid=test.user,o=test"), 3, |
| | | ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("uid=test.user,o=test"), 3, |
| | | ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | |
| | | |
| | | DeleteRequestProtocolOp deleteRequest = |
| | | new DeleteRequestProtocolOp(ByteString.valueOf("ou=People,o=test")); |
| | | new DeleteRequestProtocolOp(ByteString.valueOfUtf8("ou=People,o=test")); |
| | | |
| | | List<Control> controls = new ArrayList<>(); |
| | | controls.add(new LDAPControl(OID_PASSWORD_POLICY_CONTROL, true)); |
| | |
| | | try |
| | | { |
| | | BindRequestProtocolOp bindRequest = new BindRequestProtocolOp( |
| | | ByteString.valueOf(userDN), 3, |
| | | ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8(userDN), 3, |
| | | ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | "foo")); |
| | | |
| | | ModifyRequestProtocolOp modifyRequest = |
| | | new ModifyRequestProtocolOp(ByteString.valueOf(entryDN), mods); |
| | | new ModifyRequestProtocolOp(ByteString.valueOfUtf8(entryDN), mods); |
| | | |
| | | List<Control> controls = new ArrayList<>(); |
| | | controls.add(new LDAPControl(OID_PASSWORD_POLICY_CONTROL, true)); |
| | |
| | | try |
| | | { |
| | | BindRequestProtocolOp bindRequest = new BindRequestProtocolOp( |
| | | ByteString.valueOf(userDN), 3, |
| | | ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8(userDN), 3, |
| | | ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | "foo")); |
| | | |
| | | ModifyRequestProtocolOp modifyRequest = |
| | | new ModifyRequestProtocolOp(ByteString.valueOf(entryDN), mods); |
| | | new ModifyRequestProtocolOp(ByteString.valueOfUtf8(entryDN), mods); |
| | | |
| | | List<Control> controls = new ArrayList<>(); |
| | | controls.add(new LDAPControl(OID_PASSWORD_POLICY_CONTROL, true)); |
| | | controls.add(new LDAPControl(OID_PROXIED_AUTH_V2, true, |
| | | ByteString.valueOf("dn:" + authzDN))); |
| | | ByteString.valueOfUtf8("dn:" + authzDN))); |
| | | |
| | | message = new LDAPMessage(2, modifyRequest, controls); |
| | | w.writeMessage(message); |
| | |
| | | try |
| | | { |
| | | BindRequestProtocolOp bindRequest = new BindRequestProtocolOp( |
| | | ByteString.valueOf("uid=test.user,o=test"), 3, |
| | | ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("uid=test.user,o=test"), 3, |
| | | ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | |
| | | ModifyRequestProtocolOp modifyRequest = |
| | | new ModifyRequestProtocolOp( |
| | | ByteString.valueOf("uid=test.user,o=test"), mods); |
| | | ByteString.valueOfUtf8("uid=test.user,o=test"), mods); |
| | | |
| | | List<Control> controls = new ArrayList<>(); |
| | | controls.add(new LDAPControl(OID_PASSWORD_POLICY_CONTROL, true)); |
| | |
| | | try |
| | | { |
| | | BindRequestProtocolOp bindRequest = new BindRequestProtocolOp( |
| | | ByteString.valueOf("uid=test.user,o=test"), 3, |
| | | ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("uid=test.user,o=test"), 3, |
| | | ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | |
| | | ModifyRequestProtocolOp modifyRequest = |
| | | new ModifyRequestProtocolOp( |
| | | ByteString.valueOf("uid=test.user,o=test"), mods); |
| | | ByteString.valueOfUtf8("uid=test.user,o=test"), mods); |
| | | |
| | | List<Control> controls = new ArrayList<>(); |
| | | controls.add(new LDAPControl(OID_PASSWORD_POLICY_CONTROL, true)); |
| | |
| | | try |
| | | { |
| | | BindRequestProtocolOp bindRequest = new BindRequestProtocolOp( |
| | | ByteString.valueOf("uid=test.user,o=test"), 3, |
| | | ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("uid=test.user,o=test"), 3, |
| | | ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | |
| | | ModifyRequestProtocolOp modifyRequest = |
| | | new ModifyRequestProtocolOp( |
| | | ByteString.valueOf("uid=test.user,o=test"), mods); |
| | | ByteString.valueOfUtf8("uid=test.user,o=test"), mods); |
| | | |
| | | List<Control> controls = new ArrayList<>(); |
| | | controls.add(new LDAPControl(OID_PASSWORD_POLICY_CONTROL, true)); |
| | |
| | | try |
| | | { |
| | | BindRequestProtocolOp bindRequest = new BindRequestProtocolOp( |
| | | ByteString.valueOf("uid=test.user,o=test"), 3, |
| | | ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("uid=test.user,o=test"), 3, |
| | | ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | |
| | | ModifyRequestProtocolOp modifyRequest = |
| | | new ModifyRequestProtocolOp( |
| | | ByteString.valueOf("uid=test.user,o=test"), mods); |
| | | ByteString.valueOfUtf8("uid=test.user,o=test"), mods); |
| | | |
| | | List<Control> controls = new ArrayList<>(); |
| | | controls.add(new LDAPControl(OID_PASSWORD_POLICY_CONTROL, true)); |
| | |
| | | try |
| | | { |
| | | BindRequestProtocolOp bindRequest = new BindRequestProtocolOp( |
| | | ByteString.valueOf("uid=test.user,o=test"), 3, |
| | | ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("uid=test.user,o=test"), 3, |
| | | ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | |
| | | ModifyDNRequestProtocolOp modifyDNRequest = |
| | | new ModifyDNRequestProtocolOp( |
| | | ByteString.valueOf("ou=People,o=test"), |
| | | ByteString.valueOf("ou=Users"), true); |
| | | ByteString.valueOfUtf8("ou=People,o=test"), |
| | | ByteString.valueOfUtf8("ou=Users"), true); |
| | | |
| | | List<Control> controls = new ArrayList<>(); |
| | | controls.add(new LDAPControl(OID_PASSWORD_POLICY_CONTROL, true)); |
| | |
| | | try |
| | | { |
| | | BindRequestProtocolOp bindRequest = new BindRequestProtocolOp( |
| | | ByteString.valueOf("uid=test.user,o=test"), 3, |
| | | ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("uid=test.user,o=test"), 3, |
| | | ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | |
| | | |
| | | SearchRequestProtocolOp searchRequest = |
| | | new SearchRequestProtocolOp(ByteString.valueOf("o=test"), |
| | | new SearchRequestProtocolOp(ByteString.valueOfUtf8("o=test"), |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | LDAPFilter.objectClassPresent(), |
| | |
| | | try |
| | | { |
| | | control = new LDAPControl(OID_PERSISTENT_SEARCH, isCritical, |
| | | ByteString.valueOf("invalid value")); |
| | | ByteString.valueOfUtf8("invalid value")); |
| | | psc = PersistentSearchControl.DECODER.decode(control.isCritical(), control.getValue()); |
| | | fail(); |
| | | } |
| | |
| | | mods.add(new LDAPModification(ModificationType.REPLACE, attr)); |
| | | |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(ByteString.valueOf("cn=config"), mods); |
| | | conn.processModify(ByteString.valueOfUtf8("cn=config"), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | //Create a persistent search request. |
| | |
| | | |
| | | |
| | | // Try an empty DN, which is acceptable. |
| | | proxyControl = new ProxiedAuthV1Control(ByteString.valueOf("")); |
| | | proxyControl = new ProxiedAuthV1Control(ByteString.valueOfUtf8("")); |
| | | assertEquals(proxyControl.getOID(), OID_PROXIED_AUTH_V1); |
| | | assertTrue(proxyControl.isCritical()); |
| | | assertTrue(proxyControl.getAuthorizationDN().isRootDN()); |
| | |
| | | |
| | | // Try a valid DN, which is acceptable. |
| | | proxyControl = |
| | | new ProxiedAuthV1Control(ByteString.valueOf("uid=test,o=test")); |
| | | new ProxiedAuthV1Control(ByteString.valueOfUtf8("uid=test,o=test")); |
| | | assertEquals(proxyControl.getOID(), OID_PROXIED_AUTH_V1); |
| | | assertTrue(proxyControl.isCritical()); |
| | | assertEquals(proxyControl.getAuthorizationDN(), |
| | |
| | | |
| | | // Try an invalid DN, which will be initally accepted but will fail when |
| | | // attempting to get the authorization DN. |
| | | proxyControl = new ProxiedAuthV1Control(ByteString.valueOf("invalid")); |
| | | proxyControl = new ProxiedAuthV1Control(ByteString.valueOfUtf8("invalid")); |
| | | assertEquals(proxyControl.getOID(), OID_PROXIED_AUTH_V1); |
| | | assertTrue(proxyControl.isCritical()); |
| | | try |
| | |
| | | { |
| | | LDAPControl c = |
| | | new LDAPControl(OID_PROXIED_AUTH_V1, true, |
| | | ByteString.valueOf("uid=test,o=test")); |
| | | ByteString.valueOfUtf8("uid=test,o=test")); |
| | | |
| | | ProxiedAuthV1Control.DECODER.decode(c.isCritical(), c.getValue()); |
| | | } |
| | |
| | | LDAPControl c = |
| | | new LDAPControl(OID_PROXIED_AUTH_V1, true, bsb.toByteString()); |
| | | |
| | | assertEquals(ByteString.valueOf("uid=element1,o=test"), |
| | | assertEquals(ByteString.valueOfUtf8("uid=element1,o=test"), |
| | | ProxiedAuthV1Control.DECODER.decode(c.isCritical(), |
| | | c.getValue()).getRawAuthorizationDN()); |
| | | } |
| | |
| | | throws Exception |
| | | { |
| | | ProxiedAuthV1Control proxyControl = |
| | | new ProxiedAuthV1Control(ByteString.valueOf("")); |
| | | assertEquals(proxyControl.getRawAuthorizationDN(), ByteString.valueOf("")); |
| | | new ProxiedAuthV1Control(ByteString.valueOfUtf8("")); |
| | | assertEquals(proxyControl.getRawAuthorizationDN(), ByteString.valueOfUtf8("")); |
| | | |
| | | proxyControl = |
| | | new ProxiedAuthV1Control(ByteString.valueOf("uid=test,o=test")); |
| | | new ProxiedAuthV1Control(ByteString.valueOfUtf8("uid=test,o=test")); |
| | | assertEquals(proxyControl.getRawAuthorizationDN(), |
| | | ByteString.valueOf("uid=test,o=test")); |
| | | ByteString.valueOfUtf8("uid=test,o=test")); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | ProxiedAuthV1Control proxyControl = |
| | | new ProxiedAuthV1Control(DN.rootDN()); |
| | | assertEquals(proxyControl.getRawAuthorizationDN(), ByteString.valueOf("")); |
| | | assertEquals(proxyControl.getRawAuthorizationDN(), ByteString.valueOfUtf8("")); |
| | | assertEquals(proxyControl.getAuthorizationDN(), DN.rootDN()); |
| | | |
| | | proxyControl = |
| | | new ProxiedAuthV1Control(DN.valueOf("uid=test,o=test")); |
| | | assertEquals(proxyControl.getRawAuthorizationDN(), |
| | | ByteString.valueOf("uid=test,o=test")); |
| | | ByteString.valueOfUtf8("uid=test,o=test")); |
| | | assertEquals(proxyControl.getAuthorizationDN(), |
| | | DN.valueOf("uid=test,o=test")); |
| | | } |
| | |
| | | // The default toString() calls the version that takes a string builder |
| | | // argument, so we only need to use the default version to cover both cases. |
| | | ProxiedAuthV1Control proxyControl = |
| | | new ProxiedAuthV1Control(ByteString.valueOf("uid=test,o=test")); |
| | | new ProxiedAuthV1Control(ByteString.valueOfUtf8("uid=test,o=test")); |
| | | proxyControl.toString(); |
| | | |
| | | proxyControl = new ProxiedAuthV1Control(DN.valueOf("uid=test,o=test")); |
| | |
| | | public void testConstructorEmptyAuthzID() |
| | | { |
| | | ProxiedAuthV2Control proxyControl = |
| | | new ProxiedAuthV2Control(ByteString.valueOf("")); |
| | | assertEquals(proxyControl.getAuthorizationID(), ByteString.valueOf("")); |
| | | new ProxiedAuthV2Control(ByteString.valueOfUtf8("")); |
| | | assertEquals(proxyControl.getAuthorizationID(), ByteString.valueOfUtf8("")); |
| | | } |
| | | |
| | | |
| | |
| | | public void testConstructorNonEmptyAuthzIDDN() |
| | | { |
| | | ProxiedAuthV2Control proxyControl = |
| | | new ProxiedAuthV2Control(ByteString.valueOf("dn:uid=test,o=test")); |
| | | new ProxiedAuthV2Control(ByteString.valueOfUtf8("dn:uid=test,o=test")); |
| | | assertEquals(proxyControl.getAuthorizationID(), |
| | | ByteString.valueOf("dn:uid=test,o=test")); |
| | | ByteString.valueOfUtf8("dn:uid=test,o=test")); |
| | | } |
| | | |
| | | |
| | |
| | | public void testConstructorNonEmptyAuthzIDUsername() |
| | | { |
| | | ProxiedAuthV2Control proxyControl = |
| | | new ProxiedAuthV2Control(ByteString.valueOf("u:test")); |
| | | new ProxiedAuthV2Control(ByteString.valueOfUtf8("u:test")); |
| | | assertEquals(proxyControl.getAuthorizationID(), |
| | | ByteString.valueOf("u:test")); |
| | | ByteString.valueOfUtf8("u:test")); |
| | | } |
| | | |
| | | |
| | |
| | | throws Exception |
| | | { |
| | | LDAPControl c = new LDAPControl(OID_PROXIED_AUTH_V2, false, |
| | | ByteString.valueOf("u:test")); |
| | | ByteString.valueOfUtf8("u:test")); |
| | | ProxiedAuthV2Control.DECODER.decode(c.isCritical(), c.getValue()); |
| | | } |
| | | |
| | |
| | | public void testDecodeControlDNValue() |
| | | throws Exception |
| | | { |
| | | ByteString authzID = ByteString.valueOf("dn:uid=test,o=test"); |
| | | ByteString authzID = ByteString.valueOfUtf8("dn:uid=test,o=test"); |
| | | |
| | | LDAPControl c = new LDAPControl(OID_PROXIED_AUTH_V2, true, authzID); |
| | | ProxiedAuthV2Control proxyControl = ProxiedAuthV2Control.DECODER.decode(c.isCritical(), c.getValue()); |
| | |
| | | public void testDecodeControlUsernameValue() |
| | | throws Exception |
| | | { |
| | | ByteString authzID = ByteString.valueOf("u:test"); |
| | | ByteString authzID = ByteString.valueOfUtf8("u:test"); |
| | | |
| | | LDAPControl c = new LDAPControl(OID_PROXIED_AUTH_V2, true, authzID); |
| | | ProxiedAuthV2Control proxyControl = ProxiedAuthV2Control.DECODER.decode(c.isCritical(), c.getValue()); |
| | |
| | | public void testDecodeControlInvalidValue() |
| | | throws Exception |
| | | { |
| | | ByteString authzID = ByteString.valueOf("invalid"); |
| | | ByteString authzID = ByteString.valueOfUtf8("invalid"); |
| | | |
| | | LDAPControl c = new LDAPControl(OID_PROXIED_AUTH_V2, true, authzID); |
| | | ProxiedAuthV2Control proxyControl = ProxiedAuthV2Control.DECODER.decode(c.isCritical(), c.getValue()); |
| | |
| | | public void testDecodeControlLegacyDNValue() |
| | | throws Exception |
| | | { |
| | | ByteString innerValue = ByteString.valueOf("dn:uid=test,o=test"); |
| | | ByteString innerValue = ByteString.valueOfUtf8("dn:uid=test,o=test"); |
| | | ByteStringBuilder bsb = new ByteStringBuilder(); |
| | | ASN1Writer writer = ASN1.getWriter(bsb); |
| | | writer.writeOctetString(innerValue); |
| | |
| | | public void testDecodeControlLegacyUsernameValue() |
| | | throws Exception |
| | | { |
| | | ByteString innerValue = ByteString.valueOf("u:test"); |
| | | ByteString innerValue = ByteString.valueOfUtf8("u:test"); |
| | | ByteStringBuilder bsb = new ByteStringBuilder(); |
| | | ASN1Writer writer = ASN1.getWriter(bsb); |
| | | writer.writeOctetString(innerValue); |
| | |
| | | throws Exception |
| | | { |
| | | ProxiedAuthV2Control proxyControl = |
| | | new ProxiedAuthV2Control(ByteString.valueOf("")); |
| | | new ProxiedAuthV2Control(ByteString.valueOfUtf8("")); |
| | | assertNull(proxyControl.getAuthorizationEntry()); |
| | | } |
| | | |
| | |
| | | throws Exception |
| | | { |
| | | ProxiedAuthV2Control proxyControl = |
| | | new ProxiedAuthV2Control(ByteString.valueOf("dn:")); |
| | | new ProxiedAuthV2Control(ByteString.valueOfUtf8("dn:")); |
| | | assertNull(proxyControl.getAuthorizationEntry()); |
| | | } |
| | | |
| | |
| | | "cn: Test User"); |
| | | |
| | | ProxiedAuthV2Control proxyControl = |
| | | new ProxiedAuthV2Control(ByteString.valueOf("dn:uid=test,o=test")); |
| | | new ProxiedAuthV2Control(ByteString.valueOfUtf8("dn:uid=test,o=test")); |
| | | assertEquals(proxyControl.getAuthorizationEntry().getName(), |
| | | DN.valueOf("uid=test,o=test")); |
| | | } |
| | |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | ProxiedAuthV2Control proxyControl = |
| | | new ProxiedAuthV2Control(ByteString.valueOf("dn:uid=test,o=test")); |
| | | new ProxiedAuthV2Control(ByteString.valueOfUtf8("dn:uid=test,o=test")); |
| | | proxyControl.getAuthorizationEntry(); |
| | | } |
| | | |
| | |
| | | "ds-pwp-account-disabled: true"); |
| | | |
| | | ProxiedAuthV2Control proxyControl = |
| | | new ProxiedAuthV2Control(ByteString.valueOf("dn:uid=test,o=test")); |
| | | new ProxiedAuthV2Control(ByteString.valueOfUtf8("dn:uid=test,o=test")); |
| | | proxyControl.getAuthorizationEntry(); |
| | | } |
| | | |
| | |
| | | throws Exception |
| | | { |
| | | ProxiedAuthV2Control proxyControl = |
| | | new ProxiedAuthV2Control(ByteString.valueOf("u:")); |
| | | new ProxiedAuthV2Control(ByteString.valueOfUtf8("u:")); |
| | | assertNull(proxyControl.getAuthorizationEntry()); |
| | | } |
| | | |
| | |
| | | "cn: Test User"); |
| | | |
| | | ProxiedAuthV2Control proxyControl = |
| | | new ProxiedAuthV2Control(ByteString.valueOf("u:test")); |
| | | new ProxiedAuthV2Control(ByteString.valueOfUtf8("u:test")); |
| | | assertEquals(proxyControl.getAuthorizationEntry().getName(), |
| | | DN.valueOf("uid=test,o=test")); |
| | | } |
| | |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | ProxiedAuthV2Control proxyControl = |
| | | new ProxiedAuthV2Control(ByteString.valueOf("u:test")); |
| | | new ProxiedAuthV2Control(ByteString.valueOfUtf8("u:test")); |
| | | proxyControl.getAuthorizationEntry(); |
| | | } |
| | | |
| | |
| | | "ds-pwp-account-disabled: true"); |
| | | |
| | | ProxiedAuthV2Control proxyControl = |
| | | new ProxiedAuthV2Control(ByteString.valueOf("u:test")); |
| | | new ProxiedAuthV2Control(ByteString.valueOfUtf8("u:test")); |
| | | proxyControl.getAuthorizationEntry(); |
| | | } |
| | | |
| | |
| | | throws Exception |
| | | { |
| | | ProxiedAuthV2Control proxyControl = |
| | | new ProxiedAuthV2Control(ByteString.valueOf("invalid")); |
| | | new ProxiedAuthV2Control(ByteString.valueOfUtf8("invalid")); |
| | | proxyControl.getAuthorizationEntry(); |
| | | } |
| | | |
| | |
| | | // The default toString() calls the version that takes a string builder |
| | | // argument, so we only need to use the default version to cover both cases. |
| | | ProxiedAuthV2Control proxyControl = |
| | | new ProxiedAuthV2Control(ByteString.valueOf("dn:uid=test,o=test")); |
| | | new ProxiedAuthV2Control(ByteString.valueOfUtf8("dn:uid=test,o=test")); |
| | | proxyControl.toString(); |
| | | |
| | | proxyControl = new ProxiedAuthV2Control(ByteString.valueOf("u:test")); |
| | | proxyControl = new ProxiedAuthV2Control(ByteString.valueOfUtf8("u:test")); |
| | | proxyControl.toString(); |
| | | } |
| | | } |
| | |
| | | throws Exception |
| | | { |
| | | VLVRequestControl vlvRequest = |
| | | new VLVRequestControl(true, 0, 9, 1, 0, ByteString.valueOf("foo")); |
| | | new VLVRequestControl(true, 0, 9, 1, 0, ByteString.valueOfUtf8("foo")); |
| | | |
| | | assertEquals(vlvRequest.isCritical(), true); |
| | | assertEquals(vlvRequest.getBeforeCount(), 0); |
| | |
| | | throws Exception |
| | | { |
| | | VLVRequestControl vlvRequest = |
| | | new VLVRequestControl(0, 9, ByteString.valueOf("a")); |
| | | new VLVRequestControl(0, 9, ByteString.valueOfUtf8("a")); |
| | | |
| | | assertEquals(vlvRequest.isCritical(), false); |
| | | assertEquals(vlvRequest.getBeforeCount(), 0); |
| | |
| | | throws Exception |
| | | { |
| | | VLVRequestControl vlvRequest = |
| | | new VLVRequestControl(true, 0, 9, ByteString.valueOf("a"), null); |
| | | new VLVRequestControl(true, 0, 9, ByteString.valueOfUtf8("a"), null); |
| | | |
| | | assertEquals(vlvRequest.isCritical(), true); |
| | | assertEquals(vlvRequest.getBeforeCount(), 0); |
| | |
| | | throws Exception |
| | | { |
| | | VLVRequestControl vlvRequest = |
| | | new VLVRequestControl(true, 0, 9, ByteString.valueOf("a"), |
| | | ByteString.valueOf("foo")); |
| | | new VLVRequestControl(true, 0, 9, ByteString.valueOfUtf8("a"), |
| | | ByteString.valueOfUtf8("foo")); |
| | | |
| | | assertEquals(vlvRequest.isCritical(), true); |
| | | assertEquals(vlvRequest.getBeforeCount(), 0); |
| | |
| | | ByteStringBuilder builder = new ByteStringBuilder(); |
| | | ASN1Writer writer = ASN1.getWriter(builder); |
| | | VLVResponseControl vlvResponse = new VLVResponseControl(true, 0, 15, 0, |
| | | ByteString.valueOf("foo")); |
| | | ByteString.valueOfUtf8("foo")); |
| | | vlvResponse.writeValue(writer); |
| | | |
| | | ASN1Reader reader = ASN1.getReader(builder.toByteString()); |
| | |
| | | throws Exception |
| | | { |
| | | VLVResponseControl vlvResponse = |
| | | new VLVResponseControl(true, 0, 15, 0, ByteString.valueOf("foo")); |
| | | new VLVResponseControl(true, 0, 15, 0, ByteString.valueOfUtf8("foo")); |
| | | |
| | | assertEquals(vlvResponse.isCritical(), true); |
| | | assertEquals(vlvResponse.getTargetPosition(), 0); |
| | |
| | | |
| | | SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, "(objectClass=person)") |
| | | .addControl(new ServerSideSortRequestControl("givenName")) |
| | | .addControl(new VLVRequestControl(0, 3, ByteString.valueOf("a"))); |
| | | .addControl(new VLVRequestControl(0, 3, ByteString.valueOfUtf8("a"))); |
| | | InternalSearchOperation internalSearch = getRootConnection().processSearch(request); |
| | | assertEquals(internalSearch.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | |
| | | |
| | | SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, "(objectClass=person)") |
| | | .addControl(new ServerSideSortRequestControl("givenName")) |
| | | .addControl(new VLVRequestControl(0, 3, ByteString.valueOf("aaccf"))); |
| | | .addControl(new VLVRequestControl(0, 3, ByteString.valueOfUtf8("aaccf"))); |
| | | InternalSearchOperation internalSearch = getRootConnection().processSearch(request); |
| | | assertEquals(internalSearch.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | |
| | | |
| | | SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, "(objectClass=person)") |
| | | .addControl(new ServerSideSortRequestControl("givenName")) |
| | | .addControl(new VLVRequestControl(0, 3, ByteString.valueOf("albert"))); |
| | | .addControl(new VLVRequestControl(0, 3, ByteString.valueOfUtf8("albert"))); |
| | | InternalSearchOperation internalSearch = getRootConnection().processSearch(request); |
| | | assertEquals(internalSearch.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | |
| | | |
| | | SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, "(objectClass=person)") |
| | | .addControl(new ServerSideSortRequestControl("givenName")) |
| | | .addControl(new VLVRequestControl(1, 3, ByteString.valueOf("albert"))); |
| | | .addControl(new VLVRequestControl(1, 3, ByteString.valueOfUtf8("albert"))); |
| | | InternalSearchOperation internalSearch = getRootConnection().processSearch(request); |
| | | assertEquals(internalSearch.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | |
| | | |
| | | SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, "(objectClass=person)") |
| | | .addControl(new ServerSideSortRequestControl("sn")) |
| | | .addControl(new VLVRequestControl(0, 3, ByteString.valueOf("zz"))); |
| | | .addControl(new VLVRequestControl(0, 3, ByteString.valueOfUtf8("zz"))); |
| | | InternalSearchOperation internalSearch = getRootConnection().processSearch(request); |
| | | |
| | | // It will be successful because the control isn't critical. |
| | |
| | | TestCaseUtils.configureSocket(s); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | attributes.add(new LDAPAttribute("ou", "People")); |
| | | |
| | | AddRequestProtocolOp addRequest = |
| | | new AddRequestProtocolOp(ByteString.valueOf("ou=People,o=test"), attributes); |
| | | new AddRequestProtocolOp(ByteString.valueOfUtf8("ou=People,o=test"), attributes); |
| | | message = new LDAPMessage(2, addRequest, |
| | | DelayPreOpPlugin.createDelayControlList(5000)); |
| | | w.writeMessage(message); |
| | |
| | | TestCaseUtils.configureSocket(s); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | // the delay request control so it won't complete before we can send the |
| | | // abandon request. |
| | | CompareRequestProtocolOp compareRequest = |
| | | new CompareRequestProtocolOp(ByteString.valueOf("o=test"), "o", |
| | | ByteString.valueOf("test")); |
| | | new CompareRequestProtocolOp(ByteString.valueOfUtf8("o=test"), "o", |
| | | ByteString.valueOfUtf8("test")); |
| | | message = new LDAPMessage(2, compareRequest, |
| | | DelayPreOpPlugin.createDelayControlList(5000)); |
| | | w.writeMessage(message); |
| | |
| | | TestCaseUtils.configureSocket(s); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | // the delay request control so it won't complete before we can send the |
| | | // abandon request. |
| | | DeleteRequestProtocolOp deleteRequest = |
| | | new DeleteRequestProtocolOp(ByteString.valueOf("cn=test,o=test")); |
| | | new DeleteRequestProtocolOp(ByteString.valueOfUtf8("cn=test,o=test")); |
| | | message = new LDAPMessage(2, deleteRequest, |
| | | DelayPreOpPlugin.createDelayControlList(5000)); |
| | | w.writeMessage(message); |
| | |
| | | TestCaseUtils.configureSocket(s); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | TestCaseUtils.configureSocket(s); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | new LDAPAttribute("description", "foo"))); |
| | | |
| | | ModifyRequestProtocolOp modifyRequest = |
| | | new ModifyRequestProtocolOp(ByteString.valueOf("o=test"), mods); |
| | | new ModifyRequestProtocolOp(ByteString.valueOfUtf8("o=test"), mods); |
| | | message = new LDAPMessage(2, modifyRequest, |
| | | DelayPreOpPlugin.createDelayControlList(5000)); |
| | | w.writeMessage(message); |
| | |
| | | TestCaseUtils.configureSocket(s); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | // include the delay request control so it won't complete before we can send |
| | | // the abandon request. |
| | | ModifyDNRequestProtocolOp modifyDNRequest = |
| | | new ModifyDNRequestProtocolOp(ByteString.valueOf("cn=test,o=test"), |
| | | ByteString.valueOf("cn=test2"), true); |
| | | new ModifyDNRequestProtocolOp(ByteString.valueOfUtf8("cn=test,o=test"), |
| | | ByteString.valueOfUtf8("cn=test2"), true); |
| | | message = new LDAPMessage(2, modifyDNRequest, |
| | | DelayPreOpPlugin.createDelayControlList(5000)); |
| | | w.writeMessage(message); |
| | |
| | | TestCaseUtils.configureSocket(s); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | // the delay request control so it won't complete before we can send the |
| | | // abandon request. |
| | | SearchRequestProtocolOp searchRequest = |
| | | new SearchRequestProtocolOp(ByteString.valueOf("o=test"), |
| | | new SearchRequestProtocolOp(ByteString.valueOfUtf8("o=test"), |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, |
| | | 0, false, |
| | |
| | | Operation[] opArray = new Operation[] |
| | | { |
| | | new AddOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(), |
| | | null, ByteString.valueOf("ou=People,o=test"), |
| | | null, ByteString.valueOfUtf8("ou=People,o=test"), |
| | | ldapAttrList), |
| | | new AddOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(), |
| | | noControls, ByteString.valueOf("ou=People,o=test"), |
| | | noControls, ByteString.valueOfUtf8("ou=People,o=test"), |
| | | ldapAttrList), |
| | | new AddOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(), |
| | | null, entry.getName(), entry.getObjectClasses(), |
| | |
| | | ByteString originalDN = addOperation.getRawEntryDN(); |
| | | assertNotNull(originalDN); |
| | | |
| | | addOperation.setRawEntryDN(ByteString.valueOf("uid=test,o=test")); |
| | | addOperation.setRawEntryDN(ByteString.valueOfUtf8("uid=test,o=test")); |
| | | assertNotNull(addOperation.getRawEntryDN()); |
| | | assertEquals(addOperation.getRawEntryDN(), |
| | | ByteString.valueOf("uid=test,o=test")); |
| | | ByteString.valueOfUtf8("uid=test,o=test")); |
| | | |
| | | addOperation.setRawEntryDN(originalDN); |
| | | assertNotNull(addOperation.getRawEntryDN()); |
| | |
| | | |
| | | AddOperationBasis addOperation = |
| | | new AddOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(), |
| | | null, ByteString.valueOf("ou=People,o=test"), |
| | | null, ByteString.valueOfUtf8("ou=People,o=test"), |
| | | ldapAttrList); |
| | | assertNotNull(addOperation.getEntryDN()); |
| | | } |
| | |
| | | ArrayList<ByteString> values = new ArrayList<>(); |
| | | for (String s : v) |
| | | { |
| | | values.add(ByteString.valueOf(s)); |
| | | values.add(ByteString.valueOfUtf8(s)); |
| | | } |
| | | return values; |
| | | } |
| | |
| | | entry.getOperationalAttributes()); |
| | | assertNotNull(addOperation.getEntryDN()); |
| | | |
| | | addOperation.setRawEntryDN(ByteString.valueOf("ou=Users,o=test")); |
| | | addOperation.setRawEntryDN(ByteString.valueOfUtf8("ou=Users,o=test")); |
| | | assertNotNull(addOperation.getEntryDN()); |
| | | } |
| | | |
| | |
| | | boolean foundBar = false; |
| | | for (Attribute attr : attrList) |
| | | { |
| | | if (attr.contains(ByteString.valueOf("foo"))) |
| | | if (attr.contains(ByteString.valueOfUtf8("foo"))) |
| | | { |
| | | foundFoo = true; |
| | | } |
| | | |
| | | if (attr.contains(ByteString.valueOf("bar"))) |
| | | if (attr.contains(ByteString.valueOfUtf8("bar"))) |
| | | { |
| | | foundBar = true; |
| | | } |
| | |
| | | new LDAPAttribute("objectClass", newArrayList("top", "undefined")), |
| | | new LDAPAttribute("ou", "People")); |
| | | |
| | | AddOperation addOperation = getRootConnection().processAdd(ByteString.valueOf("ou=People,o=test"), attrs); |
| | | AddOperation addOperation = getRootConnection().processAdd(ByteString.valueOfUtf8("ou=People,o=test"), attrs); |
| | | assertNotEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | new LDAPAttribute("ou", "People"), |
| | | new LDAPAttribute("description", "bar")); |
| | | |
| | | AddOperation addOperation = getRootConnection().processAdd(ByteString.valueOf("ou=People,o=test"), attrs); |
| | | AddOperation addOperation = getRootConnection().processAdd(ByteString.valueOfUtf8("ou=People,o=test"), attrs); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | new LDAPAttribute("ou", "People"), |
| | | new LDAPAttribute("description;lang-en-us", "foo")); |
| | | |
| | | AddOperation addOperation = getRootConnection().processAdd(ByteString.valueOf("ou=People,o=test"), attrs); |
| | | AddOperation addOperation = getRootConnection().processAdd(ByteString.valueOfUtf8("ou=People,o=test"), attrs); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | new LDAPAttribute("ou", "People"), |
| | | new LDAPAttribute("description;lang-en-us", "foo")); |
| | | |
| | | AddOperation addOperation = getRootConnection().processAdd(ByteString.valueOf("ou=People,o=test"), attrs); |
| | | AddOperation addOperation = getRootConnection().processAdd(ByteString.valueOfUtf8("ou=People,o=test"), attrs); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | private void bind(LDAPReader r, LDAPWriter w) throws Exception |
| | | { |
| | | final BindRequestProtocolOp bindRequest = new BindRequestProtocolOp( |
| | | ByteString.valueOf("cn=Directory Manager"), 3, ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("cn=Directory Manager"), 3, ByteString.valueOfUtf8("password")); |
| | | w.writeMessage(new LDAPMessage(1, bindRequest)); |
| | | |
| | | final LDAPMessage message = r.readMessage(); |
| | |
| | | private void writeAddRequest(LDAPWriter w, ArrayList<RawAttribute> attrs, |
| | | String section) throws IOException |
| | | { |
| | | AddRequestProtocolOp addRequest = new AddRequestProtocolOp(ByteString.valueOf("ou=People,o=test"), attrs); |
| | | AddRequestProtocolOp addRequest = new AddRequestProtocolOp(ByteString.valueOfUtf8("ou=People,o=test"), attrs); |
| | | List<Control> controls = section != null |
| | | ? DisconnectClientPlugin.createDisconnectControlList(section) |
| | | : null; |
| | |
| | | |
| | | AddOperationBasis addOperation = |
| | | new AddOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(), |
| | | controls, ByteString.valueOf("o=test"), rawAttrs); |
| | | controls, ByteString.valueOfUtf8("o=test"), rawAttrs); |
| | | addOperation.run(); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertFalse(DirectoryServer.entryExists(DN.valueOf("o=test"))); |
| | |
| | | noControls, "3", nullOS, nullOS), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | noControls, "3", |
| | | ByteString.valueOf("cn=Directory Manager"), |
| | | ByteString.valueOf("password")), |
| | | ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | ByteString.valueOfUtf8("password")), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | null, "3", DN.rootDN(), ByteString.empty()), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | |
| | | noControls, "3", nullDN, nullOS), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | noControls, "3", DN.valueOf("cn=Directory Manager"), |
| | | ByteString.valueOf("password")) |
| | | ByteString.valueOfUtf8("password")) |
| | | }; |
| | | |
| | | Object[][] array = new Object[simpleBinds.length][1]; |
| | |
| | | noControls, "3", nullOS, "EXTERNAL", null), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | null, "3", ByteString.empty(), "PLAIN", |
| | | ByteString.valueOf("\u0000u:test.user\u0000password")), |
| | | ByteString.valueOfUtf8("\u0000u:test.user\u0000password")), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | noControls, "3", ByteString.empty(), "PLAIN", |
| | | ByteString.valueOf("\u0000u:test.user\u0000password")), |
| | | ByteString.valueOfUtf8("\u0000u:test.user\u0000password")), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | null, "3", nullOS, "PLAIN", |
| | | ByteString.valueOf("\u0000u:test.user\u0000password")), |
| | | ByteString.valueOfUtf8("\u0000u:test.user\u0000password")), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | noControls, "3", nullOS, "PLAIN", |
| | | ByteString.valueOf("\u0000u:test.user\u0000password")), |
| | | ByteString.valueOfUtf8("\u0000u:test.user\u0000password")), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | null, "3", DN.rootDN(), "EXTERNAL", null), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | |
| | | noControls, "3", nullDN, "EXTERNAL", null), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | null, "3", DN.rootDN(), "PLAIN", |
| | | ByteString.valueOf("\u0000u:test.user\u0000password")), |
| | | ByteString.valueOfUtf8("\u0000u:test.user\u0000password")), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | noControls, "3", DN.rootDN(), "PLAIN", |
| | | ByteString.valueOf("\u0000u:test.user\u0000password")), |
| | | ByteString.valueOfUtf8("\u0000u:test.user\u0000password")), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | null, "3", nullDN, "PLAIN", |
| | | ByteString.valueOf("\u0000u:test.user\u0000password")), |
| | | ByteString.valueOfUtf8("\u0000u:test.user\u0000password")), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | noControls, "3", nullDN, "PLAIN", |
| | | ByteString.valueOf("\u0000u:test.user\u0000password")) |
| | | ByteString.valueOfUtf8("\u0000u:test.user\u0000password")) |
| | | }; |
| | | |
| | | Object[][] array = new Object[saslBinds.length][1]; |
| | |
| | | o.setRawBindDN(ByteString.empty()); |
| | | assertEquals(o.getRawBindDN(), ByteString.empty()); |
| | | |
| | | o.setRawBindDN(ByteString.valueOf("cn=Directory Manager")); |
| | | assertEquals(o.getRawBindDN(), ByteString.valueOf("cn=Directory Manager")); |
| | | o.setRawBindDN(ByteString.valueOfUtf8("cn=Directory Manager")); |
| | | assertEquals(o.getRawBindDN(), ByteString.valueOfUtf8("cn=Directory Manager")); |
| | | |
| | | o.setRawBindDN(originalRawBindDN); |
| | | assertEquals(o.getRawBindDN(), originalRawBindDN); |
| | |
| | | o.setRawBindDN(ByteString.empty()); |
| | | assertEquals(o.getRawBindDN(), ByteString.empty()); |
| | | |
| | | o.setRawBindDN(ByteString.valueOf("cn=Directory Manager")); |
| | | assertEquals(o.getRawBindDN(), ByteString.valueOf("cn=Directory Manager")); |
| | | o.setRawBindDN(ByteString.valueOfUtf8("cn=Directory Manager")); |
| | | assertEquals(o.getRawBindDN(), ByteString.valueOfUtf8("cn=Directory Manager")); |
| | | |
| | | o.setRawBindDN(originalRawBindDN); |
| | | assertEquals(o.getRawBindDN(), originalRawBindDN); |
| | |
| | | assertNull(o.getSASLCredentials()); |
| | | |
| | | o.setSASLCredentials("PLAIN", |
| | | ByteString.valueOf("\u0000u:test.user\u0000password")); |
| | | ByteString.valueOfUtf8("\u0000u:test.user\u0000password")); |
| | | assertEquals(o.getAuthenticationType(), AuthenticationType.SASL); |
| | | assertNotNull(o.getSASLMechanism()); |
| | | assertNotNull(o.getSASLCredentials()); |
| | |
| | | assertEquals(o.getAuthenticationType(), AuthenticationType.SASL); |
| | | assertNull(o.getSimplePassword()); |
| | | |
| | | o.setSimplePassword(ByteString.valueOf("password")); |
| | | o.setSimplePassword(ByteString.valueOfUtf8("password")); |
| | | assertEquals(o.getAuthenticationType(), AuthenticationType.SIMPLE); |
| | | assertNotNull(o.getSimplePassword()); |
| | | |
| | |
| | | new InternalClientConnection(new AuthenticationInfo()); |
| | | |
| | | ByteString saslCreds = |
| | | ByteString.valueOf("\u0000dn:cn=Directory Manager\u0000password"); |
| | | ByteString.valueOfUtf8("\u0000dn:cn=Directory Manager\u0000password"); |
| | | |
| | | BindOperation bindOperation = |
| | | conn.processSASLBind(DN.rootDN(), "PLAIN", saslCreds); |
| | |
| | | new InternalClientConnection(new AuthenticationInfo()); |
| | | |
| | | BindOperation bindOperation = |
| | | conn.processSimpleBind(ByteString.valueOf("cn=Directory Manager"), |
| | | ByteString.valueOf("password")); |
| | | conn.processSimpleBind(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | ByteString.valueOfUtf8("password")); |
| | | assertEquals(bindOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertNotNull(bindOperation.getUserEntryDN()); |
| | | } |
| | |
| | | new InternalClientConnection(new AuthenticationInfo()); |
| | | |
| | | ByteString saslCreds = |
| | | ByteString.valueOf("\u0000dn:cn=Directory Manager\u0000password"); |
| | | ByteString.valueOfUtf8("\u0000dn:cn=Directory Manager\u0000password"); |
| | | |
| | | BindOperation bindOperation = |
| | | conn.processSASLBind(DN.rootDN(), "PLAIN", saslCreds); |
| | |
| | | new InternalClientConnection(new AuthenticationInfo()); |
| | | |
| | | BindOperation bindOperation = |
| | | conn.processSimpleBind(ByteString.valueOf("cn=Directory Manager"), |
| | | ByteString.valueOf("password")); |
| | | conn.processSimpleBind(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | ByteString.valueOfUtf8("password")); |
| | | assertEquals(bindOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertTrue(bindOperation.getProcessingStartTime() > 0); |
| | | assertTrue(bindOperation.getProcessingStopTime() >= |
| | |
| | | new InternalClientConnection(new AuthenticationInfo()); |
| | | |
| | | ByteString saslCreds = |
| | | ByteString.valueOf("\u0000dn:cn=Directory Manager\u0000password"); |
| | | ByteString.valueOfUtf8("\u0000dn:cn=Directory Manager\u0000password"); |
| | | |
| | | BindOperation bindOperation = |
| | | conn.processSASLBind(DN.rootDN(), "PLAIN", saslCreds); |
| | |
| | | new InternalClientConnection(new AuthenticationInfo()); |
| | | |
| | | BindOperation bindOperation = |
| | | conn.processSimpleBind(ByteString.valueOf("cn=Directory Manager"), |
| | | ByteString.valueOf("password")); |
| | | conn.processSimpleBind(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | ByteString.valueOfUtf8("password")); |
| | | assertEquals(bindOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | // assertTrue(InvocationCounterPlugin.getPreParseCount() > 0); |
| | |
| | | new InternalClientConnection(new AuthenticationInfo()); |
| | | |
| | | ByteString saslCreds = |
| | | ByteString.valueOf("\u0000dn:cn=Directory Manager\u0000password"); |
| | | ByteString.valueOfUtf8("\u0000dn:cn=Directory Manager\u0000password"); |
| | | |
| | | BindOperation bindOperation = |
| | | conn.processSASLBind(DN.rootDN(), "PLAIN", saslCreds); |
| | |
| | | TestCaseUtils.configureSocket(s); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest, |
| | | DisconnectClientPlugin.createDisconnectControlList("PreParse")); |
| | | w.writeMessage(message); |
| | |
| | | TestCaseUtils.configureSocket(s); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest, |
| | | DisconnectClientPlugin.createDisconnectControlList( |
| | | "PreOperation")); |
| | |
| | | TestCaseUtils.configureSocket(s); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest, |
| | | DisconnectClientPlugin.createDisconnectControlList( |
| | | "PostOperation")); |
| | |
| | | TestCaseUtils.configureSocket(s); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest, |
| | | DisconnectClientPlugin.createDisconnectControlList( |
| | | "PostResponse")); |
| | |
| | | TestCaseUtils.configureSocket(s); |
| | | |
| | | ByteString saslCreds = |
| | | ByteString.valueOf("\u0000dn:cn=Directory Manager\u0000password"); |
| | | ByteString.valueOfUtf8("\u0000dn:cn=Directory Manager\u0000password"); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.empty(), "PLAIN", saslCreds); |
| | |
| | | TestCaseUtils.configureSocket(s); |
| | | |
| | | ByteString saslCreds = |
| | | ByteString.valueOf("\u0000dn:cn=Directory Manager\u0000password"); |
| | | ByteString.valueOfUtf8("\u0000dn:cn=Directory Manager\u0000password"); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.empty(), "PLAIN", saslCreds); |
| | |
| | | TestCaseUtils.configureSocket(s); |
| | | |
| | | ByteString saslCreds = |
| | | ByteString.valueOf("\u0000dn:cn=Directory Manager\u0000password"); |
| | | ByteString.valueOfUtf8("\u0000dn:cn=Directory Manager\u0000password"); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.empty(), "PLAIN", saslCreds); |
| | |
| | | TestCaseUtils.configureSocket(s); |
| | | |
| | | ByteString saslCreds = |
| | | ByteString.valueOf("\u0000dn:cn=Directory Manager\u0000password"); |
| | | ByteString.valueOfUtf8("\u0000dn:cn=Directory Manager\u0000password"); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.empty(), "PLAIN", saslCreds); |
| | |
| | | TestCaseUtils.configureSocket(s); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest, |
| | | ShortCircuitPlugin.createShortCircuitControlList(80, "PreParse")); |
| | | w.writeMessage(message); |
| | |
| | | TestCaseUtils.configureSocket(s); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest, |
| | | ShortCircuitPlugin.createShortCircuitControlList(80, |
| | | "PreOperation")); |
| | |
| | | TestCaseUtils.configureSocket(s); |
| | | |
| | | ByteString saslCreds = |
| | | ByteString.valueOf("\u0000dn:cn=Directory Manager\u0000password"); |
| | | ByteString.valueOfUtf8("\u0000dn:cn=Directory Manager\u0000password"); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.empty(), "PLAIN", saslCreds); |
| | |
| | | TestCaseUtils.configureSocket(s); |
| | | |
| | | ByteString saslCreds = |
| | | ByteString.valueOf("\u0000dn:cn=Directory Manager\u0000password"); |
| | | ByteString.valueOfUtf8("\u0000dn:cn=Directory Manager\u0000password"); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.empty(), "PLAIN", saslCreds); |
| | |
| | | new InternalClientConnection(new AuthenticationInfo()); |
| | | |
| | | BindOperation bindOperation = |
| | | conn.processSimpleBind(ByteString.valueOf("invaliddn"), |
| | | ByteString.valueOf("password")); |
| | | conn.processSimpleBind(ByteString.valueOfUtf8("invaliddn"), |
| | | ByteString.valueOfUtf8("password")); |
| | | assertEquals(bindOperation.getResultCode(), ResultCode.INVALID_CREDENTIALS); |
| | | } |
| | | |
| | |
| | | new InternalClientConnection(new AuthenticationInfo()); |
| | | |
| | | ByteString saslCreds = |
| | | ByteString.valueOf("\u0000dn:cn=Directory Manager\u0000password"); |
| | | ByteString.valueOfUtf8("\u0000dn:cn=Directory Manager\u0000password"); |
| | | |
| | | BindOperation bindOperation = |
| | | conn.processSASLBind(ByteString.valueOf("invaliddn"), "PLAIN", |
| | | conn.processSASLBind(ByteString.valueOfUtf8("invaliddn"), "PLAIN", |
| | | saslCreds); |
| | | assertEquals(bindOperation.getResultCode(), ResultCode.INVALID_CREDENTIALS); |
| | | } |
| | |
| | | requestControls.add(new LDAPControl("1.2.3.4", true)); |
| | | |
| | | ByteString saslCreds = |
| | | ByteString.valueOf("\u0000dn:cn=Directory Manager\u0000password"); |
| | | ByteString.valueOfUtf8("\u0000dn:cn=Directory Manager\u0000password"); |
| | | |
| | | BindOperationBasis bindOperation = |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | |
| | | requestControls.add(new LDAPControl("1.2.3.4", false)); |
| | | |
| | | ByteString saslCreds = |
| | | ByteString.valueOf("\u0000dn:cn=Directory Manager\u0000password"); |
| | | ByteString.valueOfUtf8("\u0000dn:cn=Directory Manager\u0000password"); |
| | | |
| | | BindOperationBasis bindOperation = |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | |
| | | new InternalClientConnection(new AuthenticationInfo()); |
| | | |
| | | BindOperation bindOperation = |
| | | conn.processSimpleBind(ByteString.valueOf("uid=test,o=test"), |
| | | ByteString.valueOf("password")); |
| | | conn.processSimpleBind(ByteString.valueOfUtf8("uid=test,o=test"), |
| | | ByteString.valueOfUtf8("password")); |
| | | assertEquals(bindOperation.getResultCode(), ResultCode.INVALID_CREDENTIALS); |
| | | } |
| | | |
| | |
| | | new InternalClientConnection(new AuthenticationInfo()); |
| | | |
| | | BindOperation bindOperation = |
| | | conn.processSimpleBind(ByteString.valueOf("cn=Directory Manager"), |
| | | conn.processSimpleBind(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | ByteString.empty()); |
| | | assertEquals(bindOperation.getResultCode(), |
| | | ResultCode.UNWILLING_TO_PERFORM); |
| | |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | BindOperation bindOperation = |
| | | conn.processSimpleBind(ByteString.valueOf("cn=Directory Manager"), |
| | | conn.processSimpleBind(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | ByteString.empty()); |
| | | assertEquals(bindOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | BindOperation bindOperation = |
| | | conn.processSimpleBind(ByteString.valueOf("uid=test,o=test"), |
| | | ByteString.valueOf("password")); |
| | | conn.processSimpleBind(ByteString.valueOfUtf8("uid=test,o=test"), |
| | | ByteString.valueOfUtf8("password")); |
| | | assertEquals(bindOperation.getResultCode(), ResultCode.INVALID_CREDENTIALS); |
| | | } |
| | | |
| | |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | BindOperation bindOperation = |
| | | conn.processSimpleBind(ByteString.valueOf("uid=test,ou=people,dc=example,dc=com"), |
| | | ByteString.valueOf("password")); |
| | | conn.processSimpleBind(ByteString.valueOfUtf8("uid=test,ou=people,dc=example,dc=com"), |
| | | ByteString.valueOfUtf8("password")); |
| | | assertEquals(bindOperation.getResultCode(), ResultCode.REFERRAL); |
| | | |
| | | List<String> referralURLs = bindOperation.getReferralURLs(); |
| | |
| | | new InternalClientConnection(new AuthenticationInfo()); |
| | | |
| | | BindOperation bindOperation = |
| | | conn.processSimpleBind(ByteString.valueOf("cn=Directory Manager"), |
| | | ByteString.valueOf("wrongpassword")); |
| | | conn.processSimpleBind(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | ByteString.valueOfUtf8("wrongpassword")); |
| | | assertEquals(bindOperation.getResultCode(), ResultCode.INVALID_CREDENTIALS); |
| | | } |
| | | |
| | |
| | | new InternalClientConnection(new AuthenticationInfo()); |
| | | |
| | | BindOperation bindOperation = |
| | | conn.processSimpleBind(ByteString.valueOf("cn=Directory Manager"), |
| | | ByteString.valueOf("wrongpassword")); |
| | | conn.processSimpleBind(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | ByteString.valueOfUtf8("wrongpassword")); |
| | | assertEquals(bindOperation.getResultCode(), ResultCode.INVALID_CREDENTIALS); |
| | | assertThat(bindOperation.getErrorMessage()).isEmpty(); |
| | | |
| | |
| | | "--set", "return-bind-error-messages:true"); |
| | | |
| | | bindOperation = |
| | | conn.processSimpleBind(ByteString.valueOf("cn=Directory Manager"), |
| | | ByteString.valueOf("wrongpassword")); |
| | | conn.processSimpleBind(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | ByteString.valueOfUtf8("wrongpassword")); |
| | | assertEquals(bindOperation.getResultCode(), ResultCode.INVALID_CREDENTIALS); |
| | | assertTrue(bindOperation.getErrorMessage().length() > 0); |
| | | |
| | |
| | | "--set", "return-bind-error-messages:false"); |
| | | |
| | | bindOperation = |
| | | conn.processSimpleBind(ByteString.valueOf("cn=Directory Manager"), |
| | | ByteString.valueOf("wrongpassword")); |
| | | conn.processSimpleBind(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | ByteString.valueOfUtf8("wrongpassword")); |
| | | assertEquals(bindOperation.getResultCode(), ResultCode.INVALID_CREDENTIALS); |
| | | assertThat(bindOperation.getErrorMessage()).isEmpty(); |
| | | } |
| | |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf(dnString), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8(dnString), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | // for previous ops to complete. |
| | | TestCaseUtils.quiesceServer(); |
| | | bindRequest = new BindRequestProtocolOp( |
| | | ByteString.valueOf("cn=Directory Manager"), 3, |
| | | ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("cn=Directory Manager"), 3, |
| | | ByteString.valueOfUtf8("password")); |
| | | message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf(dnString), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8(dnString), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf(dnString), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8(dnString), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf(entry.getName().toString()), |
| | | "uid", ByteString.valueOf("rogasawara")) |
| | | ByteString.valueOfUtf8(entry.getName().toString()), |
| | | "uid", ByteString.valueOfUtf8("rogasawara")) |
| | | }; |
| | | } |
| | | |
| | |
| | | conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf(entry.getName().toString()), |
| | | "uid", ByteString.valueOf("rogasawara")); |
| | | ByteString.valueOfUtf8(entry.getName().toString()), |
| | | "uid", ByteString.valueOfUtf8("rogasawara")); |
| | | |
| | | compareOperation.run(); |
| | | assertEquals(compareOperation.getResultCode(), |
| | |
| | | conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf(entry.getName().toString()), |
| | | "uid", ByteString.valueOf("rogasawala")); |
| | | ByteString.valueOfUtf8(entry.getName().toString()), |
| | | "uid", ByteString.valueOfUtf8("rogasawala")); |
| | | |
| | | compareOperation.run(); |
| | | assertEquals(compareOperation.getResultCode(), |
| | |
| | | conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf("o=nonexistent,o=test"), |
| | | "o", ByteString.valueOf("nonexistent")); |
| | | ByteString.valueOfUtf8("o=nonexistent,o=test"), |
| | | "o", ByteString.valueOfUtf8("nonexistent")); |
| | | |
| | | compareOperation.run(); |
| | | assertEquals(compareOperation.getResultCode(), |
| | |
| | | conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf("rogasawara,o=test"), |
| | | "uid", ByteString.valueOf("rogasawara")); |
| | | ByteString.valueOfUtf8("rogasawara,o=test"), |
| | | "uid", ByteString.valueOfUtf8("rogasawara")); |
| | | |
| | | compareOperation.run(); |
| | | assertEquals(compareOperation.getResultCode(), |
| | |
| | | conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf(entry.getName().toString()), |
| | | "description", ByteString.valueOf("rogasawara")); |
| | | ByteString.valueOfUtf8(entry.getName().toString()), |
| | | "description", ByteString.valueOfUtf8("rogasawara")); |
| | | |
| | | compareOperation.run(); |
| | | assertEquals(compareOperation.getResultCode(), |
| | |
| | | conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf(entry.getName().toString()), |
| | | ByteString.valueOfUtf8(entry.getName().toString()), |
| | | "NotAnAttribute", |
| | | ByteString.valueOf("rogasawara")); |
| | | ByteString.valueOfUtf8("rogasawara")); |
| | | |
| | | compareOperation.run(); |
| | | assertEquals(compareOperation.getResultCode(), |
| | |
| | | conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf(entry.getName().toString()), |
| | | ByteString.valueOfUtf8(entry.getName().toString()), |
| | | "name", |
| | | ByteString.valueOf("Ogasawara")); |
| | | ByteString.valueOfUtf8("Ogasawara")); |
| | | |
| | | compareOperation.run(); |
| | | assertEquals(compareOperation.getResultCode(), |
| | |
| | | conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf(entry.getName().toString()), |
| | | ByteString.valueOfUtf8(entry.getName().toString()), |
| | | "sn", |
| | | ByteString.valueOf("Ogasawara")); |
| | | ByteString.valueOfUtf8("Ogasawara")); |
| | | |
| | | compareOperation.run(); |
| | | assertEquals(compareOperation.getResultCode(), |
| | |
| | | conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf(entry.getName().toString()), |
| | | ByteString.valueOfUtf8(entry.getName().toString()), |
| | | "sn;lang-ja", |
| | | ByteString.valueOf("Ogasawara")); |
| | | ByteString.valueOfUtf8("Ogasawara")); |
| | | |
| | | compareOperation.run(); |
| | | assertEquals(compareOperation.getResultCode(), |
| | |
| | | conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf(entry.getName().toString()), |
| | | ByteString.valueOfUtf8(entry.getName().toString()), |
| | | "givenName;lAnG-En", |
| | | ByteString.valueOf("Rodney")); |
| | | ByteString.valueOfUtf8("Rodney")); |
| | | |
| | | compareOperation.run(); |
| | | assertEquals(compareOperation.getResultCode(), |
| | |
| | | conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | controls, |
| | | ByteString.valueOf(entry.getName().toString()), |
| | | "uid", ByteString.valueOf("rogasawara")); |
| | | ByteString.valueOfUtf8(entry.getName().toString()), |
| | | "uid", ByteString.valueOfUtf8("rogasawara")); |
| | | |
| | | compareOperation.run(); |
| | | assertEquals(compareOperation.getResultCode(), |
| | |
| | | conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | controls, |
| | | ByteString.valueOf(entry.getName().toString()), |
| | | "uid", ByteString.valueOf("rogasawara")); |
| | | ByteString.valueOfUtf8(entry.getName().toString()), |
| | | "uid", ByteString.valueOfUtf8("rogasawara")); |
| | | |
| | | compareOperation.run(); |
| | | assertEquals(compareOperation.getResultCode(), |
| | |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | |
| | | Control authV1Control = |
| | | new ProxiedAuthV1Control(ByteString.valueOf( |
| | | new ProxiedAuthV1Control(ByteString.valueOfUtf8( |
| | | "cn=Directory Manager,cn=Root DNs,cn=config")); |
| | | List<Control> controls = newArrayList(authV1Control); |
| | | |
| | |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | controls, |
| | | ByteString.valueOf(entry.getName().toString()), |
| | | "uid", ByteString.valueOf("rogasawara")); |
| | | ByteString.valueOfUtf8(entry.getName().toString()), |
| | | "uid", ByteString.valueOfUtf8("rogasawara")); |
| | | |
| | | compareOperation.run(); |
| | | assertEquals(compareOperation.getResultCode(), |
| | |
| | | |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | |
| | | Control authV1Control = new ProxiedAuthV1Control(ByteString.valueOf("cn=nonexistent,o=test")); |
| | | Control authV1Control = new ProxiedAuthV1Control(ByteString.valueOfUtf8("cn=nonexistent,o=test")); |
| | | List<Control> controls = newArrayList(authV1Control); |
| | | |
| | | CompareOperationBasis compareOperation = |
| | |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | controls, |
| | | ByteString.valueOf(entry.getName().toString()), |
| | | "uid", ByteString.valueOf("rogasawara")); |
| | | ByteString.valueOfUtf8(entry.getName().toString()), |
| | | "uid", ByteString.valueOfUtf8("rogasawara")); |
| | | |
| | | compareOperation.run(); |
| | | assertEquals(compareOperation.getResultCode(), |
| | |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | |
| | | Control authV2Control = |
| | | new ProxiedAuthV2Control(ByteString.valueOf( |
| | | new ProxiedAuthV2Control(ByteString.valueOfUtf8( |
| | | "dn:cn=Directory Manager,cn=Root DNs,cn=config")); |
| | | List<Control> controls = newArrayList(authV2Control); |
| | | |
| | |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | controls, |
| | | ByteString.valueOf(entry.getName().toString()), |
| | | "uid", ByteString.valueOf("rogasawara")); |
| | | ByteString.valueOfUtf8(entry.getName().toString()), |
| | | "uid", ByteString.valueOfUtf8("rogasawara")); |
| | | |
| | | compareOperation.run(); |
| | | assertEquals(compareOperation.getResultCode(), |
| | |
| | | { |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | |
| | | Control authV2Control = new ProxiedAuthV2Control(ByteString.valueOf("dn:cn=nonexistent,o=test")); |
| | | Control authV2Control = new ProxiedAuthV2Control(ByteString.valueOfUtf8("dn:cn=nonexistent,o=test")); |
| | | List<Control> controls = newArrayList(authV2Control); |
| | | |
| | | CompareOperationBasis compareOperation = |
| | |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | controls, |
| | | ByteString.valueOf(entry.getName().toString()), |
| | | "uid", ByteString.valueOf("rogasawara")); |
| | | ByteString.valueOfUtf8(entry.getName().toString()), |
| | | "uid", ByteString.valueOfUtf8("rogasawara")); |
| | | |
| | | compareOperation.run(); |
| | | assertEquals(compareOperation.getResultCode(), |
| | |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | controls, |
| | | ByteString.valueOf(entry.getName().toString()), |
| | | "uid", ByteString.valueOf("rogasawara")); |
| | | ByteString.valueOfUtf8(entry.getName().toString()), |
| | | "uid", ByteString.valueOfUtf8("rogasawara")); |
| | | |
| | | compareOperation.run(); |
| | | assertEquals(compareOperation.getResultCode(), |
| | |
| | | conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | controls, |
| | | ByteString.valueOf(entry.getName().toString()), |
| | | "uid", ByteString.valueOf("rogasawara")); |
| | | ByteString.valueOfUtf8(entry.getName().toString()), |
| | | "uid", ByteString.valueOfUtf8("rogasawara")); |
| | | |
| | | compareOperation.run(); |
| | | assertEquals(compareOperation.getResultCode(), |
| | |
| | | { |
| | | newDeleteOperation(noControls, ByteString.empty()), |
| | | newDeleteOperation(null, ByteString.empty()), |
| | | newDeleteOperation(noControls, ByteString.valueOf("o=test")), |
| | | newDeleteOperation(null, ByteString.valueOf("o=test")), |
| | | newDeleteOperation(noControls, ByteString.valueOfUtf8("o=test")), |
| | | newDeleteOperation(null, ByteString.valueOfUtf8("o=test")), |
| | | newDeleteOperation(noControls, DN.rootDN()), |
| | | newDeleteOperation(null, DN.rootDN()), |
| | | newDeleteOperation(noControls, DN.valueOf("o=test")), |
| | |
| | | ByteString originalRawDN = deleteOperation.getRawEntryDN(); |
| | | assertNotNull(originalRawDN); |
| | | |
| | | deleteOperation.setRawEntryDN(ByteString.valueOf("dc=example,dc=com")); |
| | | deleteOperation.setRawEntryDN(ByteString.valueOfUtf8("dc=example,dc=com")); |
| | | assertEquals(deleteOperation.getRawEntryDN(), |
| | | ByteString.valueOf("dc=example,dc=com")); |
| | | ByteString.valueOfUtf8("dc=example,dc=com")); |
| | | |
| | | deleteOperation.setRawEntryDN(originalRawDN); |
| | | assertEquals(deleteOperation.getRawEntryDN(), originalRawDN); |
| | |
| | | public void testGetEntryDNNull() |
| | | { |
| | | DeleteOperation deleteOperation = |
| | | newDeleteOperation(null, ByteString.valueOf("o=test")); |
| | | newDeleteOperation(null, ByteString.valueOfUtf8("o=test")); |
| | | assertNotNull(deleteOperation.getEntryDN()); |
| | | } |
| | | |
| | |
| | | newDeleteOperation(null, DN.valueOf("o=test")); |
| | | assertNotNull(deleteOperation.getEntryDN()); |
| | | |
| | | deleteOperation.setRawEntryDN(ByteString.valueOf("dc=example,dc=com")); |
| | | deleteOperation.setRawEntryDN(ByteString.valueOfUtf8("dc=example,dc=com")); |
| | | assertNotNull(deleteOperation.getEntryDN()); |
| | | } |
| | | |
| | |
| | | |
| | | private DeleteOperation processDeleteRaw(String entryDN) |
| | | { |
| | | return getRootConnection().processDelete(ByteString.valueOf(entryDN)); |
| | | return getRootConnection().processDelete(ByteString.valueOfUtf8(entryDN)); |
| | | } |
| | | |
| | | private DeleteOperation processDelete(String entryDN) throws DirectoryException |
| | |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | DeleteOperation deleteOperation = |
| | | newDeleteOperation(null, ByteString.valueOf("o=test")); |
| | | newDeleteOperation(null, ByteString.valueOfUtf8("o=test")); |
| | | |
| | | CancelRequest cancelRequest = new CancelRequest(false, |
| | | LocalizableMessage.raw("testCancelBeforeStartup")); |
| | |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | DeleteOperation deleteOperation = |
| | | newDeleteOperation(null, ByteString.valueOf("o=test")); |
| | | newDeleteOperation(null, ByteString.valueOfUtf8("o=test")); |
| | | deleteOperation.run(); |
| | | |
| | | CancelRequest cancelRequest = new CancelRequest(false, |
| | |
| | | TestCaseUtils.configureSocket(s); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | |
| | | |
| | | DeleteRequestProtocolOp deleteRequest = |
| | | new DeleteRequestProtocolOp(ByteString.valueOf("o=test")); |
| | | new DeleteRequestProtocolOp(ByteString.valueOfUtf8("o=test")); |
| | | message = new LDAPMessage(2, deleteRequest, |
| | | DisconnectClientPlugin.createDisconnectControlList("PreParse")); |
| | | w.writeMessage(message); |
| | |
| | | TestCaseUtils.configureSocket(s); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | |
| | | |
| | | DeleteRequestProtocolOp deleteRequest = |
| | | new DeleteRequestProtocolOp(ByteString.valueOf("o=test")); |
| | | new DeleteRequestProtocolOp(ByteString.valueOfUtf8("o=test")); |
| | | message = new LDAPMessage(2, deleteRequest, |
| | | DisconnectClientPlugin.createDisconnectControlList( |
| | | "PreOperation")); |
| | |
| | | TestCaseUtils.configureSocket(s); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | |
| | | |
| | | DeleteRequestProtocolOp deleteRequest = |
| | | new DeleteRequestProtocolOp(ByteString.valueOf("o=test")); |
| | | new DeleteRequestProtocolOp(ByteString.valueOfUtf8("o=test")); |
| | | message = new LDAPMessage(2, deleteRequest, |
| | | DisconnectClientPlugin.createDisconnectControlList( |
| | | "PostOperation")); |
| | |
| | | TestCaseUtils.configureSocket(s); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | |
| | | |
| | | DeleteRequestProtocolOp deleteRequest = |
| | | new DeleteRequestProtocolOp(ByteString.valueOf("o=test")); |
| | | new DeleteRequestProtocolOp(ByteString.valueOfUtf8("o=test")); |
| | | message = new LDAPMessage(2, deleteRequest, |
| | | DisconnectClientPlugin.createDisconnectControlList( |
| | | "PostResponse")); |
| | |
| | | ShortCircuitPlugin.createShortCircuitControlList(0, "PreParse"); |
| | | |
| | | DeleteOperation deleteOperation = |
| | | newDeleteOperation(controls, ByteString.valueOf("o=test")); |
| | | newDeleteOperation(controls, ByteString.valueOfUtf8("o=test")); |
| | | deleteOperation.run(); |
| | | assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertTrue(DirectoryServer.entryExists(DN.valueOf("o=test"))); |
| | |
| | | |
| | | |
| | | BindRequestProtocolOp bindRequest = new BindRequestProtocolOp( |
| | | ByteString.valueOf("uid=test.user,o=test"), 3, |
| | | ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("uid=test.user,o=test"), 3, |
| | | ByteString.valueOfUtf8("password")); |
| | | LDAPMessage m = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(m); |
| | | |
| | |
| | | |
| | | |
| | | BindRequestProtocolOp bindRequest = new BindRequestProtocolOp( |
| | | ByteString.valueOf("uid=test.user,o=test"), 3, |
| | | ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("uid=test.user,o=test"), 3, |
| | | ByteString.valueOfUtf8("password")); |
| | | LDAPMessage m = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(m); |
| | | |
| | |
| | | |
| | | opList.add(newModifyOperation(null, ByteString.empty(), ldapMods)); |
| | | opList.add(newModifyOperation(noControls, ByteString.empty(), ldapMods)); |
| | | opList.add(newModifyOperation(null, ByteString.valueOf("o=test"), ldapMods)); |
| | | opList.add(newModifyOperation(noControls, ByteString.valueOf("o=test"), ldapMods)); |
| | | opList.add(newModifyOperation(null, ByteString.valueOfUtf8("o=test"), ldapMods)); |
| | | opList.add(newModifyOperation(noControls, ByteString.valueOfUtf8("o=test"), ldapMods)); |
| | | |
| | | ldapMods = newRawModifications(delete(ldapAttr)); |
| | | |
| | | opList.add(newModifyOperation(null, ByteString.empty(), ldapMods)); |
| | | opList.add(newModifyOperation(noControls, ByteString.empty(), ldapMods)); |
| | | opList.add(newModifyOperation(null, ByteString.valueOf("o=test"), ldapMods)); |
| | | opList.add(newModifyOperation(noControls, ByteString.valueOf("o=test"), ldapMods)); |
| | | opList.add(newModifyOperation(null, ByteString.valueOfUtf8("o=test"), ldapMods)); |
| | | opList.add(newModifyOperation(noControls, ByteString.valueOfUtf8("o=test"), ldapMods)); |
| | | |
| | | ldapMods = newRawModifications(replace(ldapAttr)); |
| | | |
| | | opList.add(newModifyOperation(null, ByteString.empty(), ldapMods)); |
| | | opList.add(newModifyOperation(noControls, ByteString.empty(), ldapMods)); |
| | | opList.add(newModifyOperation(null, ByteString.valueOf("o=test"), ldapMods)); |
| | | opList.add(newModifyOperation(noControls, ByteString.valueOf("o=test"), ldapMods)); |
| | | opList.add(newModifyOperation(null, ByteString.valueOfUtf8("o=test"), ldapMods)); |
| | | opList.add(newModifyOperation(noControls, ByteString.valueOfUtf8("o=test"), ldapMods)); |
| | | |
| | | String value2 = "bar"; |
| | | LDAPAttribute ldapAttr2 = new LDAPAttribute("description", value2); |
| | |
| | | |
| | | opList.add(newModifyOperation(null, ByteString.empty(), ldapMods)); |
| | | opList.add(newModifyOperation(noControls, ByteString.empty(), ldapMods)); |
| | | opList.add(newModifyOperation(null, ByteString.valueOf("o=test"), ldapMods)); |
| | | opList.add(newModifyOperation(noControls, ByteString.valueOf("o=test"), ldapMods)); |
| | | opList.add(newModifyOperation(null, ByteString.valueOfUtf8("o=test"), ldapMods)); |
| | | opList.add(newModifyOperation(noControls, ByteString.valueOfUtf8("o=test"), ldapMods)); |
| | | |
| | | ldapAttr2 = new LDAPAttribute("cn", value2); |
| | | ldapMods = newRawModifications(replace(ldapAttr), replace(ldapAttr2)); |
| | | |
| | | opList.add(newModifyOperation(null, ByteString.empty(), ldapMods)); |
| | | opList.add(newModifyOperation(noControls, ByteString.empty(), ldapMods)); |
| | | opList.add(newModifyOperation(null, ByteString.valueOf("o=test"), ldapMods)); |
| | | opList.add(newModifyOperation(noControls, ByteString.valueOf("o=test"), ldapMods)); |
| | | opList.add(newModifyOperation(null, ByteString.valueOfUtf8("o=test"), ldapMods)); |
| | | opList.add(newModifyOperation(noControls, ByteString.valueOfUtf8("o=test"), ldapMods)); |
| | | |
| | | |
| | | |
| | |
| | | ByteString originalDN = modifyOperation.getRawEntryDN(); |
| | | assertNotNull(originalDN); |
| | | |
| | | modifyOperation.setRawEntryDN(ByteString.valueOf("uid=test,o=test")); |
| | | modifyOperation.setRawEntryDN(ByteString.valueOfUtf8("uid=test,o=test")); |
| | | assertNotNull(modifyOperation.getRawEntryDN()); |
| | | assertEquals(modifyOperation.getRawEntryDN(), |
| | | ByteString.valueOf("uid=test,o=test")); |
| | | ByteString.valueOfUtf8("uid=test,o=test")); |
| | | |
| | | modifyOperation.setRawEntryDN(originalDN); |
| | | assertNotNull(modifyOperation.getRawEntryDN()); |
| | |
| | | ModifyOperation modifyOperation = newModifyOperation(null, DN.rootDN(), mods); |
| | | assertNotNull(modifyOperation.getEntryDN()); |
| | | |
| | | modifyOperation.setRawEntryDN(ByteString.valueOf("ou=Users,o=test")); |
| | | modifyOperation.setRawEntryDN(ByteString.valueOfUtf8("ou=Users,o=test")); |
| | | assertNotNull(modifyOperation.getEntryDN()); |
| | | } |
| | | |
| | |
| | | List<RawModification> mods) |
| | | { |
| | | InternalClientConnection conn = getRootConnection(); |
| | | return conn.processModify(ByteString.valueOf(entryDN), mods); |
| | | return conn.processModify(ByteString.valueOfUtf8(entryDN), mods); |
| | | } |
| | | |
| | | private ModifyOperation processModify(String entryDN, RawModification... mods) |
| | | { |
| | | InternalClientConnection conn = getRootConnection(); |
| | | return conn.processModify(ByteString.valueOf(entryDN), Arrays.asList(mods)); |
| | | return conn.processModify(ByteString.valueOfUtf8(entryDN), Arrays.asList(mods)); |
| | | } |
| | | |
| | | private ModifyOperation processModify(String entryDN, |
| | | List<RawModification> mods, List<Control> requestControls) |
| | | { |
| | | InternalClientConnection conn = getRootConnection(); |
| | | return conn.processModify(ByteString.valueOf(entryDN), mods, requestControls); |
| | | return conn.processModify(ByteString.valueOfUtf8(entryDN), mods, requestControls); |
| | | } |
| | | |
| | | /** |
| | |
| | | TestCaseUtils.configureSocket(s); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | |
| | | ModifyRequestProtocolOp modifyRequest = |
| | | new ModifyRequestProtocolOp( |
| | | ByteString.valueOf("uid=test.user," + baseDN), mods); |
| | | ByteString.valueOfUtf8("uid=test.user," + baseDN), mods); |
| | | message = new LDAPMessage(2, modifyRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | TestCaseUtils.configureSocket(s); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | |
| | | ModifyRequestProtocolOp modifyRequest = |
| | | new ModifyRequestProtocolOp( |
| | | ByteString.valueOf("uid=test.user," + baseDN), mods); |
| | | ByteString.valueOfUtf8("uid=test.user," + baseDN), mods); |
| | | message = new LDAPMessage(2, modifyRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | TestCaseUtils.configureSocket(s); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | |
| | | ModifyRequestProtocolOp modifyRequest = |
| | | new ModifyRequestProtocolOp( |
| | | ByteString.valueOf("uid=test.user," + baseDN), mods); |
| | | ByteString.valueOfUtf8("uid=test.user," + baseDN), mods); |
| | | message = new LDAPMessage(2, modifyRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | List<RawModification> mods = newRawModifications(replace(attr)); |
| | | |
| | | ModifyOperation modifyOperation = |
| | | newModifyOperation(null, ByteString.valueOf(baseDN), mods); |
| | | newModifyOperation(null, ByteString.valueOfUtf8(baseDN), mods); |
| | | |
| | | CancelRequest cancelRequest = new CancelRequest(false, |
| | | LocalizableMessage.raw("testCancelBeforeStartup")); |
| | |
| | | List<RawModification> mods = newRawModifications(replace(attr)); |
| | | |
| | | ModifyOperation modifyOperation = |
| | | newModifyOperation(null, ByteString.valueOf(baseDN), mods); |
| | | newModifyOperation(null, ByteString.valueOfUtf8(baseDN), mods); |
| | | modifyOperation.run(); |
| | | |
| | | CancelRequest cancelRequest = new CancelRequest(false, |
| | |
| | | TestCaseUtils.configureSocket(s); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | List<RawModification> mods = newRawModifications(replace(attr)); |
| | | |
| | | ModifyRequestProtocolOp modifyRequest = |
| | | new ModifyRequestProtocolOp(ByteString.valueOf(baseDN), mods); |
| | | new ModifyRequestProtocolOp(ByteString.valueOfUtf8(baseDN), mods); |
| | | message = new LDAPMessage(2, modifyRequest, |
| | | DisconnectClientPlugin.createDisconnectControlList("PreParse")); |
| | | w.writeMessage(message); |
| | |
| | | TestCaseUtils.configureSocket(s); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | List<RawModification> mods = newRawModifications(replace(attr)); |
| | | |
| | | ModifyRequestProtocolOp modifyRequest = |
| | | new ModifyRequestProtocolOp(ByteString.valueOf("o=test"), mods); |
| | | new ModifyRequestProtocolOp(ByteString.valueOfUtf8("o=test"), mods); |
| | | message = new LDAPMessage(2, modifyRequest, |
| | | DisconnectClientPlugin.createDisconnectControlList( |
| | | "PreOperation")); |
| | |
| | | TestCaseUtils.configureSocket(s); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | List<RawModification> mods = newRawModifications(replace(attr)); |
| | | |
| | | ModifyRequestProtocolOp modifyRequest = |
| | | new ModifyRequestProtocolOp(ByteString.valueOf(baseDN), mods); |
| | | new ModifyRequestProtocolOp(ByteString.valueOfUtf8(baseDN), mods); |
| | | message = new LDAPMessage(2, modifyRequest, |
| | | DisconnectClientPlugin.createDisconnectControlList( |
| | | "PostOperation")); |
| | |
| | | TestCaseUtils.configureSocket(s); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | List<RawModification> mods = newRawModifications(replace(attr)); |
| | | |
| | | ModifyRequestProtocolOp modifyRequest = |
| | | new ModifyRequestProtocolOp(ByteString.valueOf(baseDN), mods); |
| | | new ModifyRequestProtocolOp(ByteString.valueOfUtf8(baseDN), mods); |
| | | message = new LDAPMessage(2, modifyRequest, |
| | | DisconnectClientPlugin.createDisconnectControlList( |
| | | "PostResponse")); |
| | |
| | | RawModification.create(ModificationType.REPLACE, "description", "foo")); |
| | | |
| | | ModifyOperation modifyOperation = |
| | | newModifyOperation(controls, ByteString.valueOf("o=test"), mods); |
| | | newModifyOperation(controls, ByteString.valueOfUtf8("o=test"), mods); |
| | | modifyOperation.run(); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertTrue(DirectoryServer.entryExists(DN.valueOf("o=test"))); |
| | |
| | | |
| | | InternalClientConnection conn = new InternalClientConnection( |
| | | new AuthenticationInfo()); |
| | | ByteString user = ByteString.valueOf("cn=Directory Manager"); |
| | | ByteString password = ByteString.valueOf("password"); |
| | | ByteString user = ByteString.valueOfUtf8("cn=Directory Manager"); |
| | | ByteString password = ByteString.valueOfUtf8("password"); |
| | | BindOperation bindOperation = conn.processSimpleBind(user, password); |
| | | assertEquals(bindOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | |
| | | AtomicInteger nextMessageID = new AtomicInteger(1); |
| | | LDAPAuthenticationHandler authHandler = new LDAPAuthenticationHandler( |
| | | reader, writer, "localhost", nextMessageID); |
| | | authHandler.doSimpleBind(3, ByteString.valueOf("cn=Directory Manager"), |
| | | ByteString.valueOf("password"), new ArrayList<Control>(), |
| | | authHandler.doSimpleBind(3, ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | ByteString.valueOfUtf8("password"), new ArrayList<Control>(), |
| | | new ArrayList<Control>()); |
| | | ByteString authzID = authHandler.requestAuthorizationIdentity(); |
| | | assertNotNull(authzID); |
| | |
| | | |
| | | InternalClientConnection conn = new InternalClientConnection( |
| | | new AuthenticationInfo()); |
| | | ByteString user = ByteString.valueOf("cn=Directory Manager"); |
| | | ByteString password = ByteString.valueOf("password"); |
| | | ByteString user = ByteString.valueOfUtf8("cn=Directory Manager"); |
| | | ByteString password = ByteString.valueOfUtf8("password"); |
| | | // Unauthenticated BIND request. |
| | | BindOperation bindOperation = conn.processSimpleBind(DN.rootDN(), null); |
| | | assertEquals(bindOperation.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp( |
| | | ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | { |
| | | SearchRequestProtocolOp searchRequest = |
| | | new SearchRequestProtocolOp( |
| | | ByteString.valueOf(BASE), |
| | | ByteString.valueOfUtf8(BASE), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | |
| | | LinkedHashSet<String> attributes = newLinkedHashSet("*"); |
| | | SearchRequestProtocolOp searchRequest = |
| | | new SearchRequestProtocolOp( |
| | | ByteString.valueOf(BASE), |
| | | ByteString.valueOfUtf8(BASE), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | |
| | | { |
| | | SearchRequestProtocolOp searchRequest = |
| | | new SearchRequestProtocolOp( |
| | | ByteString.valueOf(BASE), |
| | | ByteString.valueOfUtf8(BASE), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | |
| | | LinkedHashSet<String> attributes = newLinkedHashSet("*"); |
| | | SearchRequestProtocolOp searchRequest = |
| | | new SearchRequestProtocolOp( |
| | | ByteString.valueOf(BASE), |
| | | ByteString.valueOfUtf8(BASE), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | |
| | | LinkedHashSet<String> attributes = newLinkedHashSet("objectclass"); |
| | | SearchRequestProtocolOp searchRequest = |
| | | new SearchRequestProtocolOp( |
| | | ByteString.valueOf(BASE), |
| | | ByteString.valueOfUtf8(BASE), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | |
| | | LinkedHashSet<String> attributes = newLinkedHashSet("objectclass"); |
| | | SearchRequestProtocolOp searchRequest = |
| | | new SearchRequestProtocolOp( |
| | | ByteString.valueOf(BASE), |
| | | ByteString.valueOfUtf8(BASE), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | |
| | | LinkedHashSet<String> attributes = newLinkedHashSet("uid", "createtimestamp"); |
| | | SearchRequestProtocolOp searchRequest = |
| | | new SearchRequestProtocolOp( |
| | | ByteString.valueOf(BASE), |
| | | ByteString.valueOfUtf8(BASE), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | |
| | | LinkedHashSet<String> attributes = newLinkedHashSet("title"); |
| | | SearchRequestProtocolOp searchRequest = |
| | | new SearchRequestProtocolOp( |
| | | ByteString.valueOf(BASE), |
| | | ByteString.valueOfUtf8(BASE), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | |
| | | LinkedHashSet<String> attributes = newLinkedHashSet("title"); |
| | | SearchRequestProtocolOp searchRequest = |
| | | new SearchRequestProtocolOp( |
| | | ByteString.valueOf(BASE), |
| | | ByteString.valueOfUtf8(BASE), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | |
| | | LinkedHashSet<String> attributes = newLinkedHashSet("title;lang-ja;phonetic"); |
| | | SearchRequestProtocolOp searchRequest = |
| | | new SearchRequestProtocolOp( |
| | | ByteString.valueOf(BASE), |
| | | ByteString.valueOfUtf8(BASE), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | |
| | | |
| | | SearchRequestProtocolOp searchRequest = |
| | | new SearchRequestProtocolOp( |
| | | ByteString.valueOf(BASE), |
| | | ByteString.valueOfUtf8(BASE), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | |
| | | |
| | | SearchRequestProtocolOp searchRequest = |
| | | new SearchRequestProtocolOp( |
| | | ByteString.valueOf(userDNString), |
| | | ByteString.valueOfUtf8(userDNString), |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | |
| | | Attribute attribute = description.get(0); |
| | | assertEquals(attribute.size(), 1); |
| | | assertFalse(attribute.hasOptions()); |
| | | assertTrue(attribute.contains(ByteString.valueOf("inherited description"))); |
| | | assertTrue(attribute.contains(ByteString.valueOfUtf8("inherited description"))); |
| | | } |
| | | finally |
| | | { |
| | |
| | | assertTrue(entry.hasAttribute(attrType)); |
| | | for (String value : values) |
| | | { |
| | | assertTrue(entry.hasValue(attrType, null, ByteString.valueOf(value))); |
| | | assertTrue(entry.hasValue(attrType, null, ByteString.valueOfUtf8(value))); |
| | | } |
| | | } |
| | | |
| | |
| | | assertTrue(entry.hasAttribute(attrType)); |
| | | for (String value : values) |
| | | { |
| | | assertFalse(entry.hasValue(attrType, null, ByteString.valueOf(value))); |
| | | assertFalse(entry.hasValue(attrType, null, ByteString.valueOfUtf8(value))); |
| | | } |
| | | } |
| | | |
| | |
| | | assertEquals(searchOperation.getEntriesSent(), 1); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrNull("collectiveattributesubentries"); |
| | | Entry e = searchOperation.getSearchEntries().getFirst(); |
| | | assertTrue(e.hasValue(attrType, null, ByteString.valueOf(collectiveSubentry.getName()))); |
| | | assertTrue(e.hasValue(attrType, null, ByteString.valueOfObject(collectiveSubentry.getName()))); |
| | | } |
| | | |
| | | @Test |
| | |
| | | { |
| | | InternalClientConnection conn = getRootConnection(); |
| | | List<RawModification> mods = newRawModifications(DELETE, attrType); |
| | | ModifyOperation modifyOperation = conn.processModify(ByteString.valueOf(e.getName().toString()), mods); |
| | | ModifyOperation modifyOperation = conn.processModify(ByteString.valueOfUtf8(e.getName().toString()), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | { |
| | | InternalClientConnection conn = getRootConnection(); |
| | | List<RawModification> mods = newRawModifications(REPLACE, attrType, newValue); |
| | | ModifyOperation modifyOperation = conn.processModify(ByteString.valueOf(e.getName().toString()), mods); |
| | | ModifyOperation modifyOperation = conn.processModify(ByteString.valueOfUtf8(e.getName().toString()), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | // for the user entry. |
| | | assertTrue(testEntry.hasAttribute(attrType)); |
| | | assertTrue(testEntry.hasValue(attrType, null, |
| | | ByteString.valueOf(defaultPolicy.getDN().toString()))); |
| | | ByteString.valueOfUtf8(defaultPolicy.getDN().toString()))); |
| | | |
| | | // Add new subentry policy with the |
| | | // scope to apply to the user entry. |
| | |
| | | assertNotNull(testEntry); |
| | | |
| | | assertTrue(testEntry.hasAttribute(attrType)); |
| | | assertTrue(testEntry.hasValue(attrType, null, ByteString.valueOf("cn=Temp Policy," + SUFFIX))); |
| | | assertTrue(testEntry.hasValue(attrType, null, ByteString.valueOfUtf8("cn=Temp Policy," + SUFFIX))); |
| | | |
| | | // Remove subentry policy and make sure |
| | | // default policy is in effect again. |
| | |
| | | |
| | | assertTrue(testEntry.hasAttribute(attrType)); |
| | | assertTrue(testEntry.hasValue(attrType, null, |
| | | ByteString.valueOf(defaultPolicy.getDN().toString()))); |
| | | ByteString.valueOfUtf8(defaultPolicy.getDN().toString()))); |
| | | } |
| | | } |
| | |
| | | |
| | | private ByteString b(String s) |
| | | { |
| | | return s != null ? ByteString.valueOf(s) : null; |
| | | return s != null ? ByteString.valueOfUtf8(s) : null; |
| | | } |
| | | |
| | | private DN dn(String s) throws DirectoryException |
| | |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | new ArrayList<Control>(), "3", DN.rootDN(), |
| | | SASL_MECHANISM_ANONYMOUS, |
| | | ByteString.valueOf("Internal Trace String")); |
| | | ByteString.valueOfUtf8("Internal Trace String")); |
| | | handler.processSASLBind(bindOperation); |
| | | assertEquals(bindOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | |
| | | new AttributeValuePasswordValidator(); |
| | | validator.initializePasswordValidator(configuration); |
| | | |
| | | ByteString pwOS = ByteString.valueOf(password); |
| | | ByteString pwOS = ByteString.valueOfUtf8(password); |
| | | ArrayList<Modification> mods = CollectionUtils.newArrayList( |
| | | new Modification(ModificationType.REPLACE, Attributes.create("userpassword", password))); |
| | | |
| | |
| | | new InternalClientConnection(new AuthenticationInfo()); |
| | | BindOperation bindOperation = |
| | | conn.processSASLBind(DN.rootDN(), SASL_MECHANISM_CRAM_MD5, |
| | | ByteString.valueOf("invalid")); |
| | | ByteString.valueOfUtf8("invalid")); |
| | | assertNotEquals(bindOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | |
| | | bindOperation = |
| | | conn.processSASLBind(DN.rootDN(), SASL_MECHANISM_CRAM_MD5, |
| | | ByteString.valueOf("malformed")); |
| | | ByteString.valueOfUtf8("malformed")); |
| | | assertNotEquals(bindOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | ResultCode.SASL_BIND_IN_PROGRESS); |
| | | |
| | | ByteString creds = |
| | | ByteString.valueOf("dn:cn=Directory Manager malformeddigest"); |
| | | ByteString.valueOfUtf8("dn:cn=Directory Manager malformeddigest"); |
| | | bindOperation = |
| | | conn.processSASLBind(DN.rootDN(), SASL_MECHANISM_CRAM_MD5, creds); |
| | | assertNotEquals(bindOperation.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | ResultCode.SASL_BIND_IN_PROGRESS); |
| | | |
| | | ByteString creds = |
| | | ByteString.valueOf("dn:cn=Directory Manager " + |
| | | ByteString.valueOfUtf8("dn:cn=Directory Manager " + |
| | | "malformedcredswiththerightlength"); |
| | | bindOperation = |
| | | conn.processSASLBind(DN.rootDN(), SASL_MECHANISM_CRAM_MD5, creds); |
| | |
| | | new org.opends.server.tools.LDAPWriter(socket); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | attributes.add(new LDAPAttribute("ou", "People")); |
| | | |
| | | AddRequestProtocolOp addRequest = |
| | | new AddRequestProtocolOp(ByteString.valueOf("ou=People,o=test"), attributes); |
| | | new AddRequestProtocolOp(ByteString.valueOfUtf8("ou=People,o=test"), attributes); |
| | | message = new LDAPMessage(2, addRequest, |
| | | DelayPreOpPlugin.createDelayControlList(5000)); |
| | | w.writeMessage(message); |
| | |
| | | new org.opends.server.tools.LDAPWriter(socket); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | // the delay request control so it won't complete before we can send the |
| | | // cancel request. |
| | | CompareRequestProtocolOp compareRequest = |
| | | new CompareRequestProtocolOp(ByteString.valueOf("o=test"), "o", |
| | | ByteString.valueOf("test")); |
| | | new CompareRequestProtocolOp(ByteString.valueOfUtf8("o=test"), "o", |
| | | ByteString.valueOfUtf8("test")); |
| | | message = new LDAPMessage(2, compareRequest, |
| | | DelayPreOpPlugin.createDelayControlList(5000)); |
| | | w.writeMessage(message); |
| | |
| | | new org.opends.server.tools.LDAPWriter(socket); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | // the delay request control so it won't complete before we can send the |
| | | // cancel request. |
| | | DeleteRequestProtocolOp deleteRequest = |
| | | new DeleteRequestProtocolOp(ByteString.valueOf("cn=test,o=test")); |
| | | new DeleteRequestProtocolOp(ByteString.valueOfUtf8("cn=test,o=test")); |
| | | message = new LDAPMessage(2, deleteRequest, |
| | | DelayPreOpPlugin.createDelayControlList(5000)); |
| | | w.writeMessage(message); |
| | |
| | | new org.opends.server.tools.LDAPWriter(socket); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | new org.opends.server.tools.LDAPWriter(socket); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | new LDAPAttribute("description", "foo"))); |
| | | |
| | | ModifyRequestProtocolOp modifyRequest = |
| | | new ModifyRequestProtocolOp(ByteString.valueOf("o=test"), mods); |
| | | new ModifyRequestProtocolOp(ByteString.valueOfUtf8("o=test"), mods); |
| | | message = new LDAPMessage(2, modifyRequest, |
| | | DelayPreOpPlugin.createDelayControlList(5000)); |
| | | w.writeMessage(message); |
| | |
| | | new org.opends.server.tools.LDAPWriter(socket); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | // include the delay request control so it won't complete before we can send |
| | | // the cancel request. |
| | | ModifyDNRequestProtocolOp modifyDNRequest = |
| | | new ModifyDNRequestProtocolOp(ByteString.valueOf("cn=test,o=test"), |
| | | ByteString.valueOf("cn=test2"), true); |
| | | new ModifyDNRequestProtocolOp(ByteString.valueOfUtf8("cn=test,o=test"), |
| | | ByteString.valueOfUtf8("cn=test2"), true); |
| | | message = new LDAPMessage(2, modifyDNRequest, |
| | | DelayPreOpPlugin.createDelayControlList(5000)); |
| | | w.writeMessage(message); |
| | |
| | | new org.opends.server.tools.LDAPWriter(socket); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | // the delay request control so it won't complete before we can send the |
| | | // cancel request. |
| | | SearchRequestProtocolOp searchRequest = |
| | | new SearchRequestProtocolOp(ByteString.valueOf("o=test"), |
| | | new SearchRequestProtocolOp(ByteString.valueOfUtf8("o=test"), |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, |
| | | 0, false, |
| | |
| | | new org.opends.server.tools.LDAPWriter(socket); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | new org.opends.server.tools.LDAPWriter(socket); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | new org.opends.server.tools.LDAPWriter(socket); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | // Create a cancel request and send it to the server. |
| | | ExtendedRequestProtocolOp extendedRequest = |
| | | new ExtendedRequestProtocolOp(OID_CANCEL_REQUEST, |
| | | ByteString.valueOf("malformed")); |
| | | ByteString.valueOfUtf8("malformed")); |
| | | message = new LDAPMessage(3, extendedRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | new org.opends.server.tools.LDAPWriter(socket); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | new CharacterSetPasswordValidator(); |
| | | validator.initializePasswordValidator(configuration); |
| | | |
| | | ByteString pwOS = ByteString.valueOf(password); |
| | | ByteString pwOS = ByteString.valueOfUtf8(password); |
| | | ArrayList<Modification> mods = newArrayList( |
| | | new Modification(REPLACE, Attributes.create("userpassword", password))); |
| | | |
| | |
| | | new DictionaryPasswordValidator(); |
| | | validator.initializePasswordValidator(configuration); |
| | | |
| | | ByteString pwOS = ByteString.valueOf(password); |
| | | ByteString pwOS = ByteString.valueOfUtf8(password); |
| | | ArrayList<Modification> mods = newArrayList( |
| | | new Modification(REPLACE, Attributes.create("userpassword", password))); |
| | | |
| | |
| | | new InternalClientConnection(new AuthenticationInfo()); |
| | | BindOperation bindOperation = |
| | | conn.processSASLBind(DN.rootDN(), SASL_MECHANISM_DIGEST_MD5, |
| | | ByteString.valueOf("invalid")); |
| | | ByteString.valueOfUtf8("invalid")); |
| | | assertNotEquals(bindOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | |
| | | bindOperation = |
| | | conn.processSASLBind(DN.rootDN(), SASL_MECHANISM_DIGEST_MD5, |
| | | ByteString.valueOf("malformed")); |
| | | ByteString.valueOfUtf8("malformed")); |
| | | assertNotEquals(bindOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | } |
| | |
| | | private static final String DESCRIPTION = "description"; |
| | | private static final String ETAG = "etag"; |
| | | |
| | | private final ByteString dummyValue = ByteString.valueOf("dummy"); |
| | | private final ByteString dummyValue = ByteString.valueOfUtf8("dummy"); |
| | | private final EntityTagVirtualAttributeProvider provider = new EntityTagVirtualAttributeProvider(); |
| | | private boolean changeListenerRemoved; |
| | | private boolean changeListenerAdded; |
| | |
| | | // Apply a change using the assertion control for optimistic concurrency. |
| | | Attribute attr = Attributes.create(DESCRIPTION, "first modify"); |
| | | List<Modification> mods = newArrayList(new Modification(ModificationType.REPLACE, attr)); |
| | | Control c = new LDAPAssertionRequestControl(true, LDAPFilter.createEqualityFilter(ETAG, ByteString.valueOf(etag1))); |
| | | Control c = new LDAPAssertionRequestControl(true, LDAPFilter.createEqualityFilter(ETAG, ByteString.valueOfUtf8(etag1))); |
| | | List<Control> ctrls = Collections.singletonList(c); |
| | | ModifyOperation modifyOperation = conn.processModify(userDN, mods, ctrls); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | { |
| | | assertFalse(a.isEmpty()); |
| | | assertEquals(a.size(), 1); |
| | | assertTrue(a.contains(ByteString.valueOf(entryDN.toString()))); |
| | | assertTrue(a.contains(ByteString.valueOfUtf8(entryDN.toString()))); |
| | | } |
| | | } |
| | | |
| | |
| | | Attribute values = provider.getValues(entry, getRule(provider)); |
| | | assertNotNull(values); |
| | | assertEquals(values.size(), 1); |
| | | assertTrue(values.contains(ByteString.valueOf("o=test"))); |
| | | assertTrue(values.contains(ByteString.valueOfUtf8("o=test"))); |
| | | } |
| | | |
| | | |
| | |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | assertTrue(provider.hasValue(entry, getRule(provider), ByteString.valueOf("o=test"))); |
| | | assertTrue(provider.hasValue(entry, getRule(provider), ByteString.valueOfUtf8("o=test"))); |
| | | } |
| | | |
| | | |
| | |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | assertFalse(provider.hasValue(entry, getRule(provider), ByteString.valueOf("o=not test"))); |
| | | assertFalse(provider.hasValue(entry, getRule(provider), ByteString.valueOfUtf8("o=not test"))); |
| | | } |
| | | |
| | | |
| | |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | LinkedList<ByteString> subAny = newLinkedList(ByteString.valueOf("=")); |
| | | LinkedList<ByteString> subAny = newLinkedList(ByteString.valueOfUtf8("=")); |
| | | |
| | | assertEquals(provider.matchesSubstring(entry, getRule(provider), null, subAny, null), |
| | | ConditionResult.UNDEFINED); |
| | |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | ByteString value = ByteString.valueOf("o=test2"); |
| | | ByteString value = ByteString.valueOfUtf8("o=test2"); |
| | | assertEquals(provider.greaterThanOrEqualTo(entry, getRule(provider), value), |
| | | ConditionResult.UNDEFINED); |
| | | } |
| | |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | ByteString value = ByteString.valueOf("o=test2"); |
| | | ByteString value = ByteString.valueOfUtf8("o=test2"); |
| | | assertEquals(provider.lessThanOrEqualTo(entry, getRule(provider), value), |
| | | ConditionResult.UNDEFINED); |
| | | } |
| | |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | ByteString value = ByteString.valueOf("o=test2"); |
| | | ByteString value = ByteString.valueOfUtf8("o=test2"); |
| | | assertEquals(provider.approximatelyEqualTo(entry, getRule(provider), value), |
| | | ConditionResult.UNDEFINED); |
| | | } |
| | |
| | | { |
| | | assertFalse(a.isEmpty()); |
| | | assertEquals(a.size(), 1); |
| | | assertTrue(a.contains(ByteString.valueOf(uuidString))); |
| | | assertTrue(a.contains(ByteString.valueOfUtf8(uuidString))); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | assertFalse(a.isEmpty()); |
| | | assertEquals(a.size(), 1); |
| | | assertFalse(a.contains(ByteString.valueOf(uuidString))); |
| | | assertFalse(a.contains(ByteString.valueOfUtf8(uuidString))); |
| | | } |
| | | } |
| | | |
| | |
| | | Attribute values = provider.getValues(entry, rule); |
| | | assertNotNull(values); |
| | | assertEquals(values.size(), 1); |
| | | assertTrue(values.contains(ByteString.valueOf(uuidString))); |
| | | assertTrue(values.contains(ByteString.valueOfUtf8(uuidString))); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | Entry entry = makeEntry(); |
| | | VirtualAttributeRule rule = getRule(provider); |
| | | assertTrue(provider.hasValue(entry, rule, ByteString.valueOf(uuidString))); |
| | | assertTrue(provider.hasValue(entry, rule, ByteString.valueOfUtf8(uuidString))); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | Entry entry = makeEntry(); |
| | | VirtualAttributeRule rule = getRule(provider); |
| | | assertFalse(provider.hasValue(entry, rule, ByteString.valueOf("wrong"))); |
| | | assertFalse(provider.hasValue(entry, rule, ByteString.valueOfUtf8("wrong"))); |
| | | } |
| | | |
| | | private Entry makeEntry() throws Exception |
| | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | // Create a modification to change the map attribute from uid to cn. |
| | | ArrayList<ByteString> values = newArrayList(ByteString.valueOf("cn")); |
| | | ArrayList<ByteString> values = newArrayList(ByteString.valueOfUtf8("cn")); |
| | | |
| | | ArrayList<RawModification> mods = new ArrayList<>(); |
| | | mods.add(new LDAPModification(ModificationType.REPLACE, |
| | | new LDAPAttribute("ds-cfg-match-attribute", |
| | | values))); |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(ByteString.valueOf(mapperDNString), mods); |
| | | conn.processModify(ByteString.valueOfUtf8(mapperDNString), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | |
| | | |
| | | // Change the configuration back to the way it was. |
| | | values.set(0, ByteString.valueOf("uid")); |
| | | values.set(0, ByteString.valueOfUtf8("uid")); |
| | | modifyOperation = |
| | | conn.processModify(ByteString.valueOf(mapperDNString), mods); |
| | | conn.processModify(ByteString.valueOfUtf8(mapperDNString), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | // Create a modification to set the map base DN to "dc=example,dc=com". |
| | | ArrayList<ByteString> values = newArrayList(ByteString.valueOf("dc=example,dc=com")); |
| | | ArrayList<ByteString> values = newArrayList(ByteString.valueOfUtf8("dc=example,dc=com")); |
| | | |
| | | ArrayList<RawModification> mods = new ArrayList<>(); |
| | | mods.add(new LDAPModification(ModificationType.REPLACE, |
| | | new LDAPAttribute("ds-cfg-match-base-dn", |
| | | values))); |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(ByteString.valueOf(mapperDNString), mods); |
| | | conn.processModify(ByteString.valueOfUtf8(mapperDNString), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | |
| | | |
| | | // Change the base DN to "o=test". |
| | | values.set(0, ByteString.valueOf("o=test")); |
| | | values.set(0, ByteString.valueOfUtf8("o=test")); |
| | | modifyOperation = |
| | | conn.processModify(ByteString.valueOf(mapperDNString), mods); |
| | | conn.processModify(ByteString.valueOfUtf8(mapperDNString), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | // Change the configuration back to its original setting. |
| | | values.clear(); |
| | | modifyOperation = |
| | | conn.processModify(ByteString.valueOf(mapperDNString), mods); |
| | | conn.processModify(ByteString.valueOfUtf8(mapperDNString), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | InternalClientConnection.getRootConnection(); |
| | | String mapperDNString = "cn=Exact Match,cn=Identity Mappers,cn=config"; |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(ByteString.valueOf(mapperDNString), mods); |
| | | conn.processModify(ByteString.valueOfUtf8(mapperDNString), mods); |
| | | assertNotSame(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | InternalClientConnection.getRootConnection(); |
| | | String mapperDNString = "cn=Exact Match,cn=Identity Mappers,cn=config"; |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(ByteString.valueOf(mapperDNString), mods); |
| | | conn.processModify(ByteString.valueOfUtf8(mapperDNString), mods); |
| | | assertNotSame(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | InternalClientConnection.getRootConnection(); |
| | | String mapperDNString = "cn=Exact Match,cn=Identity Mappers,cn=config"; |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(ByteString.valueOf(mapperDNString), mods); |
| | | conn.processModify(ByteString.valueOfUtf8(mapperDNString), mods); |
| | | assertNotSame(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | } |
| | |
| | | { |
| | | assertFalse(a.isEmpty()); |
| | | assertEquals(a.size(), 1); |
| | | assertTrue(a.contains(ByteString.valueOf(ruleId))); |
| | | assertTrue(a.contains(ByteString.valueOfUtf8(ruleId))); |
| | | } |
| | | } |
| | | |
| | |
| | | Attribute values = provider.getValues(entry, getRule(provider)); |
| | | assertNotNull(values); |
| | | assertEquals(values.size(), 1); |
| | | assertTrue(values.contains(ByteString.valueOf("22"))); |
| | | assertTrue(values.contains(ByteString.valueOfUtf8("22"))); |
| | | } |
| | | |
| | | |
| | |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | assertTrue(provider.hasValue(entry, getRule(provider), ByteString.valueOf("22"))); |
| | | assertTrue(provider.hasValue(entry, getRule(provider), ByteString.valueOfUtf8("22"))); |
| | | } |
| | | |
| | | |
| | |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | assertFalse(provider.hasValue(entry, getRule(provider), ByteString.valueOf("1"))); |
| | | assertFalse(provider.hasValue(entry, getRule(provider), ByteString.valueOfUtf8("1"))); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | assertFalse(a.isEmpty()); |
| | | assertEquals(a.size(), 1); |
| | | assertTrue(a.contains(ByteString.valueOf(toUpperCase(String.valueOf(hasSubs))))); |
| | | assertTrue(a.contains(ByteString.valueOfUtf8(toUpperCase(String.valueOf(hasSubs))))); |
| | | } |
| | | } |
| | | |
| | |
| | | assertEquals(a.size(), 1); |
| | | |
| | | assertFalse(a.isEmpty()); |
| | | assertTrue(a.contains(ByteString.valueOf("cn=test static group,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOf("cn=not a group,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOf("invalid"))); |
| | | assertTrue(a.contains(ByteString.valueOfUtf8("cn=test static group,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOfUtf8("cn=not a group,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOfUtf8("invalid"))); |
| | | } |
| | | |
| | | delete("cn=test static group,ou=groups,o=test"); |
| | |
| | | assertEquals(a.size(), 1); |
| | | |
| | | assertFalse(a.isEmpty()); |
| | | assertTrue(a.contains(ByteString.valueOf("cn=test static group,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOf("cn=not a group,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOf("invalid"))); |
| | | assertTrue(a.contains(ByteString.valueOfUtf8("cn=test static group,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOfUtf8("cn=not a group,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOfUtf8("invalid"))); |
| | | } |
| | | |
| | | delete("cn=test static group,ou=groups,o=test"); |
| | |
| | | assertEquals(a.size(), 1); |
| | | |
| | | assertFalse(a.isEmpty()); |
| | | assertTrue(a.contains(ByteString.valueOf("cn=test dynamic group,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOf("cn=not a group,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOf("invalid"))); |
| | | assertTrue(a.contains(ByteString.valueOfUtf8("cn=test dynamic group,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOfUtf8("cn=not a group,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOfUtf8("invalid"))); |
| | | } |
| | | |
| | | delete("cn=test dynamic group,ou=groups,o=test"); |
| | |
| | | assertEquals(a.size(), 2); |
| | | |
| | | assertFalse(a.isEmpty()); |
| | | assertTrue(a.contains(ByteString.valueOf("cn=test group 1,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOf("cn=test group 2,ou=groups,o=test"))); |
| | | assertTrue(a.contains(ByteString.valueOf("cn=test group 3,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOf("cn=not a group,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOf("invalid"))); |
| | | assertTrue(a.contains(ByteString.valueOfUtf8("cn=test group 1,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOfUtf8("cn=test group 2,ou=groups,o=test"))); |
| | | assertTrue(a.contains(ByteString.valueOfUtf8("cn=test group 3,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOfUtf8("cn=not a group,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOfUtf8("invalid"))); |
| | | } |
| | | |
| | | delete("cn=test group 1,ou=groups,o=test", |
| | |
| | | assertEquals(a.size(), 4); |
| | | |
| | | assertFalse(a.isEmpty()); |
| | | assertTrue(a.contains(ByteString.valueOf("cn=test group 1,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOf("cn=test group 2,ou=groups,o=test"))); |
| | | assertTrue(a.contains(ByteString.valueOf("cn=test group 3,ou=groups,o=test"))); |
| | | assertTrue(a.contains(ByteString.valueOf("cn=test group 4,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOf("cn=test group 5,ou=groups,o=test"))); |
| | | assertTrue(a.contains(ByteString.valueOf("cn=test group 6,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOf("cn=not a group,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOf("invalid"))); |
| | | assertTrue(a.contains(ByteString.valueOfUtf8("cn=test group 1,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOfUtf8("cn=test group 2,ou=groups,o=test"))); |
| | | assertTrue(a.contains(ByteString.valueOfUtf8("cn=test group 3,ou=groups,o=test"))); |
| | | assertTrue(a.contains(ByteString.valueOfUtf8("cn=test group 4,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOfUtf8("cn=test group 5,ou=groups,o=test"))); |
| | | assertTrue(a.contains(ByteString.valueOfUtf8("cn=test group 6,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOfUtf8("cn=not a group,ou=groups,o=test"))); |
| | | assertFalse(a.contains(ByteString.valueOfUtf8("invalid"))); |
| | | } |
| | | |
| | | delete("cn=test group 1,ou=groups,o=test", |
| | |
| | | |
| | | VirtualAttributeRule rule = buildRule(provider); |
| | | |
| | | LinkedList<ByteString> subAny = newLinkedList(ByteString.valueOf("=")); |
| | | LinkedList<ByteString> subAny = newLinkedList(ByteString.valueOfUtf8("=")); |
| | | |
| | | assertEquals(provider.matchesSubstring(entry, rule, null, subAny, null), |
| | | ConditionResult.UNDEFINED); |
| | |
| | | |
| | | VirtualAttributeRule rule = buildRule(provider); |
| | | |
| | | ByteString value = ByteString.valueOf("o=test2"); |
| | | ByteString value = ByteString.valueOfUtf8("o=test2"); |
| | | assertEquals(provider.greaterThanOrEqualTo(entry, rule, value), |
| | | ConditionResult.UNDEFINED); |
| | | } |
| | |
| | | |
| | | VirtualAttributeRule rule = buildRule(provider); |
| | | |
| | | ByteString value = ByteString.valueOf("o=test2"); |
| | | ByteString value = ByteString.valueOfUtf8("o=test2"); |
| | | assertEquals(provider.lessThanOrEqualTo(entry, rule, value), |
| | | ConditionResult.UNDEFINED); |
| | | } |
| | |
| | | |
| | | VirtualAttributeRule rule = buildRule(provider); |
| | | |
| | | ByteString value = ByteString.valueOf("o=test2"); |
| | | ByteString value = ByteString.valueOfUtf8("o=test2"); |
| | | assertEquals(provider.approximatelyEqualTo(entry, rule, value), |
| | | ConditionResult.UNDEFINED); |
| | | } |
| | |
| | | final Object result = mockProvider.assertExpectedEventWasReceived(event); |
| | | if (result instanceof String) |
| | | { |
| | | return ByteString.valueOf((String) result); |
| | | return ByteString.valueOfUtf8((String) result); |
| | | } |
| | | else |
| | | { |
| | |
| | | try |
| | | { |
| | | return GeneralizedTimeSyntax.decodeGeneralizedTimeValue(ByteString |
| | | .valueOf(currentTime)); |
| | | .valueOfUtf8(currentTime)); |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | |
| | | // Perform authentication. |
| | | try |
| | | { |
| | | state.passwordMatches(ByteString.valueOf(userPassword)); |
| | | state.passwordMatches(ByteString.valueOfUtf8(userPassword)); |
| | | fail("password match unexpectedly succeeded"); |
| | | } |
| | | catch (final DirectoryException e) |
| | |
| | | // Perform authentication. |
| | | try |
| | | { |
| | | state.passwordMatches(ByteString.valueOf(userPassword)); |
| | | state.passwordMatches(ByteString.valueOfUtf8(userPassword)); |
| | | fail("password match unexpectedly succeeded"); |
| | | } |
| | | catch (final DirectoryException e) |
| | |
| | | // Perform authentication. |
| | | try |
| | | { |
| | | state.passwordMatches(ByteString.valueOf(userPassword)); |
| | | state.passwordMatches(ByteString.valueOfUtf8(userPassword)); |
| | | fail("password match unexpectedly succeeded"); |
| | | } |
| | | catch (final DirectoryException e) |
| | |
| | | } |
| | | |
| | | // Perform authentication. |
| | | assertTrue(state.passwordMatches(ByteString.valueOf(userPassword))); |
| | | assertTrue(state.passwordMatches(ByteString.valueOfUtf8(userPassword))); |
| | | |
| | | state.finalizeStateAfterBind(); |
| | | } |
| | |
| | | { |
| | | case 0: |
| | | // First attempt should succeed. |
| | | assertTrue(state.passwordMatches(ByteString.valueOf(userPassword))); |
| | | assertTrue(state.passwordMatches(ByteString.valueOfUtf8(userPassword))); |
| | | break; |
| | | case 1: |
| | | // Second attempt should fail. |
| | | try |
| | | { |
| | | state.passwordMatches(ByteString.valueOf(userPassword)); |
| | | state.passwordMatches(ByteString.valueOfUtf8(userPassword)); |
| | | fail("password match unexpectedly succeeded"); |
| | | } |
| | | catch (final DirectoryException e) |
| | |
| | | case 2: |
| | | // Third attempt should succeed, once the monitor has run. |
| | | provider.runMonitorTasks(); |
| | | assertTrue(state.passwordMatches(ByteString.valueOf(userPassword))); |
| | | assertTrue(state.passwordMatches(ByteString.valueOfUtf8(userPassword))); |
| | | break; |
| | | } |
| | | |
| | |
| | | { |
| | | case 0: |
| | | // First attempt should succeed. |
| | | assertTrue(state.passwordMatches(ByteString.valueOf(userPassword))); |
| | | assertTrue(state.passwordMatches(ByteString.valueOfUtf8(userPassword))); |
| | | break; |
| | | case 1: |
| | | // Second attempt should fail. |
| | | try |
| | | { |
| | | state.passwordMatches(ByteString.valueOf(userPassword)); |
| | | state.passwordMatches(ByteString.valueOfUtf8(userPassword)); |
| | | fail("password match unexpectedly succeeded"); |
| | | } |
| | | catch (final DirectoryException e) |
| | |
| | | case 2: |
| | | // Third attempt should succeed, once the monitor has run. |
| | | provider.runMonitorTasks(); |
| | | assertTrue(state.passwordMatches(ByteString.valueOf(userPassword))); |
| | | assertTrue(state.passwordMatches(ByteString.valueOfUtf8(userPassword))); |
| | | break; |
| | | } |
| | | |
| | |
| | | try |
| | | { |
| | | connection = factory.getConnection(); |
| | | connection.simpleBind(ByteString.valueOf(searchBindDNString), |
| | | ByteString.valueOf(userPassword)); |
| | | connection.simpleBind(ByteString.valueOfUtf8(searchBindDNString), |
| | | ByteString.valueOfUtf8(userPassword)); |
| | | fail("Bind attempt should have failed"); |
| | | } |
| | | catch (final DirectoryException e) |
| | |
| | | try |
| | | { |
| | | connection = factory.getConnection(); |
| | | connection.simpleBind(ByteString.valueOf(searchBindDNString), |
| | | ByteString.valueOf(userPassword)); |
| | | connection.simpleBind(ByteString.valueOfUtf8(searchBindDNString), |
| | | ByteString.valueOfUtf8(userPassword)); |
| | | fail("Bind attempt should have failed"); |
| | | } |
| | | catch (final DirectoryException e) |
| | |
| | | try |
| | | { |
| | | connection = factory.getConnection(); |
| | | connection.simpleBind(ByteString.valueOf(searchBindDNString), |
| | | ByteString.valueOf(userPassword)); |
| | | connection.simpleBind(ByteString.valueOfUtf8(searchBindDNString), |
| | | ByteString.valueOfUtf8(userPassword)); |
| | | fail("Bind attempt should have failed"); |
| | | } |
| | | catch (final DirectoryException e) |
| | |
| | | try |
| | | { |
| | | connection = factory.getConnection(); |
| | | connection.simpleBind(ByteString.valueOf(searchBindDNString), |
| | | ByteString.valueOf(userPassword)); |
| | | connection.simpleBind(ByteString.valueOfUtf8(searchBindDNString), |
| | | ByteString.valueOfUtf8(userPassword)); |
| | | fail("Bind attempt should have failed"); |
| | | } |
| | | catch (final DirectoryException e) |
| | |
| | | try |
| | | { |
| | | connection = factory.getConnection(); |
| | | connection.simpleBind(ByteString.valueOf(searchBindDNString), |
| | | ByteString.valueOf(userPassword)); |
| | | connection.simpleBind(ByteString.valueOfUtf8(searchBindDNString), |
| | | ByteString.valueOfUtf8(userPassword)); |
| | | fail("Bind attempt should have failed"); |
| | | } |
| | | catch (final DirectoryException e) |
| | |
| | | try |
| | | { |
| | | connection = factory.getConnection(); |
| | | connection.simpleBind(ByteString.valueOf(searchBindDNString), |
| | | ByteString.valueOf(userPassword)); |
| | | connection.simpleBind(ByteString.valueOfUtf8(searchBindDNString), |
| | | ByteString.valueOfUtf8(userPassword)); |
| | | } |
| | | finally |
| | | { |
| | |
| | | final ByteString username = connection.search(searchBindDN, |
| | | SearchScope.WHOLE_SUBTREE, |
| | | SearchFilter.createFilterFromString("(uid=aduser)")); |
| | | assertEquals(username, ByteString.valueOf(adDNString)); |
| | | assertEquals(username, ByteString.valueOfUtf8(adDNString)); |
| | | } |
| | | finally |
| | | { |
| | |
| | | assertEquals(state.getAuthenticationPolicy(), policy); |
| | | |
| | | // Perform authentication. |
| | | assertTrue(state.passwordMatches(ByteString.valueOf(userPassword))); |
| | | assertTrue(state.passwordMatches(ByteString.valueOfUtf8(userPassword))); |
| | | |
| | | state.finalizeStateAfterBind(); |
| | | } |
| | |
| | | switch (bindResultCode.asEnum()) |
| | | { |
| | | case SUCCESS: |
| | | assertTrue(state.passwordMatches(ByteString.valueOf(userPassword))); |
| | | assertTrue(state.passwordMatches(ByteString.valueOfUtf8(userPassword))); |
| | | break; |
| | | case INVALID_CREDENTIALS: |
| | | assertFalse(state.passwordMatches(ByteString.valueOf(userPassword))); |
| | | assertFalse(state.passwordMatches(ByteString.valueOfUtf8(userPassword))); |
| | | break; |
| | | default: |
| | | try |
| | | { |
| | | state.passwordMatches(ByteString.valueOf(userPassword)); |
| | | state.passwordMatches(ByteString.valueOfUtf8(userPassword)); |
| | | fail("password match did not fail"); |
| | | } |
| | | catch (final DirectoryException e) |
| | |
| | | // Perform authentication. |
| | | try |
| | | { |
| | | state.passwordMatches(ByteString.valueOf(userPassword)); |
| | | state.passwordMatches(ByteString.valueOfUtf8(userPassword)); |
| | | fail("password match unexpectedly succeeded"); |
| | | } |
| | | catch (final DirectoryException e) |
| | |
| | | assertEquals(state.getAuthenticationPolicy(), policy); |
| | | |
| | | // Perform authentication. |
| | | assertTrue(state.passwordMatches(ByteString.valueOf(userPassword))); |
| | | assertTrue(state.passwordMatches(ByteString.valueOfUtf8(userPassword))); |
| | | |
| | | // There should be no more pending events. |
| | | provider.assertAllExpectedEventsReceived(); |
| | |
| | | assertEquals(state.getAuthenticationPolicy(), policy); |
| | | |
| | | // Perform authentication. |
| | | assertTrue(state.passwordMatches(ByteString.valueOf(userPassword))); |
| | | assertTrue(state.passwordMatches(ByteString.valueOfUtf8(userPassword))); |
| | | |
| | | // There should be no more pending events. |
| | | provider.assertAllExpectedEventsReceived(); |
| | |
| | | assertEquals(state.getAuthenticationPolicy(), policy); |
| | | |
| | | // Perform authentication. |
| | | assertTrue(state.passwordMatches(ByteString.valueOf(userPassword))); |
| | | assertTrue(state.passwordMatches(ByteString.valueOfUtf8(userPassword))); |
| | | |
| | | // There should be no more pending events. |
| | | provider.assertAllExpectedEventsReceived(); |
| | |
| | | |
| | | try |
| | | { |
| | | state.passwordMatches(ByteString.valueOf(userPassword)); |
| | | state.passwordMatches(ByteString.valueOfUtf8(userPassword)); |
| | | fail("password match unexpectedly succeeded"); |
| | | } |
| | | catch (final DirectoryException e) |
| | |
| | | // Perform authentication. |
| | | if (i < 2) |
| | | { |
| | | assertTrue(state.passwordMatches(ByteString.valueOf(userPassword))); |
| | | assertTrue(state.passwordMatches(ByteString.valueOfUtf8(userPassword))); |
| | | } |
| | | else |
| | | { |
| | | try |
| | | { |
| | | state.passwordMatches(ByteString.valueOf(userPassword)); |
| | | state.passwordMatches(ByteString.valueOfUtf8(userPassword)); |
| | | fail("password match unexpectedly succeeded"); |
| | | } |
| | | catch (final DirectoryException e) |
| | |
| | | // Perform authentication. |
| | | try |
| | | { |
| | | state.passwordMatches(ByteString.valueOf(userPassword)); |
| | | state.passwordMatches(ByteString.valueOfUtf8(userPassword)); |
| | | fail("password match unexpectedly succeeded"); |
| | | } |
| | | catch (final DirectoryException e) |
| | |
| | | final AuthenticationPolicyState state2 = policy |
| | | .createAuthenticationPolicyState(userEntry); |
| | | assertEquals(state2.getAuthenticationPolicy(), policy); |
| | | assertTrue(state2.passwordMatches(ByteString.valueOf(userPassword))); |
| | | assertTrue(state2.passwordMatches(ByteString.valueOfUtf8(userPassword))); |
| | | state2.finalizeStateAfterBind(); |
| | | |
| | | // Run monitor which should still have nothing to do. |
| | |
| | | |
| | | // Authenticate three times, the third time was failing because the pool |
| | | // would not retry the operation on a new connection. |
| | | ByteString username = ByteString.valueOf(searchBindDNString); |
| | | ByteString password = ByteString.valueOf("searchPassword"); |
| | | ByteString username = ByteString.valueOfUtf8(searchBindDNString); |
| | | ByteString password = ByteString.valueOfUtf8("searchPassword"); |
| | | |
| | | Connection c1 = pool.getConnection(); |
| | | c1.simpleBind(username, password); |
| | |
| | | final AuthenticationPolicyState state = policy |
| | | .createAuthenticationPolicyState(testUser); |
| | | assertEquals(state.getAuthenticationPolicy(), policy); |
| | | assertEquals(state.passwordMatches(ByteString.valueOf(presentedPassword)), |
| | | assertEquals(state.passwordMatches(ByteString.valueOfUtf8(presentedPassword)), |
| | | expectedBindResultIsSuccess); |
| | | state.finalizeStateAfterBind(); |
| | | |
| | |
| | | { |
| | | assertFalse(newCachedPassword.equals(testCachedPassword)); |
| | | assertTrue(UserPasswordSyntax.isEncoded(ByteString |
| | | .valueOf(newCachedPassword))); |
| | | .valueOfUtf8(newCachedPassword))); |
| | | assertEquals(newCachedPasswordTime, testCurrentTimeGMT); |
| | | } |
| | | else |
| | |
| | | BindRequestProtocolOp newBindRequest(final String dn, final String password) |
| | | throws LDAPException |
| | | { |
| | | return new BindRequestProtocolOp(ByteString.valueOf(dn), 3, |
| | | ByteString.valueOf(password)); |
| | | return new BindRequestProtocolOp(ByteString.valueOfUtf8(dn), 3, |
| | | ByteString.valueOfUtf8(password)); |
| | | } |
| | | |
| | | |
| | |
| | | throws LDAPException |
| | | { |
| | | final int timeout = (int) (cfg.getConnectionTimeout() / 1000); |
| | | return new SearchRequestProtocolOp(ByteString.valueOf(dn), |
| | | return new SearchRequestProtocolOp(ByteString.valueOfUtf8(dn), |
| | | SearchScope.WHOLE_SUBTREE, DereferenceAliasesPolicy.ALWAYS, 1, timeout, |
| | | true, RawFilter.create(filter), |
| | | LDAPPassThroughAuthenticationPolicyFactory.NO_ATTRIBUTES); |
| | |
| | | for (int i=0; i < 20; i++) |
| | | { |
| | | buffer.append('x'); |
| | | ByteString password = ByteString.valueOf(buffer.toString()); |
| | | ByteString password = ByteString.valueOfUtf8(buffer.toString()); |
| | | |
| | | ModifyOperationBasis op = newModifyOperation(buffer); |
| | | |
| | |
| | | for (int i=0; i < 20; i++) |
| | | { |
| | | buffer.append('x'); |
| | | ByteString password = ByteString.valueOf(buffer.toString()); |
| | | ByteString password = ByteString.valueOfUtf8(buffer.toString()); |
| | | |
| | | ModifyOperationBasis op = newModifyOperation(buffer); |
| | | |
| | |
| | | for (int i=0; i < 20; i++) |
| | | { |
| | | buffer.append('x'); |
| | | ByteString password = ByteString.valueOf(buffer.toString()); |
| | | ByteString password = ByteString.valueOfUtf8(buffer.toString()); |
| | | |
| | | ModifyOperationBasis op = newModifyOperation(buffer); |
| | | |
| | |
| | | for (int i=0; i < 20; i++) |
| | | { |
| | | buffer.append('x'); |
| | | ByteString password = ByteString.valueOf(buffer.toString()); |
| | | ByteString password = ByteString.valueOfUtf8(buffer.toString()); |
| | | |
| | | ModifyOperationBasis op = newModifyOperation(buffer); |
| | | |
| | |
| | | { |
| | | assertFalse(a.isEmpty()); |
| | | assertEquals(a.size(), 1); |
| | | assertTrue(a.contains(ByteString.valueOf(String.valueOf(count)))); |
| | | assertTrue(a.contains(ByteString.valueOfUtf8(String.valueOf(count)))); |
| | | } |
| | | } |
| | | |
| | |
| | | @Test |
| | | public void testFailureInvalidRequestValueFormat() |
| | | { |
| | | ByteString requestValue = ByteString.valueOf("malformed"); |
| | | ByteString requestValue = ByteString.valueOfUtf8("malformed"); |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | ExtendedOperation extOp = conn.processExtendedOperation(OID_PASSWORD_MODIFY_REQUEST, requestValue); |
| | |
| | | // Perform an internal bind to verify the password was actually changed. |
| | | InternalClientConnection conn = new InternalClientConnection(new AuthenticationInfo()); |
| | | BindOperation bindOperation = |
| | | conn.processSimpleBind(name, ByteString.valueOf(newPwd)); |
| | | conn.processSimpleBind(name, ByteString.valueOfUtf8(newPwd)); |
| | | assertEquals(bindOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | return new Object[][] |
| | | { |
| | | new Object[] { ByteString.empty() }, |
| | | new Object[] { ByteString.valueOf("") }, |
| | | new Object[] { ByteString.valueOf("\u0000") }, |
| | | new Object[] { ByteString.valueOf("\t") }, |
| | | new Object[] { ByteString.valueOf("\n") }, |
| | | new Object[] { ByteString.valueOf("\r\n") }, |
| | | new Object[] { ByteString.valueOf(" ") }, |
| | | new Object[] { ByteString.valueOf("Test1\tTest2\tTest3") }, |
| | | new Object[] { ByteString.valueOf("Test1\nTest2\nTest3") }, |
| | | new Object[] { ByteString.valueOf("Test1\r\nTest2\r\nTest3") }, |
| | | new Object[] { ByteString.valueOf("a") }, |
| | | new Object[] { ByteString.valueOf("ab") }, |
| | | new Object[] { ByteString.valueOf("abc") }, |
| | | new Object[] { ByteString.valueOf("abcd") }, |
| | | new Object[] { ByteString.valueOf("abcde") }, |
| | | new Object[] { ByteString.valueOf("abcdef") }, |
| | | new Object[] { ByteString.valueOf("abcdefg") }, |
| | | new Object[] { ByteString.valueOf("abcdefgh") }, |
| | | new Object[] { ByteString.valueOf("The Quick Brown Fox Jumps Over " + |
| | | new Object[] { ByteString.valueOfUtf8("") }, |
| | | new Object[] { ByteString.valueOfUtf8("\u0000") }, |
| | | new Object[] { ByteString.valueOfUtf8("\t") }, |
| | | new Object[] { ByteString.valueOfUtf8("\n") }, |
| | | new Object[] { ByteString.valueOfUtf8("\r\n") }, |
| | | new Object[] { ByteString.valueOfUtf8(" ") }, |
| | | new Object[] { ByteString.valueOfUtf8("Test1\tTest2\tTest3") }, |
| | | new Object[] { ByteString.valueOfUtf8("Test1\nTest2\nTest3") }, |
| | | new Object[] { ByteString.valueOfUtf8("Test1\r\nTest2\r\nTest3") }, |
| | | new Object[] { ByteString.valueOfUtf8("a") }, |
| | | new Object[] { ByteString.valueOfUtf8("ab") }, |
| | | new Object[] { ByteString.valueOfUtf8("abc") }, |
| | | new Object[] { ByteString.valueOfUtf8("abcd") }, |
| | | new Object[] { ByteString.valueOfUtf8("abcde") }, |
| | | new Object[] { ByteString.valueOfUtf8("abcdef") }, |
| | | new Object[] { ByteString.valueOfUtf8("abcdefg") }, |
| | | new Object[] { ByteString.valueOfUtf8("abcdefgh") }, |
| | | new Object[] { ByteString.valueOfUtf8("The Quick Brown Fox Jumps Over " + |
| | | "The Lazy Dog") }, |
| | | new Object[] { ByteString.valueOf("\u00BFD\u00F3nde est\u00E1 el " + |
| | | new Object[] { ByteString.valueOfUtf8("\u00BFD\u00F3nde est\u00E1 el " + |
| | | "ba\u00F1o?") } |
| | | }; |
| | | } |
| | |
| | | assertNotNull(encodedPassword); |
| | | assertTrue(scheme.passwordMatches(plaintext, encodedPassword)); |
| | | assertFalse(scheme.passwordMatches(plaintext, |
| | | ByteString.valueOf("garbage"))); |
| | | ByteString.valueOfUtf8("garbage"))); |
| | | |
| | | ByteString schemeEncodedPassword = |
| | | scheme.encodePasswordWithScheme(plaintext); |
| | |
| | | // or other characters that will cause LDIF parsing errors. |
| | | // We really don't need many test cases here, since that functionality |
| | | // is tested above. |
| | | new Object[] { ByteString.valueOf("a") }, |
| | | new Object[] { ByteString.valueOf("abcdefgh") }, |
| | | new Object[] { ByteString.valueOf("abcdefghi") }, |
| | | new Object[] { ByteString.valueOfUtf8("a") }, |
| | | new Object[] { ByteString.valueOfUtf8("abcdefgh") }, |
| | | new Object[] { ByteString.valueOfUtf8("abcdefghi") }, |
| | | }; |
| | | } |
| | | |
| | |
| | | if (passwordString != null) |
| | | { |
| | | String[] pwComps = UserPasswordSyntax.decodeUserPassword(passwordString); |
| | | ByteString encodedPassword = ByteString.valueOf(pwComps[1]); |
| | | ByteString encodedPassword = ByteString.valueOfUtf8(pwComps[1]); |
| | | |
| | | assertTrue(scheme.passwordMatches(plaintext, encodedPassword)); |
| | | } |
| | |
| | | { |
| | | return new Object[][] |
| | | { |
| | | new Object[] { ByteString.valueOf("a") }, |
| | | new Object[] { ByteString.valueOf("ab") }, |
| | | new Object[] { ByteString.valueOf("abc") }, |
| | | new Object[] { ByteString.valueOf("abcd") }, |
| | | new Object[] { ByteString.valueOf("abcde") }, |
| | | new Object[] { ByteString.valueOf("abcdef") }, |
| | | new Object[] { ByteString.valueOf("abcdefg") }, |
| | | new Object[] { ByteString.valueOf("abcdefgh") }, |
| | | new Object[] { ByteString.valueOf("The Quick Brown Fox Jumps Over " + |
| | | new Object[] { ByteString.valueOfUtf8("a") }, |
| | | new Object[] { ByteString.valueOfUtf8("ab") }, |
| | | new Object[] { ByteString.valueOfUtf8("abc") }, |
| | | new Object[] { ByteString.valueOfUtf8("abcd") }, |
| | | new Object[] { ByteString.valueOfUtf8("abcde") }, |
| | | new Object[] { ByteString.valueOfUtf8("abcdef") }, |
| | | new Object[] { ByteString.valueOfUtf8("abcdefg") }, |
| | | new Object[] { ByteString.valueOfUtf8("abcdefgh") }, |
| | | new Object[] { ByteString.valueOfUtf8("The Quick Brown Fox Jumps Over " + |
| | | "The Lazy Dog") }, |
| | | }; |
| | | } |
| | |
| | | throws Exception |
| | | { |
| | | ByteString rootCreds = |
| | | ByteString.valueOf("\u0000dn:cn=Directory Manager\u0000password"); |
| | | ByteString.valueOfUtf8("\u0000dn:cn=Directory Manager\u0000password"); |
| | | |
| | | InternalClientConnection anonymousConn = |
| | | new InternalClientConnection(new AuthenticationInfo()); |
| | |
| | | { |
| | | new Object[] { null }, |
| | | new Object[] { ByteString.empty() }, |
| | | new Object[] { ByteString.valueOf("u:test.user") }, |
| | | new Object[] { ByteString.valueOf("password") }, |
| | | new Object[] { ByteString.valueOf("\u0000") }, |
| | | new Object[] { ByteString.valueOf("\u0000\u0000") }, |
| | | new Object[] { ByteString.valueOf("\u0000password") }, |
| | | new Object[] { ByteString.valueOf("\u0000\u0000password") }, |
| | | new Object[] { ByteString.valueOf("\u0000u:test.user\u0000") }, |
| | | new Object[] { ByteString.valueOf("\u0000dn:\u0000password") }, |
| | | new Object[] { ByteString.valueOf("\u0000dn:bogus\u0000password") }, |
| | | new Object[] { ByteString.valueOf("\u0000dn:cn=no such user" + |
| | | new Object[] { ByteString.valueOfUtf8("u:test.user") }, |
| | | new Object[] { ByteString.valueOfUtf8("password") }, |
| | | new Object[] { ByteString.valueOfUtf8("\u0000") }, |
| | | new Object[] { ByteString.valueOfUtf8("\u0000\u0000") }, |
| | | new Object[] { ByteString.valueOfUtf8("\u0000password") }, |
| | | new Object[] { ByteString.valueOfUtf8("\u0000\u0000password") }, |
| | | new Object[] { ByteString.valueOfUtf8("\u0000u:test.user\u0000") }, |
| | | new Object[] { ByteString.valueOfUtf8("\u0000dn:\u0000password") }, |
| | | new Object[] { ByteString.valueOfUtf8("\u0000dn:bogus\u0000password") }, |
| | | new Object[] { ByteString.valueOfUtf8("\u0000dn:cn=no such user" + |
| | | "\u0000password") }, |
| | | new Object[] { ByteString.valueOf("\u0000u:\u0000password") }, |
| | | new Object[] { ByteString.valueOf("\u0000u:nosuchuser\u0000password") }, |
| | | new Object[] { ByteString.valueOf("\u0000u:test.user\u0000" + |
| | | new Object[] { ByteString.valueOfUtf8("\u0000u:\u0000password") }, |
| | | new Object[] { ByteString.valueOfUtf8("\u0000u:nosuchuser\u0000password") }, |
| | | new Object[] { ByteString.valueOfUtf8("\u0000u:test.user\u0000" + |
| | | "wrongpassword") }, |
| | | }; |
| | | } |
| | |
| | | private void assertAcceptable(RepeatedCharactersPasswordValidator validator, String value, Entry userEntry, |
| | | boolean expectedResult) throws DirectoryException |
| | | { |
| | | ByteString password = ByteString.valueOf(value); |
| | | ByteString password = ByteString.valueOfUtf8(value); |
| | | ModifyOperationBasis modifyOperation = replaceUserPasswordAttribute(value); |
| | | |
| | | LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder(); |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | |
| | | scheme.initializePasswordStorageScheme(configuration); |
| | | // The stored value has a 12 byte salt instead of the default 8 |
| | | assertTrue(scheme.passwordMatches(ByteString.valueOf("password"), |
| | | ByteString.valueOf("so5s1vK3oEi4uL/oVY3bqs5LRlKjgMN+u4A4bw=="))); |
| | | assertTrue(scheme.passwordMatches(ByteString.valueOfUtf8("password"), |
| | | ByteString.valueOfUtf8("so5s1vK3oEi4uL/oVY3bqs5LRlKjgMN+u4A4bw=="))); |
| | | } |
| | | } |
| | |
| | | for (int i=0; i < 20; i++) |
| | | { |
| | | buffer.append('x'); |
| | | ByteString password = ByteString.valueOf(buffer.toString()); |
| | | ByteString password = ByteString.valueOfUtf8(buffer.toString()); |
| | | |
| | | ArrayList<Modification> mods = newArrayList( |
| | | new Modification(REPLACE, Attributes.create("userpassword", buffer.toString()))); |
| | |
| | | |
| | | StringBuilder buffer = new StringBuilder(); |
| | | HashSet<ByteString> currentPassword = new HashSet<>(3); |
| | | currentPassword.add(ByteString.valueOf("xxx")); |
| | | currentPassword.add(ByteString.valueOfUtf8("xxx")); |
| | | for (int i=0; i < 7; i++) |
| | | { |
| | | buffer.append('x'); |
| | | ByteString password = ByteString.valueOf(buffer.toString()); |
| | | ByteString password = ByteString.valueOfUtf8(buffer.toString()); |
| | | |
| | | ArrayList<Modification> mods = newArrayList( |
| | | new Modification(REPLACE, Attributes.create("userpassword", buffer.toString()))); |
| | |
| | | { |
| | | assertFalse(a.isEmpty()); |
| | | assertEquals(a.size(), 1); |
| | | assertTrue(a.contains(ByteString.valueOf(e.getStructuralObjectClass().getNameOrOID()))); |
| | | assertTrue(a.contains(ByteString.valueOfUtf8(e.getStructuralObjectClass().getNameOrOID()))); |
| | | } |
| | | } |
| | | |
| | |
| | | Attribute values = provider.getValues(entry, rule); |
| | | assertNotNull(values); |
| | | assertEquals(values.size(), 1); |
| | | assertTrue(values.contains(ByteString.valueOf(entry.getStructuralObjectClass().getNameOrOID()))); |
| | | assertTrue(values.contains(ByteString.valueOfUtf8(entry.getStructuralObjectClass().getNameOrOID()))); |
| | | } |
| | | |
| | | |
| | |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | assertTrue(provider.hasValue(entry, rule, |
| | | ByteString.valueOf(entry.getStructuralObjectClass().getNameOrOID()))); |
| | | ByteString.valueOfUtf8(entry.getStructuralObjectClass().getNameOrOID()))); |
| | | } |
| | | |
| | | |
| | |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | assertFalse(provider.hasValue(entry, rule, ByteString.valueOf("inetorgperson"))); |
| | | assertFalse(provider.hasValue(entry, rule, ByteString.valueOfUtf8("inetorgperson"))); |
| | | } |
| | | } |
| | |
| | | { |
| | | assertFalse(a.isEmpty()); |
| | | assertEquals(a.size(), 1); |
| | | assertTrue(a.contains(ByteString.valueOf("cn=schema"))); |
| | | assertTrue(a.contains(ByteString.valueOfUtf8("cn=schema"))); |
| | | } |
| | | } |
| | | |
| | |
| | | Attribute values = provider.getValues(entry, rule); |
| | | assertNotNull(values); |
| | | assertEquals(values.size(), 1); |
| | | assertTrue(values.contains(ByteString.valueOf("cn=schema"))); |
| | | assertTrue(values.contains(ByteString.valueOfUtf8("cn=schema"))); |
| | | } |
| | | |
| | | |
| | |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | assertTrue(provider.hasValue(entry, rule, ByteString.valueOf("cn=schema"))); |
| | | assertTrue(provider.hasValue(entry, rule, ByteString.valueOfUtf8("cn=schema"))); |
| | | } |
| | | |
| | | |
| | |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | assertFalse(provider.hasValue(entry, rule, ByteString.valueOf("cn=not schema"))); |
| | | assertFalse(provider.hasValue(entry, rule, ByteString.valueOfUtf8("cn=not schema"))); |
| | | } |
| | | } |
| | |
| | | new UniqueCharactersPasswordValidator(); |
| | | validator.initializePasswordValidator(configuration); |
| | | |
| | | ByteString password = ByteString.valueOf("password"); |
| | | ByteString password = ByteString.valueOfUtf8("password"); |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("userpassword", "password"))); |
| | |
| | | new UniqueCharactersPasswordValidator(); |
| | | validator.initializePasswordValidator(configuration); |
| | | |
| | | ByteString password = ByteString.valueOf("passw"); |
| | | ByteString password = ByteString.valueOfUtf8("passw"); |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("userpassword", "passw"))); |
| | |
| | | new UniqueCharactersPasswordValidator(); |
| | | validator.initializePasswordValidator(configuration); |
| | | |
| | | ByteString password = ByteString.valueOf("pasSw"); |
| | | ByteString password = ByteString.valueOfUtf8("pasSw"); |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("userpassword", "pasSw"))); |
| | |
| | | new UniqueCharactersPasswordValidator(); |
| | | validator.initializePasswordValidator(configuration); |
| | | |
| | | ByteString password = ByteString.valueOf("pasSw"); |
| | | ByteString password = ByteString.valueOfUtf8("pasSw"); |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("userpassword", "pasSw"))); |
| | |
| | | new UniqueCharactersPasswordValidator(); |
| | | validator.initializePasswordValidator(configuration); |
| | | |
| | | ByteString password = ByteString.valueOf("aaaaaaaa"); |
| | | ByteString password = ByteString.valueOfUtf8("aaaaaaaa"); |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("userpassword", "aaaaaaaa"))); |
| | |
| | | new UniqueCharactersPasswordValidator(); |
| | | validator.initializePasswordValidator(configuration); |
| | | |
| | | ByteString password = ByteString.valueOf("aaaaaaaa"); |
| | | ByteString password = ByteString.valueOfUtf8("aaaaaaaa"); |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("userpassword", "aaaaaaaa"))); |
| | |
| | | |
| | | Attribute attr = attrList.get(0); |
| | | assertEquals(attr.size(), 1); |
| | | assertTrue(attr.contains(ByteString.valueOf(value))); |
| | | assertTrue(attr.contains(ByteString.valueOfUtf8(value))); |
| | | } |
| | | finally |
| | | { |
| | |
| | | |
| | | Attribute attr = attrList.get(0); |
| | | assertEquals(attr.size(), 2); |
| | | assertTrue(attr.contains(ByteString.valueOf(value1))); |
| | | assertTrue(attr.contains(ByteString.valueOf(value2))); |
| | | assertTrue(attr.contains(ByteString.valueOfUtf8(value1))); |
| | | assertTrue(attr.contains(ByteString.valueOfUtf8(value2))); |
| | | } |
| | | finally |
| | | { |
| | |
| | | |
| | | Attribute attr = attrList.get(0); |
| | | assertEquals(attr.size(), 1); |
| | | assertTrue(attr.contains(ByteString.valueOf(realValue))); |
| | | assertTrue(attr.contains(ByteString.valueOfUtf8(realValue))); |
| | | } |
| | | finally |
| | | { |
| | |
| | | |
| | | Attribute attr = attrList.get(0); |
| | | assertEquals(attr.size(), 1); |
| | | assertTrue(attr.contains(ByteString.valueOf(virtualValue))); |
| | | assertTrue(attr.contains(ByteString.valueOfUtf8(virtualValue))); |
| | | } |
| | | finally |
| | | { |
| | |
| | | Attribute a = attrList.get(0); |
| | | assertEquals(a.size(), 2); |
| | | |
| | | assertTrue(a.contains(ByteString.valueOf(realValue))); |
| | | assertTrue(a.contains(ByteString.valueOf(virtualValue))); |
| | | assertTrue(a.contains(ByteString.valueOfUtf8(realValue))); |
| | | assertTrue(a.contains(ByteString.valueOfUtf8(virtualValue))); |
| | | |
| | | } |
| | | finally |
| | |
| | | Attribute a = attrList.get(0); |
| | | assertEquals(a.size(), 2); |
| | | |
| | | assertTrue(a.contains(ByteString.valueOf(realValue))); |
| | | assertTrue(a.contains(ByteString.valueOf(virtualValue))); |
| | | assertTrue(a.contains(ByteString.valueOfUtf8(realValue))); |
| | | assertTrue(a.contains(ByteString.valueOfUtf8(virtualValue))); |
| | | } |
| | | finally |
| | | { |
| | |
| | | assertNotNull(values); |
| | | assertFalse(values.isEmpty()); |
| | | assertTrue(provider.hasValue(entry, rule)); |
| | | assertTrue(provider.hasValue(entry, rule, ByteString.valueOf(u1.toString()))); |
| | | assertFalse(provider.hasValue(entry, rule, ByteString.valueOf(ne.toString()))); |
| | | assertTrue(provider.hasValue(entry, rule, ByteString.valueOfUtf8(u1.toString()))); |
| | | assertFalse(provider.hasValue(entry, rule, ByteString.valueOfUtf8(ne.toString()))); |
| | | assertEquals(provider.matchesSubstring(entry, rule, null, null, null), |
| | | ConditionResult.UNDEFINED); |
| | | assertEquals(provider.greaterThanOrEqualTo(entry, rule, null), |
| | |
| | | assertNotNull(values); |
| | | assertTrue(values.isEmpty()); |
| | | assertFalse(provider.hasValue(entry, rule)); |
| | | assertFalse(provider.hasValue(entry, rule, ByteString.valueOf(u1.toString()))); |
| | | assertFalse(provider.hasValue(entry, rule, ByteString.valueOf(ne.toString()))); |
| | | assertFalse(provider.hasValue(entry, rule, ByteString.valueOfUtf8(u1.toString()))); |
| | | assertFalse(provider.hasValue(entry, rule, ByteString.valueOfUtf8(ne.toString()))); |
| | | assertEquals(provider.matchesSubstring(entry, rule, null, null, null), |
| | | ConditionResult.UNDEFINED); |
| | | assertEquals(provider.greaterThanOrEqualTo(entry, rule, null), |
| | |
| | | |
| | | Attribute a = e.getAttribute(memberType).get(0); |
| | | assertEquals(a.size(), 4); |
| | | assertTrue(a.contains(ByteString.valueOf(u1.toString()))); |
| | | assertTrue(a.contains(ByteString.valueOfUtf8(u1.toString()))); |
| | | |
| | | cleanUp(); |
| | | } |
| | |
| | | Attribute a = e.getAttribute(memberType).get(0); |
| | | assertEquals(a.size(), 1); |
| | | |
| | | ByteString v = ByteString.valueOf(u4.toString()); |
| | | ByteString v = ByteString.valueOfUtf8(u4.toString()); |
| | | assertTrue(a.contains(v)); |
| | | |
| | | LinkedList<Modification> mods = newLinkedList(new Modification(ModificationType.ADD, |
| | |
| | | Attribute a = e.getAttribute(memberType).get(0); |
| | | assertEquals(a.size(), 1); |
| | | |
| | | ByteString v = ByteString.valueOf(u4.toString()); |
| | | ByteString v = ByteString.valueOfUtf8(u4.toString()); |
| | | assertTrue(a.contains(v)); |
| | | |
| | | |
| | |
| | | a = e.getAttribute(memberType).get(0); |
| | | assertEquals(a.size(), 0); |
| | | |
| | | v = ByteString.valueOf(u4.toString()); |
| | | v = ByteString.valueOfUtf8(u4.toString()); |
| | | assertTrue(a.contains(v)); |
| | | |
| | | |
| | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(reader, writer, "localhost", |
| | | nextMessageID); |
| | | authHandler.doSimpleBind(3, ByteString.valueOf("cn=Directory Manager"), |
| | | ByteString.valueOf("password"), |
| | | authHandler.doSimpleBind(3, ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | ByteString.valueOfUtf8("password"), |
| | | new ArrayList<Control>(), |
| | | new ArrayList<Control>()); |
| | | ByteString authzID = authHandler.requestAuthorizationIdentity(); |
| | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(reader, writer, "localhost", |
| | | nextMessageID); |
| | | authHandler.doSimpleBind(3, ByteString.valueOf("uid=test.user,o=test"), |
| | | ByteString.valueOf("password"), |
| | | authHandler.doSimpleBind(3, ByteString.valueOfUtf8("uid=test.user,o=test"), |
| | | ByteString.valueOfUtf8("password"), |
| | | new ArrayList<Control>(), |
| | | new ArrayList<Control>()); |
| | | ByteString authzID = authHandler.requestAuthorizationIdentity(); |
| | |
| | | saslProperties.put("authzID", newArrayList("dn:uid=test.user,o=test")); |
| | | |
| | | authHandler.doSASLPlain(ByteString.empty(), |
| | | ByteString.valueOf("password"), saslProperties, |
| | | ByteString.valueOfUtf8("password"), saslProperties, |
| | | new ArrayList<Control>(), |
| | | new ArrayList<Control>()); |
| | | ByteString authzID = authHandler.requestAuthorizationIdentity(); |
| | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(reader, writer, "localhost", |
| | | nextMessageID); |
| | | authHandler.doSimpleBind(3, ByteString.valueOf("uid=proxy.user,o=test"), |
| | | ByteString.valueOf("password"), |
| | | authHandler.doSimpleBind(3, ByteString.valueOfUtf8("uid=proxy.user,o=test"), |
| | | ByteString.valueOfUtf8("password"), |
| | | new ArrayList<Control>(), |
| | | new ArrayList<Control>()); |
| | | ByteString authzID = authHandler.requestAuthorizationIdentity(); |
| | |
| | | new ExtendedRequestProtocolOp(OID_WHO_AM_I_REQUEST); |
| | | ArrayList<Control> requestControls = new ArrayList<>(1); |
| | | requestControls.add(new ProxiedAuthV2Control( |
| | | ByteString.valueOf("dn:uid=test.user,o=test"))); |
| | | ByteString.valueOfUtf8("dn:uid=test.user,o=test"))); |
| | | LDAPMessage message = new LDAPMessage(nextMessageID.getAndIncrement(), |
| | | extendedRequest, requestControls); |
| | | writer.writeMessage(message); |
| | |
| | | new LDAPAuthenticationHandler(reader, writer, "localhost", |
| | | nextMessageID); |
| | | authHandler.doSimpleBind(3, |
| | | ByteString.valueOf("uid=cantproxy.user,o=test"), |
| | | ByteString.valueOf("password"), |
| | | ByteString.valueOfUtf8("uid=cantproxy.user,o=test"), |
| | | ByteString.valueOfUtf8("password"), |
| | | new ArrayList<Control>(), |
| | | new ArrayList<Control>()); |
| | | ByteString authzID = authHandler.requestAuthorizationIdentity(); |
| | |
| | | new ExtendedRequestProtocolOp(OID_WHO_AM_I_REQUEST); |
| | | ArrayList<Control> requestControls = new ArrayList<>(1); |
| | | requestControls.add(new ProxiedAuthV2Control( |
| | | ByteString.valueOf("dn:uid=test.user,o=test"))); |
| | | ByteString.valueOfUtf8("dn:uid=test.user,o=test"))); |
| | | LDAPMessage message = new LDAPMessage(nextMessageID.getAndIncrement(), |
| | | extendedRequest, requestControls); |
| | | writer.writeMessage(message); |
| | |
| | | * sn: Surname |
| | | */ |
| | | ArrayList<ByteString> values = new ArrayList<>(); |
| | | values.add(ByteString.valueOf("top")); |
| | | values.add(ByteString.valueOf("person")); |
| | | values.add(ByteString.valueOf("organizationalperson")); |
| | | values.add(ByteString.valueOf("inetorgperson")); |
| | | values.add(ByteString.valueOfUtf8("top")); |
| | | values.add(ByteString.valueOfUtf8("person")); |
| | | values.add(ByteString.valueOfUtf8("organizationalperson")); |
| | | values.add(ByteString.valueOfUtf8("inetorgperson")); |
| | | |
| | | List<RawAttribute> rawAttributes = new ArrayList<>(); |
| | | rawAttributes.add(RawAttribute.create("objectClass", values)); |
| | |
| | | 1, |
| | | 1, |
| | | null, |
| | | ByteString.valueOf("dn: uid=test,dc=example,dc=com"), |
| | | ByteString.valueOfUtf8("dn: uid=test,dc=example,dc=com"), |
| | | rawAttributes); |
| | | |
| | | /* Process the operation. The processing should continue. */ |
| | |
| | | */ |
| | | |
| | | ArrayList<ByteString> values = new ArrayList<>(); |
| | | values.add(ByteString.valueOf("top")); |
| | | values.add(ByteString.valueOf("person")); |
| | | values.add(ByteString.valueOf("organizationalperson")); |
| | | values.add(ByteString.valueOf("inetorgperson")); |
| | | values.add(ByteString.valueOfUtf8("top")); |
| | | values.add(ByteString.valueOfUtf8("person")); |
| | | values.add(ByteString.valueOfUtf8("organizationalperson")); |
| | | values.add(ByteString.valueOfUtf8("inetorgperson")); |
| | | |
| | | List<RawAttribute> rawAttributes = new ArrayList<>(); |
| | | |
| | |
| | | 1, |
| | | 1, |
| | | null, |
| | | ByteString.valueOf("dn: uid=test,dc=example,dc=com"), |
| | | ByteString.valueOfUtf8("dn: uid=test,dc=example,dc=com"), |
| | | rawAttributes); |
| | | |
| | | /* Process the operation and expect the server to continue |
| | |
| | | 1, |
| | | 1, |
| | | null, |
| | | ByteString.valueOf("dn: uid=test,dc=example,dc=com"), |
| | | ByteString.valueOfUtf8("dn: uid=test,dc=example,dc=com"), |
| | | rawMods); |
| | | |
| | | /* Process the request. The result should be SUCCESS and the server |
| | |
| | | 1, |
| | | 1, |
| | | null, |
| | | ByteString.valueOf("dn: uid=test,dc=example,dc=com"), |
| | | ByteString.valueOfUtf8("dn: uid=test,dc=example,dc=com"), |
| | | rawMods); |
| | | |
| | | /* Process the MODIFY operation making sure the remaining number of |
| | |
| | | 1, |
| | | 1, |
| | | null, |
| | | ByteString.valueOf("dn: uid=test,dc=example,dc=com"), |
| | | ByteString.valueOfUtf8("dn: uid=test,dc=example,dc=com"), |
| | | rawMods); |
| | | |
| | | /* Process the MODIFY operation. */ |
| | |
| | | InternalSearchOperation operation = getRootConnection().processSearch(request); |
| | | for (SearchResultEntry entry : operation.getSearchEntries()) { |
| | | for(String dn : dns) { |
| | | ByteString value = ByteString.valueOf(dn); |
| | | ByteString value = ByteString.valueOfUtf8(dn); |
| | | assertEquals(entry.hasValue(type, null, value), expected); |
| | | } |
| | | } |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | ByteString dn = ByteString.valueOf("cn=test,o=test"); |
| | | ByteString dn = ByteString.valueOfUtf8("cn=test,o=test"); |
| | | |
| | | ArrayList<RawAttribute> attrs = new ArrayList<>(); |
| | | attrs.add(new LDAPAttribute("objectClass", newArrayList("top", "device"))); |
| | |
| | | { |
| | | InternalClientConnection conn = getRootConnection(); |
| | | BindOperation bindOperation = |
| | | conn.processSimpleBind(ByteString.valueOf("cn=Directory Manager"), |
| | | ByteString.valueOf("password")); |
| | | conn.processSimpleBind(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | ByteString.valueOfUtf8("password")); |
| | | assertEquals(bindOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | BindOperation bindOperation = |
| | | conn.processSimpleBind(DN.valueOf("cn=Directory Manager"), |
| | | ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("password")); |
| | | assertEquals(bindOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | throws Exception |
| | | { |
| | | ByteString creds = |
| | | ByteString.valueOf("\u0000dn:cn=Directory Manager\u0000password"); |
| | | ByteString.valueOfUtf8("\u0000dn:cn=Directory Manager\u0000password"); |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | BindOperation bindOperation = |
| | |
| | | throws Exception |
| | | { |
| | | ByteString creds = |
| | | ByteString.valueOf("\u0000dn:cn=Directory Manager\u0000password"); |
| | | ByteString.valueOfUtf8("\u0000dn:cn=Directory Manager\u0000password"); |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | BindOperation bindOperation = |
| | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | CompareOperation compareOperation = |
| | | conn.processCompare(ByteString.valueOf("cn=test,o=test"), "cn", |
| | | ByteString.valueOf("test")); |
| | | conn.processCompare(ByteString.valueOfUtf8("cn=test,o=test"), "cn", |
| | | ByteString.valueOfUtf8("test")); |
| | | assertEquals(compareOperation.getResultCode(), ResultCode.COMPARE_TRUE); |
| | | } |
| | | |
| | |
| | | CompareOperation compareOperation = |
| | | conn.processCompare(DN.valueOf("cn=test,o=test"), |
| | | DirectoryServer.getAttributeTypeOrDefault("cn"), |
| | | ByteString.valueOf("test")); |
| | | ByteString.valueOfUtf8("test")); |
| | | assertEquals(compareOperation.getResultCode(), ResultCode.COMPARE_TRUE); |
| | | } |
| | | |
| | |
| | | "cn: test"); |
| | | |
| | | DeleteOperation deleteOperation = |
| | | getRootConnection().processDelete(ByteString.valueOf("cn=test,o=test")); |
| | | getRootConnection().processDelete(ByteString.valueOfUtf8("cn=test,o=test")); |
| | | assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(ByteString.valueOf("cn=test,o=test"), mods); |
| | | conn.processModify(ByteString.valueOfUtf8("cn=test,o=test"), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | ModifyDNOperation modifyDNOperation = |
| | | conn.processModifyDN(ByteString.valueOf("cn=test,o=test"), |
| | | ByteString.valueOf("cn=test2"), true); |
| | | conn.processModifyDN(ByteString.valueOfUtf8("cn=test,o=test"), |
| | | ByteString.valueOfUtf8("cn=test2"), true); |
| | | assertEquals(modifyDNOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | ModifyDNOperation modifyDNOperation = |
| | | conn.processModifyDN(ByteString.valueOf("cn=test,o=test"), |
| | | ByteString.valueOf("cn=test2"), true, |
| | | ByteString.valueOf("dc=example,dc=com")); |
| | | conn.processModifyDN(ByteString.valueOfUtf8("cn=test,o=test"), |
| | | ByteString.valueOfUtf8("cn=test2"), true, |
| | | ByteString.valueOfUtf8("dc=example,dc=com")); |
| | | assertEquals(modifyDNOperation.getResultCode(), |
| | | ResultCode.UNWILLING_TO_PERFORM); |
| | | } |
| | |
| | | LDAPWriter writer = new LDAPWriter(socket); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | writer.writeMessage(message); |
| | | |
| | |
| | | attrList.add(RawAttribute.create("o", "test")); |
| | | |
| | | AddRequestProtocolOp addRequest = |
| | | new AddRequestProtocolOp(ByteString.valueOf("o=test"), attrList); |
| | | new AddRequestProtocolOp(ByteString.valueOfUtf8("o=test"), attrList); |
| | | writer.writeMessage(new LDAPMessage(2, addRequest)); |
| | | |
| | | message = reader.readMessage(); |
| | |
| | | LDAPWriter writer = new LDAPWriter(socket); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | writer.writeMessage(message); |
| | | |
| | |
| | | |
| | | |
| | | CompareRequestProtocolOp compareRequest = |
| | | new CompareRequestProtocolOp(ByteString.valueOf("o=test"), "o", |
| | | ByteString.valueOf("test")); |
| | | new CompareRequestProtocolOp(ByteString.valueOfUtf8("o=test"), "o", |
| | | ByteString.valueOfUtf8("test")); |
| | | writer.writeMessage(new LDAPMessage(2, compareRequest)); |
| | | |
| | | message = reader.readMessage(); |
| | |
| | | LDAPWriter writer = new LDAPWriter(socket); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | writer.writeMessage(message); |
| | | |
| | |
| | | |
| | | |
| | | DeleteRequestProtocolOp deleteRequest = |
| | | new DeleteRequestProtocolOp(ByteString.valueOf("o=test")); |
| | | new DeleteRequestProtocolOp(ByteString.valueOfUtf8("o=test")); |
| | | writer.writeMessage(new LDAPMessage(2, deleteRequest)); |
| | | |
| | | message = reader.readMessage(); |
| | |
| | | LDAPWriter writer = new LDAPWriter(socket); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | writer.writeMessage(message); |
| | | |
| | |
| | | LDAPWriter writer = new LDAPWriter(socket); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | writer.writeMessage(message); |
| | | |
| | |
| | | mods.add(RawModification.create(ModificationType.REPLACE, "description", "foo")); |
| | | |
| | | ModifyRequestProtocolOp modifyRequest = |
| | | new ModifyRequestProtocolOp(ByteString.valueOf("o=test"), mods); |
| | | new ModifyRequestProtocolOp(ByteString.valueOfUtf8("o=test"), mods); |
| | | writer.writeMessage(new LDAPMessage(2, modifyRequest)); |
| | | |
| | | message = reader.readMessage(); |
| | |
| | | LDAPWriter writer = new LDAPWriter(socket); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | writer.writeMessage(message); |
| | | |
| | |
| | | |
| | | |
| | | ModifyDNRequestProtocolOp modifyDNRequest = |
| | | new ModifyDNRequestProtocolOp(ByteString.valueOf("ou=People,o=test"), |
| | | ByteString.valueOf("ou=Users"), true); |
| | | new ModifyDNRequestProtocolOp(ByteString.valueOfUtf8("ou=People,o=test"), |
| | | ByteString.valueOfUtf8("ou=Users"), true); |
| | | writer.writeMessage(new LDAPMessage(2, modifyDNRequest)); |
| | | |
| | | message = reader.readMessage(); |
| | |
| | | LDAPWriter writer = new LDAPWriter(socket); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | writer.writeMessage(message); |
| | | |
| | |
| | | |
| | | |
| | | SearchRequestProtocolOp searchRequest = |
| | | new SearchRequestProtocolOp(ByteString.valueOf("o=test"), |
| | | new SearchRequestProtocolOp(ByteString.valueOfUtf8("o=test"), |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | 0, 0, false, |
| | |
| | | CompareOperationBasis compareOp = new CompareOperationBasis( |
| | | conn, conn.nextOperationID(), conn.nextMessageID(), controls, |
| | | targetDN, DirectoryServer.getAttributeTypeOrDefault("cn"), |
| | | ByteString.valueOf("PWReset Target")); |
| | | ByteString.valueOfUtf8("PWReset Target")); |
| | | assertSuccess(hasProxyPrivilege, compareOp); |
| | | |
| | | // Test a search operation against the PWReset Target user. |
| | |
| | | |
| | | ArrayList<Control> controls = new ArrayList<>(1); |
| | | controls.add(new ProxiedAuthV2Control( |
| | | ByteString.valueOf("dn:cn=PWReset Target,o=test"))); |
| | | ByteString.valueOfUtf8("dn:cn=PWReset Target,o=test"))); |
| | | |
| | | // Try to add the entry. If this fails with the proxy control, then add it |
| | | // with a root connection so we can do other things with it. |
| | |
| | | |
| | | DN targetDN = DN.valueOf("cn=PWReset Target,o=test"); |
| | | ArrayList<Control> controls = new ArrayList<>(1); |
| | | controls.add(new ProxiedAuthV2Control(ByteString.valueOf("dn:" + targetDN))); |
| | | controls.add(new ProxiedAuthV2Control(ByteString.valueOfUtf8("dn:" + targetDN))); |
| | | |
| | | // Test a compare operation against the PWReset Target user. |
| | | CompareOperationBasis compareOp = new CompareOperationBasis( |
| | | conn, conn.nextOperationID(), conn.nextMessageID(), controls, |
| | | targetDN, DirectoryServer.getAttributeTypeOrDefault("cn"), |
| | | ByteString.valueOf("PWReset Target")); |
| | | ByteString.valueOfUtf8("PWReset Target")); |
| | | assertSuccess(hasProxyPrivilege, compareOp); |
| | | |
| | | // Test a search operation against the PWReset Target user. |
| | |
| | | { |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp( |
| | | ByteString.valueOf("cn=Directory Manager"), 2, |
| | | ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("cn=Directory Manager"), 2, |
| | | ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | ByteString.wrap(Base64.decode(CERT)))); |
| | | |
| | | AddRequestProtocolOp addRequest = |
| | | new AddRequestProtocolOp(ByteString.valueOf("uid=user.7,o=test"), |
| | | new AddRequestProtocolOp(ByteString.valueOfUtf8("uid=user.7,o=test"), |
| | | addAttrs); |
| | | message = new LDAPMessage(2, addRequest); |
| | | w.writeMessage(message); |
| | |
| | | attrs.add("sn"); |
| | | attrs.add("userCertificate;binary"); |
| | | SearchRequestProtocolOp searchRequest = |
| | | new SearchRequestProtocolOp(ByteString.valueOf("o=test"), |
| | | new SearchRequestProtocolOp(ByteString.valueOfUtf8("o=test"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, 0, |
| | | 0, false, |
| | |
| | | { |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp( |
| | | ByteString.valueOf("cn=Directory Manager"), 2, |
| | | ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("cn=Directory Manager"), 2, |
| | | ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | { |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp( |
| | | ByteString.valueOf("cn=Directory Manager"), 2, |
| | | ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("cn=Directory Manager"), 2, |
| | | ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | { |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp( |
| | | ByteString.valueOf("cn=Directory Manager"), 2, |
| | | ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("cn=Directory Manager"), 2, |
| | | ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | addAttrs.add(RawAttribute.create("ou", "People")); |
| | | |
| | | AddRequestProtocolOp addRequest = |
| | | new AddRequestProtocolOp(ByteString.valueOf("ou=People,o=test"), addAttrs); |
| | | new AddRequestProtocolOp(ByteString.valueOfUtf8("ou=People,o=test"), addAttrs); |
| | | ArrayList<Control> controls = new ArrayList<>(1); |
| | | controls.add(new LDAPControl(OID_MANAGE_DSAIT_CONTROL, true)); |
| | | message = new LDAPMessage(2, addRequest, controls); |
| | |
| | | { |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp( |
| | | ByteString.valueOf("cn=Directory Manager"), 2, |
| | | ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("cn=Directory Manager"), 2, |
| | | ByteString.valueOfUtf8("password")); |
| | | ArrayList<Control> controls = new ArrayList<>(1); |
| | | controls.add(new LDAPControl(OID_MANAGE_DSAIT_CONTROL, true)); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest, controls); |
| | |
| | | { |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp( |
| | | ByteString.valueOf("cn=Directory Manager"), 2, |
| | | ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("cn=Directory Manager"), 2, |
| | | ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | assertEquals(bindResponse.getResultCode(), 0); |
| | | |
| | | CompareRequestProtocolOp compareRequest = |
| | | new CompareRequestProtocolOp(ByteString.valueOf("o=test"), |
| | | "o", ByteString.valueOf("test")); |
| | | new CompareRequestProtocolOp(ByteString.valueOfUtf8("o=test"), |
| | | "o", ByteString.valueOfUtf8("test")); |
| | | ArrayList<Control> controls = new ArrayList<>(1); |
| | | controls.add(new LDAPControl(OID_MANAGE_DSAIT_CONTROL, true)); |
| | | message = new LDAPMessage(2, compareRequest, controls); |
| | |
| | | { |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp( |
| | | ByteString.valueOf("cn=Directory Manager"), 2, |
| | | ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("cn=Directory Manager"), 2, |
| | | ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | assertEquals(bindResponse.getResultCode(), 0); |
| | | |
| | | DeleteRequestProtocolOp deleteRequest = |
| | | new DeleteRequestProtocolOp(ByteString.valueOf("o=test")); |
| | | new DeleteRequestProtocolOp(ByteString.valueOfUtf8("o=test")); |
| | | ArrayList<Control> controls = new ArrayList<>(1); |
| | | controls.add(new LDAPControl(OID_MANAGE_DSAIT_CONTROL, true)); |
| | | message = new LDAPMessage(2, deleteRequest, controls); |
| | |
| | | { |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp( |
| | | ByteString.valueOf("cn=Directory Manager"), 2, |
| | | ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("cn=Directory Manager"), 2, |
| | | ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | mods.add(RawModification.create(ModificationType.REPLACE, "description", "foo")); |
| | | |
| | | ModifyRequestProtocolOp modifyRequest = |
| | | new ModifyRequestProtocolOp(ByteString.valueOf("o=test"), mods); |
| | | new ModifyRequestProtocolOp(ByteString.valueOfUtf8("o=test"), mods); |
| | | ArrayList<Control> controls = new ArrayList<>(1); |
| | | controls.add(new LDAPControl(OID_MANAGE_DSAIT_CONTROL, true)); |
| | | message = new LDAPMessage(2, modifyRequest, controls); |
| | |
| | | { |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp( |
| | | ByteString.valueOf("cn=Directory Manager"), 2, |
| | | ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("cn=Directory Manager"), 2, |
| | | ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | assertEquals(bindResponse.getResultCode(), 0); |
| | | |
| | | ModifyDNRequestProtocolOp modifyDNRequest = |
| | | new ModifyDNRequestProtocolOp(ByteString.valueOf("o=test"), |
| | | ByteString.valueOf("cn=test"), false); |
| | | new ModifyDNRequestProtocolOp(ByteString.valueOfUtf8("o=test"), |
| | | ByteString.valueOfUtf8("cn=test"), false); |
| | | ArrayList<Control> controls = new ArrayList<>(1); |
| | | controls.add(new LDAPControl(OID_MANAGE_DSAIT_CONTROL, true)); |
| | | message = new LDAPMessage(2, modifyDNRequest, controls); |
| | |
| | | { |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp( |
| | | ByteString.valueOf("cn=Directory Manager"), 2, |
| | | ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("cn=Directory Manager"), 2, |
| | | ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | /** The protocol op type for add responses. */ |
| | | private static final byte OP_TYPE_ADD_RESPONSE = 0x69; |
| | | /** The DN for add requests in this test case. */ |
| | | private static final ByteString dn = ByteString.valueOf("dc=example,dc=com"); |
| | | private static final ByteString dn = ByteString.valueOfUtf8("dc=example,dc=com"); |
| | | |
| | | /** |
| | | * Generate attributes for use in test cases. Attributes will have names |
| | |
| | | List<RawAttribute> attributes = |
| | | generateAttributes(numAttributes, numValues, " test"); |
| | | |
| | | ByteString dnNeedsBase64 = ByteString.valueOf("dc=example,dc=com "); |
| | | ByteString dnNeedsBase64 = ByteString.valueOfUtf8("dc=example,dc=com "); |
| | | |
| | | AddRequestProtocolOp addRequest = |
| | | new AddRequestProtocolOp(dnNeedsBase64, attributes); |
| | |
| | | |
| | | //Setup the DN to use in the response tests. |
| | | AttributeType attribute = DirectoryServer.getAttributeTypeOrDefault("testAttribute"); |
| | | ByteString attributeValue = ByteString.valueOf("testValue"); |
| | | ByteString attributeValue = ByteString.valueOfUtf8("testValue"); |
| | | dn = new DN(new RDN[] { RDN.create(attribute, attributeValue) }); |
| | | } |
| | | |
| | |
| | | ASN1Writer simpleWriter = ASN1.getWriter(simpleBuilder); |
| | | ByteStringBuilder saslBuilder = new ByteStringBuilder(); |
| | | ASN1Writer saslWriter = ASN1.getWriter(saslBuilder); |
| | | ByteString bindDn=ByteString.valueOf(dn); |
| | | ByteString pw=ByteString.valueOf(pwd); |
| | | ByteString bindDn=ByteString.valueOfUtf8(dn); |
| | | ByteString pw=ByteString.valueOfUtf8(pwd); |
| | | BindRequestProtocolOp simple = |
| | | new BindRequestProtocolOp(bindDn, 3, pw); |
| | | BindRequestProtocolOp sasl = |
| | |
| | | @Test |
| | | public void testBindRequestToString() throws Exception |
| | | { |
| | | ByteString bindDn=ByteString.valueOf(dn); |
| | | ByteString pw=ByteString.valueOf(pwd); |
| | | ByteString bindDn=ByteString.valueOfUtf8(dn); |
| | | ByteString pw=ByteString.valueOfUtf8(pwd); |
| | | BindRequestProtocolOp sasl = |
| | | new BindRequestProtocolOp(bindDn, SASL_MECHANISM_PLAIN, pw); |
| | | StringBuilder sb = new StringBuilder(); |
| | |
| | | referralURLs.add(url); |
| | | DN responseDn = DN.valueOf(dn); |
| | | ByteString serverSASLCredentials = |
| | | ByteString.valueOf(saslCreds); |
| | | ByteString.valueOfUtf8(saslCreds); |
| | | BindResponseProtocolOp r = |
| | | new BindResponseProtocolOp(okCode.intValue(), |
| | | message, responseDn, referralURLs, |
| | |
| | | public void testBindResponseBadReferral() throws Exception { |
| | | DN responseDn = DN.valueOf(dn); |
| | | ByteString serverSASLCredentials = |
| | | ByteString.valueOf(saslCreds); |
| | | ByteString.valueOfUtf8(saslCreds); |
| | | |
| | | ByteStringBuilder bsb = new ByteStringBuilder(); |
| | | ASN1Writer writer = ASN1.getWriter(bsb); |
| | |
| | | referralURLs.add(url); |
| | | DN responseDn = DN.valueOf(dn); |
| | | ByteString serverSASLCredentials = |
| | | ByteString.valueOf(saslCreds); |
| | | ByteString.valueOfUtf8(saslCreds); |
| | | |
| | | BindResponseProtocolOp saslOkResp = |
| | | new BindResponseProtocolOp(okCode.intValue(), |
| | |
| | | |
| | | /** The DN for compare requests in this test case. */ |
| | | private static final ByteString dn = |
| | | ByteString.valueOf("dc=example,dc=com"); |
| | | ByteString.valueOfUtf8("dc=example,dc=com"); |
| | | |
| | | /** The assertion value for this compare request. */ |
| | | private ByteString assertionValue = ByteString.valueOf("=test"); |
| | | private ByteString assertionValue = ByteString.valueOfUtf8("=test"); |
| | | |
| | | /** The attribute type for this compare request. */ |
| | | private String attributeType = "testAttribute"; |
| | |
| | | |
| | | //Setup the DN to use in the response tests. |
| | | AttributeType attribute = DirectoryServer.getAttributeTypeOrDefault("testAttribute"); |
| | | ByteString attributeValue = ByteString.valueOf("testValue"); |
| | | ByteString attributeValue = ByteString.valueOfUtf8("testValue"); |
| | | dn = new DN(new RDN[] { RDN.create(attribute, attributeValue) }); |
| | | } |
| | | |
| | |
| | | * The DN for delete requests in this test case. |
| | | */ |
| | | private static final ByteString dn = |
| | | ByteString.valueOf("dc=example,dc=com"); |
| | | ByteString.valueOfUtf8("dc=example,dc=com"); |
| | | |
| | | /** |
| | | * The alternative DN for delete requests in this test case. |
| | | */ |
| | | private static final ByteString dnAlt = |
| | | ByteString.valueOf("dc=sun,dc=com"); |
| | | ByteString.valueOfUtf8("dc=sun,dc=com"); |
| | | |
| | | /** |
| | | * Test the constructors to make sure the right objects are constructed. |
| | |
| | | |
| | | //Setup the DN to use in the response tests. |
| | | AttributeType attribute = DirectoryServer.getAttributeTypeOrDefault("testAttribute"); |
| | | ByteString attributeValue = ByteString.valueOf("testValue"); |
| | | ByteString attributeValue = ByteString.valueOfUtf8("testValue"); |
| | | dn = new DN(new RDN[] { RDN.create(attribute, attributeValue) }); |
| | | } |
| | | |
| | |
| | | public Object[][] getFilterStrings() throws Exception |
| | | { |
| | | LDAPFilter equal = LDAPFilter.createEqualityFilter("objectClass", |
| | | ByteString.valueOf("\\test*(Value)")); |
| | | ByteString.valueOfUtf8("\\test*(Value)")); |
| | | LDAPFilter equal2 = LDAPFilter.createEqualityFilter("objectClass", |
| | | ByteString.valueOf("")); |
| | | ByteString.valueOfUtf8("")); |
| | | LDAPFilter approx = LDAPFilter.createApproximateFilter("sn", |
| | | ByteString.valueOf("\\test*(Value)")); |
| | | ByteString.valueOfUtf8("\\test*(Value)")); |
| | | LDAPFilter greater = LDAPFilter.createGreaterOrEqualFilter("employeeNumber", |
| | | ByteString.valueOf("\\test*(Value)")); |
| | | ByteString.valueOfUtf8("\\test*(Value)")); |
| | | LDAPFilter less = LDAPFilter.createLessOrEqualFilter("dob", |
| | | ByteString.valueOf("\\test*(Value)")); |
| | | ByteString.valueOfUtf8("\\test*(Value)")); |
| | | LDAPFilter presense = LDAPFilter.createPresenceFilter("login"); |
| | | |
| | | ArrayList<ByteString> any = new ArrayList<>(0); |
| | | ArrayList<ByteString> multiAny = newArrayList(ByteString.valueOf("\\wid*(get)"), ByteString.valueOf("*")); |
| | | ArrayList<ByteString> multiAny = newArrayList(ByteString.valueOfUtf8("\\wid*(get)"), ByteString.valueOfUtf8("*")); |
| | | |
| | | LDAPFilter substring1 = LDAPFilter.createSubstringFilter("givenName", |
| | | ByteString.valueOf("\\Jo*()"), |
| | | ByteString.valueOfUtf8("\\Jo*()"), |
| | | any, |
| | | ByteString.valueOf("\\n*()")); |
| | | ByteString.valueOfUtf8("\\n*()")); |
| | | LDAPFilter substring2 = LDAPFilter.createSubstringFilter("givenName", |
| | | ByteString.valueOf("\\Jo*()"), |
| | | ByteString.valueOfUtf8("\\Jo*()"), |
| | | multiAny, |
| | | ByteString.valueOf("\\n*()")); |
| | | ByteString.valueOfUtf8("\\n*()")); |
| | | LDAPFilter substring3 = LDAPFilter.createSubstringFilter("givenName", |
| | | ByteString.valueOf(""), |
| | | ByteString.valueOfUtf8(""), |
| | | any, |
| | | ByteString.valueOf("\\n*()")); |
| | | ByteString.valueOfUtf8("\\n*()")); |
| | | LDAPFilter substring4 = LDAPFilter.createSubstringFilter("givenName", |
| | | ByteString.valueOf("\\Jo*()"), |
| | | ByteString.valueOfUtf8("\\Jo*()"), |
| | | any, |
| | | ByteString.valueOf("")); |
| | | ByteString.valueOfUtf8("")); |
| | | LDAPFilter substring5 = LDAPFilter.createSubstringFilter("givenName", |
| | | ByteString.valueOf(""), |
| | | ByteString.valueOfUtf8(""), |
| | | multiAny, |
| | | ByteString.valueOf("")); |
| | | ByteString.valueOfUtf8("")); |
| | | LDAPFilter extensible1 = LDAPFilter.createExtensibleFilter("2.4.6.8.19", |
| | | "cn", |
| | | ByteString.valueOf("\\John* (Doe)"), |
| | | ByteString.valueOfUtf8("\\John* (Doe)"), |
| | | false); |
| | | LDAPFilter extensible2 = LDAPFilter.createExtensibleFilter("2.4.6.8.19", |
| | | "cn", |
| | | ByteString.valueOf("\\John* (Doe)"), |
| | | ByteString.valueOfUtf8("\\John* (Doe)"), |
| | | true); |
| | | LDAPFilter extensible3 = LDAPFilter.createExtensibleFilter("2.4.6.8.19", |
| | | null, |
| | | ByteString.valueOf("\\John* (Doe)"), |
| | | ByteString.valueOfUtf8("\\John* (Doe)"), |
| | | true); |
| | | LDAPFilter extensible4 = LDAPFilter.createExtensibleFilter(null, |
| | | "cn", |
| | | ByteString.valueOf("\\John* (Doe)"), |
| | | ByteString.valueOfUtf8("\\John* (Doe)"), |
| | | true); |
| | | LDAPFilter extensible5 = LDAPFilter.createExtensibleFilter("2.4.6.8.19", |
| | | null, |
| | | ByteString.valueOf("\\John* (Doe)"), |
| | | ByteString.valueOfUtf8("\\John* (Doe)"), |
| | | false); |
| | | |
| | | ArrayList<RawFilter> list1 = new ArrayList<>(); |
| | |
| | | { |
| | | "(ds-sync-conflict=uid=\\5c+3904211775265,ou=SharedAddressBook,cn=1038372,dc=cab)", |
| | | LDAPFilter.createEqualityFilter("ds-sync-conflict", |
| | | ByteString.valueOf("uid=\\+3904211775265,ou=SharedAddressBook,cn=1038372,dc=cab")) }, |
| | | ByteString.valueOfUtf8("uid=\\+3904211775265,ou=SharedAddressBook,cn=1038372,dc=cab")) }, |
| | | |
| | | // OPENDJ-735 |
| | | { "(&)", LDAPFilter.createANDFilter(new ArrayList<RawFilter>()) }, |
| | |
| | | * The DN for modify DN requests in this test case. |
| | | */ |
| | | private static final ByteString dn = |
| | | ByteString.valueOf("dc=example,dc=com"); |
| | | ByteString.valueOfUtf8("dc=example,dc=com"); |
| | | |
| | | /** |
| | | * The alt DN for modify DN requests in this test case. |
| | | */ |
| | | private static final ByteString altDn = |
| | | ByteString.valueOf("dc=alt,dc=example,dc=com"); |
| | | ByteString.valueOfUtf8("dc=alt,dc=example,dc=com"); |
| | | |
| | | /** |
| | | * The new DN for modify DN requests in this test case. |
| | | */ |
| | | private static final ByteString newRdn = |
| | | ByteString.valueOf("dc=example-new"); |
| | | ByteString.valueOfUtf8("dc=example-new"); |
| | | |
| | | /** |
| | | * The alt new DN for modify DN requests in this test case. |
| | | */ |
| | | private static final ByteString altNewRdn = |
| | | ByteString.valueOf("ou=alt,dc=example-new"); |
| | | ByteString.valueOfUtf8("ou=alt,dc=example-new"); |
| | | |
| | | /** |
| | | * The new superiour DN for modify DN requests in this test case. |
| | | */ |
| | | private static final ByteString newSuperiorDn = |
| | | ByteString.valueOf("dc=widget,dc=com"); |
| | | ByteString.valueOfUtf8("dc=widget,dc=com"); |
| | | |
| | | /** |
| | | * The alt new superiour DN for modify DN requests in this test case. |
| | | */ |
| | | private static final ByteString altNewSuperiorDn = |
| | | ByteString.valueOf("dc=alt,dc=widget,dc=com"); |
| | | ByteString.valueOfUtf8("dc=alt,dc=widget,dc=com"); |
| | | |
| | | /** |
| | | * Test to make sure the class processes the right LDAP op type. |
| | |
| | | |
| | | //Setup the DN to use in the response tests. |
| | | AttributeType attribute = DirectoryServer.getAttributeTypeOrDefault("testAttribute"); |
| | | ByteString attributeValue = ByteString.valueOf("testValue"); |
| | | ByteString attributeValue = ByteString.valueOfUtf8("testValue"); |
| | | dn = new DN(new RDN[] { RDN.create(attribute, attributeValue) }); |
| | | } |
| | | |
| | |
| | | * The DN for modify requests in this test case. |
| | | */ |
| | | private static final ByteString dn = |
| | | ByteString.valueOf("dc=example,dc=com"); |
| | | ByteString.valueOfUtf8("dc=example,dc=com"); |
| | | |
| | | /** |
| | | * The alternative DN for add requests in this test case. |
| | | */ |
| | | private static final ByteString dnAlt = |
| | | ByteString.valueOf("dc=sun,dc=com"); |
| | | ByteString.valueOfUtf8("dc=sun,dc=com"); |
| | | |
| | | /** |
| | | * Generate modifications for use in test cases. Attributes will have names |
| | |
| | | |
| | | //Setup the DN to use in the response tests. |
| | | AttributeType attribute = DirectoryServer.getAttributeTypeOrDefault("testAttribute"); |
| | | ByteString attributeValue = ByteString.valueOf("testValue"); |
| | | ByteString attributeValue = ByteString.valueOfUtf8("testValue"); |
| | | dn = new DN(new RDN[] { RDN.create(attribute, attributeValue) }); |
| | | } |
| | | |
| | |
| | | @SuppressWarnings("javadoc") |
| | | public class TestSearchProtocolOp extends LdapTestCase |
| | | { |
| | | private ByteString baseDN = ByteString.valueOf("dc=example,dc=COM"); |
| | | private ByteString baseDN = ByteString.valueOfUtf8("dc=example,dc=COM"); |
| | | private SearchScope scope = SearchScope.WHOLE_SUBTREE; |
| | | private DereferenceAliasesPolicy dereferencePolicy = |
| | | DereferenceAliasesPolicy.IN_SEARCHING; |
| | |
| | | List<Attribute> attrList = newEntry.getAttribute(attrTypeStr); |
| | | Assertions.assertThat(attrList).isNotEmpty(); |
| | | Attribute attr = attrList.get(0); |
| | | boolean foundAttributeValue = attr.contains(ByteString.valueOf(valueString)); |
| | | boolean foundAttributeValue = attr.contains(ByteString.valueOfUtf8(valueString)); |
| | | assertEquals(foundAttributeValue, expectedAttributeValueFound, foundMsg); |
| | | return null; |
| | | } |
| | |
| | | @DataProvider(name = "attrInfo") |
| | | public Object[][] createData() |
| | | { |
| | | ByteString att1 = ByteString.valueOf("string"); |
| | | ByteString att2 = ByteString.valueOf("value"); |
| | | ByteString att3 = ByteString.valueOf("again"); |
| | | ByteString att1 = ByteString.valueOfUtf8("string"); |
| | | ByteString att2 = ByteString.valueOfUtf8("value"); |
| | | ByteString att3 = ByteString.valueOfUtf8("again"); |
| | | |
| | | CSN del1 = new CSN(1, 0, 1); |
| | | CSN del2 = new CSN(1, 1, 1); |
| | |
| | | ByteString[] results = new ByteString[strings.length]; |
| | | for (int i = 0; i < results.length; i++) |
| | | { |
| | | results[i] = ByteString.valueOf(strings[i]); |
| | | results[i] = ByteString.valueOfUtf8(strings[i]); |
| | | } |
| | | return results; |
| | | } |
| | |
| | | private void assertAttributeValue(Entry entry, String expectedValue) |
| | | { |
| | | ByteString actualValue = getActualValue(entry.getAttribute(toLowerCase(ATTRIBUTE_NAME))); |
| | | assertEquals(actualValue, expectedValue != null ? ByteString.valueOf(expectedValue) : null); |
| | | assertEquals(actualValue, expectedValue != null ? ByteString.valueOfUtf8(expectedValue) : null); |
| | | } |
| | | |
| | | private void verifyModSuppressed(Iterator<Modification> it) |
| | |
| | | CSN del1 = new CSN(1, 0, 1); |
| | | CSN del2 = new CSN(1, 1, 1); |
| | | |
| | | ByteString v1 = ByteString.valueOf("a:" + del1); |
| | | ByteString v2 = ByteString.valueOf("a:" + del2); |
| | | ByteString v1 = ByteString.valueOfUtf8("a:" + del1); |
| | | ByteString v2 = ByteString.valueOfUtf8("a:" + del2); |
| | | |
| | | Assertion assert1 = rule.getAssertion(v2); |
| | | assertEquals(assert1.matches(rule.normalizeAttributeValue(v1)), ConditionResult.TRUE); |
| | |
| | | assertThat(attr).hasSize(expectedValues.length); |
| | | for (String value : expectedValues) |
| | | { |
| | | attr.contains(ByteString.valueOf(value)); |
| | | attr.contains(ByteString.valueOfUtf8(value)); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | @DataProvider(name = "valueInfo") |
| | | public Object[][] createData() { |
| | | ByteString att1 = ByteString.valueOf("string"); |
| | | ByteString att2 = ByteString.valueOf("value"); |
| | | ByteString att3 = ByteString.valueOf("again"); |
| | | ByteString att1 = ByteString.valueOfUtf8("string"); |
| | | ByteString att2 = ByteString.valueOfUtf8("value"); |
| | | ByteString att3 = ByteString.valueOfUtf8("again"); |
| | | |
| | | CSN del1 = new CSN(1, 0, 1); |
| | | CSN del2 = new CSN(1, 1, 1); |
| | |
| | | { |
| | | AttrValueHistorical valInfo1 = new AttrValueHistorical(value, csnUpdate, csnDelete); |
| | | AttrValueHistorical valInfo2 = new AttrValueHistorical(value, csnUpdate, csnUpdate); |
| | | AttrValueHistorical valInfo3 = new AttrValueHistorical(ByteString.valueOf("Test"), |
| | | AttrValueHistorical valInfo3 = new AttrValueHistorical(ByteString.valueOfUtf8("Test"), |
| | | csnUpdate, csnUpdate); |
| | | |
| | | // Check equals |
| | |
| | | LocalizableMessageBuilder reason = new LocalizableMessageBuilder(); |
| | | // test the valueIsAcceptable method |
| | | Boolean liveResult = |
| | | syntax.valueIsAcceptable(ByteString.valueOf(value), reason); |
| | | syntax.valueIsAcceptable(ByteString.valueOfUtf8(value), reason); |
| | | |
| | | assertSame(liveResult, result, syntax + ".valueIsAcceptable gave bad result for " + value + " reason : " + reason); |
| | | } |
| | |
| | | |
| | | |
| | | // Create an attribute type definition and verify that it is acceptable. |
| | | ByteString definition = ByteString.valueOf( |
| | | ByteString definition = ByteString.valueOfUtf8( |
| | | "( testxapproxtype-oid NAME 'testXApproxType' " + |
| | | "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 " + |
| | | "X-APPROX 'ds-mr-double-metaphone-approx' )"); |
| | |
| | | |
| | | private Object[] generateValues(String password) throws Exception |
| | | { |
| | | ByteString bytePassword = ByteString.valueOf(password); |
| | | ByteString bytePassword = ByteString.valueOfUtf8(password); |
| | | SaltedMD5PasswordStorageScheme scheme = new SaltedMD5PasswordStorageScheme(); |
| | | |
| | | ConfigEntry configEntry = |
| | |
| | | @Test(dataProvider= "equalityMatchingRuleInvalidValues", expectedExceptions = { DecodeException.class }) |
| | | public void equalityMatchingRulesInvalidValues(String value) throws Exception |
| | | { |
| | | getRule().normalizeAttributeValue(ByteString.valueOf(value)); |
| | | getRule().normalizeAttributeValue(ByteString.valueOfUtf8(value)); |
| | | } |
| | | |
| | | /** Test the valuesMatch method used for extensible filters. */ |
| | |
| | | |
| | | // normalize the 2 provided values and check that they are equals |
| | | ByteString normalizedValue1 = |
| | | rule.normalizeAttributeValue(ByteString.valueOf(value1)); |
| | | Assertion assertion = rule.getAssertion(ByteString.valueOf(value2)); |
| | | rule.normalizeAttributeValue(ByteString.valueOfUtf8(value1)); |
| | | Assertion assertion = rule.getAssertion(ByteString.valueOfUtf8(value2)); |
| | | |
| | | ConditionResult liveResult = assertion.matches(normalizedValue1); |
| | | assertEquals(liveResult, ConditionResult.valueOf(result)); |
| | |
| | | { |
| | | Syntax syntax = new BitStringSyntax().getSDKSyntax(CoreSchema.getInstance()); |
| | | |
| | | ByteString byteStringValue = ByteString.valueOf(value); |
| | | ByteString byteStringValue = ByteString.valueOfUtf8(value); |
| | | |
| | | LocalizableMessageBuilder reason = new LocalizableMessageBuilder(); |
| | | Boolean liveResult = |
| | |
| | | try { |
| | | return new Object [][] { |
| | | {ByteString.wrap(Base64.decode(validcert1)), true}, |
| | | {ByteString.valueOf(validcert1), false}, |
| | | {ByteString.valueOfUtf8(validcert1), false}, |
| | | {ByteString.wrap(Base64.decode(invalidcert1)), false}, |
| | | {ByteString.wrap(Base64.decode(brokencert1)), false}, |
| | | {ByteString.valueOf("invalid"), false} |
| | | {ByteString.valueOfUtf8("invalid"), false} |
| | | }; |
| | | } |
| | | catch (Exception e) |
| | |
| | | // normalize the 2 provided values |
| | | try |
| | | { |
| | | rule.normalizeAttributeValue(ByteString.valueOf(value)); |
| | | rule.normalizeAttributeValue(ByteString.valueOfUtf8(value)); |
| | | fail("The matching rule : " + rule.getNameOrOID() |
| | | + " should detect that value \"" + value + "\" is invalid"); |
| | | } |
| | |
| | | |
| | | // normalize the 2 provided values and check that they are equals |
| | | ByteString normalizedValue1 = |
| | | rule.normalizeAttributeValue(ByteString.valueOf(value1)); |
| | | Assertion assertion = rule.getAssertion(ByteString.valueOf(value2)); |
| | | rule.normalizeAttributeValue(ByteString.valueOfUtf8(value1)); |
| | | Assertion assertion = rule.getAssertion(ByteString.valueOfUtf8(value2)); |
| | | |
| | | ConditionResult liveResult = assertion.matches(normalizedValue1); |
| | | assertEquals(liveResult, ConditionResult.valueOf(result)); |
| | |
| | | { |
| | | MatchingRule partialTimeRule = DirectoryServer.getMatchingRule( |
| | | EXT_PARTIAL_DATE_TIME_NAME.toLowerCase()); |
| | | Assertion assertion = partialTimeRule.getAssertion(ByteString.valueOf(assertionValue)); |
| | | assertEquals(assertion.matches(ByteString.valueOf(attributeValue)), ConditionResult.TRUE); |
| | | Assertion assertion = partialTimeRule.getAssertion(ByteString.valueOfUtf8(assertionValue)); |
| | | assertEquals(assertion.matches(ByteString.valueOfLong(attributeValue)), ConditionResult.TRUE); |
| | | } |
| | | |
| | | |
| | |
| | | DirectoryServer.getMatchingRule(EXT_OMR_RELATIVE_TIME_LT_ALT_NAME.toLowerCase()); |
| | | try |
| | | { |
| | | relativeTimeLTRule.getAssertion(ByteString.valueOf(assertion)); |
| | | relativeTimeLTRule.getAssertion(ByteString.valueOfUtf8(assertion)); |
| | | // An invalid value can't get away without throwing exception. |
| | | assertTrue(isValid); |
| | | } |
| | |
| | | DirectoryServer.getMatchingRule(EXT_PARTIAL_DATE_TIME_OID); |
| | | try |
| | | { |
| | | partialDTRule.getAssertion(ByteString.valueOf(assertion)); |
| | | partialDTRule.getAssertion(ByteString.valueOfUtf8(assertion)); |
| | | assertTrue(isValid); |
| | | } |
| | | catch (DecodeException e) |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | |
| | | |
| | | private Object[] generateValues(String password) throws Exception |
| | | { |
| | | ByteString bytePassword = ByteString.valueOf(password); |
| | | ByteString bytePassword = ByteString.valueOfUtf8(password); |
| | | SaltedMD5PasswordStorageScheme scheme = new SaltedMD5PasswordStorageScheme(); |
| | | |
| | | ConfigEntry configEntry = DirectoryServer.getConfigEntry( |
| | |
| | | @Test(dataProvider= "equalityMatchingRuleInvalidValues", expectedExceptions = { DecodeException.class }) |
| | | public void equalityMatchingRulesInvalidValues(String value) throws Exception |
| | | { |
| | | getRule().normalizeAttributeValue(ByteString.valueOf(value)); |
| | | getRule().normalizeAttributeValue(ByteString.valueOfUtf8(value)); |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | MatchingRule rule = getRule(); |
| | | |
| | | ByteString normalizedValue1 = rule.normalizeAttributeValue(ByteString.valueOf(value1)); |
| | | Assertion assertion = rule.getAssertion(ByteString.valueOf(value2)); |
| | | ByteString normalizedValue1 = rule.normalizeAttributeValue(ByteString.valueOfUtf8(value1)); |
| | | Assertion assertion = rule.getAssertion(ByteString.valueOfUtf8(value2)); |
| | | |
| | | ConditionResult liveResult = assertion.matches(normalizedValue1); |
| | | assertEquals(liveResult, ConditionResult.valueOf(result)); |
| | |
| | | new org.opends.server.tools.LDAPWriter(s); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | new org.opends.server.tools.LDAPWriter(s); |
| | | |
| | | BindRequestProtocolOp bindRequest = |
| | | new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"), |
| | | 3, ByteString.valueOf("password")); |
| | | new BindRequestProtocolOp(ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | 3, ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | authHandler.doSimpleBind(3, ByteString.valueOf("cn=Directory Manager"), |
| | | ByteString.valueOf("password"), requestControls, |
| | | authHandler.doSimpleBind(3, ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | ByteString.valueOfUtf8("password"), requestControls, |
| | | responseControls); |
| | | |
| | | s.close(); |
| | |
| | | |
| | | try |
| | | { |
| | | authHandler.doSimpleBind(3, ByteString.valueOf("cn=Directory Manager"), |
| | | authHandler.doSimpleBind(3, ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | ByteString.empty(), requestControls, |
| | | responseControls); |
| | | } |
| | |
| | | |
| | | try |
| | | { |
| | | authHandler.doSimpleBind(3, ByteString.valueOf("cn=Directory Manager"), |
| | | ByteString.valueOf("wrongPassword"), |
| | | authHandler.doSimpleBind(3, ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | ByteString.valueOfUtf8("wrongPassword"), |
| | | requestControls, responseControls); |
| | | } |
| | | finally |
| | |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | authHandler.doSimpleBind(3, ByteString.valueOf("cn=Directory Manager"), |
| | | ByteString.valueOf("password"), |
| | | authHandler.doSimpleBind(3, ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | ByteString.valueOfUtf8("password"), |
| | | requestControls, responseControls); |
| | | |
| | | s.close(); |
| | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), |
| | | ByteString.valueOfUtf8("password"), |
| | | "CRAM-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), |
| | | ByteString.valueOfUtf8("password"), |
| | | "CRAM-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | s.close(); |
| | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), |
| | | ByteString.valueOfUtf8("password"), |
| | | "CRAM-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), |
| | | ByteString.valueOfUtf8("password"), |
| | | "CRAM-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("invalidPassword"), |
| | | ByteString.valueOfUtf8("invalidPassword"), |
| | | "CRAM-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), |
| | | ByteString.valueOfUtf8("password"), |
| | | "CRAM-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), |
| | | ByteString.valueOfUtf8("password"), |
| | | "CRAM-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), |
| | | ByteString.valueOfUtf8("password"), |
| | | "CRAM-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), |
| | | ByteString.valueOfUtf8("password"), |
| | | "CRAM-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), |
| | | ByteString.valueOfUtf8("password"), |
| | | "CRAM-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), |
| | | ByteString.valueOfUtf8("password"), |
| | | "CRAM-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | s.close(); |
| | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, this.hostname, messageID); |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | |
| | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, this.hostname, messageID); |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | |
| | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, this.hostname, messageID); |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | |
| | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("wrongPassword"), |
| | | ByteString.valueOfUtf8("wrongPassword"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, this.hostname, messageID); |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | |
| | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), "PLAIN", |
| | | ByteString.valueOfUtf8("password"), "PLAIN", |
| | | saslProperties, requestControls, responseControls); |
| | | } |
| | | finally |
| | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), "PLAIN", |
| | | ByteString.valueOfUtf8("password"), "PLAIN", |
| | | saslProperties, requestControls, responseControls); |
| | | |
| | | s.close(); |
| | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), "PLAIN", |
| | | ByteString.valueOfUtf8("password"), "PLAIN", |
| | | saslProperties, requestControls, responseControls); |
| | | } |
| | | finally |
| | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), "PLAIN", |
| | | ByteString.valueOfUtf8("password"), "PLAIN", |
| | | saslProperties, requestControls, responseControls); |
| | | } |
| | | finally |
| | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), "PLAIN", |
| | | ByteString.valueOfUtf8("password"), "PLAIN", |
| | | saslProperties, requestControls, responseControls); |
| | | } |
| | | finally |
| | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), "PLAIN", |
| | | ByteString.valueOfUtf8("password"), "PLAIN", |
| | | saslProperties, requestControls, responseControls); |
| | | } |
| | | finally |
| | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), "PLAIN", |
| | | ByteString.valueOfUtf8("password"), "PLAIN", |
| | | saslProperties, requestControls, responseControls); |
| | | } |
| | | finally |
| | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), "PLAIN", |
| | | ByteString.valueOfUtf8("password"), "PLAIN", |
| | | saslProperties, requestControls, responseControls); |
| | | } |
| | | finally |
| | |
| | | try |
| | | { |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), "PLAIN", |
| | | ByteString.valueOfUtf8("password"), "PLAIN", |
| | | saslProperties, requestControls, responseControls); |
| | | } |
| | | finally |
| | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), "PLAIN", |
| | | ByteString.valueOfUtf8("password"), "PLAIN", |
| | | saslProperties, requestControls, responseControls); |
| | | |
| | | s.close(); |
| | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("wrongPassword"), "PLAIN", |
| | | ByteString.valueOfUtf8("wrongPassword"), "PLAIN", |
| | | saslProperties, requestControls, responseControls); |
| | | |
| | | s.close(); |
| | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), "PLAIN", |
| | | ByteString.valueOfUtf8("password"), "PLAIN", |
| | | saslProperties, requestControls, responseControls); |
| | | |
| | | s.close(); |
| | |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | authHandler.doSimpleBind(3, ByteString.valueOf("cn=Directory Manager"), |
| | | ByteString.valueOf("password"), requestControls, |
| | | authHandler.doSimpleBind(3, ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | ByteString.valueOfUtf8("password"), requestControls, |
| | | responseControls); |
| | | assertNotNull(authHandler.requestAuthorizationIdentity()); |
| | | |
| | |
| | | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | authHandler.doSimpleBind(3, ByteString.valueOf("uid=test.user,o=test"), |
| | | ByteString.valueOf("password"), requestControls, |
| | | authHandler.doSimpleBind(3, ByteString.valueOfUtf8("uid=test.user,o=test"), |
| | | ByteString.valueOfUtf8("password"), requestControls, |
| | | responseControls); |
| | | assertNotNull(authHandler.requestAuthorizationIdentity()); |
| | | |
| | |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), |
| | | ByteString.valueOfUtf8("password"), |
| | | "CRAM-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | assertNotNull(authHandler.requestAuthorizationIdentity()); |
| | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, this.hostname, messageID); |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), |
| | | ByteString.valueOfUtf8("password"), |
| | | "DIGEST-MD5", saslProperties, requestControls, |
| | | responseControls); |
| | | assertNotNull(authHandler.requestAuthorizationIdentity()); |
| | |
| | | LDAPAuthenticationHandler authHandler = |
| | | new LDAPAuthenticationHandler(r, w, "localhost", messageID); |
| | | authHandler.doSASLBind(ByteString.empty(), |
| | | ByteString.valueOf("password"), "PLAIN", |
| | | ByteString.valueOfUtf8("password"), "PLAIN", |
| | | saslProperties, requestControls, responseControls); |
| | | assertNotNull(authHandler.requestAuthorizationIdentity()); |
| | | |
| | |
| | | cnType = DirectoryServer.getAttributeTypeOrNull("cn"); |
| | | Assert.assertNotNull(cnType); |
| | | |
| | | cnValue = ByteString.valueOf("john doe"); |
| | | cnValue = ByteString.valueOfUtf8("john doe"); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | Assert.assertEquals(a.size(), 2); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("value1"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("value2"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("value1"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("value2"))); |
| | | } |
| | | |
| | | |
| | |
| | | AttributeBuilder builder = new AttributeBuilder(cnType); |
| | | |
| | | // Note duplicate values. |
| | | Assert.assertTrue(builder.addAll(Arrays.asList(ByteString.valueOf("value1"), ByteString.valueOf("value1"), ByteString.valueOf("value2")))); |
| | | Assert.assertTrue(builder.addAll(Arrays.asList(ByteString.valueOfUtf8("value1"), ByteString.valueOfUtf8("value1"), ByteString.valueOfUtf8("value2")))); |
| | | Assert.assertEquals(builder.size(), 2); |
| | | |
| | | // Add same values. |
| | | Assert.assertFalse(builder.addAll(Arrays.asList(ByteString.valueOf("value1"), ByteString.valueOf("value1"), ByteString.valueOf("value2")))); |
| | | Assert.assertFalse(builder.addAll(Arrays.asList(ByteString.valueOfUtf8("value1"), ByteString.valueOfUtf8("value1"), ByteString.valueOfUtf8("value2")))); |
| | | Assert.assertEquals(builder.size(), 2); |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | Assert.assertEquals(a.size(), 2); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("value1"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("value2"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("value1"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("value2"))); |
| | | } |
| | | |
| | | |
| | |
| | | Assert.assertFalse(builder.add(cnValue)); |
| | | Assert.assertEquals(builder.size(), 1); |
| | | |
| | | Assert.assertTrue(builder.add(ByteString.valueOf("jane doe"))); |
| | | Assert.assertTrue(builder.add(ByteString.valueOfUtf8("jane doe"))); |
| | | Assert.assertEquals(builder.size(), 2); |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | Assert.assertEquals(a.size(), 2); |
| | | Assert.assertTrue(a.contains(cnValue)); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("jane doe"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("jane doe"))); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | Assert.assertEquals(a.size(), 2); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("value1"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("value2"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("value1"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("value2"))); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | AttributeBuilder builder = new AttributeBuilder(cnType); |
| | | |
| | | assertTrue(builder.add(ByteString.valueOf("value1"))); |
| | | assertTrue(builder.add(ByteString.valueOfUtf8("value1"))); |
| | | assertEquals(builder.size(), 1); |
| | | |
| | | assertFalse(builder.add(ByteString.valueOf("value1"))); |
| | | assertFalse(builder.add(ByteString.valueOfUtf8("value1"))); |
| | | assertEquals(builder.size(), 1); |
| | | |
| | | assertTrue(builder.add(ByteString.valueOf("value2"))); |
| | | assertTrue(builder.add(ByteString.valueOfUtf8("value2"))); |
| | | assertEquals(builder.size(), 2); |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | assertEquals(a.size(), 2); |
| | | assertTrue(a.contains(ByteString.valueOf("value1"))); |
| | | assertTrue(a.contains(ByteString.valueOf("value2"))); |
| | | assertTrue(a.contains(ByteString.valueOfUtf8("value1"))); |
| | | assertTrue(a.contains(ByteString.valueOfUtf8("value2"))); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | builder.addAll(createAttribute(cnType, "cn", noOptions, twoValues)); |
| | | |
| | | Assert.assertTrue(builder.contains(ByteString.valueOf("value1"))); |
| | | Assert.assertTrue(builder.contains(ByteString.valueOf("value2"))); |
| | | Assert.assertFalse(builder.contains(ByteString.valueOf("value3"))); |
| | | Assert.assertTrue(builder.contains(ByteString.valueOfUtf8("value1"))); |
| | | Assert.assertTrue(builder.contains(ByteString.valueOfUtf8("value2"))); |
| | | Assert.assertFalse(builder.contains(ByteString.valueOfUtf8("value3"))); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | builder.addAll(createAttribute(cnType, "cn", noOptions, twoValues)); |
| | | |
| | | ByteString av1 = ByteString.valueOf("value1"); |
| | | ByteString av2 = ByteString.valueOf("value2"); |
| | | ByteString av3 = ByteString.valueOf("value3"); |
| | | ByteString av1 = ByteString.valueOfUtf8("value1"); |
| | | ByteString av2 = ByteString.valueOfUtf8("value2"); |
| | | ByteString av3 = ByteString.valueOfUtf8("value3"); |
| | | |
| | | Assert.assertTrue(builder.containsAll(Collections.<ByteString> emptySet())); |
| | | |
| | |
| | | |
| | | builder.add("value1"); |
| | | Assert.assertTrue(builder.iterator().hasNext()); |
| | | Assert.assertEquals(builder.iterator().next(), ByteString.valueOf("value1")); |
| | | Assert.assertEquals(builder.iterator().next(), ByteString.valueOfUtf8("value1")); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | Assert.assertEquals(a.size(), 1); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("value3"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("value3"))); |
| | | } |
| | | |
| | | |
| | |
| | | builder.addAll(createAttribute(cnType, "cn", noOptions, threeValues)); |
| | | |
| | | // Remove existing values. |
| | | Assert.assertTrue(builder.removeAll(Arrays.asList(ByteString.valueOf("value1"), ByteString.valueOf("value2")))); |
| | | Assert.assertTrue(builder.removeAll(Arrays.asList(ByteString.valueOfUtf8("value1"), ByteString.valueOfUtf8("value2")))); |
| | | Assert.assertEquals(builder.size(), 1); |
| | | |
| | | // Remove removed values. |
| | | Assert.assertFalse(builder.removeAll(Arrays.asList(ByteString.valueOf("value1"), ByteString.valueOf("value2")))); |
| | | Assert.assertFalse(builder.removeAll(Arrays.asList(ByteString.valueOfUtf8("value1"), ByteString.valueOfUtf8("value2")))); |
| | | Assert.assertEquals(builder.size(), 1); |
| | | |
| | | // Remove nothing. |
| | |
| | | |
| | | // Remove non existent value. |
| | | Assert.assertFalse(builder.removeAll(Collections |
| | | .singleton(ByteString.valueOf("value4")))); |
| | | .singleton(ByteString.valueOfUtf8("value4")))); |
| | | Assert.assertEquals(builder.size(), 1); |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | Assert.assertEquals(a.size(), 1); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("value3"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("value3"))); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | builder.addAll(createAttribute(cnType, "cn", noOptions, threeValues)); |
| | | |
| | | Assert.assertTrue(builder.remove(ByteString.valueOf("value1"))); |
| | | Assert.assertTrue(builder.remove(ByteString.valueOfUtf8("value1"))); |
| | | Assert.assertEquals(builder.size(), 2); |
| | | |
| | | // Already removed. |
| | | Assert.assertFalse(builder.remove(ByteString.valueOf("value1"))); |
| | | Assert.assertFalse(builder.remove(ByteString.valueOfUtf8("value1"))); |
| | | Assert.assertEquals(builder.size(), 2); |
| | | |
| | | // Non existent. |
| | | Assert.assertFalse(builder.remove(ByteString.valueOf("value4"))); |
| | | Assert.assertFalse(builder.remove(ByteString.valueOfUtf8("value4"))); |
| | | Assert.assertEquals(builder.size(), 2); |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | Assert.assertEquals(a.size(), 2); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("value2"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("value3"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("value2"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("value3"))); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | Assert.assertEquals(a.size(), 2); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("value2"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("value3"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("value2"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("value3"))); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | Assert.assertEquals(a.size(), 2); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("value2"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("value4"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("value2"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("value4"))); |
| | | } |
| | | |
| | | |
| | |
| | | builder.addAll(createAttribute(cnType, "cn", noOptions, threeValues)); |
| | | |
| | | // Note duplicate values. |
| | | builder.replaceAll(Arrays.asList(ByteString.valueOf("value2"), |
| | | ByteString.valueOf("value2"), ByteString.valueOf("value4"))); |
| | | builder.replaceAll(Arrays.asList(ByteString.valueOfUtf8("value2"), |
| | | ByteString.valueOfUtf8("value2"), ByteString.valueOfUtf8("value4"))); |
| | | Assert.assertEquals(builder.size(), 2); |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | Assert.assertEquals(a.size(), 2); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("value2"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("value4"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("value2"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("value4"))); |
| | | } |
| | | |
| | | |
| | |
| | | AttributeBuilder builder = new AttributeBuilder(cnType); |
| | | builder.addAll(createAttribute(cnType, "cn", noOptions, threeValues)); |
| | | |
| | | builder.replace(ByteString.valueOf("value4")); |
| | | builder.replace(ByteString.valueOfUtf8("value4")); |
| | | Assert.assertEquals(builder.size(), 1); |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | Assert.assertEquals(a.size(), 1); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("value4"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("value4"))); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | Assert.assertEquals(a.size(), 1); |
| | | Assert.assertTrue(a.contains(ByteString.valueOf("value4"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("value4"))); |
| | | } |
| | | |
| | | |
| | |
| | | // Check contains(). |
| | | for (String value : values) |
| | | { |
| | | Assert.assertTrue(a.contains(ByteString.valueOf(value))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8(value))); |
| | | |
| | | // Assumes internal normalization to lower-case. |
| | | Assert.assertTrue(a.contains(ByteString.valueOf(value.toUpperCase()))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8(value.toUpperCase()))); |
| | | } |
| | | |
| | | Assert.assertFalse(a.contains(ByteString.valueOf("xxxx"))); |
| | | Assert.assertFalse(a.contains(ByteString.valueOfUtf8("xxxx"))); |
| | | } |
| | | |
| | | |
| | |
| | | Set<ByteString> expectedValues = new HashSet<>(); |
| | | for (String value : values) |
| | | { |
| | | expectedValues.add(ByteString.valueOf(value)); |
| | | expectedValues.add(ByteString.valueOfUtf8(value)); |
| | | } |
| | | |
| | | Assert.assertTrue(a.containsAll(Collections.<ByteString> emptySet())); |
| | |
| | | } |
| | | |
| | | Set<ByteString> bigSet = new HashSet<>(expectedValues); |
| | | bigSet.add(ByteString.valueOf("xxxx")); |
| | | bigSet.add(ByteString.valueOfUtf8("xxxx")); |
| | | Assert.assertFalse(a.containsAll(bigSet)); |
| | | |
| | | expectedValues.clear(); |
| | | for (String value : values) |
| | | { |
| | | // Assumes internal normalization to lower-case. |
| | | expectedValues.add(ByteString.valueOf(value.toUpperCase())); |
| | | expectedValues.add(ByteString.valueOfUtf8(value.toUpperCase())); |
| | | } |
| | | Assert.assertTrue(a.containsAll(expectedValues)); |
| | | } |
| | |
| | | |
| | | ByteString v = i.next(); |
| | | ByteString nv = a.getAttributeType().getEqualityMatchingRule().normalizeAttributeValue(v); |
| | | Assert.assertEquals(nv, ByteString.valueOf(value)); |
| | | Assert.assertEquals(nv, ByteString.valueOfUtf8(value)); |
| | | |
| | | try |
| | | { |
| | |
| | | assertThat(a3.isNormalized()).isTrue(); |
| | | |
| | | // no normalization on contains for 0-element and 1-element set |
| | | a1.contains(ByteString.valueOf("one")); |
| | | a1.contains(ByteString.valueOfUtf8("one")); |
| | | assertThat(a1.isNormalized()).isFalse(); |
| | | |
| | | // normalization on contains for 1-element set |
| | | a2.contains(ByteString.valueOf("one")); |
| | | a2.contains(ByteString.valueOfUtf8("one")); |
| | | assertThat(a2.isNormalized()).isTrue(); |
| | | } |
| | | |
| | |
| | | |
| | | AttributeType cnAttrType = DirectoryServer.getAttributeTypeOrNull("cn"); |
| | | CompareOperation compareOperation = conn.processCompare( |
| | | DN.valueOf("cn=config"), cnAttrType, ByteString.valueOf("config")); |
| | | DN.valueOf("cn=config"), cnAttrType, ByteString.valueOfUtf8("config")); |
| | | if (hasPrivilege) |
| | | { |
| | | assertEquals(compareOperation.getResultCode(), COMPARE_TRUE); |
| | |
| | | nextOperationID(), nextMessageID(), |
| | | controls, targetDN, |
| | | DirectoryServer.getAttributeTypeOrDefault("cn"), |
| | | ByteString.valueOf("PWReset Target")); |
| | | ByteString.valueOfUtf8("PWReset Target")); |
| | | compareOperation.run(); |
| | | if (hasProxyPrivilege) |
| | | { |
| | |
| | | "sn: Test"); |
| | | |
| | | List<Control> controls = new ArrayList<>(1); |
| | | controls.add(new ProxiedAuthV2Control(ByteString.valueOf("dn:cn=PWReset Target,o=test"))); |
| | | controls.add(new ProxiedAuthV2Control(ByteString.valueOfUtf8("dn:cn=PWReset Target,o=test"))); |
| | | |
| | | |
| | | // Try to add the entry. If this fails with the proxy control, then add it |
| | |
| | | |
| | | DN targetDN = DN.valueOf("cn=PWReset Target,o=test"); |
| | | List<Control> controls = new ArrayList<>(1); |
| | | controls.add(new ProxiedAuthV2Control(ByteString.valueOf("dn:" + targetDN))); |
| | | controls.add(new ProxiedAuthV2Control(ByteString.valueOfUtf8("dn:" + targetDN))); |
| | | |
| | | |
| | | // Test a compare operation against the PWReset Target user. |
| | | CompareOperation compareOperation = new CompareOperationBasis(conn, nextOperationID(), |
| | | nextMessageID(), controls, targetDN, |
| | | DirectoryServer.getAttributeTypeOrDefault("cn"), |
| | | ByteString.valueOf("PWReset Target")); |
| | | ByteString.valueOfUtf8("PWReset Target")); |
| | | compareOperation.run(); |
| | | if (hasProxyPrivilege) |
| | | { |
| | |
| | | LDAPWriter w = new LDAPWriter(s); |
| | | |
| | | BindRequestProtocolOp bindRequest = new BindRequestProtocolOp( |
| | | ByteString.valueOf("cn=Test User,o=test"), 3, |
| | | ByteString.valueOf("password")); |
| | | ByteString.valueOfUtf8("cn=Test User,o=test"), 3, |
| | | ByteString.valueOfUtf8("password")); |
| | | LDAPMessage message = new LDAPMessage(1, bindRequest); |
| | | w.writeMessage(message); |
| | | |
| | |
| | | |
| | | description.filterType = filterType; |
| | | description.attributeType = DirectoryServer.getAttributeTypeOrNull(attributeType); |
| | | description.assertionValue = ByteString.valueOf(attributeValue); |
| | | description.assertionValue = ByteString.valueOfUtf8(attributeValue); |
| | | |
| | | if (filterType == FilterType.EQUALITY) { |
| | | description.searchFilter = SearchFilter.createEqualityFilter(description.attributeType, |
| | |
| | | description.filterType = FilterType.SUBSTRING; |
| | | description.attributeType = DirectoryServer.getAttributeTypeOrNull(attributeType); |
| | | |
| | | description.subInitialElement = ByteString.valueOf(subInitial); |
| | | description.subInitialElement = ByteString.valueOfUtf8(subInitial); |
| | | description.subAnyElements = new ArrayList<>(); |
| | | if (subAny != null) |
| | | { |
| | | for (String s : subAny) |
| | | { |
| | | description.subAnyElements.add(ByteString.valueOf(s)); |
| | | description.subAnyElements.add(ByteString.valueOfUtf8(s)); |
| | | } |
| | | } |
| | | description.subFinalElement = ByteString.valueOf(subFinal); |
| | | description.subFinalElement = ByteString.valueOfUtf8(subFinal); |
| | | |
| | | description.searchFilter = SearchFilter.createSubstringFilter(description.attributeType, |
| | | description.subInitialElement, |
| | |
| | | */ |
| | | @Test(dataProvider = "testDNs") |
| | | public void testDecodeByteString(String rawDN, String normDN, String unused) throws Exception { |
| | | DN dn = DN.decode(ByteString.valueOf(rawDN)); |
| | | DN dn = DN.decode(ByteString.valueOfUtf8(rawDN)); |
| | | assertEquals(dn.toNormalizedUrlSafeString(), normDN); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Test(dataProvider = "illegalDNs", expectedExceptions = DirectoryException.class) |
| | | public void testIllegalOctetStringDNs(String dn) throws Exception { |
| | | ByteString octetString = ByteString.valueOf(dn); |
| | | ByteString octetString = ByteString.valueOfUtf8(dn); |
| | | DN.decode(octetString); |
| | | } |
| | | |
| | |
| | | + "SYNTAX 1.3.6.1.4.1.1466.115.121.1.45 )"; |
| | | |
| | | AttributeType type = AttributeTypeSyntax.decodeAttributeType( |
| | | ByteString.valueOf(string), |
| | | ByteString.valueOfUtf8(string), |
| | | DirectoryServer.getSchema(), false); |
| | | |
| | | // Test values. |
| | |
| | | AttributeType dummy = getAttributeTypeOrDefault(attrName, attrName, getDefaultIntegerSyntax()); |
| | | DirectoryServer.getSchema().registerAttributeType(dummy, true); |
| | | |
| | | AV_DC_ORG = ByteString.valueOf("org"); |
| | | AV_CN = ByteString.valueOf("hello world"); |
| | | AV_DC_ORG = ByteString.valueOfUtf8("org"); |
| | | AV_CN = ByteString.valueOfUtf8("hello world"); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | @Test |
| | | public void testEscaping() { |
| | | RDN rdn = new RDN(AT_DC, ByteString.valueOf(" ")); |
| | | RDN rdn = new RDN(AT_DC, ByteString.valueOfUtf8(" ")); |
| | | assertEquals(rdn.toString(), "dc=\\ "); |
| | | } |
| | | |
| | |
| | | throws Exception |
| | | { |
| | | assertEquals(virtualAttribute.size(), 1); |
| | | assertTrue(virtualAttribute.contains(ByteString.valueOf("o=test"))); |
| | | assertTrue(virtualAttribute.contains(ByteString.valueOfUtf8("o=test"))); |
| | | |
| | | assertFalse(virtualAttribute.isEmpty()); |
| | | |
| | | assertTrue(virtualAttribute.contains(ByteString.valueOf("o=test"))); |
| | | assertFalse(virtualAttribute.contains(ByteString.valueOf("o=not test"))); |
| | | assertTrue(virtualAttribute.contains(ByteString.valueOfUtf8("o=test"))); |
| | | assertFalse(virtualAttribute.contains(ByteString.valueOfUtf8("o=not test"))); |
| | | |
| | | LinkedHashSet<ByteString> testValues = new LinkedHashSet<>(); |
| | | testValues.add(ByteString.valueOf("o=test")); |
| | | testValues.add(ByteString.valueOfUtf8("o=test")); |
| | | assertTrue(virtualAttribute.containsAll(testValues)); |
| | | |
| | | testValues.add(ByteString.valueOf("o=not test")); |
| | | testValues.add(ByteString.valueOfUtf8("o=not test")); |
| | | assertFalse(virtualAttribute.containsAll(testValues)); |
| | | } |
| | | |
| | |
| | | throws Exception |
| | | { |
| | | assertEquals(virtualAttribute.matchesSubstring( |
| | | ByteString.valueOf("o="), null, |
| | | ByteString.valueOf("test")), |
| | | ByteString.valueOfUtf8("o="), null, |
| | | ByteString.valueOfUtf8("test")), |
| | | ConditionResult.UNDEFINED); |
| | | |
| | | ByteString assertionValue = ByteString.valueOf("o=test"); |
| | | ByteString assertionValue = ByteString.valueOfUtf8("o=test"); |
| | | assertEquals(virtualAttribute.greaterThanOrEqualTo(assertionValue), |
| | | ConditionResult.UNDEFINED); |
| | | assertEquals(virtualAttribute.lessThanOrEqualTo(assertionValue), |
| | |
| | | .valueOf("cn=john, dc=foo, dc=com")); |
| | | Assert.assertTrue(entry.hasObjectClass(OC_TOP)); |
| | | Assert.assertTrue(entry.hasObjectClass(OC_PERSON)); |
| | | Assert.assertTrue(entry.hasValue(AT_CN, null, ByteString.valueOf("john"))); |
| | | Assert.assertTrue(entry.hasValue(AT_SN, null, ByteString.valueOf("smith"))); |
| | | Assert.assertTrue(entry.hasValue(AT_CN, null, ByteString.valueOfUtf8("john"))); |
| | | Assert.assertTrue(entry.hasValue(AT_SN, null, ByteString.valueOfUtf8("smith"))); |
| | | |
| | | Assert.assertNull(reader.readEntry()); |
| | | |
| | |
| | | try { |
| | | Entry entry = reader.readEntry(); |
| | | Assert.assertNotNull(entry); |
| | | Assert.assertTrue(entry.hasValue(AT_DESCR, null, ByteString.valueOf("once upon a time in the west"))); |
| | | Assert.assertTrue(entry.hasValue(AT_DESCR, null, ByteString.valueOfUtf8("once upon a time in the west"))); |
| | | } finally { |
| | | reader.close(); |
| | | } |
| | |
| | | try { |
| | | Entry entry = reader.readEntry(); |
| | | Assert.assertNotNull(entry); |
| | | Assert.assertTrue(entry.hasValue(AT_DESCR, null, ByteString.valueOf("once upon a time in the west"))); |
| | | Assert.assertTrue(entry.hasValue(AT_DESCR, null, ByteString.valueOfUtf8("once upon a time in the west"))); |
| | | } finally { |
| | | reader.close(); |
| | | } |
| | |
| | | .valueOf("cn=anne, dc=foo, dc=com")); |
| | | Assert.assertTrue(entry.hasObjectClass(OC_TOP)); |
| | | Assert.assertTrue(entry.hasObjectClass(OC_PERSON)); |
| | | Assert.assertTrue(entry.hasValue(AT_CN, null, ByteString.valueOf("anne"))); |
| | | Assert.assertTrue(entry.hasValue(AT_SN, null, ByteString.valueOf("other"))); |
| | | Assert.assertTrue(entry.hasValue(AT_CN, null, ByteString.valueOfUtf8("anne"))); |
| | | Assert.assertTrue(entry.hasValue(AT_SN, null, ByteString.valueOfUtf8("other"))); |
| | | |
| | | Assert.assertNull(reader.readEntry()); |
| | | |
| | |
| | | @Test(dataProvider = "needsBase64EncodingTestData") |
| | | public void testNeedsBase64EncodingBytes(String s, boolean result) |
| | | throws Exception { |
| | | ByteString bytes = s != null ? ByteString.valueOf(s) : null; |
| | | ByteString bytes = s != null ? ByteString.valueOfUtf8(s) : null; |
| | | Assert.assertEquals(StaticUtils.needsBase64Encoding(bytes), result); |
| | | } |
| | | |
| | |
| | | @Test(dataProvider = "stringCaseConversionTestData") |
| | | public void testToLowerCaseBytes(String input, String lower, String upper) |
| | | throws Exception { |
| | | ByteString bytes = input != null ? ByteString.valueOf(input) : null; |
| | | ByteString bytes = input != null ? ByteString.valueOfUtf8(input) : null; |
| | | StringBuilder buffer = new StringBuilder(); |
| | | StaticUtils.toLowerCase(bytes, buffer, false); |
| | | Assert.assertEquals(buffer.toString(), input != null ? lower : ""); |
| | |
| | | public void testToLowerCaseWithTrim(String input, String lower) throws Exception |
| | | { |
| | | StringBuilder sb = new StringBuilder(); |
| | | ByteString bytes = input != null ? ByteString.valueOf(input) : null; |
| | | ByteString bytes = input != null ? ByteString.valueOfUtf8(input) : null; |
| | | StaticUtils.toLowerCase(bytes, sb, true); |
| | | Assert.assertEquals(sb.toString(), lower); |
| | | } |