/** * Retrieves an attribute that is equivalent to this compact attribute. * * @return An attribute that is equivalent to this compact attribute. */ Attribute toAttribute() { return new Attribute(name, values); } }
/** * Adds the provided value to the set of values for this attribute. * * @param attrBytes The value to add to this attribute. */ public void addValue(final byte[] attrBytes) { attribute = Attribute.mergeAttributes(attribute, new Attribute(attribute.getName(), attrBytes)); }
@Override public String getAsString() { return attribute.getValue(); }
/** * Removes the provided value from this attribute. * * @param attrValue The value to remove. */ public void removeValue(final String attrValue) { attribute = Attribute.removeValues(attribute, new Attribute(attribute.getName(), attrValue)); }
/** * Creates a compact attribute from the provided attribute. * * @param attribute The attribute to use to create this compact attribute. */ CompactAttribute(final Attribute attribute) { name = internName(attribute.getName()); values = attribute.getValueByteArrays(); }
final String baseName = StaticUtils.toLowerCase(a.getBaseName()); if (baseSourceNames.contains(baseName)) if (a.hasOptions()) for (final String option : a.getOptions()) newName = a.getName(); instanceof DistinguishedNameMatchingRule)) final String[] originalValues = a.getValues(); newValues = new String[originalValues.length]; for (int i=0; i < originalValues.length; i++) newValues = a.getValues(); newAttributes.add(new Attribute(newName, schema, newValues));
} else { attrList.add(new Attribute("x-name", dir.ldapValue())); for(String opt: a.getOptions()) { putMember(out, key, a.getValue(), langTag, dir.ldapValueMatchingPattern()); for (String v: attrList.get(0).getValues()) { jsonString = attrList.get(0).getValue(); String[] array = attrList.get(0).getValues(); Boolean bool = attrList.get(0).getValueAsBoolean(); putMember(out, key, attrList.get(0).getValueAsInteger(), null, dir.ldapValueMatchingPattern()); String genTimeStr = attrList.get(0).getValue(); Long timeStamp = StaticUtils.decodeGeneralizedTime(genTimeStr).getTime() / 1000; putMember(out, key, timeStamp, null, dir.ldapValueMatchingPattern()); putMember(out, key, attrList.get(0).getValueAsLong(), null, dir.ldapValueMatchingPattern()); putMember(out, key, JSONValue.parse(attrList.get(0).getValue()), null, null);
attrList.add(new Attribute(attrName, attrValue)); for (int i=0; i < attrList.size(); i++) valueArray[i] = attrList.get(i).getValueByteArray(); oldAttributes.add(new Attribute(attrList.get(0).getName(), valueArray));
/** * {@inheritDoc} */ public Entry transformEntry(final Entry e) { if (e == null) { return null; } // Iterate through the attributes in the entry and make any appropriate DN // replacements final Collection<Attribute> originalAttributes = e.getAttributes(); final ArrayList<Attribute> newAttributes = new ArrayList<Attribute>(originalAttributes.size()); for (final Attribute a : originalAttributes) { final String[] originalValues = a.getValues(); final String[] newValues = new String[originalValues.length]; for (int i=0; i < originalValues.length; i++) { newValues[i] = processString(originalValues[i]); } newAttributes.add(new Attribute(a.getName(), newValues)); } return new Entry(processString(e.getDN()), newAttributes); }
/** * Composes an LDAP modify request for the specified entry. * * @param entry The entry. Must not be {@code null}. * * @return The modify request. */ public ModifyRequest composeModifyRequest(final Entry entry) { List<Modification> mods = new LinkedList<>(); // Compose list of attribute updates List<String> updatedAttributes = new LinkedList<>(); for (com.unboundid.ldap.sdk.Attribute attr: entry.getAttributes()) { if (! getModifiableAttributes().contains(attr.getBaseName())) { continue; // skip, attribute not modifiable } // Flag attribute for replace, set new value(s) mods.add(new Modification(ModificationType.REPLACE, attr.getName(), attr.getValues())); updatedAttributes.add(attr.getBaseName()); // trim any lang-tags } // Compose list of attribute deletions for (String supAttr: getModifiableAttributes()) { if (! updatedAttributes.contains(supAttr)) { // Flag for delete via replace mods.add(new Modification(ModificationType.REPLACE, supAttr)); } } return new ModifyRequest(entry.getDN(), mods); }
private void setAccountRoles(LDAPConnection ldapConnection, SearchResultEntry accountSearchResult, Account account) { String accountDN = accountSearchResult.getDN(); String groupMemberPattern = this.groupMemberPattern.replace("${dn}", escapeLDAPSearchFilter(accountDN)); groupMemberPattern = groupMemberPattern.replace("${username}", escapeLDAPSearchFilter(account.getUsername())); // Fill in attributes into groupMemberPattern for (Attribute attribute : accountSearchResult.getAttributes()) { groupMemberPattern = groupMemberPattern.replace("${" + attribute.getName() + "}", escapeLDAPSearchFilter(attribute.getValue())); } SearchResult groupsSearchResult = doSearch(ldapConnection, groupBase, true, groupMemberPattern, Arrays.asList("cn")); if (groupsSearchResult != null && groupsSearchResult.getEntryCount() > 0) { for (int i = 0; i < groupsSearchResult.getEntryCount(); i++) { SearchResultEntry groupEntry = groupsSearchResult.getSearchEntries().get(i); String roleName = groupEntry.getAttribute("cn").getValue(); account.getAuthorizations().addRole(roleName); } } }
pattern = pattern.replace("${" + userAttribute.getName() + "}", userAttribute.getValue()); if (attribute != null && attribute.hasValue()) { account.setName(attribute.getValue()); pattern = pattern.replace("${" + userAttribute.getName() + "}", userAttribute.getValue()); if (attribute != null && attribute.hasValue()) { account.addEmailAddress(attribute.getValue());
/** * Retrieves the set of parsed monitor attributes for this monitor entry, * mapped from a unique identifier (in all lowercase characters) to the * corresponding monitor attribute. * * @return The set of parsed monitor attributes for this monitor entry. */ public Map<String,MonitorAttribute> getMonitorAttributes() { // Retrieve a map of all attributes in the entry except cn and objectClass. final LinkedHashMap<String,MonitorAttribute> attrs = new LinkedHashMap<String,MonitorAttribute>(); for (final Attribute a : entry.getAttributes()) { final String lowerName = toLowerCase(a.getName()); if (lowerName.equals("cn") || lowerName.equals("objectclass")) { continue; } attrs.put(lowerName, new MonitorAttribute(lowerName, a.getName(), "", a.getValues())); } return Collections.unmodifiableMap(attrs); }
if ((changesAttr == null) || (! changesAttr.hasValue())) final byte[] valueBytes = changesAttr.getValueByteArray(); if (valueBytes.length == 0) if ((valueBytes.length > 0) && (valueBytes[valueBytes.length-1] == 0x00)) final String fullValue = changesAttr.getValue(); final String realValue = fullValue.substring(0, fullValue.length()-2); tokenizer = new StringTokenizer(realValue, "\r\n"); tokenizer = new StringTokenizer(changesAttr.getValue(), "\r\n");
@Override public String[] getValuesAsStringArray() { return attribute.getValues(); }
/** * Retrieves the base name for this attribute, which is the name or OID of the * attribute type, without any attribute options. For an attribute without * any options, the value returned by this method will be identical the value * returned by the {@code getName} method. * * @return The base name for this attribute. */ public String getBaseName() { return getBaseName(name); }
/** * Retrieves the name for this attribute. * * @return The name for this attribute. */ public String getName() { return attribute.getName(); }
final String lowerName = StaticUtils.toLowerCase(a.getName()); if (lowerName.startsWith("extended-op-") && lowerName.endsWith("-total-count")) final long total = a.getValueAsLong(); final long failed = entry.getLong( "extended-op-" + dashedOID + "-failed-count");
for (final Attribute a : attrList) final Set<String> attrOptions = a.getOptions(); String attrName = null; for (final String s : attrOptions) a.getName());
rdnNameList.add(a.getName()); rdnValueList.add(a.getValueByteArray()); rdnNameList.add(a.getName()); rdnValueList.add(a.getValueByteArray());