Commit 5344c94d authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Allowed photos to be retrieved from LDAP for vcards. JM-773

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@9341 b35dd754-fafc-0310-a699-88a17e54d16e
parent 1528fa89
......@@ -239,7 +239,8 @@
## Added key: 'user.roster.filter.all'
## Added key: 'user.roster.filter.noshared'
## Added key: 'user.roster.filter.onlyshared'
## Added key: 'setup.ldap.user.vcard.photo'
# Openfire
short.title = Openfire
......@@ -1605,6 +1606,7 @@ setup.ldap.user.vcard.email=Email
setup.ldap.user.vcard.fullname=Full Name
setup.ldap.user.vcard.nickname=Nickname
setup.ldap.user.vcard.birthday=Birthday
setup.ldap.user.vcard.photo=Photo/Avatar
setup.ldap.user.vcard.home=Home
setup.ldap.user.vcard.street=Street Address
setup.ldap.user.vcard.city=City
......
......@@ -2226,3 +2226,4 @@ system.clustering.using-embedded-db=Clustering no esta disponible cuando se util
system.clustering.not-installed=No se ha encontrado soporte para clustering en el sistema. Instale Openfire Corporativo para habilitarlo.
system.clustering.not-valid-license=La licencia de Openfire Corporativo no incluye clustering. Necesita actualizar su licencia para habilitar clustering.
system.clustering.starting=Clustering esta arrancando. Puede tardar hasta 30 segundos para completar. Haga clic {0}aqui{1} para refrescar.
setup.ldap.user.vcard.photo=Foto/Avatar
\ No newline at end of file
......@@ -13,11 +13,11 @@ package org.jivesoftware.admin;
import org.dom4j.*;
import org.dom4j.io.OutputFormat;
import org.jivesoftware.openfire.ldap.LdapManager;
import org.jivesoftware.openfire.ldap.LdapVCardProvider;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.XMLWriter;
import org.jivesoftware.openfire.ldap.LdapManager;
import org.jivesoftware.openfire.ldap.LdapVCardProvider;
import java.io.IOException;
import java.io.StringWriter;
......@@ -36,6 +36,7 @@ public class LdapUserProfile {
private String fullName = "";
private String nickname = "";
private String birthday = "";
private String photo = "";
private String homeStreet = "";
private String homeCity = "";
private String homeState = "";
......@@ -97,6 +98,14 @@ public class LdapUserProfile {
this.birthday = birthday;
}
public String getPhoto() {
return photo;
}
public void setPhoto(String photo) {
this.photo = photo;
}
public String getHomeStreet() {
return homeStreet;
}
......@@ -347,6 +356,12 @@ public class LdapUserProfile {
if (birthday != null && birthday.trim().length() > 0) {
vCard.addElement("BDAY").setText(birthday.trim());
}
// Add photo/avatar
if (photo != null && photo.trim().length() > 0) {
Element element = vCard.addElement("PHOTO");
element.addElement("TYPE").setText("image/jpeg");
element.addElement("BINVAL").setText(photo.trim());
}
// Add home address
subelement = vCard.addElement("ADR");
subelement.addElement("HOME");
......
......@@ -12,6 +12,7 @@
package org.jivesoftware.admin;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.Base64;
import org.jivesoftware.openfire.ldap.LdapManager;
import org.xmpp.packet.JID;
......@@ -40,6 +41,7 @@ public class LdapUserTester {
public static final String FULL_NAME = "FullName";
public static final String NICKNAME = "Nickname";
public static final String BIRTHDAY = "Birthday";
public static final String PHOTO = "Photo";
public static final String HOME_STREET = "HomeStreet";
public static final String HOME_CITY = "HomeCity";
public static final String HOME_STATE = "HomeState";
......@@ -163,7 +165,14 @@ public class LdapUserTester {
for (String field : mapping.getFields()) {
Attribute ldapField = attrs.get(field);
if (ldapField != null) {
value = value.replace("{"+field+"}", (String)ldapField.get());
String answer;
Object ob = ldapField.get();
if (ob instanceof String) {
answer = (String) ob;
} else {
answer = Base64.encodeBytes((byte[]) ob);
}
value = value.replace("{" + field + "}", answer);
}
}
userAttributes.put(attribute, value);
......@@ -204,6 +213,9 @@ public class LdapUserTester {
if (profile.getBirthday() != null && profile.getBirthday().trim().length() > 0) {
map.put(BIRTHDAY, new PropertyMapping(profile.getBirthday()));
}
if (profile.getPhoto() != null && profile.getPhoto().trim().length() > 0) {
map.put(PHOTO, new PropertyMapping(profile.getPhoto()));
}
if (profile.getHomeStreet() != null && profile.getHomeStreet().trim().length() > 0) {
map.put(HOME_STREET, new PropertyMapping(profile.getHomeStreet()));
}
......
......@@ -147,7 +147,12 @@ public class LdapVCardProvider implements VCardProvider, PropertyEventListener {
value = "";
}
else {
value = (String) attrs.get(attribute).get();
Object ob = attrs.get(attribute).get();
if(ob instanceof String) {
value = (String)ob;
} else {
value = Base64.encodeBytes((byte[])ob);
}
}
Log.debug("Ldap attribute '" + attribute + "'=>'" + value + "'");
map.put(attribute, value);
......
......@@ -298,6 +298,14 @@
<input type="text" name="birthday" value="<%= vcardBean.getBirthday() %>" id="birthday" size="22" maxlength="50" onFocus="jiveRowHighlight(this);">
</td>
</tr>
<tr>
<td class="jive-vcardTable-label jive-vardBorderBottom jive-vardBorderRight" nowrap>
<strong><fmt:message key="setup.ldap.user.vcard.photo" /></strong>
</td>
<td class="jive-vcardTable-value jive-vardBorderBottom">
<input type="text" name="photo" value="<%= vcardBean.getPhoto() %>" id="photo" size="22" maxlength="50" onFocus="jiveRowHighlight(this);">
</td>
</tr>
<tr>
<td class="jive-vcardTable-label jive-vardBorderBottom jive-vardBorderRight" nowrap>
<strong><fmt:message key="setup.ldap.user.vcard.home" /></strong>
......
......@@ -7,6 +7,7 @@
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Map" %>
<%@ page import="org.jivesoftware.util.StringUtils" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
......@@ -125,6 +126,13 @@ html>body .jive-testPanel {
<td class="jive-testpanel-vcard-value"><%= failed || value == null? "" : value%></td>
</tr>
<tr>
<% value = attributes.get(LdapUserTester.PHOTO);
failed = value != null && value.contains("{");
%>
<td class="jive-testpanel-vcard-label"><%= value != null ? "<strong>" : ""%><fmt:message key="setup.ldap.user.vcard.photo" />:<%= value != null ? "</strong>" : ""%></td>
<td class="jive-testpanel-vcard-value"><%= failed || value == null? "" : StringUtils.chopAtWord(value , 17) + "..."%></td>
</tr>
<tr>
<td colspan="2"></td>
</tr>
<tr>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment