use of com.novell.ldap.LDAPAttribute in project ldapchai by ldapchai.
the class JLDAPProviderImpl method writeStringAttributes.
@LdapOperation
@ModifyOperation
public final void writeStringAttributes(final String entryDN, final Map<String, String> attributeValues, final boolean overwrite) throws ChaiUnavailableException, ChaiOperationException {
activityPreCheck();
getInputValidator().writeStringAttributes(entryDN, attributeValues, overwrite);
final int modOption = overwrite ? LDAPModification.REPLACE : LDAPModification.ADD;
final List<LDAPModification> modifications = new ArrayList<>();
for (final Map.Entry<String, String> entry : attributeValues.entrySet()) {
final String attrName = entry.getKey();
final LDAPAttribute ldapAttr = new LDAPAttribute(attrName, entry.getValue());
final LDAPModification mod = new LDAPModification(modOption, ldapAttr);
modifications.add(mod);
}
final LDAPModification[] modificationArray = modifications.toArray(new LDAPModification[modifications.size()]);
try {
ldapConnection.modify(entryDN, modificationArray);
} catch (LDAPException e) {
throw ChaiOperationException.forErrorMessage(e.getLDAPErrorMessage());
}
}
use of com.novell.ldap.LDAPAttribute in project ldapchai by ldapchai.
the class JLDAPProviderImpl method compareStringAttribute.
@ChaiProvider.LdapOperation
public boolean compareStringAttribute(final String entryDN, final String attribute, final String value) throws ChaiOperationException, ChaiUnavailableException, IllegalStateException {
activityPreCheck();
getInputValidator().compareStringAttribute(entryDN, attribute, value);
final LDAPAttribute ldapAttr = new LDAPAttribute(attribute, value);
try {
return ldapConnection.compare(entryDN, ldapAttr);
} catch (LDAPException e) {
throw ChaiOperationException.forErrorMessage(e.getLDAPErrorMessage());
}
}
use of com.novell.ldap.LDAPAttribute in project ldapchai by ldapchai.
the class JLDAPProviderImpl method writeBinaryAttribute.
@ChaiProvider.LdapOperation
@ChaiProvider.ModifyOperation
public void writeBinaryAttribute(final String entryDN, final String attribute, final byte[][] values, final boolean overwrite, final ChaiRequestControl[] controls) throws ChaiOperationException, ChaiUnavailableException, IllegalStateException {
activityPreCheck();
getInputValidator().writeBinaryAttribute(entryDN, attribute, values, overwrite);
final LDAPAttribute ldapAttr = new LDAPAttribute(attribute);
for (final byte[] value : values) {
ldapAttr.addValue(value);
}
final LDAPModification mod = new LDAPModification(overwrite ? LDAPModification.REPLACE : LDAPModification.ADD, ldapAttr);
try {
if (controls != null && controls.length > 0) {
final LDAPConstraints constraints = new LDAPConstraints();
constraints.setControls(convertControls(controls));
ldapConnection.modify(entryDN, mod, constraints);
} else {
ldapConnection.modify(entryDN, mod);
}
} catch (LDAPException e) {
throw ChaiOperationException.forErrorMessage(e.getLDAPErrorMessage());
}
}
use of com.novell.ldap.LDAPAttribute in project janrufmonitor by tbrandt77.
the class LdapMappingManager method mapAttributes.
private IAttributeMap mapAttributes(LDAPEntry entry) {
IAttributeMap attributes = getRuntime().getCallerFactory().createAttributeMap();
LDAPAttributeSet attributeSet = entry.getAttributeSet();
Iterator allAttributes = attributeSet.iterator();
while (allAttributes.hasNext()) {
LDAPAttribute attribute = (LDAPAttribute) allAttributes.next();
if (m_attributeMappings.values().contains(attribute.getName())) {
String value = attribute.getStringValue();
if (m_logger.isLoggable(Level.INFO)) {
m_logger.info("Adding LDAP attribute: " + attribute.getName() + ", value: " + value);
}
if (!m_inversAttributeMappings.getProperty(attribute.getName()).equalsIgnoreCase(IJAMConst.ATTRIBUTE_NAME_IMAGEPATH)) {
attributes.add(getRuntime().getCallerFactory().createAttribute(m_inversAttributeMappings.getProperty(attribute.getName()), value));
} else {
try {
addImage(attributes, attribute.getByteValue(), entry);
} catch (IOException e) {
m_logger.log(Level.SEVERE, e.toString(), e);
}
}
}
}
return attributes;
}
use of com.novell.ldap.LDAPAttribute in project janrufmonitor by tbrandt77.
the class LdapMappingManager method mapPhones.
private List mapPhones(LDAPEntry entry, IAttributeMap attributes) {
List phones = new ArrayList();
LDAPAttributeSet attributeSet = entry.getAttributeSet();
Iterator allAttributes = attributeSet.iterator();
while (allAttributes.hasNext()) {
LDAPAttribute attribute = (LDAPAttribute) allAttributes.next();
if (m_phonenumberMappings.keySet().contains(attribute.getName())) {
Enumeration allValues = attribute.getStringValues();
if (allValues != null) {
String value = null;
while (allValues.hasMoreElements()) {
value = (String) allValues.nextElement();
if (!Base64.isLDIFSafe(value)) {
value = attribute.getStringValue();
}
if (m_logger.isLoggable(Level.INFO)) {
m_logger.info("Adding LDAP attribute: " + attribute.getName() + ", value: " + value);
}
if (this.m_logger.isLoggable(Level.INFO)) {
this.m_logger.info("LdapMappingManager raw number: " + value);
}
IPhonenumber pn = PhonenumberAnalyzer.getInstance(getRuntime()).toIdentifiedPhonenumber(value);
if (this.m_logger.isLoggable(Level.INFO)) {
this.m_logger.info("LdapMappingManager identified number: " + pn);
}
if (pn != null) {
phones.add(pn);
attributes.add(getNumberTypeAttribute(attribute.getName(), pn));
}
}
}
}
}
return phones;
}
Aggregations