Options to customize LDAP queries

ice4sip 5071
Ingo Bauersachs 12 years ago
parent a38f149940
commit 600410a57e

@ -811,6 +811,14 @@ impl.gui.main.account.DUMMY_PROTOCOL_DESCRIPTION=select network
# LDAP
impl.ldap.CONFIG_FORM_TITLE=LDAP configuration
impl.ldap.GENERAL=General
impl.ldap.FIELDS=Fields
impl.ldap.QUERY=Query
impl.ldap.QUERY_DEFAULT=Create automatically
impl.ldap.QUERY_CUSTOM=Custom query
impl.ldap.QUERY_CUSTOM_HINT=Use {0} as a placeholder for the search term.
impl.ldap.QUERY_CUSTOM_AUTO_WILDCARD=Automatically add wildcards to the query term
impl.ldap.QUERY_PHOTO_INLINE=Fetch photo along with other attributes
impl.ldap.NEW=New
impl.ldap.EDIT=edit
impl.ldap.REMOVE=Remove

@ -269,7 +269,7 @@ private void processLdapResponse(LdapEvent evt)
try
{
sourceContact.setImage(person.fetchPhoto());
sourceContact.setImage(person.getPhoto());
}
catch (OutOfMemoryError oome)
{

@ -54,7 +54,11 @@ public class LdapDirectoryImpl
/**
* Name of avatar attribute.
*/
private static final String PHOTO_ATTRIBUTE = "jpegPhoto";
private static final String[] PHOTO_ATTRIBUTES = new String[]
{
"jpegPhoto",
"thumbnailPhoto"
};
/**
* data structure used to store the LDAP attributes that
@ -208,6 +212,12 @@ public LdapDirectoryImpl(LdapDirectorySettings settings)
{
searchableAttrs.add(s);
}
if (settings.isPhotoInline())
{
retrievableAttributes.add("jpegPhoto");
retrievableAttributes.add("thumbnailPhoto");
}
}
/**
@ -385,7 +395,7 @@ public void run()
SearchResult searchResult =
(SearchResult) results.next();
Map<String, Set<String>> retrievedAttributes =
Map<String, Set<Object>> retrievedAttributes =
retrieveAttributes(searchResult);
LdapPersonFound person =
buildPerson(
@ -411,7 +421,7 @@ public void run()
}
catch(OperationNotSupportedException e)
{
logger.trace(
logger.error(
"use bind DN without password during search" +
" for real query \"" +
realQueryString + "\" (initial query: \"" +
@ -425,7 +435,7 @@ public void run()
}
catch(AuthenticationException e)
{
logger.trace(
logger.error(
"authentication failed during search" +
" for real query \"" +
realQueryString + "\" (initial query: \"" +
@ -439,7 +449,7 @@ public void run()
}
catch(NamingException e)
{
logger.trace(
logger.error(
"an external exception was thrown during search" +
" for real query \"" +
realQueryString + "\" (initial query: \"" +
@ -469,6 +479,19 @@ public void run()
// whether sleep was interrupted
// is not that important
}
catch (Exception e)
{
logger.error("search for real query \"" + realQueryString +
"\" (initial query: \"" + query.toString() +
"\") on " + LdapDirectoryImpl.this +
" cancelled at state " + cancelState, e);
endEvent = new LdapEvent(
LdapDirectoryImpl.this,
LdapEvent.LdapEventCause.SEARCH_ERROR,
query
);
}
finally
{
fireLdapEvent(endEvent, caller);
@ -504,9 +527,14 @@ private void checkCancel()
searchThread.start();
}
private static String[]
private String[]
buildIntermediateQueryStrings(String initialQueryString)
{
if (!this.settings.isMangleQuery())
{
return new String[] { initialQueryString };
}
// search for "doe john" as well "as john doe"
String[] words = initialQueryString.split(" ");
String[] intermediateQueryStrings;
@ -534,28 +562,27 @@ private void checkCancel()
* @param searchResult the results to browse for attributes
* @return the attributes in a Map
*/
private Map<String, Set<String>>
private Map<String, Set<Object>>
retrieveAttributes(SearchResult searchResult)
throws NamingException
{
Attributes attributes =
searchResult.getAttributes();
Map<String, Set<String>> retrievedAttributes =
new HashMap<String, Set<String>>();
Map<String, Set<Object>> retrievedAttributes =
new HashMap<String, Set<Object>>();
NamingEnumeration<String> ids = attributes.getIDs();
while(ids.hasMore())
{
String id = ids.next();
if(retrievableAttributes.contains(id) || containsAttribute(id))
{
Set<String> valuesSet = new HashSet<String>();
Set<Object> valuesSet = new HashSet<Object>();
retrievedAttributes.put(id, valuesSet);
Attribute attribute = attributes.get(id);
NamingEnumeration<?> values = attribute.getAll();
while(values.hasMore())
{
String value = (String) values.next();
valuesSet.add(value);
valuesSet.add(values.next());
}
}
}
@ -574,7 +601,7 @@ private void checkCancel()
LdapQuery query,
String dn,
Map<String,
Set<String>> retrievedAttributes
Set<Object>> retrievedAttributes
)
{
LdapPersonFound person =
@ -584,19 +611,22 @@ private void checkCancel()
if(retrievedAttributes.get("givenname") != null)
{
String firstName =
retrievedAttributes.get("givenname").iterator().next();
(String) retrievedAttributes.get("givenname")
.iterator().next();
person.setFirstName(firstName);
}
else if(retrievedAttributes.get("givenName") != null)
{
String firstName =
retrievedAttributes.get("givenName").iterator().next();
(String) retrievedAttributes.get("givenName")
.iterator().next();
person.setFirstName(firstName);
}
else if(retrievedAttributes.get("gn") != null)
{
String firstName =
retrievedAttributes.get("gn").iterator().next();
(String) retrievedAttributes.get("gn")
.iterator().next();
person.setFirstName(firstName);
}
@ -604,13 +634,15 @@ else if(retrievedAttributes.get("gn") != null)
if(retrievedAttributes.get("sn") != null)
{
String surname =
retrievedAttributes.get("sn").iterator().next();
(String) retrievedAttributes.get("sn")
.iterator().next();
person.setSurname(surname);
}
else if(retrievedAttributes.get("surname") != null)
{
String surname =
retrievedAttributes.get("surname").iterator().next();
(String) retrievedAttributes.get("surname")
.iterator().next();
person.setSurname(surname);
}
@ -618,19 +650,22 @@ else if(retrievedAttributes.get("surname") != null)
if(retrievedAttributes.get("displayName") != null)
{
String displayName =
retrievedAttributes.get("displayName").iterator().next();
(String) retrievedAttributes.get("displayName")
.iterator().next();
person.setDisplayName(displayName);
}
else if(retrievedAttributes.get("cn") != null)
{
String displayName =
retrievedAttributes.get("cn").iterator().next();
(String) retrievedAttributes.get("cn")
.iterator().next();
person.setDisplayName(displayName);
}
else if(retrievedAttributes.get("commonname") != null)
{
String displayName =
retrievedAttributes.get("commonname").iterator().next();
(String) retrievedAttributes.get("commonname")
.iterator().next();
person.setDisplayName(displayName);
}
if(person.getDisplayName() == null)
@ -648,20 +683,21 @@ else if(retrievedAttributes.get("commonname") != null)
if(retrievedAttributes.get("o") != null)
{
String organization =
retrievedAttributes.get("o").iterator().next();
(String) retrievedAttributes.get("o").iterator().next();
person.setOrganization(organization);
}
else if(retrievedAttributes.get("organizationName") != null)
{
String organization =
retrievedAttributes.get("organizationName").iterator()
.next();
(String) retrievedAttributes.get("organizationName")
.iterator().next();
person.setOrganization(organization);
}
else if(retrievedAttributes.get("company") != null)
{
String organization =
retrievedAttributes.get("company").iterator().next();
(String) retrievedAttributes.get("company")
.iterator().next();
person.setOrganization(organization);
}
@ -669,42 +705,60 @@ else if(retrievedAttributes.get("company") != null)
if(retrievedAttributes.get("company") != null)
{
String department =
retrievedAttributes.get("company").iterator().next();
(String) retrievedAttributes.get("company")
.iterator().next();
person.setDepartment(department);
}
else if(retrievedAttributes.get("ou") != null)
{
String department =
retrievedAttributes.get("ou").iterator().next();
(String) retrievedAttributes.get("ou").iterator().next();
person.setDepartment(department);
}
else if(retrievedAttributes.get("orgunit") != null)
{
String department =
retrievedAttributes.get("orgunit").iterator().next();
(String) retrievedAttributes.get("orgunit")
.iterator().next();
person.setDepartment(department);
}
else if(retrievedAttributes.get("organizationalUnitName") != null)
{
String department =
retrievedAttributes.get("organizationalUnitName").
(String) retrievedAttributes.get("organizationalUnitName").
iterator().next();
person.setDepartment(department);
}
else if(retrievedAttributes.get("department") != null)
{
String department =
retrievedAttributes.get("department").iterator().next();
(String) retrievedAttributes.get("department")
.iterator().next();
person.setDepartment(department);
}
else if(retrievedAttributes.get("departmentNumber") != null)
{
String department =
retrievedAttributes.get("departmentNumber").iterator().
next();
(String) retrievedAttributes.get("departmentNumber")
.iterator().next();
person.setDepartment(department);
}
if(retrievedAttributes.get("jpegPhoto") != null)
{
byte[] photo =
(byte[])retrievedAttributes.get("jpegPhoto")
.iterator().next();
person.setPhoto(photo);
}
else if(retrievedAttributes.get("thumbnailPhoto") != null)
{
byte[] photo =
(byte[])retrievedAttributes.get("thumbnailPhoto")
.iterator().next();
person.setPhoto(photo);
}
// mail
List<String> attrs = attributesMap.get("mail");
@ -712,8 +766,9 @@ else if(retrievedAttributes.get("departmentNumber") != null)
{
if(retrievedAttributes.get(attr) != null)
{
for(String mail : retrievedAttributes.get(attr))
for(Object o : retrievedAttributes.get(attr))
{
String mail = o.toString();
if(!mail.contains("@"))
{
if(settings.getMailSuffix() != null)
@ -736,7 +791,8 @@ else if(retrievedAttributes.get("departmentNumber") != null)
if(retrievedAttributes.get(attr) != null)
{
String phone =
retrievedAttributes.get(attr).iterator().next();
(String) retrievedAttributes.get(attr)
.iterator().next();
person.addWorkPhone(phone);
}
}
@ -748,9 +804,9 @@ else if(retrievedAttributes.get("departmentNumber") != null)
{
if(retrievedAttributes.get(attr) != null)
{
for(String phone : retrievedAttributes.get(attr))
for(Object phone : retrievedAttributes.get(attr))
{
person.addMobilePhone(phone);
person.addMobilePhone(phone.toString());
}
}
}
@ -762,9 +818,9 @@ else if(retrievedAttributes.get("departmentNumber") != null)
{
if(retrievedAttributes.get(attr) != null)
{
for(String phone : retrievedAttributes.get(attr))
for(Object phone : retrievedAttributes.get(attr))
{
person.addHomePhone(phone);
person.addHomePhone(phone.toString());
}
}
}
@ -836,27 +892,21 @@ private boolean textHasContent(String aText)
}
/**
* Builds an LDAP search filter, base on the query string entered
* e.g. (&(|(mail=*)(telephoneNumber=*))(|(cn=*query*)(sn=*query*)(givenname=*query*)))
* Builds an LDAP search filter, based on the query string entered and the
* searchable fields defined in the static constructor. If a custom query is
* defined this is used instead. e.g.
* (|(|(mail=query)(telephoneNumber=query)))
*
* @return an LDAP search filter
*/
private String buildSearchFilter(String query)
{
StringBuffer searchFilter = new StringBuffer();
/*
searchFilter.append("(&(|");
for(String attribute : retrievableAttributes)
if ("custom".equals(settings.getQueryMode()))
{
searchFilter.append("(");
searchFilter.append(attribute);
searchFilter.append("=*)");
return settings.getCustomQuery().replace("<query>", query);
}
searchFilter.append(")(|");
*/
StringBuffer searchFilter = new StringBuffer();
searchFilter.append("(|");
/* cn=*query* OR sn=*query* OR ... */
@ -966,6 +1016,11 @@ public Collection<String> searchChildren(final String dn)
*/
byte[] fetchPhotoForPerson(String dn)
{
if (this.settings.isPhotoInline())
{
return null;
}
byte[] photo = null;
InitialDirContext dirContext = null;
@ -973,8 +1028,7 @@ byte[] fetchPhotoForPerson(String dn)
final SearchControls searchCtl = new SearchControls();
searchCtl.setSearchScope(SearchControls.OBJECT_SCOPE);
String[] returningAttributes = { PHOTO_ATTRIBUTE };
searchCtl.setReturningAttributes(returningAttributes);
searchCtl.setReturningAttributes(PHOTO_ATTRIBUTES);
logger.trace("starting photo retrieval...");
try
@ -991,13 +1045,16 @@ byte[] fetchPhotoForPerson(String dn)
{
SearchResult searchResult = (SearchResult) result.next();
Attributes attributes = searchResult.getAttributes();
Attribute attribute = attributes.get(PHOTO_ATTRIBUTE);
if(attribute != null)
for (String a : PHOTO_ATTRIBUTES)
{
NamingEnumeration<?> values = attribute.getAll();
if(values.hasMore())
Attribute attribute = attributes.get(a);
if(attribute != null)
{
photo = (byte[]) values.next();
NamingEnumeration<?> values = attribute.getAll();
if(values.hasMore())
{
photo = (byte[]) values.next();
}
}
}
}

@ -41,6 +41,10 @@ public LdapDirectorySettingsImpl()
this.setBaseDN("");
this.setScope(Scope.defaultValue());
this.setGlobalPhonePrefix("");
this.setQueryMode("");
this.setCustomQuery("");
this.setMangleQuery(true);
this.setPhotoInline(false);
// mail
List<String> lst = new ArrayList<String>();
lst.add("mail");
@ -93,6 +97,10 @@ public LdapDirectorySettingsImpl(LdapDirectorySettingsImpl settings)
this.setGlobalPhonePrefix(settings.getGlobalPhonePrefix());
this.mapAttributes = settings.mapAttributes;
this.mailSuffix = settings.mailSuffix;
this.queryMode = settings.queryMode;
this.customQuery = settings.customQuery;
this.mangleQuery = settings.mangleQuery;
this.photoInline = settings.photoInline;
}
/**
@ -170,6 +178,26 @@ public LdapDirectorySettingsImpl(LdapDirectorySettingsImpl settings)
*/
private String mailSuffix = null;
/**
* How the query should be constructed.
*/
private String queryMode;
/**
* The user defined LDAP query.
*/
private String customQuery;
/**
* Whether the query term should be automatically expanded for wildcards.
*/
private boolean mangleQuery;
/**
* Whether photos are retrieved along with the other attributes.
*/
private boolean photoInline;
/**
* Attributes map.
*/
@ -465,7 +493,11 @@ public boolean equals(LdapDirectorySettings other)
this.getPassword().equals(other.getPassword()) &&
this.getBaseDN().equals(other.getBaseDN()) &&
this.getScope().equals(other.getScope()) &&
this.getGlobalPhonePrefix().equals(other.getGlobalPhonePrefix());
this.getGlobalPhonePrefix().equals(other.getGlobalPhonePrefix()) &&
this.getCustomQuery().equals(other.getCustomQuery()) &&
this.getQueryMode().equals(other.getQueryMode()) &&
this.isMangleQuery() == other.isMangleQuery() &&
this.isPhotoInline() == other.isPhotoInline();
}
/**
@ -501,6 +533,12 @@ public int hashCode()
this.getBaseDN().hashCode());
hash = 31 * hash + (null == this.getGlobalPhonePrefix() ? 0 :
this.getGlobalPhonePrefix().hashCode());
hash = 31 * hash + (null == this.getCustomQuery() ? 0 :
this.getCustomQuery().hashCode());
hash = 32 * hash + (null == this.getQueryMode() ? 0 :
this.getQueryMode().hashCode());
hash = 33 * hash + (this.isMangleQuery() ? 1 : 0);
hash = 34 * hash + (this.isPhotoInline() ? 1 : 0);
return hash;
}
@ -544,6 +582,87 @@ public void setMailSuffix(String suffix)
this.mailSuffix = suffix;
}
/**
* Gets the mode how the LDAP query is constructed.
* @return the mode how the LDAP query is constructed.
*/
@Override
public String getQueryMode()
{
return this.queryMode;
}
/**
* Sets the mode how the LDAP query is constructed.
* @param queryMode the mode how the LDAP query is constructed.
*/
@Override
public void setQueryMode(String queryMode)
{
this.queryMode = queryMode;
}
/**
* Gets the user-defined LDAP query.
* @return the user-defined LDAP query.
*/
@Override
public String getCustomQuery()
{
return this.customQuery;
}
/**
* Sets the user-defined LDAP query.
* @param query the user-defined LDAP query.
*/
@Override
public void setCustomQuery(String query)
{
this.customQuery = query;
}
/**
* Gets whether the query term gets mangled with wildcards.
* @return whether the query term gets mangled with wildcards.
*/
@Override
public boolean isMangleQuery()
{
return this.mangleQuery;
}
/**
* Sets whether the query term gets mangled with wildcards.
* @param mangle whether the query term gets mangled with wildcards.
*/
@Override
public void setMangleQuery(boolean mangle)
{
this.mangleQuery = mangle;
}
/**
* Gets whether photos are retrieved along with the other attributes.
* @return whether photos are retrieved along with the other attributes.
*/
@Override
public boolean isPhotoInline()
{
return this.photoInline;
}
/**
* Sets whether photos are retrieved along with the other attributes.
* @param inline whether photos are retrieved along with the other
* attributes.
*/
@Override
public void setPhotoInline(boolean inline)
{
this.photoInline = inline;
}
/**
* Returns work phone fields that we will lookup.
*
@ -700,6 +819,18 @@ public void persistentSave()
configService.setProperty(
directoriesPath + "." + node + ".globalPhonePrefix",
this.getGlobalPhonePrefix());
configService.setProperty(
directoriesPath + "." + node + ".querymode",
this.getQueryMode());
configService.setProperty(
directoriesPath + "." + node + ".customquery",
this.getCustomQuery());
configService.setProperty(
directoriesPath + "." + node + ".mangle",
this.isMangleQuery());
configService.setProperty(
directoriesPath + "." + node + ".inlinephoto",
this.isPhotoInline());
}
/**
@ -852,6 +983,48 @@ public void persistentLoad(String name)
if (ret != null)
setGlobalPhonePrefix(ret);
}
if(configService.getProperty(directoriesPath + "." + node +
".querymode") != null)
{
String ret = (String)configService.getProperty(
directoriesPath + "." + node + ".querymode");
if (ret != null)
setQueryMode(ret);
}
if(configService.getProperty(directoriesPath + "." + node +
".customquery") != null)
{
String ret = (String)configService.getProperty(
directoriesPath + "." + node + ".customquery");
if (ret != null)
setCustomQuery(ret);
}
if(configService.getProperty(directoriesPath + "." + node +
".mangle") != null)
{
Boolean ret = Boolean.parseBoolean(
(String)configService.getProperty(
directoriesPath + "." + node + ".mangle"));
if (ret != null)
setMangleQuery(ret);
}
if(configService.getProperty(directoriesPath + "." + node +
".inlinephoto") != null)
{
Boolean ret = Boolean.parseBoolean(
(String)configService.getProperty(
directoriesPath + "." + node + ".inlinephoto"));
if (ret != null)
setPhotoInline(ret);
}
}
/**
@ -913,6 +1086,18 @@ public void persistentRemove()
configService.setProperty(
directoriesPath + "." + node,
null);
configService.setProperty(
directoriesPath + "." + node + ".querymode",
null);
configService.setProperty(
directoriesPath + "." + node + ".customquery",
null);
configService.setProperty(
directoriesPath + "." + node + ".mangle",
null);
configService.setProperty(
directoriesPath + "." + node + ".inlinephoto",
null);
}
/**
@ -932,7 +1117,11 @@ public String toString()
this.getBindDN() + ", \n" +
this.getPassword() + ", \n" +
this.getBaseDN() + ", \n" +
this.getGlobalPhonePrefix() + " \n}";
this.getGlobalPhonePrefix() + " \n" +
this.queryMode + " \n" +
this.customQuery + " \n" +
this.mangleQuery + " \n" +
this.photoInline + " \n}";
}
@Override

@ -62,6 +62,11 @@ public class LdapPersonFoundImpl
*/
private String department = null;
/**
* the photo found in the directory for this person.
*/
private byte[] photo = null;
/**
* the set storing the mail addresses
*/
@ -145,11 +150,9 @@ public String getDisplayName()
* @return the photo found in the the directory for this person
* or null if not found
*/
public byte[] fetchPhoto()
public void fetchPhoto()
{
byte[] photo;
photo = this.server.fetchPhotoForPerson(this.dn);
return photo;
this.photo = this.server.fetchPhotoForPerson(this.dn);
}
/**
@ -235,6 +238,31 @@ public String getDepartment()
return this.department;
}
/**
* Gets the photo found in the directory for this person.
* @return the photo found in the directory for this person.
*/
@Override
public byte[] getPhoto()
{
if (this.photo == null)
{
this.fetchPhoto();
}
return this.photo;
}
/**
* Set the photo found in the directory for this person.
* @param photo the photo found in the directory for this person.
*/
@Override
public void setPhoto(byte[] photo)
{
this.photo = photo;
}
/**
* Adds a mail address to this person
*

@ -12,6 +12,7 @@
import java.util.List;
import javax.swing.*;
import javax.swing.border.*;
import net.java.sip.communicator.plugin.ldap.*;
import net.java.sip.communicator.service.ldap.*;
@ -66,6 +67,27 @@ public class DirectorySettingsForm
*/
private JTextField homePhoneField = new JTextField();
/** Radio button for the default query selection. */
private JRadioButton rdoDefaultQuery
= new SIPCommRadioButton(
Resources.getString("impl.ldap.QUERY_DEFAULT"));
/** Radio button for the default query selection. */
private JRadioButton rdoCustomQuery
= new SIPCommRadioButton(
Resources.getString("impl.ldap.QUERY_CUSTOM"));
/** Textbox for the custom LDAP query. */
private JTextArea txtCustomQuery = new JTextArea("", 15, 40);
/** Checkbox to indicate the automatic wildcard query term expansion */
private JCheckBox chkMangleQuery = new SIPCommCheckBox(
Resources.getString("impl.ldap.QUERY_CUSTOM_AUTO_WILDCARD"));
/** Checkbox to indicate whether photos should be retrieved inline */
private JCheckBox chkPhotoInline = new SIPCommCheckBox(
Resources.getString("impl.ldap.QUERY_PHOTO_INLINE"));
/**
* component holding the name
*/
@ -190,8 +212,11 @@ public DirectorySettingsForm()
setSize(new Dimension(400, 400));
setPreferredSize(new Dimension(400, 400));
pane.addTab("General", getContentPanel());
pane.addTab("Fields", getFieldsPanel());
pane.addTab(Resources.getString("impl.ldap.GENERAL"),
getContentPanel());
pane.addTab(Resources.getString("impl.ldap.FIELDS"), getFieldsPanel());
pane.addTab(Resources.getString("impl.ldap.QUERY"),
getCustomQueryPanel());
btnPanel.add(saveBtn);
btnPanel.add(cancelBtn);
@ -709,6 +734,42 @@ public JPanel getContentPanel()
return contentPanel;
}
/**
* Creates the for the definition of a custom query.
*
* @return a panel for a custom query definition.
*/
private JPanel getCustomQueryPanel()
{
rdoDefaultQuery.addActionListener(this);
rdoCustomQuery.addActionListener(this);
JPanel p = new TransparentPanel();
p.setLayout(new BorderLayout());
JPanel options = new TransparentPanel();
options.setLayout(new BoxLayout(options, BoxLayout.Y_AXIS));
options.add(rdoDefaultQuery);
options.add(rdoCustomQuery);
p.add(options, BorderLayout.NORTH);
p.add(txtCustomQuery, BorderLayout.CENTER);
txtCustomQuery.setBorder(new LineBorder(Color.black));
txtCustomQuery.setLineWrap(true);
txtCustomQuery.setWrapStyleWord(false);
JPanel hints = new TransparentPanel();
hints.setLayout(new BoxLayout(hints, BoxLayout.Y_AXIS));
hints.add(
new JLabel(Resources.getString("impl.ldap.QUERY_CUSTOM_HINT",
new String[] { "<query>" })));
hints.add(chkMangleQuery);
hints.add(chkPhotoInline);
p.add(hints, BorderLayout.SOUTH);
return p;
}
/**
* Loads the information from the LdapDirectorySettings instance
* into the UI.
@ -758,6 +819,16 @@ public void loadData(LdapDirectorySettings settings)
this.homePhoneField.setText(
mergeStrings(settings.getHomePhoneSearchFields()));
this.prefixField.setText(settings.getGlobalPhonePrefix());
this.rdoDefaultQuery.setSelected(
!"custom".equals(settings.getQueryMode()));
this.rdoCustomQuery.setSelected(
"custom".equals(settings.getQueryMode()));
this.txtCustomQuery.setText(settings.getCustomQuery());
this.chkMangleQuery.setSelected(settings.isMangleQuery());
this.chkPhotoInline.setSelected(settings.isPhotoInline());
txtCustomQuery.setEditable(rdoCustomQuery.isSelected());
txtCustomQuery.setEnabled(rdoCustomQuery.isSelected());
}
/**
@ -857,6 +928,12 @@ public void saveData(LdapDirectorySettings settings)
settings.setHomePhoneSearchFields(
mergeString(homePhoneField.getText()));
settings.setGlobalPhonePrefix(prefixField.getText());
settings.setQueryMode(rdoCustomQuery.isSelected()
? "custom"
: null);
settings.setCustomQuery(txtCustomQuery.getText());
settings.setMangleQuery(chkMangleQuery.isSelected());
settings.setPhotoInline(chkPhotoInline.isSelected());
}
/**
@ -925,6 +1002,18 @@ else if(src == authList)
bindDNField.setEnabled(authList.getSelectedIndex() == 1);
passwordField.setEnabled(authList.getSelectedIndex() == 1);
}
else if (src == rdoDefaultQuery)
{
txtCustomQuery.setEnabled(false);
txtCustomQuery.setEditable(false);
rdoCustomQuery.setSelected(false);
}
else if (src == rdoCustomQuery)
{
txtCustomQuery.setEnabled(true);
txtCustomQuery.setEditable(true);
rdoDefaultQuery.setSelected(false);
}
}
/**

@ -263,6 +263,55 @@ public interface LdapDirectorySettings
*/
public void setGlobalPhonePrefix(String prefix);
/**
* Gets the mode how the LDAP query is constructed.
* @return the mode how the LDAP query is constructed.
*/
public String getQueryMode();
/**
* Sets the mode how the LDAP query is constructed.
* @param queryMode the mode how the LDAP query is constructed.
*/
public void setQueryMode(String queryMode);
/**
* Gets the user-defined LDAP query.
* @return the user-defined LDAP query.
*/
public String getCustomQuery();
/**
* Sets the user-defined LDAP query.
* @param query the user-defined LDAP query.
*/
public void setCustomQuery(String query);
/**
* Gets whether the query term gets mangled with wildcards.
* @return whether the query term gets mangled with wildcards.
*/
public boolean isMangleQuery();
/**
* Sets whether the query term gets mangled with wildcards.
* @param mangle whether the query term gets mangled with wildcards.
*/
public void setMangleQuery(boolean mangle);
/**
* Gets whether photos are retrieved along with the other attributes.
* @return whether photos are retrieved along with the other attributes.
*/
public boolean isPhotoInline();
/**
* Sets whether photos are retrieved along with the other attributes.
* @param inline whether photos are retrieved along with the other
* attributes.
*/
public void setPhotoInline(boolean inline);
/**
* Saves these settings through the configuration service
*
@ -286,26 +335,6 @@ public interface LdapDirectorySettings
*/
public void persistentRemove();
/**
* Checks if both LdapDirectorySettings instance have the same content
*
* @param other object to compare
* @return whether both LdapDirectorySettings instance have the same content
*
* @see java.lang.Object#equals
*/
public boolean equals(LdapDirectorySettings other);
/**
* Returns the hash code for this instance.
* It has to be consistent with equals.
*
* @return the hash code dor this instance
*
* @see java.lang.Object#hashCode
*/
public int hashCode();
/**
* Clone this object.
*

@ -48,12 +48,22 @@ public interface LdapPersonFound
public String getDisplayName();
/**
* Tries to fetch the photo in the the directory for this person
*
* @return the photo found in the the directory for this person
* or null if not found
* Tries to fetch the photo in the the directory for this person. If
* successful, the binary photo is available from {@link #getPhoto()}
*/
public void fetchPhoto();
/**
* Gets the photo found in the directory for this person.
* @return the photo found in the directory for this person.
*/
public byte[] getPhoto();
/**
* Set the photo found in the directory for this person.
* @param photo the photo found in the directory for this person.
*/
public byte[] fetchPhoto();
public void setPhoto(byte[] photo);
/**
* Sets the first name found in the the directory for this person

Loading…
Cancel
Save