use of org.structr.ldap.entity.LDAPAttribute in project structr by structr.
the class StructrLDAPWrapper method evaluateSubstringNode.
private boolean evaluateSubstringNode(final LDAPNode node, final SubstringNode substringNode) throws FrameworkException, LdapInvalidAttributeValueException {
final Attribute attribute = new DefaultAttribute(substringNode.getAttributeType());
final String oid = attribute.getId();
final String initialPart = substringNode.getInitial();
final String finalPart = substringNode.getFinal();
final List<String> any = new LinkedList<>();
final List<String> fromNode = substringNode.getAny();
// add fragments from substring node (if present)
if (fromNode != null) {
any.addAll(fromNode);
}
final Pattern pattern = SubstringNode.getRegex(initialPart, any.toArray(new String[0]), finalPart);
for (final LDAPAttribute attr : node.getAttributes()) {
if (oid.equals(attr.getOid())) {
for (final LDAPValue value : attr.getValues()) {
final String stringValue = value.getStringValue().toLowerCase();
final Matcher matcher = pattern.matcher(stringValue);
if (matcher.matches()) {
return true;
}
}
}
}
return false;
}
use of org.structr.ldap.entity.LDAPAttribute in project structr by structr.
the class StructrLDAPWrapper method getAttribute.
public Attribute getAttribute(final LDAPAttribute src) throws LdapInvalidAttributeValueException {
final AttributeType type = schemaManager.getAttributeType(src.getOid());
final Attribute attribute = new DefaultAttribute(type);
final String name = src.getUserProvidedId();
if (name != null) {
attribute.setUpId(name);
}
for (final LDAPValue value : src.getValues()) {
attribute.add(value.getStringValue());
}
return attribute;
}
Aggregations