implemented getUserAvatarAbsoluteURL in user ws service
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vo-management/usermanagement-core@142256 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
7482fe9bb7
commit
4bd0d26d43
|
@ -1,11 +1,16 @@
|
|||
package org.gcube.vomanagement.usermanagement.impl.ws;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.auth.AuthScope;
|
||||
import org.apache.http.auth.UsernamePasswordCredentials;
|
||||
|
@ -190,7 +195,7 @@ public class LiferayWSUserManager implements UserManager{
|
|||
(String)userJSON.get("lastName"),
|
||||
buildFullName(userJSON),
|
||||
(long)userJSON.get("createDate"),
|
||||
null, // skip for now TODO getUserAvatarAbsoluteURL(u)
|
||||
getUserAvatarAbsoluteURL((String)userJSON.get("uuid"), (long)userJSON.get("portraitId")), // skip for now TODO getUserAvatarAbsoluteURL(u)
|
||||
(boolean)contactJSON.get("male"),
|
||||
(String)userJSON.get("jobTitle"),
|
||||
locationIndustry,
|
||||
|
@ -201,6 +206,26 @@ public class LiferayWSUserManager implements UserManager{
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluate the user's avatar url path (relative)
|
||||
* @param userUuid
|
||||
* @param portraitId
|
||||
* @return
|
||||
* @throws UnsupportedEncodingException
|
||||
* @throws NoSuchAlgorithmException
|
||||
*/
|
||||
private String getUserAvatarAbsoluteURL(String userUuid, long portraitId) throws UnsupportedEncodingException, NoSuchAlgorithmException{
|
||||
|
||||
// url looks like LIFERAY_PORTAL/image/user_male_portrait?img_id=21125690&img_id_token=aPduzUQfxcz9kiLzD0yrChPU8k4%3D
|
||||
// where img_id_token is the sha-1/base64 encoding, encoded as query parameter, of userUuid
|
||||
MessageDigest md = MessageDigest.getInstance("SHA-1");
|
||||
String imageId = URLEncoder.encode(Base64.encodeBase64String(md.digest(userUuid.getBytes())), "UTF-8");
|
||||
|
||||
return "/image/user_male_portrait?img_id=" + portraitId + "&img_id_token=" + imageId;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* From the json representing the user builds the fullname (which is missing, so firstname, lastname and middlename will be used)
|
||||
|
|
Loading…
Reference in New Issue